quack 1.0.0 → 1.1.0
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 +4 -4
- data/CHANGELOG.md +4 -1
- data/lib/quack/types/float.rb +2 -2
- data/lib/quack/types/integer.rb +2 -2
- data/lib/quack/version.rb +1 -1
- data/spec/quack/guesser_spec.rb +29 -29
- data/spec/quack/types/float_spec.rb +17 -1
- data/spec/quack/types/integer_spec.rb +17 -1
- data/spec/quack/types/null_spec.rb +2 -2
- data/spec/quack/types/time_spec.rb +6 -1
- data/spec/quack_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a304d056868937d1ee1826e161f6c98f0a3689b
|
4
|
+
data.tar.gz: 4b3d887a9fd30f017e476d3255d304bc68b65787
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 985c6eb97f59ade57f907f62bb34db075496e4d9ada71d228727a7d5b90c77b7379da7a837e961466689fa6bd457fed7d3a2916d7fbbf647630ba0dd77f9e3a2
|
7
|
+
data.tar.gz: 46c3e096e6196e130b8d2287ca5fa9efee3f1bec692a86619de0657fdd2e5acb2ea94e315479ce402b5a1c7f7a0fe488a72e3dd9624c6b9fdaaf2919a7b8af69
|
data/CHANGELOG.md
CHANGED
data/lib/quack/types/float.rb
CHANGED
data/lib/quack/types/integer.rb
CHANGED
data/lib/quack/version.rb
CHANGED
data/spec/quack/guesser_spec.rb
CHANGED
@@ -2,8 +2,8 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
describe Quack::Guesser do
|
4
4
|
describe "given a string integer" do
|
5
|
-
let(:
|
6
|
-
let(:subject) { Quack::Guesser.new(
|
5
|
+
let(:raw_value) { "123" }
|
6
|
+
let(:subject) { Quack::Guesser.new(raw_value) }
|
7
7
|
|
8
8
|
it "should have Integer type" do
|
9
9
|
subject.guess.class.must_equal(Quack::Types::Integer)
|
@@ -11,8 +11,8 @@ describe Quack::Guesser do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "given a Fixnum integer" do
|
14
|
-
let(:
|
15
|
-
let(:subject) { Quack::Guesser.new(
|
14
|
+
let(:raw_value) { 123 }
|
15
|
+
let(:subject) { Quack::Guesser.new(raw_value) }
|
16
16
|
|
17
17
|
it "should have Integer type" do
|
18
18
|
subject.guess.class.must_equal(Quack::Types::Integer)
|
@@ -20,8 +20,8 @@ describe Quack::Guesser do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "given a string float" do
|
23
|
-
let(:
|
24
|
-
let(:subject) { Quack::Guesser.new(
|
23
|
+
let(:raw_value) { "123.4" }
|
24
|
+
let(:subject) { Quack::Guesser.new(raw_value) }
|
25
25
|
|
26
26
|
it "should have Float type" do
|
27
27
|
subject.guess.class.must_equal(Quack::Types::Float)
|
@@ -29,8 +29,8 @@ describe Quack::Guesser do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
describe "given a Float" do
|
32
|
-
let(:
|
33
|
-
let(:subject) { Quack::Guesser.new(
|
32
|
+
let(:raw_value) { 123.4 }
|
33
|
+
let(:subject) { Quack::Guesser.new(raw_value) }
|
34
34
|
|
35
35
|
it "should have Float type" do
|
36
36
|
subject.guess.class.must_equal(Quack::Types::Float)
|
@@ -38,8 +38,8 @@ describe Quack::Guesser do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
describe "given a 'true' string" do
|
41
|
-
let(:
|
42
|
-
let(:subject) { Quack::Guesser.new(
|
41
|
+
let(:raw_value) { "true" }
|
42
|
+
let(:subject) { Quack::Guesser.new(raw_value) }
|
43
43
|
|
44
44
|
it "should have Boolean type" do
|
45
45
|
subject.guess.class.must_equal(Quack::Types::Boolean)
|
@@ -47,8 +47,8 @@ describe Quack::Guesser do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
describe "given a 'false' string" do
|
50
|
-
let(:
|
51
|
-
let(:subject) { Quack::Guesser.new(
|
50
|
+
let(:raw_value) { "false" }
|
51
|
+
let(:subject) { Quack::Guesser.new(raw_value) }
|
52
52
|
|
53
53
|
it "should have Boolean type" do
|
54
54
|
subject.guess.class.must_equal(Quack::Types::Boolean)
|
@@ -56,8 +56,8 @@ describe Quack::Guesser do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
describe "given true" do
|
59
|
-
let(:
|
60
|
-
let(:subject) { Quack::Guesser.new(
|
59
|
+
let(:raw_value) { true }
|
60
|
+
let(:subject) { Quack::Guesser.new(raw_value) }
|
61
61
|
|
62
62
|
it "should have Boolean type" do
|
63
63
|
subject.guess.class.must_equal(Quack::Types::Boolean)
|
@@ -65,8 +65,8 @@ describe Quack::Guesser do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
describe "given false" do
|
68
|
-
let(:
|
69
|
-
let(:subject) { Quack::Guesser.new(
|
68
|
+
let(:raw_value) { false }
|
69
|
+
let(:subject) { Quack::Guesser.new(raw_value) }
|
70
70
|
|
71
71
|
it "should have Boolean type" do
|
72
72
|
subject.guess.class.must_equal(Quack::Types::Boolean)
|
@@ -74,8 +74,8 @@ describe Quack::Guesser do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
describe "given an ISO 8061 UTC date" do
|
77
|
-
let(:
|
78
|
-
let(:subject) { Quack::Guesser.new(
|
77
|
+
let(:raw_value) { "2014-03-22T03:00:00Z" }
|
78
|
+
let(:subject) { Quack::Guesser.new(raw_value) }
|
79
79
|
|
80
80
|
it "should have Time type" do
|
81
81
|
subject.guess.class.must_equal(Quack::Types::Time)
|
@@ -83,8 +83,8 @@ describe Quack::Guesser do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
describe "given a padded ISO 8061 UTC date" do
|
86
|
-
let(:
|
87
|
-
let(:subject) { Quack::Guesser.new(
|
86
|
+
let(:raw_value) { " 2014-03-22T03:00:00Z " }
|
87
|
+
let(:subject) { Quack::Guesser.new(raw_value) }
|
88
88
|
|
89
89
|
it "should have Time type" do
|
90
90
|
subject.guess.class.must_equal(Quack::Types::Time)
|
@@ -92,8 +92,8 @@ describe Quack::Guesser do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
describe "given an embedded ISO 8061 UTC date" do
|
95
|
-
let(:
|
96
|
-
let(:subject) { Quack::Guesser.new(
|
95
|
+
let(:raw_value) { "something awesome will happen 2014-03-22T03:00:00Z or thereabouts" }
|
96
|
+
let(:subject) { Quack::Guesser.new(raw_value) }
|
97
97
|
|
98
98
|
it "should have String type" do
|
99
99
|
subject.guess.class.must_equal(Quack::Types::String)
|
@@ -101,8 +101,8 @@ describe Quack::Guesser do
|
|
101
101
|
end
|
102
102
|
|
103
103
|
describe "given an embedded simple date" do
|
104
|
-
let(:
|
105
|
-
let(:subject) { Quack::Guesser.new(
|
104
|
+
let(:raw_value) { "something awesome will happen 2014-03-22 or thereabouts" }
|
105
|
+
let(:subject) { Quack::Guesser.new(raw_value) }
|
106
106
|
|
107
107
|
it "should have String type" do
|
108
108
|
subject.guess.class.must_equal(Quack::Types::String)
|
@@ -110,8 +110,8 @@ describe Quack::Guesser do
|
|
110
110
|
end
|
111
111
|
|
112
112
|
describe "given an ISO 8061 non-UTC date" do
|
113
|
-
let(:
|
114
|
-
let(:subject) { Quack::Guesser.new(
|
113
|
+
let(:raw_value) { "2014-03-22T03:00:00-07:00" }
|
114
|
+
let(:subject) { Quack::Guesser.new(raw_value) }
|
115
115
|
|
116
116
|
it "should have Time type" do
|
117
117
|
subject.guess.class.must_equal(Quack::Types::Time)
|
@@ -119,11 +119,11 @@ describe Quack::Guesser do
|
|
119
119
|
end
|
120
120
|
|
121
121
|
describe "given an random string" do
|
122
|
-
let(:
|
123
|
-
let(:subject) { Quack::Guesser.new(
|
122
|
+
let(:raw_value) { "foo123" }
|
123
|
+
let(:subject) { Quack::Guesser.new(raw_value) }
|
124
124
|
|
125
125
|
it "should have String type" do
|
126
126
|
subject.guess.class.must_equal(Quack::Types::String)
|
127
127
|
end
|
128
128
|
end
|
129
|
-
end
|
129
|
+
end
|
@@ -10,6 +10,14 @@ describe Quack::Types::Float do
|
|
10
10
|
Quack::Types::Float.matches?(123.4).must_equal(true)
|
11
11
|
end
|
12
12
|
|
13
|
+
it "should be true for negative float strings" do
|
14
|
+
Quack::Types::Float.matches?("-123.4").must_equal(true)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be true for negative floats" do
|
18
|
+
Quack::Types::Float.matches?(-123.4).must_equal(true)
|
19
|
+
end
|
20
|
+
|
13
21
|
it "should be false for integer strings" do
|
14
22
|
Quack::Types::Float.matches?("123").must_equal(false)
|
15
23
|
end
|
@@ -17,6 +25,14 @@ describe Quack::Types::Float do
|
|
17
25
|
it "should be false for integers" do
|
18
26
|
Quack::Types::Float.matches?(123).must_equal(false)
|
19
27
|
end
|
28
|
+
|
29
|
+
it "should be false for negative integer strings" do
|
30
|
+
Quack::Types::Float.matches?("-123").must_equal(false)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should be false for negative integers" do
|
34
|
+
Quack::Types::Float.matches?(-123).must_equal(false)
|
35
|
+
end
|
20
36
|
end
|
21
37
|
|
22
38
|
describe "#to_coerced" do
|
@@ -31,4 +47,4 @@ describe Quack::Types::Float do
|
|
31
47
|
type.to_coerced.class.must_equal(Float)
|
32
48
|
end
|
33
49
|
end
|
34
|
-
end
|
50
|
+
end
|
@@ -10,6 +10,14 @@ describe Quack::Types::Integer do
|
|
10
10
|
Quack::Types::Integer.matches?(123).must_equal(true)
|
11
11
|
end
|
12
12
|
|
13
|
+
it "should be true for negative integer stings" do
|
14
|
+
Quack::Types::Integer.matches?("-123").must_equal(true)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be true for negative Integers" do
|
18
|
+
Quack::Types::Integer.matches?(-123).must_equal(true)
|
19
|
+
end
|
20
|
+
|
13
21
|
it "should be true for large Integer" do
|
14
22
|
num = 232305722798259244150093798251441
|
15
23
|
Quack::Types::Integer.matches?(num).must_equal(true)
|
@@ -22,6 +30,14 @@ describe Quack::Types::Integer do
|
|
22
30
|
it "should be false for floats" do
|
23
31
|
Quack::Types::Integer.matches?(123.4).must_equal(false)
|
24
32
|
end
|
33
|
+
|
34
|
+
it "should be false for negative float strings" do
|
35
|
+
Quack::Types::Integer.matches?("-123.4").must_equal(false)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should be false for negative floats" do
|
39
|
+
Quack::Types::Integer.matches?(-123.4).must_equal(false)
|
40
|
+
end
|
25
41
|
end
|
26
42
|
|
27
43
|
describe "#to_coerced" do
|
@@ -42,4 +58,4 @@ describe Quack::Types::Integer do
|
|
42
58
|
type.to_coerced.class.must_equal(1.class)
|
43
59
|
end
|
44
60
|
end
|
45
|
-
end
|
61
|
+
end
|
@@ -46,6 +46,11 @@ describe Quack::Types::Time do
|
|
46
46
|
type.to_coerced.must_equal(expected)
|
47
47
|
end
|
48
48
|
|
49
|
+
it "should raise a ParseError for dates out of range" do
|
50
|
+
type = Quack::Types::Time.new("0000-00-00")
|
51
|
+
proc { type.to_coerced }.must_raise(Quack::ParseError)
|
52
|
+
end
|
53
|
+
|
49
54
|
it "should raise a ParseError for invalid dates" do
|
50
55
|
type = Quack::Types::Time.new("foo")
|
51
56
|
proc { type.to_coerced }.must_raise(Quack::ParseError)
|
@@ -65,4 +70,4 @@ describe Quack::Types::Time do
|
|
65
70
|
type.to_s.must_equal("2014-03-22T03:10:12-07:00")
|
66
71
|
end
|
67
72
|
end
|
68
|
-
end
|
73
|
+
end
|
data/spec/quack_spec.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
describe Quack do
|
4
|
-
let(:
|
4
|
+
let(:raw_value) { "123" }
|
5
5
|
it "should proxy to the guesser" do
|
6
|
-
type = Quack(
|
6
|
+
type = Quack(raw_value)
|
7
7
|
type.class.must_equal(Quack::Types::Integer)
|
8
8
|
type.to_coerced.must_equal(123)
|
9
9
|
end
|
10
|
-
end
|
10
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derrick Reimer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|