dev_orbit 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.sample +2 -1
- data/.gitignore +2 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +14 -3
- data/README.md +29 -8
- data/bin/dev_orbit +11 -0
- data/dev_orbit.gemspec +1 -0
- data/lib/dev_orbit.rb +2 -0
- data/lib/dev_orbit/client.rb +16 -3
- data/lib/dev_orbit/dev.rb +12 -4
- data/lib/dev_orbit/interactions/comment.rb +13 -17
- data/lib/dev_orbit/interactions/follower.rb +1 -0
- data/lib/dev_orbit/version.rb +1 -1
- data/readme-images/new-comment-screenshot.png +0 -0
- data/readme-images/ways-to-use.png +0 -0
- data/scripts/check_org_comments.rb +17 -0
- metadata +19 -6
- data/bin/console +0 -15
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 051a39f2fff550c076f0a7bec373c7634f0b6516a9173121ba4b9facebfa157c
|
4
|
+
data.tar.gz: acad969ccbc5ac6dd29b176f069e4a94eb00cec1ffa69c301a9c5da5284e3d6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6953c67373ff7f8ae654a87916045b54c2254736809fd074ff26f6a46b400a9e6144226eaf29d2247e3e532877735b378adc77e28b29532e3d4325cf5b22ebce
|
7
|
+
data.tar.gz: e1a4069e95e2b5ff86b14625132bef5e5342c55e1e2d4cd767345fbd53e114cbb5ed5515826e554ffbeb04d929f1bdab1322b93868504a651a0a2ac0afef5cac
|
data/.env.sample
CHANGED
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dev_orbit (0.1.
|
4
|
+
dev_orbit (0.1.3)
|
5
5
|
actionview (~> 6.1)
|
6
6
|
activesupport (~> 6.1)
|
7
7
|
http (~> 4.4)
|
8
8
|
json (~> 2.5)
|
9
|
+
orbit_activities (~> 0.1)
|
9
10
|
thor (~> 1.1)
|
10
11
|
zeitwerk (~> 2.4)
|
11
12
|
|
@@ -59,12 +60,21 @@ GEM
|
|
59
60
|
crass (~> 1.0.2)
|
60
61
|
nokogiri (>= 1.5.9)
|
61
62
|
minitest (5.14.4)
|
62
|
-
nokogiri (1.11.
|
63
|
+
nokogiri (1.11.5-arm64-darwin)
|
64
|
+
racc (~> 1.4)
|
65
|
+
nokogiri (1.11.5-x86_64-darwin)
|
66
|
+
racc (~> 1.4)
|
67
|
+
nokogiri (1.11.5-x86_64-linux)
|
63
68
|
racc (~> 1.4)
|
64
69
|
nokogiri (1.11.3-x86_64-darwin)
|
65
70
|
racc (~> 1.4)
|
66
|
-
nokogiri (1.11.
|
71
|
+
nokogiri (1.11.3-x86_64-linux)
|
67
72
|
racc (~> 1.4)
|
73
|
+
orbit_activities (0.1.0)
|
74
|
+
http (~> 4.4)
|
75
|
+
json (~> 2.5)
|
76
|
+
rake (~> 13.0)
|
77
|
+
zeitwerk (~> 2.4)
|
68
78
|
parallel (1.20.1)
|
69
79
|
parser (3.0.0.0)
|
70
80
|
ast (~> 2.4.1)
|
@@ -125,6 +135,7 @@ PLATFORMS
|
|
125
135
|
DEPENDENCIES
|
126
136
|
byebug
|
127
137
|
dev_orbit!
|
138
|
+
orbit_activities
|
128
139
|
rake (~> 13.0)
|
129
140
|
rspec (~> 3.4)
|
130
141
|
rubocop (~> 1.7)
|
data/README.md
CHANGED
@@ -4,11 +4,14 @@
|
|
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
|
+
Add your DEV interactions into your Orbit workspace with this community-built integration.
|
8
|
+
|
9
|
+
![New DEV blog post comment in Orbit screenshot](readme-images/new-comment-screenshot.png)
|
8
10
|
|
9
11
|
|<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
12
|
|-----------------------------------------|
|
11
13
|
|
14
|
+
![There are three ways to use this integration. Install package - build and run your own applications. Run the CLI - run on-demand directly from your terminal. Schedule an automation with GitHub - get started in minutes - no coding required](readme-images/ways-to-use.png)
|
12
15
|
## Installation
|
13
16
|
|
14
17
|
Add this line to your application's Gemfile:
|
@@ -23,13 +26,14 @@ gem 'dev_orbit'
|
|
23
26
|
|
24
27
|
To instantiate a DevOrbit client, you can either pass along your credentials for DEV and Orbit directly to the instantiation or retain them in your environment variables.
|
25
28
|
|
26
|
-
The following are the
|
29
|
+
The following are the environment variables, you can provide either or both a `DEV_USERNAME` or a `DEV_ORGANIZATION`:
|
27
30
|
|
28
31
|
```ruby
|
29
32
|
ORBIT_API_KEY
|
30
33
|
ORBIT_WORKSPACE_ID
|
31
34
|
DEV_API_KEY
|
32
35
|
DEV_USERNAME
|
36
|
+
DEV_ORGANIZATION
|
33
37
|
```
|
34
38
|
|
35
39
|
With the credentials as environment variables:
|
@@ -45,19 +49,30 @@ client = DevOrbit::Client.new(
|
|
45
49
|
orbit_api_key: '...',
|
46
50
|
orbit_workspace: '...',
|
47
51
|
dev_api_key: '...',
|
48
|
-
dev_username: '...'
|
52
|
+
dev_username: '...',
|
53
|
+
dev_organization: '...'
|
49
54
|
)
|
50
55
|
```
|
51
56
|
|
52
|
-
### Post New DEV Comments to Orbit Workspace
|
57
|
+
### Post New DEV Comments from a DEV User to Orbit Workspace
|
53
58
|
|
54
|
-
You can use the gem to get new DEV comments on your DEV user
|
59
|
+
You can use the gem to get new DEV comments on your DEV user by invoking the `#comments` method on your `client` instance:
|
55
60
|
|
56
61
|
```ruby
|
57
62
|
client.comments
|
58
63
|
```
|
59
64
|
|
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.
|
65
|
+
This method will fetch all your user 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.
|
66
|
+
|
67
|
+
### Post New DEV Comments from a DEV Organization to Orbit Workspace
|
68
|
+
|
69
|
+
You can use the gem to get new DEV comments on your DEV organization by invoking the `#comments` method on your `client` instance:
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
client.organization_comments
|
73
|
+
```
|
74
|
+
|
75
|
+
This method will fetch all your organization 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.
|
61
76
|
|
62
77
|
|
63
78
|
### Post New DEV Followers to Orbit Workspace
|
@@ -74,18 +89,24 @@ You can run this either of those or any one of them as a daily cron job, for exa
|
|
74
89
|
|
75
90
|
You can also use the built-in CLI to perform the following operations:
|
76
91
|
|
77
|
-
* Check for new DEV comments and post them to Orbit
|
92
|
+
* Check for new DEV user comments and post them to Orbit
|
78
93
|
|
79
94
|
```bash
|
80
95
|
$ ORBIT_API_KEY='...' ORBIT_WORKSPACE='...' DEV_API_KEY='...' DEV_USERNAME='...' bundle exec dev_orbit --check-comments
|
81
96
|
```
|
82
97
|
|
83
|
-
* Check for new DEV followers and post them to Orbit
|
98
|
+
* Check for new DEV user followers and post them to Orbit
|
84
99
|
|
85
100
|
```bash
|
86
101
|
$ ORBIT_API_KEY='...' ORBIT_WORKSPACE='...' DEV_API_KEY='...' DEV_USERNAME='...' bundle exec dev_orbit --check-followers
|
87
102
|
```
|
88
103
|
|
104
|
+
* Check for new DEV organization comments and post them to Orbit
|
105
|
+
|
106
|
+
```bash
|
107
|
+
$ ORBIT_API_KEY='...' ORBIT_WORKSPACE='...' DEV_API_KEY='...' DEV_ORGANIZATION='...' bundle exec dev_orbit --check-organization-comments
|
108
|
+
```
|
109
|
+
|
89
110
|
## Contributing
|
90
111
|
|
91
112
|
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).
|
data/bin/dev_orbit
CHANGED
@@ -3,6 +3,7 @@ require 'optparse'
|
|
3
3
|
|
4
4
|
check_comments = false
|
5
5
|
check_followers = false
|
6
|
+
check_org_comments = false
|
6
7
|
|
7
8
|
options = {}
|
8
9
|
choices = OptionParser.new do |opts|
|
@@ -17,6 +18,9 @@ choices = OptionParser.new do |opts|
|
|
17
18
|
opts.on("--check-followers", "Check for new DEV followers") do
|
18
19
|
check_followers = true
|
19
20
|
end
|
21
|
+
opts.on("--check-organization-comments", "Check for new DEV comments for an organization") do
|
22
|
+
check_org_comments = true
|
23
|
+
end
|
20
24
|
end.parse!
|
21
25
|
|
22
26
|
$LOAD_PATH.unshift(File.expand_path('../lib/dev_orbit', __dir__))
|
@@ -24,6 +28,7 @@ $LOAD_PATH.unshift(File.expand_path('../lib/dev_orbit', __dir__))
|
|
24
28
|
require_relative '../lib/dev_orbit'
|
25
29
|
require_relative '../scripts/check_comments'
|
26
30
|
require_relative '../scripts/check_followers'
|
31
|
+
require_relative '../scripts/check_org_comments'
|
27
32
|
|
28
33
|
if check_comments
|
29
34
|
puts "Checking for new DEV comments within the past day and posting them to your Orbit workspace..."
|
@@ -36,3 +41,9 @@ if check_followers
|
|
36
41
|
ARGV[0] = 'render'
|
37
42
|
DevOrbit::Scripts::CheckFollowers.start(ARGV)
|
38
43
|
end
|
44
|
+
|
45
|
+
if check_org_comments
|
46
|
+
puts "Checking for new DEV organization comments and posting them to your Orbit workspace..."
|
47
|
+
ARGV[0] = 'render'
|
48
|
+
DevOrbit::Scripts::CheckOrgComments.start(ARGV)
|
49
|
+
end
|
data/dev_orbit.gemspec
CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_dependency "json", "~> 2.5"
|
36
36
|
spec.add_dependency "zeitwerk", "~> 2.4"
|
37
37
|
spec.add_dependency "thor", "~> 1.1"
|
38
|
+
spec.add_dependency "orbit_activities", "~> 0.1"
|
38
39
|
spec.add_development_dependency "rspec", "~> 3.4"
|
39
40
|
spec.add_development_dependency "webmock", "~> 3.12"
|
40
41
|
|
data/lib/dev_orbit.rb
CHANGED
data/lib/dev_orbit/client.rb
CHANGED
@@ -13,6 +13,9 @@
|
|
13
13
|
# @option params [String] :dev_api_key
|
14
14
|
# The API key for the DEV API
|
15
15
|
#
|
16
|
+
# @option params [String] :dev_organization
|
17
|
+
# The name of the organization in DEV to fetch interactions for
|
18
|
+
#
|
16
19
|
# @option params [String] :orbit_workspace
|
17
20
|
# The workspace ID for the Orbit workspace
|
18
21
|
#
|
@@ -25,23 +28,24 @@
|
|
25
28
|
#
|
26
29
|
module DevOrbit
|
27
30
|
class Client
|
28
|
-
attr_accessor :dev_username, :dev_api_key, :orbit_workspace, :orbit_api_key
|
31
|
+
attr_accessor :dev_username, :dev_api_key, :dev_organization, :orbit_workspace, :orbit_api_key
|
29
32
|
|
30
33
|
def initialize(params = {})
|
31
34
|
@orbit_api_key = params.fetch(:orbit_api_key, ENV["ORBIT_API_KEY"])
|
32
35
|
@orbit_workspace = params.fetch(:orbit_workspace, ENV["ORBIT_WORKSPACE_ID"])
|
33
36
|
@dev_api_key = params.fetch(:dev_api_key, ENV["DEV_API_KEY"])
|
34
37
|
@dev_username = params.fetch(:dev_username, ENV["DEV_USERNAME"])
|
38
|
+
@dev_organization = params.fetch(:dev_organization, ENV["DEV_ORGANIZATION"])
|
35
39
|
end
|
36
40
|
|
37
41
|
# Fetch new comments from DEV and post them to the Orbit workspace
|
38
|
-
def comments
|
42
|
+
def comments(type: "user")
|
39
43
|
DevOrbit::Dev.new(
|
40
44
|
api_key: @dev_api_key,
|
41
45
|
username: @dev_username,
|
42
46
|
workspace_id: @orbit_workspace,
|
43
47
|
orbit_api_key: @orbit_api_key
|
44
|
-
).process_comments
|
48
|
+
).process_comments(type: type)
|
45
49
|
end
|
46
50
|
|
47
51
|
def followers
|
@@ -53,6 +57,15 @@ module DevOrbit
|
|
53
57
|
).process_followers
|
54
58
|
end
|
55
59
|
|
60
|
+
def organization_comments(type: "organization")
|
61
|
+
DevOrbit::Dev.new(
|
62
|
+
api_key: @dev_api_key,
|
63
|
+
organization: @dev_organization,
|
64
|
+
workspace_id: @orbit_workspace,
|
65
|
+
orbit_api_key: @orbit_api_key
|
66
|
+
).process_comments(type: type)
|
67
|
+
end
|
68
|
+
|
56
69
|
def orbit
|
57
70
|
DevOrbit::Orbit.new
|
58
71
|
end
|
data/lib/dev_orbit/dev.rb
CHANGED
@@ -9,13 +9,14 @@ module DevOrbit
|
|
9
9
|
class Dev
|
10
10
|
def initialize(params = {})
|
11
11
|
@username = params.fetch(:username, ENV["DEV_USERNAME"])
|
12
|
+
@organization = params.fetch(:organization, ENV["DEV_ORGANIZATION"])
|
12
13
|
@api_key = params.fetch(:api_key, ENV["DEV_API_KEY"])
|
13
14
|
@workspace_id = params.fetch(:workspace_id, ENV["ORBIT_WORKSPACE_ID"])
|
14
15
|
@orbit_api_key = params.fetch(:orbit_api_key, ENV["ORBIT_API_KEY"])
|
15
16
|
end
|
16
17
|
|
17
|
-
def process_comments
|
18
|
-
articles = get_articles
|
18
|
+
def process_comments(type:)
|
19
|
+
articles = get_articles(type: type)
|
19
20
|
|
20
21
|
articles.each do |article|
|
21
22
|
comments = get_article_comments(article["id"])
|
@@ -54,8 +55,15 @@ module DevOrbit
|
|
54
55
|
|
55
56
|
private
|
56
57
|
|
57
|
-
def get_articles
|
58
|
-
|
58
|
+
def get_articles(type:)
|
59
|
+
if type == "user"
|
60
|
+
url = URI("https://dev.to/api/articles?username=#{@username}&top=1")
|
61
|
+
end
|
62
|
+
|
63
|
+
if type == "organization"
|
64
|
+
url = URI("https://dev.to/api/organizations/#{@organization}/articles")
|
65
|
+
end
|
66
|
+
|
59
67
|
https = Net::HTTP.new(url.host, url.port)
|
60
68
|
https.use_ssl = true
|
61
69
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "net/http"
|
4
3
|
require "json"
|
5
4
|
require "action_view"
|
6
5
|
require_relative "../utils"
|
@@ -22,22 +21,13 @@ module DevOrbit
|
|
22
21
|
end
|
23
22
|
|
24
23
|
def after_initialize!
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
req["Authorization"] = "Bearer #{@api_key}"
|
33
|
-
|
34
|
-
req.body = construct_body
|
35
|
-
|
36
|
-
req.body = req.body.to_json
|
37
|
-
|
38
|
-
response = http.request(req)
|
39
|
-
|
40
|
-
JSON.parse(response.body) if DevOrbit::Utils.valid_json?(response.body)
|
24
|
+
OrbitActivities::Request.new(
|
25
|
+
api_key: @api_key,
|
26
|
+
workspace_id: @workspace_id,
|
27
|
+
user_agent: "community-ruby-dev-orbit/#{DevOrbit::VERSION}",
|
28
|
+
action: "new_activity",
|
29
|
+
body: construct_body.to_json
|
30
|
+
)
|
41
31
|
end
|
42
32
|
|
43
33
|
def construct_body
|
@@ -65,6 +55,8 @@ module DevOrbit
|
|
65
55
|
|
66
56
|
hash[:activity][:member].merge!(github: @commenter[:github]) if @commenter[:github]
|
67
57
|
|
58
|
+
hash[:activity][:member].merge(url: @commenter[:url]) if @commenter[:url]
|
59
|
+
|
68
60
|
hash
|
69
61
|
end
|
70
62
|
|
@@ -84,6 +76,10 @@ module DevOrbit
|
|
84
76
|
hash.merge!('github': commenter[:github_username])
|
85
77
|
end
|
86
78
|
|
79
|
+
unless commenter[:website_url].nil? || commenter[:website_url] == ""
|
80
|
+
hash.merge('url': commenter[:website_url])
|
81
|
+
end
|
82
|
+
|
87
83
|
hash
|
88
84
|
end
|
89
85
|
|
data/lib/dev_orbit/version.rb
CHANGED
Binary file
|
Binary file
|
@@ -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 CheckOrgComments < Thor
|
10
|
+
desc "render", "check for new DEV comments on an organization and push them to Orbit"
|
11
|
+
def render
|
12
|
+
client = DevOrbit::Client.new
|
13
|
+
client.organization_comments
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev_orbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Orbit DevRel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-06-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -95,6 +95,20 @@ dependencies:
|
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '1.1'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: orbit_activities
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0.1'
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0.1'
|
98
112
|
- !ruby/object:Gem::Dependency
|
99
113
|
name: rspec
|
100
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,9 +142,7 @@ description: This gem integrates DEV blog interactions like comments, etc. into
|
|
128
142
|
email:
|
129
143
|
- devrel@orbit.love
|
130
144
|
executables:
|
131
|
-
- console
|
132
145
|
- dev_orbit
|
133
|
-
- setup
|
134
146
|
extensions: []
|
135
147
|
extra_rdoc_files: []
|
136
148
|
files:
|
@@ -146,9 +158,7 @@ files:
|
|
146
158
|
- LICENSE.txt
|
147
159
|
- README.md
|
148
160
|
- Rakefile
|
149
|
-
- bin/console
|
150
161
|
- bin/dev_orbit
|
151
|
-
- bin/setup
|
152
162
|
- dev_orbit.gemspec
|
153
163
|
- lib/dev_orbit.rb
|
154
164
|
- lib/dev_orbit/client.rb
|
@@ -158,8 +168,11 @@ files:
|
|
158
168
|
- lib/dev_orbit/orbit.rb
|
159
169
|
- lib/dev_orbit/utils.rb
|
160
170
|
- lib/dev_orbit/version.rb
|
171
|
+
- readme-images/new-comment-screenshot.png
|
172
|
+
- readme-images/ways-to-use.png
|
161
173
|
- scripts/check_comments.rb
|
162
174
|
- scripts/check_followers.rb
|
175
|
+
- scripts/check_org_comments.rb
|
163
176
|
homepage: https://github.com/orbit-love/community-ruby-dev-orbit
|
164
177
|
licenses:
|
165
178
|
- MIT
|
data/bin/console
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "bundler/setup"
|
5
|
-
require "dev_orbit"
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require "irb"
|
15
|
-
IRB.start(__FILE__)
|