dev_orbit 0.1.6 → 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/README.md +25 -7
- data/bin/dev_orbit +11 -0
- data/lib/dev_orbit/client.rb +16 -3
- data/lib/dev_orbit/dev.rb +12 -4
- data/lib/dev_orbit/interactions/comment.rb +6 -0
- data/lib/dev_orbit/version.rb +1 -1
- data/scripts/check_org_comments.rb +17 -0
- metadata +3 -2
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/README.md
CHANGED
@@ -26,13 +26,14 @@ gem 'dev_orbit'
|
|
26
26
|
|
27
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.
|
28
28
|
|
29
|
-
The following are the
|
29
|
+
The following are the environment variables, you can provide either or both a `DEV_USERNAME` or a `DEV_ORGANIZATION`:
|
30
30
|
|
31
31
|
```ruby
|
32
32
|
ORBIT_API_KEY
|
33
33
|
ORBIT_WORKSPACE_ID
|
34
34
|
DEV_API_KEY
|
35
35
|
DEV_USERNAME
|
36
|
+
DEV_ORGANIZATION
|
36
37
|
```
|
37
38
|
|
38
39
|
With the credentials as environment variables:
|
@@ -48,19 +49,30 @@ client = DevOrbit::Client.new(
|
|
48
49
|
orbit_api_key: '...',
|
49
50
|
orbit_workspace: '...',
|
50
51
|
dev_api_key: '...',
|
51
|
-
dev_username: '...'
|
52
|
+
dev_username: '...',
|
53
|
+
dev_organization: '...'
|
52
54
|
)
|
53
55
|
```
|
54
56
|
|
55
|
-
### Post New DEV Comments to Orbit Workspace
|
57
|
+
### Post New DEV Comments from a DEV User to Orbit Workspace
|
56
58
|
|
57
|
-
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:
|
58
60
|
|
59
61
|
```ruby
|
60
62
|
client.comments
|
61
63
|
```
|
62
64
|
|
63
|
-
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.
|
64
76
|
|
65
77
|
|
66
78
|
### Post New DEV Followers to Orbit Workspace
|
@@ -77,18 +89,24 @@ You can run this either of those or any one of them as a daily cron job, for exa
|
|
77
89
|
|
78
90
|
You can also use the built-in CLI to perform the following operations:
|
79
91
|
|
80
|
-
* Check for new DEV comments and post them to Orbit
|
92
|
+
* Check for new DEV user comments and post them to Orbit
|
81
93
|
|
82
94
|
```bash
|
83
95
|
$ ORBIT_API_KEY='...' ORBIT_WORKSPACE='...' DEV_API_KEY='...' DEV_USERNAME='...' bundle exec dev_orbit --check-comments
|
84
96
|
```
|
85
97
|
|
86
|
-
* Check for new DEV followers and post them to Orbit
|
98
|
+
* Check for new DEV user followers and post them to Orbit
|
87
99
|
|
88
100
|
```bash
|
89
101
|
$ ORBIT_API_KEY='...' ORBIT_WORKSPACE='...' DEV_API_KEY='...' DEV_USERNAME='...' bundle exec dev_orbit --check-followers
|
90
102
|
```
|
91
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
|
+
|
92
110
|
## Contributing
|
93
111
|
|
94
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/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
|
|
@@ -55,6 +55,8 @@ module DevOrbit
|
|
55
55
|
|
56
56
|
hash[:activity][:member].merge!(github: @commenter[:github]) if @commenter[:github]
|
57
57
|
|
58
|
+
hash[:activity][:member].merge(url: @commenter[:url]) if @commenter[:url]
|
59
|
+
|
58
60
|
hash
|
59
61
|
end
|
60
62
|
|
@@ -74,6 +76,10 @@ module DevOrbit
|
|
74
76
|
hash.merge!('github': commenter[:github_username])
|
75
77
|
end
|
76
78
|
|
79
|
+
unless commenter[:website_url].nil? || commenter[:website_url] == ""
|
80
|
+
hash.merge('url': commenter[:website_url])
|
81
|
+
end
|
82
|
+
|
77
83
|
hash
|
78
84
|
end
|
79
85
|
|
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 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
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- readme-images/ways-to-use.png
|
173
173
|
- scripts/check_comments.rb
|
174
174
|
- scripts/check_followers.rb
|
175
|
+
- scripts/check_org_comments.rb
|
175
176
|
homepage: https://github.com/orbit-love/community-ruby-dev-orbit
|
176
177
|
licenses:
|
177
178
|
- MIT
|