rasti-form 2.1.0 → 2.2.0

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
  SHA1:
3
- metadata.gz: 7c78c5baf69510d591b5724297c49840c1a17f59
4
- data.tar.gz: 3eff085937071179d8164e209447a04930c2c810
3
+ metadata.gz: c52204d2ee5fd0dec69e737cb54dcaadc0e1aefa
4
+ data.tar.gz: '08a1332b2f45c622de662393a551cda4797f1ce8'
5
5
  SHA512:
6
- metadata.gz: f58b495ff6f77d2ed52c8e2932642d2353a32f73ec602882f86b66f2f5a267b93384617e8bee60687000bcf9cc7ea92c39505a0a60759dbb9a3d3ea727f25c5b
7
- data.tar.gz: dd7375a659151115d589666e5211e766cbc0cffd8dfe7dab8505409fa72a7361efe172945f567c2275cab35275e8a90756b444fd267e624d0a44edcf62b9558e
6
+ metadata.gz: d83646128669902f9d7bbfd367ac7b92f9a683258687675b15725f8fab3b0c6778f6fb1553f8c5b7149f419d9b2768f6a3004471ecb28b4b1463086bd6371af8
7
+ data.tar.gz: 3600ad2b86770649044ce09d55025d6d1b51dda7e772f016c7bd7f134a634100b6e0d7bce45a3028071b51cf3762685109bfe6820cfc91e9aeb19a48c0f47fcc
@@ -0,0 +1,23 @@
1
+ module Rasti
2
+ class Form
3
+ module Types
4
+ class IO
5
+ class << self
6
+
7
+ include Castable
8
+
9
+ private
10
+
11
+ def valid?(value)
12
+ value.respond_to?(:read) && value.respond_to?(:write)
13
+ end
14
+
15
+ def transform(value)
16
+ value
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  module Rasti
2
2
  class Form
3
- VERSION = '2.1.0'
3
+ VERSION = '2.2.0'
4
4
  end
5
5
  end
data/spec/form_spec.rb CHANGED
@@ -195,16 +195,19 @@ describe Rasti::Form do
195
195
 
196
196
  it 'Time range' do
197
197
  form = build_form do
198
- attribute :from, Rasti::Form::Types::Time['%Y-%m-%d %H:%M:%S%Z']
199
- attribute :to, Rasti::Form::Types::Time['%Y-%m-%d %H:%M:%S%Z']
198
+ attribute :from, Rasti::Form::Types::Time['%Y-%m-%d %H:%M:%S %Z']
199
+ attribute :to, Rasti::Form::Types::Time['%Y-%m-%d %H:%M:%S %Z']
200
200
 
201
201
  def validate
202
202
  assert_time_range :from, :to
203
203
  end
204
204
  end
205
205
 
206
- error = proc { form.new from: '2018-01-01 15:30:00-0600', to: '2018-01-01 03:10:00-0600' }.must_raise Rasti::Form::ValidationError
207
- error.message.must_equal 'Validation error: #<Rasti::Form[from: 2018-01-01 15:30:00 -0600, to: 2018-01-01 03:10:00 -0600]> {"from":["invalid time range"]}'
206
+ from = '2018-01-01 15:30:00 +0000'
207
+ to = '2018-01-01 03:10:00 +0000'
208
+
209
+ error = proc { form.new from: from, to: to }.must_raise Rasti::Form::ValidationError
210
+ error.message.must_equal "Validation error: #<Rasti::Form[from: #{from}, to: #{to}]> {\"from\":[\"invalid time range\"]}"
208
211
  end
209
212
 
210
213
  it 'Nested form' do
@@ -0,0 +1,18 @@
1
+ require 'minitest_helper'
2
+
3
+ describe Rasti::Form::Types::IO do
4
+
5
+ [StringIO.new, File.new(__FILE__)].each do |value|
6
+ it "#{value.inspect} -> #{value}" do
7
+ Rasti::Form::Types::IO.cast(value).must_equal value
8
+ end
9
+ end
10
+
11
+ [nil, 'text', 123, :symbol, [1,2], {a: 1, b: 2}, Object.new].each do |value|
12
+ it "#{value.inspect} -> CastError" do
13
+ error = proc { Rasti::Form::Types::IO.cast(value) }.must_raise Rasti::Form::CastError
14
+ error.message.must_equal "Invalid cast: #{as_string(value)} -> Rasti::Form::Types::IO"
15
+ end
16
+ end
17
+
18
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rasti-form
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-22 00:00:00.000000000 Z
11
+ date: 2018-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_require
@@ -170,6 +170,7 @@ files:
170
170
  - lib/rasti/form/types/form.rb
171
171
  - lib/rasti/form/types/hash.rb
172
172
  - lib/rasti/form/types/integer.rb
173
+ - lib/rasti/form/types/io.rb
173
174
  - lib/rasti/form/types/regexp.rb
174
175
  - lib/rasti/form/types/string.rb
175
176
  - lib/rasti/form/types/symbol.rb
@@ -188,6 +189,7 @@ files:
188
189
  - spec/types/form_spec.rb
189
190
  - spec/types/hash_spec.rb
190
191
  - spec/types/integer_spec.rb
192
+ - spec/types/io_spec.rb
191
193
  - spec/types/regexp_spec.rb
192
194
  - spec/types/string_spec.rb
193
195
  - spec/types/symbol_spec.rb
@@ -228,6 +230,7 @@ test_files:
228
230
  - spec/types/form_spec.rb
229
231
  - spec/types/hash_spec.rb
230
232
  - spec/types/integer_spec.rb
233
+ - spec/types/io_spec.rb
231
234
  - spec/types/regexp_spec.rb
232
235
  - spec/types/string_spec.rb
233
236
  - spec/types/symbol_spec.rb