splittable 0.0.8 → 0.0.10

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: 37c4759b10b00ca1cf91aabb5e0b7611a6557f4a626e45b6ba8849b4756d6085
4
- data.tar.gz: 1afade43018d247600cbb00b360b2f0e5e859358eb84fb0a00da9d2a6bf109a3
3
+ metadata.gz: f009747d17be3ef04b3f0837101ded2552e7e519b46fa4e82d518c7291493f5e
4
+ data.tar.gz: aad637f4ff361343bf795f138c1f700b5bd375fc70aeff0494827bd9f0140fc1
5
5
  SHA512:
6
- metadata.gz: 6c7a5a283d57fc378864f8aa22236a6b58c590cb4218a6ff62783248e8052817a27ffd4d81d0812d0ec64699f6ddbb0addeda1fdbba82ecb8f1e1684786a1ac7
7
- data.tar.gz: 0f10c22baa3d728be34ccd1a01b91901cae23ff32857255d4f66c7ed3ed3bf50988ca2ecb807b7c3f6d9a93c92e5e550ede3017a94e0e7365578ea11a7de8f04
6
+ metadata.gz: 0ade5a87b48dfd30170126e3358df344b521367c00c117f6f89b5795a6aef69fb48f903fc452b79c2f8f8df7920fb9503f182179adacb7149908e4ba7eb5d87a
7
+ data.tar.gz: 68a1f19ea3bd5af29569344ea0fc3ccd7078a67a1dd2dbea950da832e6a76ca98f8c9825ae9caf6b32a439c0ed99a08612e1ba7f0749113e5c0734b0032785cd
@@ -4,8 +4,6 @@ on:
4
4
  push:
5
5
  branches:
6
6
  - master
7
- tags:
8
- - v*
9
7
 
10
8
  jobs:
11
9
  publish:
@@ -13,9 +11,22 @@ jobs:
13
11
  runs-on: ubuntu-latest
14
12
 
15
13
  steps:
16
- - uses: actions/checkout@v3
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Decide whether this version is unpublished
17
+ id: release
18
+ run: |
19
+ version=$(ruby -r ./lib/splittable/version.rb -e 'puts Splittable::VERSION')
20
+ if git ls-remote --exit-code --tags origin "refs/tags/v${version}"; then
21
+ echo "Version v${version} is already tagged. Skipping publish."
22
+ echo "publish=false" >> "$GITHUB_OUTPUT"
23
+ else
24
+ echo "Version v${version} has no tag yet."
25
+ echo "publish=true" >> "$GITHUB_OUTPUT"
26
+ fi
17
27
 
18
28
  - name: Release Gem
29
+ if: steps.release.outputs.publish == 'true'
19
30
  uses: m4rcelotoledo/publish-rubygems-action@master
20
31
  env:
21
32
  RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_RELEASE}}
data/CHANGELOG.md CHANGED
@@ -1,4 +1,33 @@
1
- # splittable 0.0.8 (Oct 14, 2025)
1
+ # splittable 0.0.10 (Sep 25, 2026)
2
+
3
+ * **Bump Versions**
4
+ * Fixed a vulnerability in libs
5
+
6
+ * **Bug Fixes**
7
+ * Fixed incorrect examples in README.md with mathematically accurate values
8
+ * Corrected division examples to show proper cent adjustment behavior
9
+ * Fixed normalize examples to demonstrate actual gem behavior
10
+
11
+ * **Error Handling Improvements**
12
+ * Added proper validation for empty installments array in normalize method
13
+ * Added validation for nil installments parameter
14
+ * Improved error messages with clear ArgumentError exceptions
15
+ * Enhanced error handling documentation with accurate examples
16
+
17
+ * **Test Coverage**
18
+ * Added comprehensive tests for error handling scenarios
19
+ * Added tests for empty and nil installments arrays
20
+ * Maintained 100% test coverage (38 examples, 0 failures)
21
+ * Improved test readability with better formatting
22
+
23
+ * **Code Quality**
24
+ * Enhanced input validation in Splittable::Normalize class
25
+ * Improved error messages for better developer experience
26
+ * All existing functionality preserved and thoroughly tested
27
+
28
+ *Marcelo Toledo*
29
+
30
+ ## splittable 0.0.8 (Oct 14, 2025)
2
31
 
3
32
  * **Documentation Improvements**
4
33
  * Complete README.md rewrite with better examples and real-world use cases
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- splittable (0.0.8)
4
+ splittable (0.0.10)
5
5
  bigdecimal (~> 3.0)
6
6
 
7
7
  GEM
@@ -13,7 +13,7 @@ GEM
13
13
  coderay (1.1.3)
14
14
  diff-lcs (1.6.2)
15
15
  docile (1.4.1)
16
- json (2.15.1)
16
+ json (2.19.9)
17
17
  language_server-protocol (3.17.0.5)
18
18
  lint_roller (1.1.0)
19
19
  method_source (1.1.0)
data/README.md CHANGED
@@ -52,7 +52,7 @@ Split a total value into equal installments:
52
52
  ```ruby
53
53
  # Basic usage - split $0.12 into 3 equal parts
54
54
  Splittable.division(value: 0.12, quantity: 3)
55
- # => [0.05, 0.03, 0.03] # Sum: 0.11 (truncated from 0.12)
55
+ # => [0.04, 0.04, 0.04] # Sum: 0.12
56
56
 
57
57
  # Custom precision - 3 decimal places
58
58
  Splittable.division(value: 10, quantity: 3, precision: 3)
@@ -79,7 +79,7 @@ Splittable.normalize(value: 100, installments: [33.333, 33.333, 33.333], precisi
79
79
  ```ruby
80
80
  # Split a $99.99 order into 3 monthly payments
81
81
  payments = Splittable.division(value: 99.99, quantity: 3)
82
- # => [33.34, 33.33, 33.33]
82
+ # => [33.33, 33.33, 33.33]
83
83
  # Total: $99.99 ✅
84
84
  ```
85
85
 
@@ -89,17 +89,17 @@ payments = Splittable.division(value: 99.99, quantity: 3)
89
89
  departments = ['Sales', 'Marketing', 'Support']
90
90
  amounts = [400.00, 350.00, 250.00]
91
91
 
92
- normalized = Splittable.normalize(value: 1000.00, installments: amounts)
92
+ normalized = Splittable.normalize(value: 1000.01, installments: amounts)
93
93
  # => [400.01, 350.00, 250.00]
94
- # Total: $1,000.00 ✅
94
+ # Total: $1,000.01 ✅
95
95
  ```
96
96
 
97
97
  ### Subscription Billing
98
98
  ```ruby
99
99
  # Annual subscription split into monthly payments
100
- monthly_payment = Splittable.division(value: 120.00, quantity: 12)
100
+ monthly_payment = Splittable.division(value: 120.01, quantity: 12)
101
101
  # => [10.01, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00, 10.00]
102
- # Total: $120.00 ✅
102
+ # Total: $120.01 ✅
103
103
  ```
104
104
 
105
105
  ## ⚠️ Error Handling
@@ -111,7 +111,11 @@ Splittable.division(value: 100, quantity: 0)
111
111
 
112
112
  # Empty installments array
113
113
  Splittable.normalize(value: 100, installments: [])
114
- # => NoMethodError: undefined method `[]' for nil:NilClass
114
+ # => ArgumentError: installments should be a non-empty array
115
+
116
+ # Nil installments
117
+ Splittable.normalize(value: 100, installments: nil)
118
+ # => ArgumentError: installments should be a non-empty array
115
119
  ```
116
120
 
117
121
  ## 🛠️ Development
@@ -2,6 +2,7 @@
2
2
 
3
3
  class Splittable::Normalize
4
4
  def initialize(value:, installments:, precision: 2)
5
+ check_installments_validity!(installments)
5
6
  @value = BigDecimal(value, 15).truncate(precision)
6
7
  @installments = installments.map { |installment| BigDecimal(installment.round(precision), 15) }
7
8
  end
@@ -17,4 +18,10 @@ class Splittable::Normalize
17
18
 
18
19
  attr_reader :value
19
20
  attr_accessor :installments
21
+
22
+ def check_installments_validity!(installments)
23
+ return if installments.is_a?(Array) && !installments.empty?
24
+
25
+ raise ArgumentError, 'installments should be a non-empty array'
26
+ end
20
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Splittable
4
- VERSION = '0.0.8'
4
+ VERSION = '0.0.10'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splittable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arthur Brandão