subroutine 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d089cc45475bdb88ee182f34ef6cbfc2fcb4c77d039fce887fd3bd420a2f210
4
- data.tar.gz: 454b7650e82cccfe16af31d8bb7ca5739763cacdcd1cab4ef810a25634dab480
3
+ metadata.gz: e6530220e9e104f3eb840fc5ad28514e4e9bb29f6831f1c8cefa96e3d511454b
4
+ data.tar.gz: 0bfaf68aae3bd5f5887c2da31b3cc1b8f8fe9c8e12b88f1365c03836bd4615cf
5
5
  SHA512:
6
- metadata.gz: 43420206b0becfd866a4ec01aa757d20c780bb939ed666c94878c8c73645561672646b230850aa199652776204f50562c0b675b37973d6efcb9ce831fc3b4d9c
7
- data.tar.gz: dc313998225594aac7480cbf9df3e5b539589c13ef041adccb39ef97c583f0608d8a5b7b7e55245d58816b98db159a8d4fedd42d39f6b72317add6670a3ac7cc
6
+ metadata.gz: 2c7e809eac6e059bed7029907f4a153b388d564c0ac93b9dde0397a6ef15c5cb57fe816b2b31fdd4d2547dafbbc8d12d52493aebe61aa550afa6c430f2db820a
7
+ data.tar.gz: 74d0b0c8c647e3f97fa0899c18a33fbddf7aa7b88a878f22740cd0edacbaf873f7181a164347b88425c1a891662565433d3e6c5dfd5a35f602b785c9b4f7341c
@@ -1,5 +1,9 @@
1
1
  name: build
2
- on: [push, pull_request]
2
+ on:
3
+ pull_request:
4
+ push:
5
+ branches:
6
+ - main
3
7
  jobs:
4
8
  build:
5
9
  runs-on: ubuntu-latest
@@ -14,10 +18,15 @@ jobs:
14
18
  experimental: true
15
19
  - ruby-version: 3.1
16
20
  experimental: true
21
+ - ruby-version: 3.2
22
+ experimental: true
17
23
  steps:
18
- - uses: actions/checkout@v3
24
+ - uses: actions/checkout@v4
25
+ with:
26
+ show-progress: 'false'
19
27
  - uses: ruby/setup-ruby@v1
20
28
  with:
21
29
  ruby-version: ${{ matrix.ruby-version }}
22
30
  bundler-cache: true # runs `bundle install` and caches installed gems automatically
23
- - run: bundle exec rake test
31
+ - run: bundle exec appraisal install
32
+ - run: bundle exec appraisal rake test
data/Appraisals ADDED
@@ -0,0 +1,9 @@
1
+ appraise "rails-6.1" do
2
+ gem 'activemodel', '~> 6.1.0'
3
+ gem 'actionpack', '~> 6.1.0'
4
+ end
5
+
6
+ appraise "rails-7.0" do
7
+ gem 'activemodel', '~> 7.0.0'
8
+ gem 'actionpack', '~> 7.0.0'
9
+ end
data/Gemfile CHANGED
@@ -5,4 +5,7 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in subroutine.gemspec
6
6
  gemspec
7
7
 
8
- eval_gemfile "gemfiles/am61.gemfile"
8
+ # Locking to specific git sha to work around
9
+ # https://github.com/thoughtbot/appraisal/issues/211
10
+ # until appraisal v3 is released
11
+ gem "appraisal", github: "thoughtbot/appraisal", ref: "b200e636903"
data/README.md CHANGED
@@ -62,3 +62,21 @@ end
62
62
  - [Using an Op](https://github.com/guideline-tech/subroutine/wiki/Using-an-Op)
63
63
  - [Errors](https://github.com/guideline-tech/subroutine/wiki/Errors)
64
64
  - [Basic Usage in Rails](https://github.com/guideline-tech/subroutine/wiki/Rails-Usage)
65
+
66
+ ## Development
67
+
68
+ Run the test suite against current Rails version:
69
+
70
+ ```
71
+ bundle exec rake test
72
+ ```
73
+
74
+ Run the test suite against all supported Rails versions using `appraisal`:
75
+
76
+ ```
77
+ bundle exec appraisal rake test
78
+ ```
79
+
80
+ For help updating the `Gemfile` or changing supported Rails versions, see the `appraisal` gem [README](https://github.com/thoughtbot/appraisal#usage).
81
+
82
+ Note that the gemfiles in `gemfiles/*` are auto-generated by `appraisal` and should not be modified directly.
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", github: "thoughtbot/appraisal", ref: "b200e636903"
6
+ gem "activemodel", "~> 6.1.0"
7
+ gem "actionpack", "~> 6.1.0"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,102 @@
1
+ GIT
2
+ remote: https://github.com/thoughtbot/appraisal.git
3
+ revision: b200e636903700098bef25f4f51dbc4c46e4c04c
4
+ ref: b200e636903
5
+ specs:
6
+ appraisal (2.4.1)
7
+ bundler
8
+ rake
9
+ thor (>= 0.14.0)
10
+
11
+ PATH
12
+ remote: ..
13
+ specs:
14
+ subroutine (3.0.0)
15
+ activemodel (>= 6.1)
16
+ activesupport (>= 6.1)
17
+
18
+ GEM
19
+ remote: https://rubygems.org/
20
+ specs:
21
+ actionpack (6.1.7.4)
22
+ actionview (= 6.1.7.4)
23
+ activesupport (= 6.1.7.4)
24
+ rack (~> 2.0, >= 2.0.9)
25
+ rack-test (>= 0.6.3)
26
+ rails-dom-testing (~> 2.0)
27
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
28
+ actionview (6.1.7.4)
29
+ activesupport (= 6.1.7.4)
30
+ builder (~> 3.1)
31
+ erubi (~> 1.4)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
34
+ activemodel (6.1.7.4)
35
+ activesupport (= 6.1.7.4)
36
+ activesupport (6.1.7.4)
37
+ concurrent-ruby (~> 1.0, >= 1.0.2)
38
+ i18n (>= 1.6, < 2)
39
+ minitest (>= 5.1)
40
+ tzinfo (~> 2.0)
41
+ zeitwerk (~> 2.3)
42
+ ansi (1.5.0)
43
+ builder (3.2.4)
44
+ byebug (11.1.3)
45
+ concurrent-ruby (1.2.2)
46
+ crass (1.0.6)
47
+ erubi (1.12.0)
48
+ i18n (1.14.1)
49
+ concurrent-ruby (~> 1.0)
50
+ loofah (2.21.3)
51
+ crass (~> 1.0.2)
52
+ nokogiri (>= 1.12.0)
53
+ m (1.6.1)
54
+ method_source (>= 0.6.7)
55
+ rake (>= 0.9.2.2)
56
+ method_source (1.0.0)
57
+ minitest (5.18.1)
58
+ minitest-reporters (1.6.0)
59
+ ansi
60
+ builder
61
+ minitest (>= 5.0)
62
+ ruby-progressbar
63
+ mocha (2.0.4)
64
+ ruby2_keywords (>= 0.0.5)
65
+ nokogiri (1.15.2-arm64-darwin)
66
+ racc (~> 1.4)
67
+ racc (1.7.1)
68
+ rack (2.2.7)
69
+ rack-test (2.1.0)
70
+ rack (>= 1.3)
71
+ rails-dom-testing (2.0.3)
72
+ activesupport (>= 4.2.0)
73
+ nokogiri (>= 1.6)
74
+ rails-html-sanitizer (1.6.0)
75
+ loofah (~> 2.21)
76
+ nokogiri (~> 1.14)
77
+ rake (13.0.6)
78
+ ruby-progressbar (1.13.0)
79
+ ruby2_keywords (0.0.5)
80
+ thor (1.2.2)
81
+ tzinfo (2.0.6)
82
+ concurrent-ruby (~> 1.0)
83
+ zeitwerk (2.6.8)
84
+
85
+ PLATFORMS
86
+ arm64-darwin-22
87
+
88
+ DEPENDENCIES
89
+ actionpack (~> 6.1.0)
90
+ activemodel (~> 6.1.0)
91
+ appraisal!
92
+ bundler
93
+ byebug
94
+ m
95
+ minitest
96
+ minitest-reporters
97
+ mocha
98
+ rake
99
+ subroutine!
100
+
101
+ BUNDLED WITH
102
+ 2.4.7
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal", github: "thoughtbot/appraisal", ref: "b200e636903"
6
+ gem "activemodel", "~> 7.0.0"
7
+ gem "actionpack", "~> 7.0.0"
8
+
9
+ gemspec path: "../"
@@ -0,0 +1,100 @@
1
+ GIT
2
+ remote: https://github.com/thoughtbot/appraisal.git
3
+ revision: b200e636903700098bef25f4f51dbc4c46e4c04c
4
+ ref: b200e636903
5
+ specs:
6
+ appraisal (2.4.1)
7
+ bundler
8
+ rake
9
+ thor (>= 0.14.0)
10
+
11
+ PATH
12
+ remote: ..
13
+ specs:
14
+ subroutine (3.0.0)
15
+ activemodel (>= 6.1)
16
+ activesupport (>= 6.1)
17
+
18
+ GEM
19
+ remote: https://rubygems.org/
20
+ specs:
21
+ actionpack (7.0.5.1)
22
+ actionview (= 7.0.5.1)
23
+ activesupport (= 7.0.5.1)
24
+ rack (~> 2.0, >= 2.2.4)
25
+ rack-test (>= 0.6.3)
26
+ rails-dom-testing (~> 2.0)
27
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
28
+ actionview (7.0.5.1)
29
+ activesupport (= 7.0.5.1)
30
+ builder (~> 3.1)
31
+ erubi (~> 1.4)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
34
+ activemodel (7.0.5.1)
35
+ activesupport (= 7.0.5.1)
36
+ activesupport (7.0.5.1)
37
+ concurrent-ruby (~> 1.0, >= 1.0.2)
38
+ i18n (>= 1.6, < 2)
39
+ minitest (>= 5.1)
40
+ tzinfo (~> 2.0)
41
+ ansi (1.5.0)
42
+ builder (3.2.4)
43
+ byebug (11.1.3)
44
+ concurrent-ruby (1.2.2)
45
+ crass (1.0.6)
46
+ erubi (1.12.0)
47
+ i18n (1.14.1)
48
+ concurrent-ruby (~> 1.0)
49
+ loofah (2.21.3)
50
+ crass (~> 1.0.2)
51
+ nokogiri (>= 1.12.0)
52
+ m (1.6.1)
53
+ method_source (>= 0.6.7)
54
+ rake (>= 0.9.2.2)
55
+ method_source (1.0.0)
56
+ minitest (5.18.1)
57
+ minitest-reporters (1.6.0)
58
+ ansi
59
+ builder
60
+ minitest (>= 5.0)
61
+ ruby-progressbar
62
+ mocha (2.0.4)
63
+ ruby2_keywords (>= 0.0.5)
64
+ nokogiri (1.15.2-arm64-darwin)
65
+ racc (~> 1.4)
66
+ racc (1.7.1)
67
+ rack (2.2.7)
68
+ rack-test (2.1.0)
69
+ rack (>= 1.3)
70
+ rails-dom-testing (2.0.3)
71
+ activesupport (>= 4.2.0)
72
+ nokogiri (>= 1.6)
73
+ rails-html-sanitizer (1.6.0)
74
+ loofah (~> 2.21)
75
+ nokogiri (~> 1.14)
76
+ rake (13.0.6)
77
+ ruby-progressbar (1.13.0)
78
+ ruby2_keywords (0.0.5)
79
+ thor (1.2.2)
80
+ tzinfo (2.0.6)
81
+ concurrent-ruby (~> 1.0)
82
+
83
+ PLATFORMS
84
+ arm64-darwin-22
85
+
86
+ DEPENDENCIES
87
+ actionpack (~> 7.0.0)
88
+ activemodel (~> 7.0.0)
89
+ appraisal!
90
+ bundler
91
+ byebug
92
+ m
93
+ minitest
94
+ minitest-reporters
95
+ mocha
96
+ rake
97
+ subroutine!
98
+
99
+ BUNDLED WITH
100
+ 2.4.7
@@ -56,7 +56,17 @@ end
56
56
  end
57
57
 
58
58
  ::Subroutine::TypeCaster.register :decimal, :big_decimal do |value, _options = {}|
59
- ::Subroutine::TypeCaster.cast(value, type: :number, methods: [:to_d, :to_f])
59
+ next nil if value.blank?
60
+
61
+ if value.respond_to?(:to_d)
62
+ begin
63
+ next BigDecimal(value.to_s, 0)
64
+ rescue ArgumentError
65
+ next BigDecimal(0)
66
+ end
67
+ end
68
+
69
+ ::Subroutine::TypeCaster.cast(value, type: :number, methods: [:to_f])
60
70
  end
61
71
 
62
72
  ::Subroutine::TypeCaster.register :string, :text do |value, _options = {}|
@@ -65,10 +75,10 @@ end
65
75
 
66
76
  ::Subroutine::TypeCaster.register :foreign_key do |value, options = {}|
67
77
  next nil if value.blank?
68
-
78
+
69
79
  calculated_type = options[:foreign_key_type].respond_to?(:call)
70
80
  calculated_value = calculated_type ? options[:foreign_key_type].call : options[:foreign_key_type]
71
-
81
+
72
82
  next ::Subroutine::TypeCaster.cast(value, type: calculated_value) if calculated_value
73
83
  next ::Subroutine::TypeCaster.cast(value, type: :integer) if options[:name] && options[:name].to_s.end_with?("_id")
74
84
 
@@ -4,7 +4,7 @@ module Subroutine
4
4
 
5
5
  MAJOR = 3
6
6
  MINOR = 0
7
- PATCH = 0
7
+ PATCH = 1
8
8
  PRE = nil
9
9
 
10
10
  VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
@@ -42,6 +42,33 @@ module Subroutine
42
42
  assert_equal 0.0, op.number_input
43
43
  end
44
44
 
45
+ def test_decimal_inputs
46
+ op.decimal_input = nil
47
+ assert_nil op.decimal_input
48
+
49
+ op.decimal_input = 4
50
+ assert_equal 4.0, op.decimal_input
51
+ assert op.decimal_input.is_a?(BigDecimal)
52
+
53
+ op.decimal_input = 0.5
54
+ assert_equal 0.5, op.decimal_input
55
+
56
+ op.decimal_input = 'foo'
57
+ assert_equal 0.0, op.decimal_input
58
+ end
59
+
60
+ def test_decimal_inputs_use_16_precision
61
+ op.decimal_input = 0.07
62
+ expected_bd_value = BigDecimal('0.07', 0)
63
+ assert_equal expected_bd_value, op.decimal_input
64
+ assert op.decimal_input.is_a?(BigDecimal)
65
+
66
+ # Ruby 3+
67
+ if op.decimal_input.respond_to?(:precision)
68
+ assert_equal expected_bd_value.precision, op.decimal_input.precision
69
+ end
70
+ end
71
+
45
72
  def test_string_inputs
46
73
  op.string_input = nil
47
74
  assert_nil op.string_input
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subroutine
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Nelson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-29 00:00:00.000000000 Z
11
+ date: 2023-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -163,12 +163,16 @@ files:
163
163
  - ".gitignore"
164
164
  - ".ruby-gemset"
165
165
  - ".ruby-version"
166
+ - Appraisals
166
167
  - CHANGELOG.MD
167
168
  - Gemfile
168
169
  - LICENSE.txt
169
170
  - README.md
170
171
  - Rakefile
171
- - gemfiles/am61.gemfile
172
+ - gemfiles/rails_6.1.gemfile
173
+ - gemfiles/rails_6.1.gemfile.lock
174
+ - gemfiles/rails_7.0.gemfile
175
+ - gemfiles/rails_7.0.gemfile.lock
172
176
  - lib/subroutine.rb
173
177
  - lib/subroutine/association_fields.rb
174
178
  - lib/subroutine/association_fields/association_type_mismatch_error.rb
@@ -202,7 +206,7 @@ homepage: https://github.com/mnelson/subroutine
202
206
  licenses:
203
207
  - MIT
204
208
  metadata: {}
205
- post_install_message:
209
+ post_install_message:
206
210
  rdoc_options: []
207
211
  require_paths:
208
212
  - lib
@@ -218,11 +222,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
222
  version: '0'
219
223
  requirements: []
220
224
  rubygems_version: 3.4.10
221
- signing_key:
225
+ signing_key:
222
226
  specification_version: 4
223
227
  summary: Feature-driven operation objects.
224
228
  test_files:
225
- - gemfiles/am61.gemfile
229
+ - gemfiles/rails_6.1.gemfile
230
+ - gemfiles/rails_6.1.gemfile.lock
231
+ - gemfiles/rails_7.0.gemfile
232
+ - gemfiles/rails_7.0.gemfile.lock
226
233
  - test/subroutine/association_test.rb
227
234
  - test/subroutine/auth_test.rb
228
235
  - test/subroutine/base_test.rb
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'activemodel', '~> 6.1.0'
4
- gem 'actionpack', '~> 6.1.0'