dev_orbit 0.0.3 → 0.0.8
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 +22 -1
- data/README.md +10 -0
- data/dev_orbit.gemspec +1 -0
- data/lib/dev_orbit/client.rb +1 -1
- data/lib/dev_orbit/dev.rb +8 -3
- 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 +1 -2
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 792e11afeefa69fd18e74185a4032bdbb91f9f61ba1a81c7438f9ce9e4135fbc
|
4
|
+
data.tar.gz: 43d69304e73007aa485da66a4531e3d0a72897749cec00c6961566c34a7e83be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3f5520a392e8cd0884650e148dd8e576e2c1a40833ea3d50b00e41b75f4b5d6163c9bf940f4b7bac61bbb10a967a27cbd8a8190d724c1f2b4d039162d00f9bd
|
7
|
+
data.tar.gz: 3fbefe52bfb1d3c5624216650f604c53481e78e6e234396d820cb903bd3d5048afb23ee485a06cec0456be6ddd0a2b1eb55a8b83b81edd3bae8e0e6504aeab91
|
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
@@ -8,4 +8,25 @@
|
|
8
8
|
|
9
9
|
## [0.0.3] - 2021-03-09
|
10
10
|
|
11
|
-
- Bug fix for the CLI functionality, now operational
|
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
|
29
|
+
|
30
|
+
## [0.0.8] - 2021-03-16
|
31
|
+
|
32
|
+
- Early return if there are no new comments
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dev_orbit (0.0.
|
4
|
+
dev_orbit (0.0.7)
|
5
|
+
actionview (~> 6.1)
|
5
6
|
activesupport (~> 6.1)
|
6
7
|
http (~> 4.4)
|
7
8
|
json (~> 2.5)
|
@@ -11,6 +12,12 @@ PATH
|
|
11
12
|
GEM
|
12
13
|
remote: https://rubygems.org/
|
13
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)
|
14
21
|
activesupport (6.1.3)
|
15
22
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
23
|
i18n (>= 1.6, < 2)
|
@@ -20,13 +27,16 @@ GEM
|
|
20
27
|
addressable (2.7.0)
|
21
28
|
public_suffix (>= 2.0.2, < 5.0)
|
22
29
|
ast (2.4.2)
|
30
|
+
builder (3.2.4)
|
23
31
|
byebug (11.1.3)
|
24
32
|
concurrent-ruby (1.1.8)
|
25
33
|
crack (0.4.5)
|
26
34
|
rexml
|
35
|
+
crass (1.0.6)
|
27
36
|
diff-lcs (1.4.4)
|
28
37
|
domain_name (0.5.20190701)
|
29
38
|
unf (>= 0.0.5, < 1.0.0)
|
39
|
+
erubi (1.10.0)
|
30
40
|
ffi (1.15.0)
|
31
41
|
ffi-compiler (1.0.1)
|
32
42
|
ffi (>= 1.0.0)
|
@@ -45,11 +55,22 @@ GEM
|
|
45
55
|
i18n (1.8.9)
|
46
56
|
concurrent-ruby (~> 1.0)
|
47
57
|
json (2.5.1)
|
58
|
+
loofah (2.9.0)
|
59
|
+
crass (~> 1.0.2)
|
60
|
+
nokogiri (>= 1.5.9)
|
48
61
|
minitest (5.14.4)
|
62
|
+
nokogiri (1.11.2-x86_64-darwin)
|
63
|
+
racc (~> 1.4)
|
49
64
|
parallel (1.20.1)
|
50
65
|
parser (3.0.0.0)
|
51
66
|
ast (~> 2.4.1)
|
52
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)
|
53
74
|
rainbow (3.0.0)
|
54
75
|
rake (13.0.3)
|
55
76
|
regexp_parser (2.1.1)
|
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/dev_orbit.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
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"
|
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,7 +19,8 @@ module DevOrbit
|
|
18
19
|
|
19
20
|
articles.each do |article|
|
20
21
|
comments = get_article_comments(article["id"])
|
21
|
-
|
22
|
+
|
23
|
+
next if comments.nil? || comments.empty?
|
22
24
|
|
23
25
|
DevOrbit::Orbit.call(
|
24
26
|
type: "comments",
|
@@ -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,10 @@ 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)
|
62
|
+
|
63
|
+
return if comments.nil? || comments.empty?
|
59
64
|
|
60
65
|
filter_comments(comments)
|
61
66
|
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
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Greenberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-16 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
|
@@ -119,6 +133,8 @@ executables:
|
|
119
133
|
extensions: []
|
120
134
|
extra_rdoc_files: []
|
121
135
|
files:
|
136
|
+
- ".env.sample"
|
137
|
+
- ".github/workflows/ci.yml"
|
122
138
|
- ".gitignore"
|
123
139
|
- ".rspec"
|
124
140
|
- ".rubocop.yml"
|
@@ -138,6 +154,7 @@ files:
|
|
138
154
|
- lib/dev_orbit/dev.rb
|
139
155
|
- lib/dev_orbit/interactions/comment.rb
|
140
156
|
- lib/dev_orbit/orbit.rb
|
157
|
+
- lib/dev_orbit/utils.rb
|
141
158
|
- lib/dev_orbit/version.rb
|
142
159
|
- scripts/check_comments.rb
|
143
160
|
homepage: https://github.com/bencgreenberg/dev_orbit
|