bouncie 0.6.0 → 0.7.0

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: 88709352c65b73b8d0309b7e568b3fbb2cba215c4110770289971ff033b507d4
4
- data.tar.gz: 1205a6c8f02271170b47a39994ccd25c0fd46ddf437e9ee46ae0960c0acd31fa
3
+ metadata.gz: 0202c63ed663c1ac4412667cdc72e6d6474150bafd4dfcfadd8e4a63c8d4ba2d
4
+ data.tar.gz: cc62cd47492c08d5ec017a2c1258b9c4c48b329b48a0478a7f8c32b0f491407e
5
5
  SHA512:
6
- metadata.gz: a2d6cecd4277f7564ea8e96c8c9dbd1e5e7c0330e00591a7bc90bd3fa3c411f24b68c57a7de5b179e04d90ce17c2dc902a701831e08cc7c406048fcac847c81a
7
- data.tar.gz: 92cfe4d41f800b4ad705fa7a1ea5e26f5c0bfbc9ced0606ea40878e1fc76bb7a2400f9955ce90e56eb47b1fa7f7a0747eb6e3c1025aea92a6bdaa6db9e987300
6
+ metadata.gz: 129ffd0ce66cd76d86b980529137ec2d0570305112c1bb4ece7cf0784aae69de38139ba0b5a90ed6e43f617338038e1f6b881dc3ca88fae294120ed7957587f7
7
+ data.tar.gz: 773c27196353fb8a3f840745f7ea78e369dc677745be41edc873530c1959a5ebbc939cfcba0b7a987182f2e64ef2a03ffb2c1d46059c0f5afa5d0f6686411c50
@@ -0,0 +1,15 @@
1
+ name: Linting
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ rubocop:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - uses: ruby/setup-ruby@v1
11
+ with:
12
+ ruby-version: 2.7
13
+ - run: bundle install
14
+ - name: Rubocop
15
+ run: rubocop
@@ -0,0 +1,24 @@
1
+ name: Matrix Testing
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ${{ matrix.os }}-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ os: [ubuntu]
16
+ ruby: [2.5, 2.6, 2.7, head, debug, jruby, jruby-head, truffleruby, truffleruby-head]
17
+ continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ - run: bundle install
24
+ - run: rspec spec
@@ -1,18 +1,48 @@
1
1
  name: Ruby Gem
2
2
 
3
3
  on:
4
- push:
5
- branches: [ master ]
4
+ # Manually publish
5
+ workflow_dispatch:
6
+ # push:
7
+ # branches: [ main ]
8
+ # pull_request:
9
+ # branches: [ main ]
6
10
 
7
11
  jobs:
8
12
  build:
9
-
13
+ name: Build + Publish
10
14
  runs-on: ubuntu-latest
15
+ permissions:
16
+ packages: write
17
+ contents: read
11
18
 
12
19
  steps:
13
- - uses: actions/checkout@v1
14
- - name: Build and publish gem
15
- uses: jstastny/publish-gem-to-github@master
20
+ - uses: actions/checkout@v2
21
+ - name: Set up Ruby 2.7
22
+ uses: ruby/setup-ruby@v1
16
23
  with:
17
- token: ${{ secrets.GITHUB_TOKEN }}
18
- owner: streetsmartslabs
24
+ ruby-version: 2.7
25
+ - run: bundle install
26
+
27
+ - name: Publish to GPR
28
+ run: |
29
+ mkdir -p $HOME/.gem
30
+ touch $HOME/.gem/credentials
31
+ chmod 0600 $HOME/.gem/credentials
32
+ printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
33
+ gem build *.gemspec
34
+ gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
35
+ env:
36
+ GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
37
+ OWNER: ${{ github.repository_owner }}
38
+
39
+ - name: Publish to RubyGems
40
+ run: |
41
+ mkdir -p $HOME/.gem
42
+ touch $HOME/.gem/credentials
43
+ chmod 0600 $HOME/.gem/credentials
44
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
45
+ gem build *.gemspec
46
+ gem push *.gem
47
+ env:
48
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
data/Gemfile.lock CHANGED
@@ -1,32 +1,39 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bouncie (0.4.0)
4
+ bouncie (0.7.0)
5
5
  activesupport
6
6
  faraday
7
- oj
7
+ json
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (6.0.3.1)
12
+ activesupport (6.1.3.1)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
- zeitwerk (~> 2.2, >= 2.2.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ zeitwerk (~> 2.3)
18
18
  ast (2.4.0)
19
19
  coderay (1.1.2)
20
- concurrent-ruby (1.1.6)
20
+ concurrent-ruby (1.1.8)
21
21
  diff-lcs (1.3)
22
- faraday (1.0.1)
22
+ faraday (1.4.1)
23
+ faraday-excon (~> 1.1)
24
+ faraday-net_http (~> 1.0)
25
+ faraday-net_http_persistent (~> 1.1)
23
26
  multipart-post (>= 1.2, < 3)
24
- i18n (1.8.3)
27
+ ruby2_keywords (>= 0.0.4)
28
+ faraday-excon (1.1.0)
29
+ faraday-net_http (1.0.1)
30
+ faraday-net_http_persistent (1.1.0)
31
+ i18n (1.8.10)
25
32
  concurrent-ruby (~> 1.0)
33
+ json (2.5.1)
26
34
  method_source (0.9.2)
27
- minitest (5.14.1)
35
+ minitest (5.14.4)
28
36
  multipart-post (2.1.1)
29
- oj (3.10.6)
30
37
  parallel (1.19.1)
31
38
  parser (2.7.1.3)
32
39
  ast (~> 2.4.0)
@@ -62,12 +69,12 @@ GEM
62
69
  rubocop-ast (0.0.3)
63
70
  parser (>= 2.7.0.1)
64
71
  ruby-progressbar (1.10.1)
65
- thread_safe (0.3.6)
66
- tzinfo (1.2.7)
67
- thread_safe (~> 0.1)
72
+ ruby2_keywords (0.0.4)
73
+ tzinfo (2.0.4)
74
+ concurrent-ruby (~> 1.0)
68
75
  unicode-display_width (1.7.0)
69
76
  yard (0.9.25)
70
- zeitwerk (2.3.0)
77
+ zeitwerk (2.4.2)
71
78
 
72
79
  PLATFORMS
73
80
  ruby
@@ -82,4 +89,4 @@ DEPENDENCIES
82
89
  yard (~> 0.9.25)
83
90
 
84
91
  BUNDLED WITH
85
- 2.0.2
92
+ 2.1.4
data/bouncie.gemspec CHANGED
@@ -38,5 +38,5 @@ Gem::Specification.new do |spec|
38
38
 
39
39
  spec.add_dependency 'activesupport'
40
40
  spec.add_dependency 'faraday'
41
- spec.add_dependency 'oj'
41
+ spec.add_dependency 'json'
42
42
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'faraday'
4
- require 'oj'
4
+ require 'json'
5
5
 
6
6
  module Bouncie
7
7
  # Class that wraps a Faraday connection in order to interact with the Bouncie API
@@ -47,10 +47,10 @@ module Bouncie
47
47
  def vehicles(imei: nil, vin: nil)
48
48
  request(
49
49
  http_method: :get,
50
- endpoint: 'vehicles',
51
- params: {
50
+ endpoint: 'vehicles',
51
+ params: {
52
52
  imei: imei,
53
- vin: vin
53
+ vin: vin
54
54
  }.compact
55
55
  ).map { |data| Bouncie::Vehicle.new(data) }
56
56
  end
@@ -64,21 +64,23 @@ module Bouncie
64
64
  Bouncie::User.new(data)
65
65
  end
66
66
 
67
+ # rubocop:disable Metrics/AbcSize
67
68
  def refresh!
68
69
  resp = Faraday.post('https://auth.bouncie.com/oauth/token', {
69
- client_id: options[:client_id],
70
- client_secret: options[:client_secret],
71
- grant_type: 'authorization_code',
72
- code: options[:authorization_code],
73
- redirect_uri: options[:redirect_uri]
74
- })
70
+ client_id: options[:client_id],
71
+ client_secret: options[:client_secret],
72
+ grant_type: 'authorization_code',
73
+ code: options[:authorization_code],
74
+ redirect_uri: options[:redirect_uri]
75
+ })
75
76
  if resp.success?
76
- parsed_resp = Oj.load(resp.body)
77
+ parsed_resp = JSON.parse(resp.body)
77
78
  @headers = headers.merge(Authorization: parsed_resp['access_token'])
78
79
  @client = build_client
79
80
  end
80
81
  resp
81
82
  end
83
+ # rubocop:enable Metrics/AbcSize
82
84
 
83
85
  private
84
86
 
@@ -100,7 +102,7 @@ module Bouncie
100
102
  def request(http_method:, endpoint:, params: {})
101
103
  params.transform_keys! { |k| k.to_s.dasherize }
102
104
  resp = client.public_send(http_method, endpoint, params)
103
- Oj.load(resp.body)
105
+ JSON.parse(resp.body)
104
106
  end
105
107
  end
106
108
  end
@@ -6,8 +6,8 @@ module Bouncie
6
6
  # Abstract base class for objects returned from API requests. Parses dates, converts keys to underscore.
7
7
  class Entity
8
8
  def initialize(data)
9
- @data = data.transform_keys { |k| k.to_s.underscore.to_sym }
10
- massage_data
9
+ transformed = data.transform_keys { |k| k.to_s.underscore.to_sym }
10
+ @data = massage_data(transformed)
11
11
  end
12
12
 
13
13
  def method_missing(method_name, *args, &block)
@@ -24,15 +24,21 @@ module Bouncie
24
24
 
25
25
  private
26
26
 
27
- def massage_data
28
- @data.each do |key, val|
29
- if val.is_a?(Hash)
30
- @data[key] = Bouncie::Entity.new(val)
31
- elsif val.is_a?(Array)
32
- @data[key] = val.map { |v| Bouncie::Entity.new(v) }
33
- elsif val.is_a?(String) && %w[_updated _time timestamp].any? { |v| key.to_s.end_with?(v) }
34
- @data[key] = DateTime.parse(val)
35
- end
27
+ def massage_data(input)
28
+ input.each_with_object({}) do |(key, val), memo|
29
+ memo[key] = massage_value(val)
30
+ end
31
+ end
32
+
33
+ def massage_value(value)
34
+ if value.is_a?(Hash)
35
+ Bouncie::Entity.new(value)
36
+ elsif value.is_a?(Array)
37
+ value.map { |v| massage_value(v) }
38
+ elsif value.is_a?(String) && value.match?(/^(\d{4})-(\d{2})-(\d{2})(T|\s)(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)((-(\d{2}):(\d{2})|Z)?)$/)
39
+ DateTime.parse(value)
40
+ else
41
+ value
36
42
  end
37
43
  end
38
44
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bouncie
4
- VERSION = '0.6.0'
4
+ VERSION = '0.7.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bouncie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Psoinos
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-10 00:00:00.000000000 Z
11
+ date: 2021-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -123,7 +123,7 @@ dependencies:
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: oj
126
+ name: json
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -136,14 +136,15 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- description:
139
+ description:
140
140
  email:
141
141
  - corey@streetsmarts.io
142
142
  executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
- - ".github/workflows/ci.yml"
146
+ - ".github/workflows/lint.yml"
147
+ - ".github/workflows/matrix_testing.yml"
147
148
  - ".github/workflows/publish.yml"
148
149
  - ".gitignore"
149
150
  - ".rubocop.yml"
@@ -175,7 +176,7 @@ licenses: []
175
176
  metadata:
176
177
  homepage_uri: https://github.com/streetsmartslabs/bouncie
177
178
  source_code_uri: https://github.com/streetsmartslabs/bouncie
178
- post_install_message:
179
+ post_install_message:
179
180
  rdoc_options: []
180
181
  require_paths:
181
182
  - lib
@@ -190,8 +191,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
191
  - !ruby/object:Gem::Version
191
192
  version: '0'
192
193
  requirements: []
193
- rubygems_version: 3.0.6
194
- signing_key:
194
+ rubygems_version: 3.1.6
195
+ signing_key:
195
196
  specification_version: 4
196
197
  summary: An API wrapper for Bouncie
197
198
  test_files: []
@@ -1,32 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches: [ master ]
6
- pull_request:
7
- branches: [ master ]
8
-
9
- jobs:
10
- test:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v2
14
- - name: Set up Ruby
15
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
16
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
17
- # uses: ruby/setup-ruby@v1
18
- uses: ruby/setup-ruby@v1
19
- with:
20
- ruby-version: 2.6
21
- - name: Install dependencies
22
- run: bundle install
23
- - name: RSpec tests
24
- run: rspec spec
25
-
26
- lint:
27
- runs-on: ubuntu-latest
28
- steps:
29
- - name: Rubocop Linter Action
30
- uses: andrewmcodes/rubocop-linter-action@v3.2.0
31
- env:
32
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}