ncore 3.14.0 → 3.15.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: 82327b8c22a9db2b69dfca2505b658b9a01d5a880cd21a7db9d11c1031d001e7
4
- data.tar.gz: abf4f4eef8f9e3bdebbce6e987507ca3adc31d4bb31ffae63d46b5466c417505
3
+ metadata.gz: 9ddf8c778ed7a75566b6c1665880413606d276e3c07269fe8f4e63ad9f98d0fc
4
+ data.tar.gz: 0a527000d932792291a0f0fce5ad834560ee7ee0637c4798354f0d63067a9784
5
5
  SHA512:
6
- metadata.gz: de4443f42157acf82e2ea6ca3741ecb6c09ce61a6585cb36f4c84d7898346a9cbf4acdd35303923b8f69cc7cf110931d5e2cf4f26cb4f01f6fd0218ed76bc331
7
- data.tar.gz: bbaa72e2993e5f56367f6aeff83825f7f7b0c852d8bac70fc275a4ed86dd02c52a07ea09395e28db44bdc82efee02185d66e56de879b203f1884f9934edcf9e9
6
+ metadata.gz: 998f66195437f3d3b05783d5cfe96569ba4dfe81d5128319c3352d942b54f273b64bbe32bde720e81e0a87ebb9c1f659a2ac8d9c196e16b27ec029c9216fe38c
7
+ data.tar.gz: 58667228dee3c13b4316839b156e01b619aa88f710ba6d5ff5c821bf4133964165d6fc14b709b03da4cc051fa01865f4e44f3caf7c529403b22aa43f3ae32b6c
@@ -0,0 +1,15 @@
1
+ <!--
2
+ Describe your PR. What's the purpose/use-case of this PR?
3
+ What's been added, changed, and/or removed?
4
+ -->
5
+
6
+ ## Contribution
7
+
8
+ <!-- Check only what applies. The goal here is clarity, not checking all the boxes. -->
9
+
10
+ - [ ] I tested my changes locally
11
+ - [ ] Includes a breaking change (be sure to explain above)
12
+ <!--
13
+ Select one: -->
14
+ - [ ] PR contents is 100% human written
15
+ - [ ] PR includes LLM output <!-- see README.md's Contributing section (near bottom) -->
data/.gitignore CHANGED
@@ -4,7 +4,6 @@
4
4
  .config
5
5
  .ruby-*
6
6
  .yardoc
7
- Gemfile.lock
8
7
  InstalledFiles
9
8
  _yardoc
10
9
  coverage
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ #### 3.15.1
2
+
3
+ - Compatibility with json gem 3.0
4
+
5
+ #### 3.15.0
6
+
7
+ - Make JSON parsing and generation more consistent by using JSON::Coder
8
+ - Remove MultiJson
9
+ - Make attr_decimal use BigDecimal and attr_money use BigMoney
10
+
1
11
  #### 3.14.0
2
12
 
3
13
  - Resources: add #to_s
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in ncore.gemspec
4
4
  gemspec
5
+
6
+ gem 'minitest-reporters'
data/Gemfile.lock ADDED
@@ -0,0 +1,63 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ncore (3.15.1)
5
+ activemodel (>= 5.2, < 8.2)
6
+ excon (< 2)
7
+ json (>= 2.17)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activemodel (8.1.3.1)
13
+ activesupport (= 8.1.3.1)
14
+ activesupport (8.1.3.1)
15
+ base64
16
+ bigdecimal
17
+ concurrent-ruby (~> 1.0, >= 1.3.1)
18
+ connection_pool (>= 2.2.5)
19
+ drb
20
+ i18n (>= 1.6, < 2)
21
+ json
22
+ logger (>= 1.4.2)
23
+ minitest (>= 5.1)
24
+ securerandom (>= 0.3)
25
+ tzinfo (~> 2.0, >= 2.0.5)
26
+ uri (>= 0.13.1)
27
+ ansi (1.6.0)
28
+ base64 (0.3.0)
29
+ bigdecimal (4.1.2)
30
+ builder (3.3.0)
31
+ concurrent-ruby (1.3.8)
32
+ connection_pool (3.0.2)
33
+ drb (2.2.3)
34
+ excon (1.7.1)
35
+ logger
36
+ i18n (1.15.2)
37
+ concurrent-ruby (~> 1.0)
38
+ json (3.0.0)
39
+ logger (1.7.0)
40
+ minitest (6.0.6)
41
+ drb (~> 2.0)
42
+ prism (~> 1.5)
43
+ minitest-reporters (1.8.0)
44
+ ansi
45
+ builder
46
+ minitest (>= 5.0, < 7)
47
+ ruby-progressbar
48
+ prism (1.9.0)
49
+ ruby-progressbar (1.13.0)
50
+ securerandom (0.4.1)
51
+ tzinfo (2.0.6)
52
+ concurrent-ruby (~> 1.0)
53
+ uri (1.1.1)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ minitest-reporters
60
+ ncore!
61
+
62
+ BUNDLED WITH
63
+ 4.0.16
@@ -1,4 +1,4 @@
1
- Copyright 2014-2025 Notioneer, Inc.
1
+ Copyright 2014-2026 Notioneer, Inc.
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -5,36 +5,35 @@ client by itself, but provides several useful building blocks to build one.
5
5
 
6
6
  It relies on `excon` for HTTP handling and `activemodel`.
7
7
 
8
- If present, uses `multi_json`. Otherwise, the stdlib 'json' is used.
9
- 'multi_json' with an accelerated json gem is recommended.
10
-
11
- See `example/` for the beginning of an actual api client.
8
+ See `example/` for the beginning of an actual api client. See [dnscaster-ruby](https://github.com/cosmicio/dnscaster-ruby) for a complete client.
12
9
 
13
10
 
14
11
  ## Installation
15
12
 
16
13
  Add this line to your application's Gemfile:
17
14
 
18
- gem 'ncore'
15
+ gem 'ncore', '~> 3'
19
16
 
20
- And then execute:
17
+ Or this to your gem's gemspec:
21
18
 
22
- $ bundle
19
+ spec.add_dependency 'ncore', '~> 3'
23
20
 
24
- Or install it yourself as:
25
21
 
26
- $ gem install ncore
22
+ ## Contributing
27
23
 
24
+ Contributions are welcomed. If unsure about the scope or reach of a potential PR, feel free to open a discussion Issue first (not required though).
28
25
 
29
- ## Contributing
26
+ Please submit human-written contributions only. No contributions containing output generated by LLMs or other non-deterministic systems are allowed.
27
+
28
+ * Code, tests, docs, PRs: must be 100% human written.
29
+ * Issues, security reports: must originally be 100% human written. If not originally in English, an LLM may be used to translate to English provided that this translation is disclosed.
30
+
31
+ We recognize that opinions about the use of LLMs and non-deterministic systems vary widely. Still, we respectfully ask that you honor this policy when interacting with this project.
30
32
 
31
- 1. Fork it
32
- 2. Create your feature branch (`git checkout -b my-new-feature`)
33
- 3. Commit your changes (`git commit -am 'Add some feature'`)
34
- 4. Push to the branch (`git push origin my-new-feature`)
35
- 5. Create new Pull Request
33
+ ###### Q: May I use LLMs apart from contributions?
34
+ All usage, training or otherwise, must respect copyrights. Beyond that, we've found that LLMs are prone to errors and misunderstandings--sometimes obvious, sometimes subtle. Please verify everything before trusting an LLM's output.
36
35
 
37
36
 
38
37
  ## License
39
38
 
40
- MIT
39
+ [MIT](LICENSE.txt)
data/Rakefile CHANGED
@@ -1 +1,5 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'minitest/test_task'
4
+ Minitest::TestTask.create
5
+ task default: :test
@@ -48,9 +48,29 @@ module NCore
48
48
  end
49
49
 
50
50
  # attr_decimal(:amount, ...)
51
- # adds: obj.amount => BigMoney if String, else raw json type
51
+ # adds: obj.amount => BigDecimal if String, else raw json type
52
52
  # obj.amount? => bool
53
53
  def attr_decimal(*attrs, predicate: true)
54
+ attrs.each do |attr|
55
+ check_existing_method(attr)
56
+ class_eval <<-AD, __FILE__, __LINE__+1
57
+ def #{attr}
58
+ case self[:#{attr}]
59
+ when String
60
+ BigDecimal(self[:#{attr}])
61
+ else
62
+ self[:#{attr}]
63
+ end
64
+ end
65
+ AD
66
+ attr_boolean :"#{attr}?" if predicate
67
+ end
68
+ end
69
+
70
+ # attr_money(:amount, ...)
71
+ # adds: obj.amount => BigMoney if String or BigDecimal, else raw json type
72
+ # obj.amount? => bool
73
+ def attr_money(*attrs, predicate: true)
54
74
  attrs.each do |attr|
55
75
  check_existing_method(attr)
56
76
  class_eval <<-AD, __FILE__, __LINE__+1
@@ -58,6 +78,8 @@ module NCore
58
78
  case self[:#{attr}]
59
79
  when String
60
80
  BigMoney.new(self[:#{attr}])
81
+ when BigDecimal
82
+ BigMoney.new(self[:#{attr}].to_s)
61
83
  else
62
84
  self[:#{attr}]
63
85
  end
data/lib/ncore/client.rb CHANGED
@@ -31,11 +31,7 @@ module NCore
31
31
  path += qs
32
32
  payload = nil
33
33
  else
34
- if defined? MultiJson
35
- payload = MultiJson.encode params.as_json
36
- else
37
- payload = params.to_json
38
- end
34
+ payload = json_coder.generate params
39
35
  end
40
36
 
41
37
  rest_opts = {
@@ -252,22 +248,42 @@ module NCore
252
248
  response
253
249
  end
254
250
 
251
+
252
+ def json_opts
253
+ { allow_duplicate_key: false,
254
+ create_additions: false,
255
+ decimal_class: BigDecimal,
256
+ symbolize_names: false,
257
+ }.tap{|opts|
258
+ opts.delete :create_additions if JSON::VERSION >= '3'
259
+ }
260
+ end
261
+
262
+ def json_coder
263
+ @json_coder ||= ::JSON::Coder.new(**json_opts) do |value, is_key|
264
+ case value
265
+ when BigDecimal
266
+ ::JSON::Fragment.new value.to_s
267
+ when DateTime, Time
268
+ value.iso8601(3)
269
+ else
270
+ if is_key
271
+ value.as_json.to_s
272
+ else
273
+ value.as_json
274
+ end
275
+ end
276
+ end
277
+ end
278
+
255
279
  def parse_response(response)
256
280
  if response.body.blank?
257
281
  json = {}
258
282
  else
259
- if defined? MultiJson
260
- begin
261
- json = MultiJson.load(response.body, symbolize_keys: false) || {}
262
- rescue MultiJson::ParseError
263
- raise module_parent::Error, "Unable to parse API response; HTTP status: #{response.status}; body: #{response.body.inspect}"
264
- end
265
- else
266
- begin
267
- json = JSON.parse(response.body, symbolize_names: false) || {}
268
- rescue JSON::ParserError
269
- raise module_parent::Error, "Unable to parse API response; HTTP status: #{response.status}; body: #{response.body.inspect}"
270
- end
283
+ begin
284
+ json = json_coder.parse response.body
285
+ rescue JSON::ParserError
286
+ raise module_parent::Error, "Unable to parse API response; HTTP status: #{response.status}; body: #{response.body.inspect}"
271
287
  end
272
288
  end
273
289
  json = json.with_indifferent_access
@@ -339,11 +355,7 @@ module NCore
339
355
  def debug_response(response)
340
356
  return unless logger.debug?
341
357
  headers = response.headers.transform_keys(&:downcase)
342
- if defined? MultiJson
343
- json = MultiJson.load(response.body||'', symbolize_keys: false) rescue response.body
344
- else
345
- json = JSON.parse(response.body||'', symbolize_names: false) rescue response.body
346
- end
358
+ json = json_coder.parse(response.body) rescue response.body
347
359
  logger << <<~DBG
348
360
  RESPONSE:
349
361
  #{response.status} | #{headers['content-type']} | #{response.body.size} bytes
data/lib/ncore/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module NCore
2
- VERSION = '3.14.0'
2
+ VERSION = '3.15.1'
3
3
  end
data/ncore.gemspec CHANGED
@@ -27,7 +27,5 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency 'activemodel', '>= 5.2', '< 8.2'
29
29
  spec.add_dependency 'excon', '< 2'
30
-
31
- spec.add_development_dependency "bundler"
32
- spec.add_development_dependency "rake"
30
+ spec.add_dependency 'json', '>= 2.17'
33
31
  end
@@ -0,0 +1,7 @@
1
+ require "test_helper"
2
+
3
+ class NCoreTest < ActiveSupport::TestCase
4
+ test "it has a version number" do
5
+ assert NCore::VERSION
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ require 'minitest/reporters'
2
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
3
+
4
+ require 'ncore'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ncore
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.14.0
4
+ version: 3.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Notioneer Team
@@ -44,33 +44,19 @@ dependencies:
44
44
  - !ruby/object:Gem::Version
45
45
  version: '2'
46
46
  - !ruby/object:Gem::Dependency
47
- name: bundler
47
+ name: json
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: '0'
53
- type: :development
54
- prerelease: false
55
- version_requirements: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: '0'
60
- - !ruby/object:Gem::Dependency
61
- name: rake
62
- requirement: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: '0'
67
- type: :development
52
+ version: '2.17'
53
+ type: :runtime
68
54
  prerelease: false
69
55
  version_requirements: !ruby/object:Gem::Requirement
70
56
  requirements:
71
57
  - - ">="
72
58
  - !ruby/object:Gem::Version
73
- version: '0'
59
+ version: '2.17'
74
60
  description: NCore - Ruby gem useful for building REST API clients
75
61
  email:
76
62
  - hello@notioneer.com
@@ -78,10 +64,12 @@ executables: []
78
64
  extensions: []
79
65
  extra_rdoc_files: []
80
66
  files:
67
+ - ".github/pull_request_template.md"
81
68
  - ".gitignore"
82
69
  - CHANGELOG.md
83
70
  - Gemfile
84
- - LICENSE
71
+ - Gemfile.lock
72
+ - LICENSE.txt
85
73
  - README.md
86
74
  - Rakefile
87
75
  - example/lib/my_api.rb
@@ -123,6 +111,8 @@ files:
123
111
  - lib/ncore/version.rb
124
112
  - lib/ncore/wait.rb
125
113
  - ncore.gemspec
114
+ - test/ncore_test.rb
115
+ - test/test_helper.rb
126
116
  homepage: https://notioneer.com/
127
117
  licenses:
128
118
  - MIT
@@ -143,7 +133,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
133
  - !ruby/object:Gem::Version
144
134
  version: '0'
145
135
  requirements: []
146
- rubygems_version: 3.6.9
136
+ rubygems_version: 4.0.16
147
137
  specification_version: 4
148
138
  summary: NCore - Gem for building REST API clients
149
- test_files: []
139
+ test_files:
140
+ - test/ncore_test.rb
141
+ - test/test_helper.rb