vector_embed 0.3.2 → 0.3.3
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.
- data/CHANGELOG +10 -0
- data/lib/vector_embed/maker/date.rb +9 -1
- data/lib/vector_embed/version.rb +1 -1
- data/spec/vector_embed_spec.rb +6 -1
- metadata +1 -1
data/CHANGELOG
CHANGED
@@ -6,15 +6,23 @@ class VectorEmbed
|
|
6
6
|
class Date < Maker
|
7
7
|
class << self
|
8
8
|
def want?(v, parent)
|
9
|
-
v
|
9
|
+
case v
|
10
|
+
when ::Date
|
11
|
+
true
|
12
|
+
when ::String
|
13
|
+
v =~ ISO_8601_DATE
|
14
|
+
end
|
10
15
|
end
|
11
16
|
end
|
12
17
|
|
13
18
|
BASE = ::Date.new(2000,1,1)
|
19
|
+
ISO_8601_DATE = /\A\d\d\d\d-\d\d-\d\d\z/
|
14
20
|
BLANK = /\A\s*\z/
|
15
21
|
|
16
22
|
def value(v)
|
17
23
|
date = case v
|
24
|
+
when ::NilClass
|
25
|
+
nil
|
18
26
|
when ::String
|
19
27
|
if v !~ BLANK
|
20
28
|
::Date.parse v
|
data/lib/vector_embed/version.rb
CHANGED
data/spec/vector_embed_spec.rb
CHANGED
@@ -137,13 +137,18 @@ describe VectorEmbed do
|
|
137
137
|
end
|
138
138
|
|
139
139
|
it "can parse some dates" do
|
140
|
-
v = VectorEmbed.new
|
140
|
+
v = VectorEmbed.new
|
141
141
|
v.line(1, 3 => '1999-12-31').should == "1 #{l_h('3')}:-1"
|
142
142
|
v.line(1, 3 => '2000-1-1').should == "1"
|
143
143
|
v.line(1, 3 => '2000-1-2').should == "1 #{l_h('3')}:1"
|
144
144
|
v.line(1, 3 => '2000-1-3').should == "1 #{l_h('3')}:2"
|
145
145
|
end
|
146
146
|
|
147
|
+
it "doesn't die on nil dates" do
|
148
|
+
v = VectorEmbed.new(features: { 3 => :Date})
|
149
|
+
v.line(1, 3 => nil).should == "1"
|
150
|
+
end
|
151
|
+
|
147
152
|
it "does not output 0 in number attributes" do
|
148
153
|
v = VectorEmbed.new
|
149
154
|
v.line(3, 1 => 1)
|