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 CHANGED
@@ -1,3 +1,13 @@
1
+ 0.3.3 / 2013-06-14
2
+
3
+ * Enhancement
4
+
5
+ * Auto-detect YYYY-MM-DD dates
6
+
7
+ * Bug fixes
8
+
9
+ * Don't die on nil date
10
+
1
11
  0.3.2 / 2013-06-14
2
12
 
3
13
  * Enhancements
@@ -6,15 +6,23 @@ class VectorEmbed
6
6
  class Date < Maker
7
7
  class << self
8
8
  def want?(v, parent)
9
- v.is_a?(::Date)
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
@@ -1,3 +1,3 @@
1
1
  class VectorEmbed
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
@@ -137,13 +137,18 @@ describe VectorEmbed do
137
137
  end
138
138
 
139
139
  it "can parse some dates" do
140
- v = VectorEmbed.new(features: { 3 => :Date})
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vector_embed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: