bullet_proof_json 0.1.0 → 0.2.1

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: aeade736ab3a008d00b531f23618b7392faa686b5c549d925cb13449d93af940
4
- data.tar.gz: acbdc1bfc70bf17d1ab143300fcd99ea418c3ad050cd561e9623d1687fd6a44a
3
+ metadata.gz: 34ddf20fa884b08de58f2b6345d6a95f15f3eca92349b29377219cc2323691d6
4
+ data.tar.gz: 9435f6aa2cf52335ab5154280c397bad0593f0e81e3d5cd1f970d32269018769
5
5
  SHA512:
6
- metadata.gz: 0c401ddb954c1947c915f7d94775a7cbdcde597fb8fcb2659ae74f9a784ef6bf80779f4dd62b2e5c7598b93da17b09df3e9ad22a51445201189664189710fb7d
7
- data.tar.gz: e47dd701ffaf691eb39c15f6eda994fd8c7fdeed536d3f7f095b8bf0878be4ddf546a9f8102e5406a0a8a68f84df6bb19ec962e18c3e4f711ff5d3aab265d2b6
6
+ metadata.gz: 33534e8d747a100b7f6e657a2eccfc74e002736d6b4863207fa18378ad01ffbc7675a6b5bdffc95c4b4ee1df2b37e24a32e85dd041988db78599076d981b7d17
7
+ data.tar.gz: eff4ea4dc8d24e85651146ae46eb65a7c6882413fa12ce479447bd725eced5141ff85605295369cc3b17eae9164e82a032286cac6c13d8a8f5f9ce697c5225ca
@@ -0,0 +1,37 @@
1
+ name: Ruby RSpec Tests
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - name: Checkout repository
17
+ uses: actions/checkout@v3
18
+
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: '3.3'
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ gem install bundler
27
+ bundle install
28
+
29
+ - name: Run RSpec tests
30
+ run: bundle exec rspec
31
+
32
+ - name: Upload coverage reports to Codecov
33
+ uses: codecov/codecov-action@v5
34
+ with:
35
+ files: coverage/.resultset.json
36
+ token: ${{ secrets.CODECOV_TOKEN }}
37
+ verbose: false
data/.gitignore CHANGED
@@ -46,11 +46,17 @@ build-iPhoneSimulator/
46
46
  # for a library or gem, you might want to ignore these files since the code is
47
47
  # intended to run in multiple environments; otherwise, check them in:
48
48
  # Gemfile.lock
49
- # .ruby-version
49
+ .ruby-version
50
50
  # .ruby-gemset
51
51
 
52
52
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
53
  .rvmrc
54
54
 
55
55
  # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
- # .rubocop-https?--*
56
+ # .rubocop-https?--*
57
+
58
+ # .DS_Store
59
+ .DS_Store
60
+
61
+ # rspec status
62
+ .rspec_status
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ ## [0.2.1] - 2025-07-22
2
+ ### Added
3
+ - How to release a new version in README
4
+ - Full test coverage
5
+ - Upload test coverage to codecov.io using codecov/codecov-action@v5 GitHub action
6
+ ### Fixed
7
+ - max_retries condition
8
+
9
+ ## [0.2.0] - 2025-07-22
10
+ ### Added
11
+ - HTTP request header User-Agent with a gem name to be identified properly by public APIs
12
+
13
+ ## [0.1.0] - 2025-02-09
14
+ - Initial version
data/Gemfile.lock CHANGED
@@ -1,15 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bullet_proof_json (0.1.0)
4
+ bullet_proof_json (0.2.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  coderay (1.1.3)
10
- diff-lcs (1.5.1)
11
- ffi (1.17.1)
12
- formatador (1.1.0)
10
+ diff-lcs (1.6.2)
11
+ docile (1.4.1)
12
+ ffi (1.17.2)
13
+ formatador (1.1.1)
13
14
  guard (2.19.1)
14
15
  formatador (>= 0.2.4)
15
16
  listen (>= 2.7, < 4.0)
@@ -29,36 +30,42 @@ GEM
29
30
  listen (3.9.0)
30
31
  rb-fsevent (~> 0.10, >= 0.10.3)
31
32
  rb-inotify (~> 0.9, >= 0.9.10)
32
- logger (1.6.5)
33
- lumberjack (1.2.10)
33
+ logger (1.7.0)
34
+ lumberjack (1.3.1)
34
35
  method_source (1.1.0)
35
36
  nenv (0.3.0)
36
37
  notiffany (0.1.3)
37
38
  nenv (~> 0.1)
38
39
  shellany (~> 0.0)
39
- ostruct (0.6.1)
40
+ ostruct (0.6.3)
40
41
  pry (0.15.2)
41
42
  coderay (~> 1.1)
42
43
  method_source (~> 1.0)
43
- rake (10.5.0)
44
+ rake (12.3.3)
44
45
  rb-fsevent (0.11.2)
45
46
  rb-inotify (0.11.1)
46
47
  ffi (~> 1.0)
47
- rspec (3.13.0)
48
+ rspec (3.13.1)
48
49
  rspec-core (~> 3.13.0)
49
50
  rspec-expectations (~> 3.13.0)
50
51
  rspec-mocks (~> 3.13.0)
51
- rspec-core (3.13.3)
52
+ rspec-core (3.13.5)
52
53
  rspec-support (~> 3.13.0)
53
- rspec-expectations (3.13.3)
54
+ rspec-expectations (3.13.5)
54
55
  diff-lcs (>= 1.2.0, < 2.0)
55
56
  rspec-support (~> 3.13.0)
56
- rspec-mocks (3.13.2)
57
+ rspec-mocks (3.13.5)
57
58
  diff-lcs (>= 1.2.0, < 2.0)
58
59
  rspec-support (~> 3.13.0)
59
- rspec-support (3.13.2)
60
+ rspec-support (3.13.4)
60
61
  shellany (0.0.1)
61
- thor (1.2.2)
62
+ simplecov (0.22.0)
63
+ docile (~> 1.1)
64
+ simplecov-html (~> 0.11)
65
+ simplecov_json_formatter (~> 0.1)
66
+ simplecov-html (0.13.2)
67
+ simplecov_json_formatter (0.1.4)
68
+ thor (1.4.0)
62
69
 
63
70
  PLATFORMS
64
71
  ruby
@@ -69,8 +76,9 @@ DEPENDENCIES
69
76
  guard (~> 2.19.1)
70
77
  guard-rspec (~> 4.7.3)
71
78
  pry (~> 0.15.2)
72
- rake (~> 10.0)
79
+ rake (~> 12.3)
73
80
  rspec (~> 3.0)
81
+ simplecov (~> 0.22.0)
74
82
 
75
83
  BUNDLED WITH
76
84
  2.6.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Grzegorz Błaszczyk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,9 @@
1
- # Goal
1
+ [![Ruby RSpec Tests](https://github.com/grzegorzblaszczyk/bullet-proof-json/actions/workflows/ruby.yml/badge.svg)](https://github.com/grzegorzblaszczyk/bullet-proof-json/actions/workflows/ruby.yml)
2
+ [![Dependabot Updates](https://github.com/grzegorzblaszczyk/bullet-proof-json/actions/workflows/dependabot/dependabot-updates/badge.svg)](https://github.com/grzegorzblaszczyk/bullet-proof-json/actions/workflows/dependabot/dependabot-updates)
3
+ [![Gem Version](https://badge.fury.io/rb/bullet-proof-json.svg)](https://badge.fury.io/rb/bullet-proof-json)
4
+ [![codecov](https://codecov.io/gh/grzegorzblaszczyk/bullet-proof-json/branch/main/graph/badge.svg)](https://codecov.io/gh/grzegorzblaszczyk/bullet-proof-json)
5
+
6
+ # The Goal
2
7
 
3
8
  Tired of dealing with unreliable REST APIs with JSON responses, endless timeouts, and complex error handling just to fetch some JSON data?
4
9
 
@@ -17,6 +22,8 @@ It depends only on a few standard Ruby libraries like:
17
22
  * JSON
18
23
  * Net::HTTP
19
24
 
25
+ 🪶 No dependencies except standard Ruby classes.
26
+
20
27
  # Installation
21
28
 
22
29
  Add this line to your application's Gemfile:
@@ -71,3 +78,16 @@ The gem is available as open source under the terms of the [MIT License](https:/
71
78
 
72
79
  Everyone interacting in the BulletProofJSON project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/grzegorzblaszczyk/bullet-proof-json-provider//blob/master/CODE_OF_CONDUCT.md).
73
80
 
81
+ ## How to release a new version to RubyGems.org
82
+
83
+ ```bash
84
+ rspec spec
85
+ mdv CHANGELOG.md
86
+ git ci -m "UPGRADE: version x.y.z" .
87
+ git push origin main
88
+ gem build bullet_proof_json.gemspec
89
+ gem push bullet_proof_json-x.y.z.gem
90
+ git tag vx.y.z
91
+ git push origin main --tags
92
+ ```
93
+
data/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a Vulnerability
4
+
5
+ Please create a new issue in Issues section: https://github.com/grzegorzblaszczyk/bullet-proof-json/issues
@@ -9,6 +9,9 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Grzegorz Błaszczyk"]
10
10
  spec.email = ["grzegorz.blaszczyk@gmail.com"]
11
11
 
12
+ spec.metadata["source_code_uri"] = "https://github.com/grzegorzblaszczyk/bullet-proof-json"
13
+ spec.metadata["changelog_uri"] = "https://github.com/grzegorzblaszczyk/bullet-proof-json/blob/main/CHANGELOG.md"
14
+
12
15
  spec.summary = "Bullet Proof JSON for Ruby with seamless request handling, smart throttling and robust retry mchanism"
13
16
  spec.description = "Bullet Proof JSON for Ruby takes the hassle out of API response handling by offering: Seamless Request Handling - automatically manage timeouts and errors so your app stays resilient, Smart Throttling - respect API rate limits without overcomplicating your code, Robust Retry Mechanism - never miss a response due to transient errors."
14
17
  spec.homepage = "https://github.com/grzegorzblaszczyk/bullet-proof-json"
@@ -29,6 +32,7 @@ Gem::Specification.new do |spec|
29
32
  spec.add_development_dependency "guard", "~> 2.19.1"
30
33
  spec.add_development_dependency "guard-rspec", "~> 4.7.3"
31
34
  spec.add_development_dependency "pry", "~> 0.15.2"
32
- spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rake", "~> 12.3"
33
36
  spec.add_development_dependency "rspec", "~> 3.0"
37
+ spec.add_development_dependency "simplecov", "~> 0.22.0"
34
38
  end
@@ -23,12 +23,13 @@ module BulletProofJson
23
23
  uri = URI(uri_string)
24
24
  http_headers = {}
25
25
  http_headers["Authorization"] = "Bearer #{@api_key}" unless @api_key.nil?
26
+ http_headers["User-Agent"] = user_agent
26
27
  response = ::Net::HTTP.get(uri, http_headers)
27
28
  json = JSON(response)
28
29
 
29
30
  rescue ::Net::ReadTimeout => e
30
31
  @logger.error(self.class.name, " #{page.nil? ? "" : (page.to_s + ":")} #{e}\n#{uri_string}")
31
- if (attempts += 1) < max_attempts
32
+ if (attempts += 1) <= max_attempts
32
33
  @logger.debug(self.class.name, "\tAttempt no. #{attempts} ...")
33
34
  sleep sleep_time
34
35
  retry
@@ -39,7 +40,7 @@ module BulletProofJson
39
40
 
40
41
  rescue ::Net::OpenTimeout => e
41
42
  @logger.error(self.class.name, " #{page.nil? ? "" : (page.to_s + ":")} #{e}\n#{uri_string}")
42
- if (attempts += 1) < max_attempts
43
+ if (attempts += 1) <= max_attempts
43
44
  @logger.debug(self.class.name, "\tAttempt no. #{attempts} ...")
44
45
  sleep sleep_time
45
46
  retry
@@ -51,7 +52,7 @@ module BulletProofJson
51
52
  rescue ::JSON::ParserError => e
52
53
  @logger.error(self.class.name, " #{page.nil? ? "" : (page.to_s + ":")} #{e}\n#{uri_string}")
53
54
 
54
- if (attempts += 1) < max_attempts
55
+ if (attempts += 1) <= max_attempts
55
56
  @logger.debug(self.class.name, "\tAttempt no. #{attempts} ...")
56
57
  sleep sleep_time
57
58
  retry
@@ -63,6 +64,11 @@ module BulletProofJson
63
64
  json
64
65
  end
65
66
 
67
+ private
68
+ def user_agent(version = BulletProofJson::VERSION)
69
+ "bullet-proof-json #{version} - https://github.com/grzegorzblaszczyk/bullet-proof-json"
70
+ end
71
+
66
72
  end
67
73
 
68
74
  class ProviderError < ::StandardError
@@ -1,3 +1,3 @@
1
1
  module BulletProofJson
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -1,5 +1,5 @@
1
- require "bullet_proof_json/version"
2
1
  require_relative "bullet_proof_json/provider"
2
+ require_relative "bullet_proof_json/version"
3
3
  require_relative "bullet_proof_json/console_logger"
4
4
 
5
5
  module BulletProofJson
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_proof_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grzegorz Błaszczyk
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-02-09 00:00:00.000000000 Z
10
+ date: 2025-07-22 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler
@@ -71,14 +71,14 @@ dependencies:
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '10.0'
74
+ version: '12.3'
75
75
  type: :development
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '10.0'
81
+ version: '12.3'
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: rspec
84
84
  requirement: !ruby/object:Gem::Requirement
@@ -93,6 +93,20 @@ dependencies:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
95
  version: '3.0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: simplecov
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.22.0
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 0.22.0
96
110
  description: 'Bullet Proof JSON for Ruby takes the hassle out of API response handling
97
111
  by offering: Seamless Request Handling - automatically manage timeouts and errors
98
112
  so your app stays resilient, Smart Throttling - respect API rate limits without
@@ -104,16 +118,19 @@ executables: []
104
118
  extensions: []
105
119
  extra_rdoc_files: []
106
120
  files:
107
- - ".DS_Store"
121
+ - ".github/workflows/ruby.yml"
108
122
  - ".gitignore"
109
123
  - ".ruby-version"
124
+ - CHANGELOG.md
110
125
  - CODE_OF_CONDUCT.md
111
126
  - Gemfile
112
127
  - Gemfile.lock
113
128
  - Guardfile
114
129
  - LICENSE
130
+ - LICENSE.txt
115
131
  - README.md
116
132
  - Rakefile
133
+ - SECURITY.md
117
134
  - bin/console
118
135
  - bin/setup
119
136
  - bullet_proof_json.gemspec
@@ -124,7 +141,9 @@ files:
124
141
  homepage: https://github.com/grzegorzblaszczyk/bullet-proof-json
125
142
  licenses:
126
143
  - MIT
127
- metadata: {}
144
+ metadata:
145
+ source_code_uri: https://github.com/grzegorzblaszczyk/bullet-proof-json
146
+ changelog_uri: https://github.com/grzegorzblaszczyk/bullet-proof-json/blob/main/CHANGELOG.md
128
147
  rdoc_options: []
129
148
  require_paths:
130
149
  - lib
data/.DS_Store DELETED
Binary file