dev_orbit 0.0.7 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -1
- data/Gemfile.lock +15 -9
- data/README.md +22 -4
- data/bin/dev_orbit +10 -0
- data/dev_orbit.gemspec +5 -5
- data/lib/dev_orbit/client.rb +9 -0
- data/lib/dev_orbit/dev.rb +34 -2
- data/lib/dev_orbit/interactions/comment.rb +1 -0
- data/lib/dev_orbit/interactions/follower.rb +52 -0
- data/lib/dev_orbit/orbit.rb +11 -0
- data/lib/dev_orbit/version.rb +1 -1
- data/scripts/check_followers.rb +17 -0
- metadata +14 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5be040bbce86eea38887b56250025c6834f84b1cd049c442ef0acff79c8fb9ac
|
4
|
+
data.tar.gz: 6e1da63c12b9c4f3f9cbccae6e0eda973e7564f2ef0ff3e15f715ad2874fc6ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ac862022a6f56a6810ab15db8a6b16fb41dbf26152169af2a476a38afe9718fec80897ed586609d16646b7456c87a05c94e4d3e565a16ce951a9dd27d31fca8
|
7
|
+
data.tar.gz: c8a31b552748c6a4cc88a3f3e2332db3c6219163a366e747dadde4baa63f7cb08bafb097a1a03263c4b684c9e31c3153b511069072e422fb1c564c6d3595a87d
|
data/CHANGELOG.md
CHANGED
@@ -25,4 +25,20 @@
|
|
25
25
|
|
26
26
|
## [0.0.7] - 2021-03-12
|
27
27
|
|
28
|
-
- Check for valid JSON from API response before continuing
|
28
|
+
- Check for valid JSON from API response before continuing
|
29
|
+
|
30
|
+
## [0.0.8] - 2021-03-16
|
31
|
+
|
32
|
+
- Early return if there are no new comments
|
33
|
+
|
34
|
+
## [0.0.9] - 2021-04-11
|
35
|
+
|
36
|
+
- Add check for new DEV followers functionality
|
37
|
+
|
38
|
+
## [0.0.10] - 2021-04-23
|
39
|
+
|
40
|
+
- Fix filter for DEV comments
|
41
|
+
## [0.1.0] - 2021-05-06
|
42
|
+
|
43
|
+
- Correct CLI `CheckFollowers` action
|
44
|
+
- Update gem specifications
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dev_orbit (0.0
|
4
|
+
dev_orbit (0.1.0)
|
5
5
|
actionview (~> 6.1)
|
6
6
|
activesupport (~> 6.1)
|
7
7
|
http (~> 4.4)
|
@@ -12,13 +12,13 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
actionview (6.1.3)
|
16
|
-
activesupport (= 6.1.3)
|
15
|
+
actionview (6.1.3.2)
|
16
|
+
activesupport (= 6.1.3.2)
|
17
17
|
builder (~> 3.1)
|
18
18
|
erubi (~> 1.4)
|
19
19
|
rails-dom-testing (~> 2.0)
|
20
20
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
21
|
-
activesupport (6.1.3)
|
21
|
+
activesupport (6.1.3.2)
|
22
22
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
23
23
|
i18n (>= 1.6, < 2)
|
24
24
|
minitest (>= 5.1)
|
@@ -52,14 +52,18 @@ GEM
|
|
52
52
|
http-form_data (2.3.0)
|
53
53
|
http-parser (1.2.3)
|
54
54
|
ffi-compiler (>= 1.0, < 2.0)
|
55
|
-
i18n (1.8.
|
55
|
+
i18n (1.8.10)
|
56
56
|
concurrent-ruby (~> 1.0)
|
57
57
|
json (2.5.1)
|
58
|
-
loofah (2.9.
|
58
|
+
loofah (2.9.1)
|
59
59
|
crass (~> 1.0.2)
|
60
60
|
nokogiri (>= 1.5.9)
|
61
61
|
minitest (5.14.4)
|
62
|
-
nokogiri (1.11.
|
62
|
+
nokogiri (1.11.3-arm64-darwin)
|
63
|
+
racc (~> 1.4)
|
64
|
+
nokogiri (1.11.3-x86_64-darwin)
|
65
|
+
racc (~> 1.4)
|
66
|
+
nokogiri (1.11.2-x86_64-linux)
|
63
67
|
racc (~> 1.4)
|
64
68
|
parallel (1.20.1)
|
65
69
|
parser (3.0.0.0)
|
@@ -74,7 +78,7 @@ GEM
|
|
74
78
|
rainbow (3.0.0)
|
75
79
|
rake (13.0.3)
|
76
80
|
regexp_parser (2.1.1)
|
77
|
-
rexml (3.2.
|
81
|
+
rexml (3.2.5)
|
78
82
|
rspec (3.10.0)
|
79
83
|
rspec-core (~> 3.10.0)
|
80
84
|
rspec-expectations (~> 3.10.0)
|
@@ -114,7 +118,9 @@ GEM
|
|
114
118
|
zeitwerk (2.4.2)
|
115
119
|
|
116
120
|
PLATFORMS
|
121
|
+
arm64-darwin-20
|
117
122
|
x86_64-darwin-19
|
123
|
+
x86_64-linux
|
118
124
|
|
119
125
|
DEPENDENCIES
|
120
126
|
byebug
|
@@ -125,4 +131,4 @@ DEPENDENCIES
|
|
125
131
|
webmock (~> 3.12)
|
126
132
|
|
127
133
|
BUNDLED WITH
|
128
|
-
2.2.
|
134
|
+
2.2.16
|
data/README.md
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
# DEV.to Interactions to Orbit Workspace
|
2
2
|
|
3
|
-
![Build Status](https://github.com/
|
3
|
+
![Build Status](https://github.com/orbit-love/community-ruby-dev-orbit/workflows/CI/badge.svg)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/dev_orbit.svg)](https://badge.fury.io/rb/dev_orbit)
|
5
5
|
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](code_of_conduct.md)
|
6
6
|
|
7
7
|
This is a Ruby gem that can be used to integrate your DEV interactions, like DEV comments on blog posts, into your organization's Orbit workspace.
|
8
8
|
|
9
|
+
|<p align="left">:sparkles:</p> This is a *community project*. The Orbit team does its best to maintain it and keep it up to date with any recent API changes.<br/><br/>We welcome community contributions to make sure that it stays current. <p align="right">:sparkles:</p>|
|
10
|
+
|-----------------------------------------|
|
11
|
+
|
9
12
|
## Installation
|
10
13
|
|
11
14
|
Add this line to your application's Gemfile:
|
@@ -56,7 +59,16 @@ client.comments
|
|
56
59
|
|
57
60
|
This method will fetch all your articles from DEV, gather their respective comments, filter them for anything within the past day, and then send them to your Orbit workspace via the Orbit API.
|
58
61
|
|
59
|
-
|
62
|
+
|
63
|
+
### Post New DEV Followers to Orbit Workspace
|
64
|
+
|
65
|
+
You can use the gem to get new DEV followers by invoking the `#followers` method on your `client` instance:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
client.followers
|
69
|
+
```
|
70
|
+
|
71
|
+
You can run this either of those or any one of them as a daily cron job, for example, to add your newest DEV comments and/or followers as activities and members in your Orbit workspace.
|
60
72
|
|
61
73
|
### CLI
|
62
74
|
|
@@ -68,9 +80,15 @@ You can also use the built-in CLI to perform the following operations:
|
|
68
80
|
$ ORBIT_API_KEY='...' ORBIT_WORKSPACE='...' DEV_API_KEY='...' DEV_USERNAME='...' bundle exec dev_orbit --check-comments
|
69
81
|
```
|
70
82
|
|
83
|
+
* Check for new DEV followers and post them to Orbit
|
84
|
+
|
85
|
+
```bash
|
86
|
+
$ ORBIT_API_KEY='...' ORBIT_WORKSPACE='...' DEV_API_KEY='...' DEV_USERNAME='...' bundle exec dev_orbit --check-followers
|
87
|
+
```
|
88
|
+
|
71
89
|
## Contributing
|
72
90
|
|
73
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
91
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/orbit-love/community-ruby-dev-orbit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/orbit-love/community-ruby-dev-orbit/blob/main/CODE_OF_CONDUCT.md).
|
74
92
|
|
75
93
|
## License
|
76
94
|
|
@@ -78,4 +96,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
78
96
|
|
79
97
|
## Code of Conduct
|
80
98
|
|
81
|
-
Everyone interacting in the project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
99
|
+
Everyone interacting in the project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/orbit-love/community-ruby-dev-orbit/blob/main/CODE_OF_CONDUCT.md).
|
data/bin/dev_orbit
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'optparse'
|
3
3
|
|
4
4
|
check_comments = false
|
5
|
+
check_followers = false
|
5
6
|
|
6
7
|
options = {}
|
7
8
|
choices = OptionParser.new do |opts|
|
@@ -13,6 +14,9 @@ choices = OptionParser.new do |opts|
|
|
13
14
|
opts.on("--check-comments", "Check for new DEV comments") do
|
14
15
|
check_comments = true
|
15
16
|
end
|
17
|
+
opts.on("--check-followers", "Check for new DEV followers") do
|
18
|
+
check_followers = true
|
19
|
+
end
|
16
20
|
end.parse!
|
17
21
|
|
18
22
|
$LOAD_PATH.unshift(File.expand_path('../lib/dev_orbit', __dir__))
|
@@ -25,3 +29,9 @@ if check_comments
|
|
25
29
|
ARGV[0] = 'render'
|
26
30
|
DevOrbit::Scripts::CheckComments.start(ARGV)
|
27
31
|
end
|
32
|
+
|
33
|
+
if check_followers
|
34
|
+
puts "Checking for new DEV followers posting them to your Orbit workspace..."
|
35
|
+
ARGV[0] = 'render'
|
36
|
+
DevOrbit::Scripts::CheckFollowers.start(ARGV)
|
37
|
+
end
|
data/dev_orbit.gemspec
CHANGED
@@ -5,18 +5,18 @@ require_relative "lib/dev_orbit/version"
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "dev_orbit"
|
7
7
|
spec.version = DevOrbit::VERSION
|
8
|
-
spec.authors = ["Ben Greenberg"]
|
9
|
-
spec.email = ["
|
8
|
+
spec.authors = ["Orbit DevRel", "Ben Greenberg"]
|
9
|
+
spec.email = ["devrel@orbit.love"]
|
10
10
|
|
11
11
|
spec.summary = "Integrate DEV interactions into your Orbit workspace"
|
12
12
|
spec.description = "This gem integrates DEV blog interactions like comments, etc. into your Orbit workspace"
|
13
|
-
spec.homepage = "https://github.com/
|
13
|
+
spec.homepage = "https://github.com/orbit-love/community-ruby-dev-orbit"
|
14
14
|
spec.license = "MIT"
|
15
15
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
-
spec.metadata["source_code_uri"] = "https://github.com/
|
19
|
-
spec.metadata["changelog_uri"] = "https://github.com/
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/orbit-love/community-ruby-dev-orbit"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/orbit-love/community-ruby-dev-orbit/blob/main/CHANGELOG.md"
|
20
20
|
|
21
21
|
# Specify which files should be added to the gem when it is released.
|
22
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
data/lib/dev_orbit/client.rb
CHANGED
@@ -44,6 +44,15 @@ module DevOrbit
|
|
44
44
|
).process_comments
|
45
45
|
end
|
46
46
|
|
47
|
+
def followers
|
48
|
+
DevOrbit::Dev.new(
|
49
|
+
api_key: @dev_api_key,
|
50
|
+
username: @dev_username,
|
51
|
+
workspace_id: @orbit_workspace,
|
52
|
+
orbit_api_key: @orbit_api_key
|
53
|
+
).process_followers
|
54
|
+
end
|
55
|
+
|
47
56
|
def orbit
|
48
57
|
DevOrbit::Orbit.new
|
49
58
|
end
|
data/lib/dev_orbit/dev.rb
CHANGED
@@ -20,7 +20,7 @@ module DevOrbit
|
|
20
20
|
articles.each do |article|
|
21
21
|
comments = get_article_comments(article["id"])
|
22
22
|
|
23
|
-
next if comments.empty?
|
23
|
+
next if comments.nil? || comments.empty?
|
24
24
|
|
25
25
|
DevOrbit::Orbit.call(
|
26
26
|
type: "comments",
|
@@ -35,6 +35,23 @@ module DevOrbit
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
def process_followers
|
39
|
+
followers = get_followers
|
40
|
+
|
41
|
+
followers.each do |follower|
|
42
|
+
next if follower.nil? || follower.empty?
|
43
|
+
|
44
|
+
DevOrbit::Orbit.call(
|
45
|
+
type: "followers",
|
46
|
+
data: {
|
47
|
+
follower: follower
|
48
|
+
},
|
49
|
+
workspace_id: @workspace_id,
|
50
|
+
api_key: @orbit_api_key
|
51
|
+
)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
38
55
|
private
|
39
56
|
|
40
57
|
def get_articles
|
@@ -49,6 +66,19 @@ module DevOrbit
|
|
49
66
|
JSON.parse(response.body) if DevOrbit::Utils.valid_json?(response.body)
|
50
67
|
end
|
51
68
|
|
69
|
+
def get_followers
|
70
|
+
url = URI("https://dev.to/api/followers/users")
|
71
|
+
https = Net::HTTP.new(url.host, url.port)
|
72
|
+
https.use_ssl = true
|
73
|
+
|
74
|
+
request = Net::HTTP::Get.new(url)
|
75
|
+
request["api_key"] = @api_key
|
76
|
+
|
77
|
+
response = https.request(request)
|
78
|
+
|
79
|
+
JSON.parse(response.body) if DevOrbit::Utils.valid_json?(response.body)
|
80
|
+
end
|
81
|
+
|
52
82
|
def get_article_comments(id)
|
53
83
|
url = URI("https://dev.to/api/comments?a_id=#{id}")
|
54
84
|
https = Net::HTTP.new(url.host, url.port)
|
@@ -60,12 +90,14 @@ module DevOrbit
|
|
60
90
|
|
61
91
|
comments = JSON.parse(response.body) if DevOrbit::Utils.valid_json?(response.body)
|
62
92
|
|
93
|
+
return if comments.nil? || comments.empty?
|
94
|
+
|
63
95
|
filter_comments(comments)
|
64
96
|
end
|
65
97
|
|
66
98
|
def filter_comments(comments)
|
67
99
|
comments.select do |comment|
|
68
|
-
comment["created_at"]
|
100
|
+
comment["created_at"] <= 1.day.ago
|
69
101
|
end
|
70
102
|
end
|
71
103
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "net/http"
|
4
|
+
require "json"
|
5
|
+
require "action_view"
|
6
|
+
require_relative "../utils"
|
7
|
+
|
8
|
+
module DevOrbit
|
9
|
+
module Interactions
|
10
|
+
class Follower
|
11
|
+
def initialize(id:, name:, username:, url:, workspace_id:, api_key:)
|
12
|
+
@id = id
|
13
|
+
@name = name
|
14
|
+
@username = username
|
15
|
+
@url = url
|
16
|
+
@workspace_id = workspace_id
|
17
|
+
@api_key = api_key
|
18
|
+
|
19
|
+
after_initialize!
|
20
|
+
end
|
21
|
+
|
22
|
+
def after_initialize!
|
23
|
+
url = URI("https://app.orbit.love/api/v1/#{@workspace_id}/members")
|
24
|
+
|
25
|
+
http = Net::HTTP.new(url.host, url.port)
|
26
|
+
http.use_ssl = true
|
27
|
+
req = Net::HTTP::Post.new(url)
|
28
|
+
req["Accept"] = "application/json"
|
29
|
+
req["Content-Type"] = "application/json"
|
30
|
+
req["Authorization"] = "Bearer #{@api_key}"
|
31
|
+
|
32
|
+
req.body = construct_body
|
33
|
+
|
34
|
+
req.body = req.body.to_json
|
35
|
+
|
36
|
+
response = http.request(req)
|
37
|
+
|
38
|
+
JSON.parse(response.body) if DevOrbit::Utils.valid_json?(response.body)
|
39
|
+
end
|
40
|
+
|
41
|
+
def construct_body
|
42
|
+
{
|
43
|
+
member: {
|
44
|
+
name: @name.include?("_") ? @name.split("_").map(&:capitalize).join(" ") : @name,
|
45
|
+
devto: @username,
|
46
|
+
url: "https://dev.to#{@url}"
|
47
|
+
}
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/dev_orbit/orbit.rb
CHANGED
@@ -17,6 +17,17 @@ module DevOrbit
|
|
17
17
|
)
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
if type == "followers"
|
22
|
+
DevOrbit::Interactions::Follower.new(
|
23
|
+
id: data[:follower]["id"],
|
24
|
+
name: data[:follower]["name"],
|
25
|
+
username: data[:follower]["username"],
|
26
|
+
url: data[:follower]["path"],
|
27
|
+
workspace_id: workspace_id,
|
28
|
+
api_key: api_key
|
29
|
+
)
|
30
|
+
end
|
20
31
|
end
|
21
32
|
end
|
22
33
|
end
|
data/lib/dev_orbit/version.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "dev_orbit"
|
5
|
+
require "thor"
|
6
|
+
|
7
|
+
module DevOrbit
|
8
|
+
module Scripts
|
9
|
+
class CheckFollowers < Thor
|
10
|
+
desc "render", "check for new DEV followers and push them to Orbit"
|
11
|
+
def render
|
12
|
+
client = DevOrbit::Client.new
|
13
|
+
client.followers
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev_orbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Orbit DevRel
|
7
8
|
- Ben Greenberg
|
8
|
-
autorequire:
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2021-
|
12
|
+
date: 2021-05-11 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: activesupport
|
@@ -125,7 +126,7 @@ dependencies:
|
|
125
126
|
description: This gem integrates DEV blog interactions like comments, etc. into your
|
126
127
|
Orbit workspace
|
127
128
|
email:
|
128
|
-
-
|
129
|
+
- devrel@orbit.love
|
129
130
|
executables:
|
130
131
|
- console
|
131
132
|
- dev_orbit
|
@@ -153,18 +154,20 @@ files:
|
|
153
154
|
- lib/dev_orbit/client.rb
|
154
155
|
- lib/dev_orbit/dev.rb
|
155
156
|
- lib/dev_orbit/interactions/comment.rb
|
157
|
+
- lib/dev_orbit/interactions/follower.rb
|
156
158
|
- lib/dev_orbit/orbit.rb
|
157
159
|
- lib/dev_orbit/utils.rb
|
158
160
|
- lib/dev_orbit/version.rb
|
159
161
|
- scripts/check_comments.rb
|
160
|
-
|
162
|
+
- scripts/check_followers.rb
|
163
|
+
homepage: https://github.com/orbit-love/community-ruby-dev-orbit
|
161
164
|
licenses:
|
162
165
|
- MIT
|
163
166
|
metadata:
|
164
|
-
homepage_uri: https://github.com/
|
165
|
-
source_code_uri: https://github.com/
|
166
|
-
changelog_uri: https://github.com/
|
167
|
-
post_install_message:
|
167
|
+
homepage_uri: https://github.com/orbit-love/community-ruby-dev-orbit
|
168
|
+
source_code_uri: https://github.com/orbit-love/community-ruby-dev-orbit
|
169
|
+
changelog_uri: https://github.com/orbit-love/community-ruby-dev-orbit/blob/main/CHANGELOG.md
|
170
|
+
post_install_message:
|
168
171
|
rdoc_options: []
|
169
172
|
require_paths:
|
170
173
|
- lib
|
@@ -179,8 +182,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
182
|
- !ruby/object:Gem::Version
|
180
183
|
version: '0'
|
181
184
|
requirements: []
|
182
|
-
rubygems_version: 3.
|
183
|
-
signing_key:
|
185
|
+
rubygems_version: 3.2.15
|
186
|
+
signing_key:
|
184
187
|
specification_version: 4
|
185
188
|
summary: Integrate DEV interactions into your Orbit workspace
|
186
189
|
test_files: []
|