diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3d2ac0bd..5547f83e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0" + ".": "0.1.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c9c6064a..811775c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.1.1 (2025-04-08) + +Full Changelog: [v0.1.0...v0.1.1](https://github.com/orbcorp/orb-ruby/compare/v0.1.0...v0.1.1) + +### Chores + +* **internal:** version bump ([ef344e2](https://github.com/orbcorp/orb-ruby/commit/ef344e295d437e08f33fc7091a89be121ee6c5e9)) +* loosen const and integer coercion rules ([#246](https://github.com/orbcorp/orb-ruby/issues/246)) ([715a138](https://github.com/orbcorp/orb-ruby/commit/715a138f44ddf1eaf26c4ffec32178f8591eb8d0)) + ## 0.1.0 (2025-04-08) Full Changelog: [v0.1.0-alpha.39...v0.1.0](https://github.com/orbcorp/orb-ruby/compare/v0.1.0-alpha.39...v0.1.0) diff --git a/Gemfile.lock b/Gemfile.lock index 54710652..8763e79a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - orb-billing (0.1.0.pre.alpha.39) + orb-billing (0.1.0) connection_pool GEM diff --git a/README.md b/README.md index 2ae58f2f..624a2a4f 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application ```ruby -gem "orb-billing", "~> 0.1.0.pre.alpha.39" +gem "orb-billing", "~> 0.1.0" ``` diff --git a/lib/orb/internal/type/converter.rb b/lib/orb/internal/type/converter.rb index 7a9bd683..04896cad 100644 --- a/lib/orb/internal/type/converter.rb +++ b/lib/orb/internal/type/converter.rb @@ -149,9 +149,9 @@ def coerce( if value.is_a?(Integer) exactness[:yes] += 1 return value - elsif strictness == :strong + elsif strictness == :strong && Integer(value, exception: false) != value message = "no implicit conversion of #{value.class} into #{target.inspect}" - raise TypeError.new(message) + raise value.is_a?(Numeric) ? ArgumentError.new(message) : TypeError.new(message) else Kernel.then do return Integer(value).tap { exactness[:maybe] += 1 } @@ -197,12 +197,20 @@ def coerce( else end in Symbol - if (value.is_a?(Symbol) || value.is_a?(String)) && value.to_sym == target - exactness[:yes] += 1 - return target - elsif strictness == :strong - message = "cannot convert non-matching #{value.class} into #{target.inspect}" - raise ArgumentError.new(message) + case value + in Symbol | String + if value.to_sym == target + exactness[:yes] += 1 + return target + else + exactness[:maybe] += 1 + return value + end + else + if strictness == :strong + message = "cannot convert non-matching #{value.class} into #{target.inspect}" + raise ArgumentError.new(message) + end end else end diff --git a/lib/orb/version.rb b/lib/orb/version.rb index 773d6b33..bb3eb23f 100644 --- a/lib/orb/version.rb +++ b/lib/orb/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Orb - VERSION = "0.1.0" + VERSION = "0.1.1" end diff --git a/test/orb/internal/type/base_model_test.rb b/test/orb/internal/type/base_model_test.rb index 3adca517..138d5e6b 100644 --- a/test/orb/internal/type/base_model_test.rb +++ b/test/orb/internal/type/base_model_test.rb @@ -111,7 +111,6 @@ def test_coerce_errors [Integer, "one"] => TypeError, [Float, "one"] => TypeError, [String, Time] => TypeError, - [:a, "one"] => ArgumentError, [Date, "one"] => ArgumentError, [Time, "one"] => ArgumentError } @@ -346,7 +345,7 @@ def test_coerce [M2, {a: "1990-09-19", c: nil}] => [{yes: 2, maybe: 2}, {a: "1990-09-19", c: nil}], [M3, {c: "c", d: "d"}] => [{yes: 3}, {c: :c, d: :d}], - [M3, {c: "d", d: "c"}] => [{yes: 1, no: 2}, {c: "d", d: "c"}], + [M3, {c: "d", d: "c"}] => [{yes: 1, maybe: 2}, {c: "d", d: "c"}], [M4, {c: 2}] => [{yes: 5}, {c: 2}], [M4, {a: "1", c: 2}] => [{yes: 4, maybe: 1}, {a: "1", c: 2}], @@ -404,7 +403,8 @@ def test_accessors cases = { M2.new({a: "1990-09-19", b: "1"}) => {a: Time.new(1990, 9, 19), b: TypeError}, M2.new(a: "one", b: "one") => {a: ArgumentError, b: TypeError}, - M2.new(a: nil, b: 2.0) => {a: TypeError, b: TypeError}, + M2.new(a: nil, b: 2.0) => {a: TypeError}, + M2.new(a: nil, b: 2.2) => {a: TypeError, b: ArgumentError}, M3.new => {d: :d}, M3.new(d: 1) => {d: ArgumentError}, @@ -520,8 +520,8 @@ def test_coerce [U0, :""] => [{no: 1}, 0, :""], [U1, "a"] => [{yes: 1}, 1, :a], - [U1, "2"] => [{maybe: 1}, 2, 2], - [U1, :b] => [{no: 1}, 2, :b], + [U1, "2"] => [{maybe: 1}, 2, "2"], + [U1, :b] => [{maybe: 1}, 2, :b], [U2, {type: :a}] => [{yes: 3}, 0, {t: :a}], [U2, {type: "b"}] => [{yes: 3}, 0, {type: :b}],