dev_orbit 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c91ef071ae7615cf957e49580b99d384b842227bdb5f16557115ae8a81449dfc
4
- data.tar.gz: f0d90c3fe043997e7ca812572b3a81b26e261a51b53d64ca98babc0a002e0287
3
+ metadata.gz: a9c02ba74434acb5637a4d93ecd37dc4883969ba36128bb001130d0b6dfbf087
4
+ data.tar.gz: 6c9eca9384cdb84eb9049d45acf25da3c05a421a75f083a2883f14fb8bef1a7e
5
5
  SHA512:
6
- metadata.gz: 621bd01a4bec7709a5a5ec196dd2bb1235c1eb6334bccb2cc7384c090fee3e8ab10419ccd180e1675d5cdf4694db17e6ccc2d0c7a5b50246cc732bd2e438f798
7
- data.tar.gz: 6f988344ad296cfc1ce2e7defcc6534946a511eeb272079689e2fff375ea37824cf0209a59c7ec3879b1ea934bcf43f03b3bc8291be01edbb35df9dada392b74
6
+ metadata.gz: e9870c95fc0e32a818528f2f0ceec830f781cf9193a63056760e30a71e94e6caa509953dfa9408cd27a3dff34003f02f5c1d030a79043d4c47cb2bd4d9606ca7
7
+ data.tar.gz: fde99905baf0e7a7faad0041c4256ad55713c2dc648e58af4590e18c25c16cf11739321176c36aee75049a249c3bf2ac423df6461a09e4541972198597facb79
@@ -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
@@ -21,4 +21,8 @@
21
21
  ## [0.0.6] - 2021-03-10
22
22
 
23
23
  - Fix misnamed env var in client instantiation
24
- - Add a sample `.env` file
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,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dev_orbit (0.0.4)
4
+ dev_orbit (0.0.6)
5
5
  actionview (~> 6.1)
6
6
  activesupport (~> 6.1)
7
7
  http (~> 4.4)
@@ -59,7 +59,7 @@ GEM
59
59
  crass (~> 1.0.2)
60
60
  nokogiri (>= 1.5.9)
61
61
  minitest (5.14.4)
62
- nokogiri (1.11.1-x86_64-darwin)
62
+ nokogiri (1.11.2-x86_64-darwin)
63
63
  racc (~> 1.4)
64
64
  parallel (1.20.1)
65
65
  parser (3.0.0.0)
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
 
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
- comments = JSON.parse(response.body)
60
+
61
+ comments = JSON.parse(response.body) if DevOrbit::Utils.valid_json?(response.body)
59
62
 
60
63
  filter_comments(comments)
61
64
  end
@@ -3,6 +3,7 @@
3
3
  require "net/http"
4
4
  require "json"
5
5
  require "action_view"
6
+ require_relative "../utils"
6
7
 
7
8
  module DevOrbit
8
9
  module Interactions
@@ -36,7 +37,7 @@ module DevOrbit
36
37
 
37
38
  response = http.request(req)
38
39
 
39
- puts JSON.parse(response.body)
40
+ JSON.parse(response.body) if DevOrbit::Utils.valid_json?(response.body)
40
41
  end
41
42
 
42
43
  def construct_body
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DevOrbit
4
+ class Utils
5
+ def self.valid_json?(string)
6
+ !JSON.parse(string).nil?
7
+ rescue JSON::ParserError
8
+ false
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DevOrbit
4
- VERSION = "0.0.6"
4
+ VERSION = "0.0.7"
5
5
  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.6
4
+ version: 0.0.7
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-10 00:00:00.000000000 Z
11
+ date: 2021-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -134,6 +134,7 @@ extensions: []
134
134
  extra_rdoc_files: []
135
135
  files:
136
136
  - ".env.sample"
137
+ - ".github/workflows/ci.yml"
137
138
  - ".gitignore"
138
139
  - ".rspec"
139
140
  - ".rubocop.yml"
@@ -153,6 +154,7 @@ files:
153
154
  - lib/dev_orbit/dev.rb
154
155
  - lib/dev_orbit/interactions/comment.rb
155
156
  - lib/dev_orbit/orbit.rb
157
+ - lib/dev_orbit/utils.rb
156
158
  - lib/dev_orbit/version.rb
157
159
  - scripts/check_comments.rb
158
160
  homepage: https://github.com/bencgreenberg/dev_orbit