quack 0.0.3 → 0.0.4

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: 7976e9ab3f6b3eecf61c0031b31b6e229ca51c92
4
- data.tar.gz: 765329e2415c5f5f9e056a4388902a39e9d9f272
3
+ metadata.gz: 8ee4849d86659335653fbe4eb06e02d97654d47f
4
+ data.tar.gz: 67448125e2da4a406be4b3ed5c36fadc2bed47c0
5
5
  SHA512:
6
- metadata.gz: 9574ad80bcfe7280c8de4d8b19bd800923d8125ab8ae0b729eebe646f52ff6b009afcfea38600b2239c5d5154535db381aaf9e7c4271bbde1efe6226689bb31e
7
- data.tar.gz: bb8c55b77390c153327560d4820cb2da76771ee4f773645108d718b39cf692113a5575a59bf932d7559192913086ac540d49eadfcbf75da09c196de1c7bc728b
6
+ metadata.gz: 994dbd358a991a928b954e344e7fceae325cea045000b646ae964f5462f40b1e55dcd412cab1203b250278563221a42b719a2e724cdb9c1a468e9287aac8966c
7
+ data.tar.gz: ec571bf7da63cc2e8a83f104ab1aaafccee4263e5749fecdf792f42f1bb0831400b569a4e010bb730d09ebb03cd40ad4e74bb7a827ccd3d772c73ac8ff857688
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # CHANGELOG
2
+
3
+ ## 0.0.4
4
+
5
+ Breaking change: Times are now only coereced if there is no surrounding text.
6
+
7
+ I.e. "It was 04-05-2016" is now considered a String rather than a Time
8
+
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Derrick Reimer
1
+ Copyright (c) 2014-2016 Derrick Reimer
2
2
 
3
3
  MIT License
4
4
 
@@ -4,13 +4,13 @@ require "quack/type"
4
4
  module Quack
5
5
  module Types
6
6
  class Time < Quack::Type
7
- YMD_FORMAT = /
7
+ YMD_FORMAT = /\A
8
8
  (?<year>\d{4})(-|\/)
9
9
  (?<month>\d{2})(-|\/)
10
10
  (?<day>\d{2})
11
- /x
11
+ \z/x
12
12
 
13
- ISO_8601 = /
13
+ ISO_8601 = /\A
14
14
  (?<year>\d{4})-
15
15
  (?<month>\d{2})-
16
16
  (?<day>\d{2})T
@@ -18,7 +18,7 @@ module Quack
18
18
  (?<minute>\d{2}):
19
19
  (?<second>\d{2})
20
20
  (?<offset>Z|(\+|-)(\d{2}):(\d{2}))
21
- /x
21
+ \z/x
22
22
 
23
23
  UTC = "+00:00"
24
24
 
@@ -28,11 +28,11 @@ module Quack
28
28
  end
29
29
 
30
30
  def iso_8601?(value)
31
- !!(value.to_s =~ ISO_8601)
31
+ !!(value.to_s.strip =~ ISO_8601)
32
32
  end
33
33
 
34
34
  def ymd?(value)
35
- !!(value.to_s =~ YMD_FORMAT)
35
+ !!(value.to_s.strip =~ YMD_FORMAT)
36
36
  end
37
37
 
38
38
  def matches?(value)
data/lib/quack/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Quack
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -4,7 +4,7 @@ describe Quack::Guesser do
4
4
  describe "given a string integer" do
5
5
  let(:value) { "123" }
6
6
  let(:subject) { Quack::Guesser.new(value) }
7
-
7
+
8
8
  it "should have Integer type" do
9
9
  subject.guess.class.must_equal(Quack::Types::Integer)
10
10
  end
@@ -82,6 +82,33 @@ describe Quack::Guesser do
82
82
  end
83
83
  end
84
84
 
85
+ describe "given a padded ISO 8061 UTC date" do
86
+ let(:value) { " 2014-03-22T03:00:00Z " }
87
+ let(:subject) { Quack::Guesser.new(value) }
88
+
89
+ it "should have Time type" do
90
+ subject.guess.class.must_equal(Quack::Types::Time)
91
+ end
92
+ end
93
+
94
+ describe "given an embedded ISO 8061 UTC date" do
95
+ let(:value) { "something awesome will happen 2014-03-22T03:00:00Z or thereabouts" }
96
+ let(:subject) { Quack::Guesser.new(value) }
97
+
98
+ it "should have String type" do
99
+ subject.guess.class.must_equal(Quack::Types::String)
100
+ end
101
+ end
102
+
103
+ describe "given an embedded simple date" do
104
+ let(:value) { "something awesome will happen 2014-03-22 or thereabouts" }
105
+ let(:subject) { Quack::Guesser.new(value) }
106
+
107
+ it "should have String type" do
108
+ subject.guess.class.must_equal(Quack::Types::String)
109
+ end
110
+ end
111
+
85
112
  describe "given an ISO 8061 non-UTC date" do
86
113
  let(:value) { "2014-03-22T03:00:00-07:00" }
87
114
  let(:subject) { Quack::Guesser.new(value) }
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derrick Reimer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-28 00:00:00.000000000 Z
11
+ date: 2017-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: A simple type coercion library
@@ -45,7 +45,8 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .gitignore
48
+ - ".gitignore"
49
+ - CHANGELOG.md
49
50
  - Gemfile
50
51
  - LICENSE.txt
51
52
  - README.md
@@ -81,17 +82,17 @@ require_paths:
81
82
  - lib
82
83
  required_ruby_version: !ruby/object:Gem::Requirement
83
84
  requirements:
84
- - - '>='
85
+ - - ">="
85
86
  - !ruby/object:Gem::Version
86
87
  version: '0'
87
88
  required_rubygems_version: !ruby/object:Gem::Requirement
88
89
  requirements:
89
- - - '>='
90
+ - - ">="
90
91
  - !ruby/object:Gem::Version
91
92
  version: '0'
92
93
  requirements: []
93
94
  rubyforge_project:
94
- rubygems_version: 2.0.3
95
+ rubygems_version: 2.5.1
95
96
  signing_key:
96
97
  specification_version: 4
97
98
  summary: Quack is a simple type coercion library for scalar Ruby objects