command_model 2.0.0 → 2.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: 9e62322d3750507b2218d0e2662517d807c4207a5f225ee98ab9eda6d39a9206
4
- data.tar.gz: 5350099e5f9e77a68441faf7fab88fdcc736c36a0d1ac9dbd9d48ca75785cf14
3
+ metadata.gz: 894d328023ecf9f0a8935bfe2a198e2fa3d26a55d42b2a4c0178bfa390e9b4bf
4
+ data.tar.gz: c00d13c0db81fd1a1c9c49e3ff9fa473d62c0c8131ca449acf8f6dd695109a7d
5
5
  SHA512:
6
- metadata.gz: 2aede9435d4d3a0dc779101807f02def57e15764b352d2228a89aa91fc341c098fcf17919f85ec2a9e222a97535b0c9e2a540dc2a104de72262d3f875e1b65c0
7
- data.tar.gz: 7a01b95bf05e04b86c4735d21b1dae876e34dc4de3f1e6117c166dbeb46c191d7f05df10889791ad60be0355134edd2866598c02d80962984afdeab8891056b9
6
+ metadata.gz: 016761f5657fd6b00664d0d8e3730d83055506314fa4a49a02194eaa6e7e7f680d8ae234590616a148c31ccc7ab5dfd613b63385121c8e10dafc96adc426cd9b
7
+ data.tar.gz: fc0b8d08827f71c8882697eeb2918f9bde7364aecd7f4796e9125727b73ceb0113022427ff76ed1ce96804c624780cc80be23823587828bcf549b6a0cc852d6b
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.1
data/README.md CHANGED
@@ -130,6 +130,8 @@ integration of Rails form helpers and validations with CommandModel.
130
130
 
131
131
  ## Version History
132
132
 
133
+ * 2.0.1 - April 3, 2023
134
+ * Date parsing allows 5 digit years
133
135
  * 2.0 - April 11, 2018
134
136
  * Rename typecast parameter option to convert
135
137
  * Any callable object can be used as a type converter
@@ -61,7 +61,7 @@ module CommandModel
61
61
  return nil if value.blank?
62
62
  return value if value.kind_of? Date
63
63
  value = value.to_s
64
- if value =~ /\A(\d\d\d\d)-(\d\d)-(\d\d)\z/
64
+ if value =~ /\A(\d{4,5})-(\d\d)-(\d\d)\z/
65
65
  ::Date.civil($1.to_i, $2.to_i, $3.to_i)
66
66
  else
67
67
  ::Date.strptime(value, "%m/%d/%Y")
@@ -1,12 +1,4 @@
1
1
  module CommandModel
2
- class TypecastError < StandardError
3
- attr_reader :original_error
4
-
5
- def initialize(original_error)
6
- @original_error = original_error
7
- end
8
- end
9
-
10
2
  class Model
11
3
  include ActiveModel::Validations
12
4
  include ActiveModel::Conversion
@@ -1,3 +1,3 @@
1
1
  module CommandModel
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
data/spec/convert_spec.rb CHANGED
@@ -30,7 +30,7 @@ describe "CommandModel::Convert" do
30
30
  expect(subject.("")).to eq(nil)
31
31
  end
32
32
 
33
- it "raises TypecastError when invalid string" do
33
+ it "raises ConvertError when invalid string" do
34
34
  expect { subject.("asdf") }.to raise_error(CommandModel::Convert::ConvertError)
35
35
  expect { subject.("0.1") }.to raise_error(CommandModel::Convert::ConvertError)
36
36
  end
@@ -52,7 +52,7 @@ describe "CommandModel::Convert" do
52
52
  expect(subject.("")).to eq(nil)
53
53
  end
54
54
 
55
- it "raises TypecastError when invalid string" do
55
+ it "raises ConvertError when invalid string" do
56
56
  expect { subject.("asdf") }.to raise_error(CommandModel::Convert::ConvertError)
57
57
  end
58
58
  end
@@ -81,7 +81,7 @@ describe "CommandModel::Convert" do
81
81
  expect(subject.("")).to eq(nil)
82
82
  end
83
83
 
84
- it "raises TypecastError when invalid string" do
84
+ it "raises ConvertError when invalid string" do
85
85
  expect { subject.("asdf") }.to raise_error(CommandModel::Convert::ConvertError)
86
86
  end
87
87
  end
@@ -93,6 +93,7 @@ describe "CommandModel::Convert" do
93
93
  expect(subject.("01/01/2000")).to eq(Date.civil(2000,1,1))
94
94
  expect(subject.("1/1/2000")).to eq(Date.civil(2000,1,1))
95
95
  expect(subject.("2000-01-01")).to eq(Date.civil(2000,1,1))
96
+ expect(subject.("29000-01-01")).to eq(Date.civil(29000,1,1))
96
97
  end
97
98
 
98
99
  it "returns existing date unchanged" do
@@ -108,7 +109,7 @@ describe "CommandModel::Convert" do
108
109
  expect(subject.("")).to eq(nil)
109
110
  end
110
111
 
111
- it "raises TypecastError when invalid string" do
112
+ it "raises ConvertError when invalid string" do
112
113
  expect { subject.("asdf") }.to raise_error(CommandModel::Convert::ConvertError)
113
114
  expect { subject.("3/50/1290") }.to raise_error(CommandModel::Convert::ConvertError)
114
115
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: command_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Christensen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-11 00:00:00.000000000 Z
11
+ date: 2023-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -61,6 +61,7 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
63
  - ".rspec"
64
+ - ".ruby-version"
64
65
  - ".travis.yml"
65
66
  - Gemfile
66
67
  - LICENSE
@@ -139,7 +140,7 @@ files:
139
140
  homepage: https://github.com/JackC/command_model
140
141
  licenses: []
141
142
  metadata: {}
142
- post_install_message:
143
+ post_install_message:
143
144
  rdoc_options: []
144
145
  require_paths:
145
146
  - lib
@@ -154,9 +155,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
155
  - !ruby/object:Gem::Version
155
156
  version: '0'
156
157
  requirements: []
157
- rubyforge_project:
158
- rubygems_version: 2.7.6
159
- signing_key:
158
+ rubygems_version: 3.4.1
159
+ signing_key:
160
160
  specification_version: 4
161
161
  summary: CommandModel integrates Rails validations with command objects. This allows
162
162
  errors from command execution to easily be handled with the familiar Rails validation