dev_orbit 0.0.1 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80bcc5826d4088f33048db1adc6cc22029b8739e5affd5154f1af496b7f63e04
4
- data.tar.gz: 714dc5857e7c11820068f67e004a203cc905c1fcb28c154ebc9f3065a5340561
3
+ metadata.gz: c91ef071ae7615cf957e49580b99d384b842227bdb5f16557115ae8a81449dfc
4
+ data.tar.gz: f0d90c3fe043997e7ca812572b3a81b26e261a51b53d64ca98babc0a002e0287
5
5
  SHA512:
6
- metadata.gz: ae17e17441b221b7a2b9cbf104517c8a3fc36d568549764ffb6670318cb5187be0e9460bf4e59ae6e3d653f40ff27ccf0bdce1deeb2b6d71e3ca6a6edbc44ee3
7
- data.tar.gz: 85d4c3d19eb02499608dd140c36f2190ca94470086cd17a881c3c51626665c36eb6d013543f705a6a651673c74ce1879d5d430debbf8a7cf8e5fd595d2e6ce28
6
+ metadata.gz: 621bd01a4bec7709a5a5ec196dd2bb1235c1eb6334bccb2cc7384c090fee3e8ab10419ccd180e1675d5cdf4694db17e6ccc2d0c7a5b50246cc732bd2e438f798
7
+ data.tar.gz: 6f988344ad296cfc1ce2e7defcc6534946a511eeb272079689e2fff375ea37824cf0209a59c7ec3879b1ea934bcf43f03b3bc8291be01edbb35df9dada392b74
data/.env.sample ADDED
@@ -0,0 +1,4 @@
1
+ ORBIT_API_KEY=
2
+ ORBIT_WORKSPACE_ID=
3
+ DEV_API_KEY=
4
+ DEV_USERNAME=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
1
  ## [0.0.1] - 2021-03-06
2
2
 
3
3
  - Initial release
4
+
5
+ ## [0.0.2] - 2021-03-09
6
+
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
data/Gemfile.lock CHANGED
@@ -1,15 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dev_orbit (0.0.1)
4
+ dev_orbit (0.0.4)
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.1-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,8 @@
1
1
  # DEV.to Interactions to Orbit Workspace
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/dev_orbit.svg)](https://badge.fury.io/rb/dev_orbit)
4
+ [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](code_of_conduct.md)
5
+
3
6
  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.
4
7
 
5
8
  ## Installation
@@ -16,6 +19,15 @@ gem 'dev_orbit'
16
19
 
17
20
  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.
18
21
 
22
+ The following are the expected environment variables:
23
+
24
+ ```ruby
25
+ ORBIT_API_KEY
26
+ ORBIT_WORKSPACE_ID
27
+ DEV_API_KEY
28
+ DEV_USERNAME
29
+ ```
30
+
19
31
  With the credentials as environment variables:
20
32
 
21
33
  ```ruby
@@ -45,6 +57,16 @@ This method will fetch all your articles from DEV, gather their respective comme
45
57
 
46
58
  You can run this a daily cron job, for example, to add your newest DEV comments as activities in your Orbit workspace.
47
59
 
60
+ ### CLI
61
+
62
+ You can also use the built-in CLI to perform the following operations:
63
+
64
+ * Check for new DEV comments and post them to Orbit
65
+
66
+ ```bash
67
+ $ ORBIT_API_KEY='...' ORBIT_WORKSPACE='...' DEV_API_KEY='...' DEV_USERNAME='...' bundle exec dev_orbit --check-comments
68
+ ```
69
+
48
70
  ## Contributing
49
71
 
50
72
  Bug reports and pull requests are welcome on GitHub at https://github.com/bencgreenberg/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/bencgreenberg/dev_orbit/blob/master/CODE_OF_CONDUCT.md).
data/bin/dev_orbit ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+
4
+ check_comments = false
5
+
6
+ options = {}
7
+ choices = OptionParser.new do |opts|
8
+ opts.banner = "Usage: dev_orbit --check-comments"
9
+ opts.on("-h", "--help", "Prints help instructions") do
10
+ puts opts
11
+ exit
12
+ end
13
+ opts.on("--check-comments", "Check for new DEV comments") do
14
+ check_comments = true
15
+ end
16
+ end.parse!
17
+
18
+ $LOAD_PATH.unshift(File.expand_path('../lib/dev_orbit', __dir__))
19
+
20
+ require_relative '../lib/dev_orbit'
21
+ require_relative '../scripts/check_comments'
22
+
23
+ if check_comments
24
+ puts "Checking for new DEV comments within the past day and posting them to your Orbit workspace..."
25
+ ARGV[0] = 'render'
26
+ DevOrbit::Scripts::CheckComments.start(ARGV)
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 = "exe"
27
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
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
 
@@ -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["ORBIT_WORKSPACE"])
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
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "net/http"
4
4
  require "json"
5
+ require "action_view"
5
6
 
6
7
  module DevOrbit
7
8
  module Interactions
@@ -29,7 +30,17 @@ module DevOrbit
29
30
  req["Content-Type"] = "application/json"
30
31
  req["Authorization"] = "Bearer #{@api_key}"
31
32
 
32
- req.body = {
33
+ req.body = construct_body
34
+
35
+ req.body = req.body.to_json
36
+
37
+ response = http.request(req)
38
+
39
+ puts JSON.parse(response.body)
40
+ end
41
+
42
+ def construct_body
43
+ hash = {
33
44
  activity: {
34
45
  activity_type: "dev:comment",
35
46
  key: "dev-comment-#{@id}",
@@ -48,17 +59,15 @@ module DevOrbit
48
59
  }
49
60
  }
50
61
 
51
- req.body[:activity][:member].merge!(twitter: @commenter[:twitter]) if @commenter[:twitter]
62
+ hash[:activity][:member].merge!(twitter: @commenter[:twitter]) if @commenter[:twitter]
52
63
 
53
- req.body[:activity][:member].merge!(github: @commenter[:github]) if @commenter[:github]
64
+ hash[:activity][:member].merge!(github: @commenter[:github]) if @commenter[:github]
54
65
 
55
- req.body = req.body.to_json
56
-
57
- response = http.request(req)
58
-
59
- JSON.parse(response.body)
66
+ hash
60
67
  end
61
68
 
69
+ private
70
+
62
71
  def construct_commenter(commenter)
63
72
  hash = {
64
73
  'name': commenter[:name],
@@ -77,7 +86,9 @@ module DevOrbit
77
86
  end
78
87
 
79
88
  def sanitize_comment(comment)
80
- comment.gsub!(/(<[^>]*>)|\n|\t/s) { " " }
89
+ comment = ActionView::Base.full_sanitizer.sanitize(comment)
90
+
91
+ comment.gsub("\n", " ")
81
92
  end
82
93
  end
83
94
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DevOrbit
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.6"
5
5
  end
@@ -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 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.1
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Greenberg
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-09 00:00:00.000000000 Z
11
+ date: 2021-03-10 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,14 @@ 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"
105
137
  - ".gitignore"
106
138
  - ".rspec"
107
139
  - ".rubocop.yml"
@@ -113,6 +145,7 @@ files:
113
145
  - README.md
114
146
  - Rakefile
115
147
  - bin/console
148
+ - bin/dev_orbit
116
149
  - bin/setup
117
150
  - dev_orbit.gemspec
118
151
  - lib/dev_orbit.rb
@@ -121,6 +154,7 @@ files:
121
154
  - lib/dev_orbit/interactions/comment.rb
122
155
  - lib/dev_orbit/orbit.rb
123
156
  - lib/dev_orbit/version.rb
157
+ - scripts/check_comments.rb
124
158
  homepage: https://github.com/bencgreenberg/dev_orbit
125
159
  licenses:
126
160
  - MIT