dev_orbit 0.0.2 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.sample +4 -0
- data/.github/workflows/ci.yml +25 -0
- data/CHANGELOG.md +22 -1
- data/Gemfile.lock +24 -1
- data/README.md +10 -0
- data/bin/dev_orbit +2 -1
- data/dev_orbit.gemspec +4 -2
- data/lib/dev_orbit/client.rb +1 -1
- data/lib/dev_orbit/dev.rb +5 -2
- data/lib/dev_orbit/interactions/comment.rb +21 -9
- data/lib/dev_orbit/utils.rb +11 -0
- data/lib/dev_orbit/version.rb +1 -1
- data/scripts/check_comments.rb +12 -5
- metadata +38 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9c02ba74434acb5637a4d93ecd37dc4883969ba36128bb001130d0b6dfbf087
|
4
|
+
data.tar.gz: 6c9eca9384cdb84eb9049d45acf25da3c05a421a75f083a2883f14fb8bef1a7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9870c95fc0e32a818528f2f0ceec830f781cf9193a63056760e30a71e94e6caa509953dfa9408cd27a3dff34003f02f5c1d030a79043d4c47cb2bd4d9606ca7
|
7
|
+
data.tar.gz: fde99905baf0e7a7faad0041c4256ad55713c2dc648e58af4590e18c25c16cf11739321176c36aee75049a249c3bf2ac423df6461a09e4541972198597facb79
|
data/.env.sample
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ main ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
strategy:
|
12
|
+
matrix:
|
13
|
+
os: [ubuntu-latest, macos-latest]
|
14
|
+
ruby: [2.7, 3.0]
|
15
|
+
runs-on: ${{ matrix.os }}
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- name: Set up Ruby
|
19
|
+
uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
22
|
+
- name: Install dependencies
|
23
|
+
run: bundle install
|
24
|
+
- name: Run tests
|
25
|
+
run: bundle exec rspec
|
data/CHANGELOG.md
CHANGED
@@ -4,4 +4,25 @@
|
|
4
4
|
|
5
5
|
## [0.0.2] - 2021-03-09
|
6
6
|
|
7
|
-
- Add a CLI to the gem to run the gem's operations
|
7
|
+
- Add a CLI to the gem to run the gem's operations
|
8
|
+
|
9
|
+
## [0.0.3] - 2021-03-09
|
10
|
+
|
11
|
+
- Bug fix for the CLI functionality, now operational
|
12
|
+
|
13
|
+
## [0.0.4] - 2021-03-10
|
14
|
+
|
15
|
+
- Bug fix for stripping the HTML from the DEV blog post comment body
|
16
|
+
|
17
|
+
## [0.0.5] - 2021-03-10
|
18
|
+
|
19
|
+
- Print out Orbit API response
|
20
|
+
|
21
|
+
## [0.0.6] - 2021-03-10
|
22
|
+
|
23
|
+
- Fix misnamed env var in client instantiation
|
24
|
+
- Add a sample `.env` file
|
25
|
+
|
26
|
+
## [0.0.7] - 2021-03-12
|
27
|
+
|
28
|
+
- Check for valid JSON from API response before continuing
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dev_orbit (0.0.
|
4
|
+
dev_orbit (0.0.6)
|
5
|
+
actionview (~> 6.1)
|
5
6
|
activesupport (~> 6.1)
|
6
7
|
http (~> 4.4)
|
7
8
|
json (~> 2.5)
|
9
|
+
thor (~> 1.1)
|
8
10
|
zeitwerk (~> 2.4)
|
9
11
|
|
10
12
|
GEM
|
11
13
|
remote: https://rubygems.org/
|
12
14
|
specs:
|
15
|
+
actionview (6.1.3)
|
16
|
+
activesupport (= 6.1.3)
|
17
|
+
builder (~> 3.1)
|
18
|
+
erubi (~> 1.4)
|
19
|
+
rails-dom-testing (~> 2.0)
|
20
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
13
21
|
activesupport (6.1.3)
|
14
22
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
23
|
i18n (>= 1.6, < 2)
|
@@ -19,13 +27,16 @@ GEM
|
|
19
27
|
addressable (2.7.0)
|
20
28
|
public_suffix (>= 2.0.2, < 5.0)
|
21
29
|
ast (2.4.2)
|
30
|
+
builder (3.2.4)
|
22
31
|
byebug (11.1.3)
|
23
32
|
concurrent-ruby (1.1.8)
|
24
33
|
crack (0.4.5)
|
25
34
|
rexml
|
35
|
+
crass (1.0.6)
|
26
36
|
diff-lcs (1.4.4)
|
27
37
|
domain_name (0.5.20190701)
|
28
38
|
unf (>= 0.0.5, < 1.0.0)
|
39
|
+
erubi (1.10.0)
|
29
40
|
ffi (1.15.0)
|
30
41
|
ffi-compiler (1.0.1)
|
31
42
|
ffi (>= 1.0.0)
|
@@ -44,11 +55,22 @@ GEM
|
|
44
55
|
i18n (1.8.9)
|
45
56
|
concurrent-ruby (~> 1.0)
|
46
57
|
json (2.5.1)
|
58
|
+
loofah (2.9.0)
|
59
|
+
crass (~> 1.0.2)
|
60
|
+
nokogiri (>= 1.5.9)
|
47
61
|
minitest (5.14.4)
|
62
|
+
nokogiri (1.11.2-x86_64-darwin)
|
63
|
+
racc (~> 1.4)
|
48
64
|
parallel (1.20.1)
|
49
65
|
parser (3.0.0.0)
|
50
66
|
ast (~> 2.4.1)
|
51
67
|
public_suffix (4.0.6)
|
68
|
+
racc (1.5.2)
|
69
|
+
rails-dom-testing (2.0.3)
|
70
|
+
activesupport (>= 4.2.0)
|
71
|
+
nokogiri (>= 1.6)
|
72
|
+
rails-html-sanitizer (1.3.0)
|
73
|
+
loofah (~> 2.3)
|
52
74
|
rainbow (3.0.0)
|
53
75
|
rake (13.0.3)
|
54
76
|
regexp_parser (2.1.1)
|
@@ -78,6 +100,7 @@ GEM
|
|
78
100
|
rubocop-ast (1.4.1)
|
79
101
|
parser (>= 2.7.1.5)
|
80
102
|
ruby-progressbar (1.11.0)
|
103
|
+
thor (1.1.0)
|
81
104
|
tzinfo (2.0.4)
|
82
105
|
concurrent-ruby (~> 1.0)
|
83
106
|
unf (0.1.4)
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# DEV.to Interactions to Orbit Workspace
|
2
2
|
|
3
|
+
![Build Status](https://github.com/bencgreenberg/dev_orbit/workflows/CI/badge.svg)
|
3
4
|
[![Gem Version](https://badge.fury.io/rb/dev_orbit.svg)](https://badge.fury.io/rb/dev_orbit)
|
4
5
|
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](code_of_conduct.md)
|
5
6
|
|
@@ -19,6 +20,15 @@ gem 'dev_orbit'
|
|
19
20
|
|
20
21
|
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.
|
21
22
|
|
23
|
+
The following are the expected environment variables:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
ORBIT_API_KEY
|
27
|
+
ORBIT_WORKSPACE_ID
|
28
|
+
DEV_API_KEY
|
29
|
+
DEV_USERNAME
|
30
|
+
```
|
31
|
+
|
22
32
|
With the credentials as environment variables:
|
23
33
|
|
24
34
|
```ruby
|
data/bin/dev_orbit
CHANGED
@@ -22,5 +22,6 @@ require_relative '../scripts/check_comments'
|
|
22
22
|
|
23
23
|
if check_comments
|
24
24
|
puts "Checking for new DEV comments within the past day and posting them to your Orbit workspace..."
|
25
|
-
|
25
|
+
ARGV[0] = 'render'
|
26
|
+
DevOrbit::Scripts::CheckComments.start(ARGV)
|
26
27
|
end
|
data/dev_orbit.gemspec
CHANGED
@@ -23,16 +23,18 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
24
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
25
25
|
end
|
26
|
-
spec.bindir = "
|
27
|
-
spec.executables = spec.files.grep(%r{
|
26
|
+
spec.bindir = "bin"
|
27
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
30
|
# Uncomment to register a new dependency of your gem
|
31
31
|
# spec.add_dependency "example-gem", "~> 1.0"
|
32
32
|
spec.add_dependency "activesupport", "~> 6.1"
|
33
|
+
spec.add_dependency "actionview", "~> 6.1"
|
33
34
|
spec.add_dependency "http", "~> 4.4"
|
34
35
|
spec.add_dependency "json", "~> 2.5"
|
35
36
|
spec.add_dependency "zeitwerk", "~> 2.4"
|
37
|
+
spec.add_dependency "thor", "~> 1.1"
|
36
38
|
spec.add_development_dependency "rspec", "~> 3.4"
|
37
39
|
spec.add_development_dependency "webmock", "~> 3.12"
|
38
40
|
|
data/lib/dev_orbit/client.rb
CHANGED
@@ -29,7 +29,7 @@ module DevOrbit
|
|
29
29
|
|
30
30
|
def initialize(params = {})
|
31
31
|
@orbit_api_key = params.fetch(:orbit_api_key, ENV["ORBIT_API_KEY"])
|
32
|
-
@orbit_workspace = params.fetch(:orbit_workspace, ENV["
|
32
|
+
@orbit_workspace = params.fetch(:orbit_workspace, ENV["ORBIT_WORKSPACE_ID"])
|
33
33
|
@dev_api_key = params.fetch(:dev_api_key, ENV["DEV_API_KEY"])
|
34
34
|
@dev_username = params.fetch(:dev_username, ENV["DEV_USERNAME"])
|
35
35
|
end
|
data/lib/dev_orbit/dev.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require "net/http"
|
4
4
|
require "json"
|
5
5
|
require "active_support/time"
|
6
|
+
require_relative "utils"
|
6
7
|
|
7
8
|
module DevOrbit
|
8
9
|
class Dev
|
@@ -18,6 +19,7 @@ module DevOrbit
|
|
18
19
|
|
19
20
|
articles.each do |article|
|
20
21
|
comments = get_article_comments(article["id"])
|
22
|
+
|
21
23
|
next if comments.empty?
|
22
24
|
|
23
25
|
DevOrbit::Orbit.call(
|
@@ -44,7 +46,7 @@ module DevOrbit
|
|
44
46
|
|
45
47
|
response = https.request(request)
|
46
48
|
|
47
|
-
JSON.parse(response.body)
|
49
|
+
JSON.parse(response.body) if DevOrbit::Utils.valid_json?(response.body)
|
48
50
|
end
|
49
51
|
|
50
52
|
def get_article_comments(id)
|
@@ -55,7 +57,8 @@ module DevOrbit
|
|
55
57
|
request = Net::HTTP::Get.new(url)
|
56
58
|
|
57
59
|
response = https.request(request)
|
58
|
-
|
60
|
+
|
61
|
+
comments = JSON.parse(response.body) if DevOrbit::Utils.valid_json?(response.body)
|
59
62
|
|
60
63
|
filter_comments(comments)
|
61
64
|
end
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require "net/http"
|
4
4
|
require "json"
|
5
|
+
require "action_view"
|
6
|
+
require_relative "../utils"
|
5
7
|
|
6
8
|
module DevOrbit
|
7
9
|
module Interactions
|
@@ -29,7 +31,17 @@ module DevOrbit
|
|
29
31
|
req["Content-Type"] = "application/json"
|
30
32
|
req["Authorization"] = "Bearer #{@api_key}"
|
31
33
|
|
32
|
-
req.body =
|
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)
|
41
|
+
end
|
42
|
+
|
43
|
+
def construct_body
|
44
|
+
hash = {
|
33
45
|
activity: {
|
34
46
|
activity_type: "dev:comment",
|
35
47
|
key: "dev-comment-#{@id}",
|
@@ -48,17 +60,15 @@ module DevOrbit
|
|
48
60
|
}
|
49
61
|
}
|
50
62
|
|
51
|
-
|
63
|
+
hash[:activity][:member].merge!(twitter: @commenter[:twitter]) if @commenter[:twitter]
|
52
64
|
|
53
|
-
|
65
|
+
hash[:activity][:member].merge!(github: @commenter[:github]) if @commenter[:github]
|
54
66
|
|
55
|
-
|
56
|
-
|
57
|
-
response = http.request(req)
|
58
|
-
|
59
|
-
JSON.parse(response.body)
|
67
|
+
hash
|
60
68
|
end
|
61
69
|
|
70
|
+
private
|
71
|
+
|
62
72
|
def construct_commenter(commenter)
|
63
73
|
hash = {
|
64
74
|
'name': commenter[:name],
|
@@ -77,7 +87,9 @@ module DevOrbit
|
|
77
87
|
end
|
78
88
|
|
79
89
|
def sanitize_comment(comment)
|
80
|
-
comment.
|
90
|
+
comment = ActionView::Base.full_sanitizer.sanitize(comment)
|
91
|
+
|
92
|
+
comment.gsub("\n", " ")
|
81
93
|
end
|
82
94
|
end
|
83
95
|
end
|
data/lib/dev_orbit/version.rb
CHANGED
data/scripts/check_comments.rb
CHANGED
@@ -2,9 +2,16 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require "dev_orbit"
|
5
|
+
require "thor"
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
module DevOrbit
|
8
|
+
module Scripts
|
9
|
+
class CheckComments < Thor
|
10
|
+
desc "render", "check for new DEV comments and push them to Orbit"
|
11
|
+
def render
|
12
|
+
client = DevOrbit::Client.new
|
13
|
+
client.comments
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev_orbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Greenberg
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '6.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: actionview
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '6.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '6.1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: http
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +80,20 @@ dependencies:
|
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '2.4'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: thor
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.1'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.1'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: rspec
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,10 +126,15 @@ description: This gem integrates DEV blog interactions like comments, etc. into
|
|
98
126
|
Orbit workspace
|
99
127
|
email:
|
100
128
|
- ben.greenberg@hey.com
|
101
|
-
executables:
|
129
|
+
executables:
|
130
|
+
- console
|
131
|
+
- dev_orbit
|
132
|
+
- setup
|
102
133
|
extensions: []
|
103
134
|
extra_rdoc_files: []
|
104
135
|
files:
|
136
|
+
- ".env.sample"
|
137
|
+
- ".github/workflows/ci.yml"
|
105
138
|
- ".gitignore"
|
106
139
|
- ".rspec"
|
107
140
|
- ".rubocop.yml"
|
@@ -121,6 +154,7 @@ files:
|
|
121
154
|
- lib/dev_orbit/dev.rb
|
122
155
|
- lib/dev_orbit/interactions/comment.rb
|
123
156
|
- lib/dev_orbit/orbit.rb
|
157
|
+
- lib/dev_orbit/utils.rb
|
124
158
|
- lib/dev_orbit/version.rb
|
125
159
|
- scripts/check_comments.rb
|
126
160
|
homepage: https://github.com/bencgreenberg/dev_orbit
|