vector_embed 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWJmNzczYzU1MjZlODE4NzcxZGMxZTc0MTgzNjdkNjFjYzc5MjRjNA==
4
+ ZjYyYTk3OTE0NmEwYzMwMGE3ZDk5YTZmODA5NmUzOGM1YTlkMDAwNA==
5
5
  data.tar.gz: !binary |-
6
- NDNhZmQwZDNjOWMwNWJlOGM3NTBiOTVmNjIwZGJjM2EzYjdlZWZiMA==
6
+ OGJjODkwMTM3NWY5NWE3ZTUyNzQ2YjQxOTgwODVkNWVlMjc0NTVkZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MDc4NjE0YWQ4ZmYzZWZmNTdhOTM3ZTkxODI0Y2RjNjU4YTAxMjMzMjdlZWQx
10
- OTUzMDY4NGE4YjFkOWY1OWJiNTVjNWJmYTFkN2I1ZDdhZTY1OWQ0YzRkYjE3
11
- MDkxZWYzYmQ2NDMyOTIxMzEyZDBkNGMwMjdkNDY1Yzc2YTMyNzk=
9
+ ZTgxMWNkODk4NjYyMTU3Mzk0YTM1YWMxMjU4YzJkODU2MWIzNTllYjdhYmZk
10
+ ZjYyN2Q5ZTExMDAxYTVhMzZkODRlMmFmMzljOGY2YjkyMzhmNmViMTJkNWM1
11
+ ZmEzNTk3Y2QzZGMwOGNjNjFjY2RmMjFkNjEyOTVhMjEyOWJjNGI=
12
12
  data.tar.gz: !binary |-
13
- ZmI5MzkzYWRmNzY2NjA0ZjBhY2NmNWIzMWMxZmM3OTU3MTVlY2Q5ZTg0YzJi
14
- NzUyZDI3MjgzNmJhNDFiYTY0YjRlOTNlNzE4NjYyYjZlMTI5ZDFhMGZhMmY2
15
- ZmYyZmU5Nzc1NzBmYjhkMmFmMDkxYzdkZjM0NTY2OTZmY2U0ODU=
13
+ ODI3MjU1YTBlMTc5NGZkNTliY2RkNDcwZmMyNGI2YTIyNmI4MTA4NDNmMGI1
14
+ YTlhMjJlYmEzY2M0ZmI5NTYwZWNlY2UxYzM4YTc4OGY1MmUwZGZiZmU2ODIz
15
+ ZjA5ZGQ0YmM1MmZiNmE5NTRlZGQ4ZTE4OGZkODgyNWU2Yzc5OGM=
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 0.3.0 / 2013-05-14
2
+
3
+ * Breaking changes
4
+
5
+ * If a value is nil, assume it's a number field (not a boolean field as before). Just a better assumption.
6
+
1
7
  0.2.0 / 2013-05-14
2
8
 
3
9
  * Breaking changes
@@ -6,7 +6,7 @@ class VectorEmbed
6
6
  class << self
7
7
  def want?(v, parent)
8
8
  case v
9
- when NilClass, TrueClass, FalseClass, TRUE, FALSE, T, F, NULL, SLASH_N
9
+ when TrueClass, FalseClass, TRUE, FALSE, T, F
10
10
  true
11
11
  else
12
12
  false
@@ -5,7 +5,12 @@ class VectorEmbed
5
5
  class Number < Maker
6
6
  class << self
7
7
  def want?(v, parent)
8
- v.is_a?(::Numeric) or v =~ JUST_A_NUMBER
8
+ case v
9
+ when Numeric, NilClass, NULL, SLASH_N
10
+ true
11
+ else
12
+ v =~ JUST_A_NUMBER
13
+ end
9
14
  end
10
15
 
11
16
  def numify(v)
@@ -1,3 +1,3 @@
1
1
  class VectorEmbed
2
- VERSION = "0.2.0"
2
+ VERSION = '0.3.0'
3
3
  end
@@ -98,22 +98,24 @@ describe VectorEmbed do
98
98
  end
99
99
 
100
100
  describe 'feature values' do
101
- it "stores true/false/nil as (1,0,0)/(0,1,0)/(0,0,1)" do
102
- v = VectorEmbed.new
103
- v.line(1, 1 => true).should == "1 #{l_h("1\x00true")}:1"
104
- v.line(1, 1 => 'true').should == "1 #{l_h("1\x00true")}:1"
105
- v.line(1, 1 => 'TRUE').should == "1 #{l_h("1\x00true")}:1"
106
- v.line(1, 1 => 't').should == "1 #{l_h("1\x00true")}:1"
107
- v.line(1, 1 => 'T').should == "1 #{l_h("1\x00true")}:1"
108
- v.line(1, 1 => false).should == "1 #{l_h("1\x00false")}:1"
109
- v.line(1, 1 => 'false').should == "1 #{l_h("1\x00false")}:1"
110
- v.line(1, 1 => 'FALSE').should == "1 #{l_h("1\x00false")}:1"
111
- v.line(1, 1 => 'f').should == "1 #{l_h("1\x00false")}:1"
112
- v.line(1, 1 => 'F').should == "1 #{l_h("1\x00false")}:1"
113
- v.line(1, 1 => nil).should == "1 #{l_h("1\x00null")}:1"
114
- v.line(1, 1 => 'null').should == "1 #{l_h("1\x00null")}:1"
115
- v.line(1, 1 => 'NULL').should == "1 #{l_h("1\x00null")}:1"
116
- v.line(1, 1 => '\N').should == "1 #{l_h("1\x00null")}:1"
101
+ describe 'in boolean attributes' do
102
+ it "stores true/false/nil as (1,0,0)/(0,1,0)/(0,0,1)" do
103
+ v = VectorEmbed.new
104
+ v.line(1, 1 => true).should == "1 #{l_h("1\x00true")}:1"
105
+ v.line(1, 1 => 'true').should == "1 #{l_h("1\x00true")}:1"
106
+ v.line(1, 1 => 'TRUE').should == "1 #{l_h("1\x00true")}:1"
107
+ v.line(1, 1 => 't').should == "1 #{l_h("1\x00true")}:1"
108
+ v.line(1, 1 => 'T').should == "1 #{l_h("1\x00true")}:1"
109
+ v.line(1, 1 => false).should == "1 #{l_h("1\x00false")}:1"
110
+ v.line(1, 1 => 'false').should == "1 #{l_h("1\x00false")}:1"
111
+ v.line(1, 1 => 'FALSE').should == "1 #{l_h("1\x00false")}:1"
112
+ v.line(1, 1 => 'f').should == "1 #{l_h("1\x00false")}:1"
113
+ v.line(1, 1 => 'F').should == "1 #{l_h("1\x00false")}:1"
114
+ v.line(1, 1 => nil).should == "1 #{l_h("1\x00null")}:1"
115
+ v.line(1, 1 => 'null').should == "1 #{l_h("1\x00null")}:1"
116
+ v.line(1, 1 => 'NULL').should == "1 #{l_h("1\x00null")}:1"
117
+ v.line(1, 1 => '\N').should == "1 #{l_h("1\x00null")}:1"
118
+ end
117
119
  end
118
120
 
119
121
  it "stores numbers as numbers" do
@@ -135,10 +137,19 @@ describe VectorEmbed do
135
137
 
136
138
  it "treats nil like zero in number attributes" do
137
139
  v = VectorEmbed.new
138
- v.line(1, 1 => 1)
140
+ v.line(1, 1 => 1) # establish it's a number
139
141
  v.line(1, 1 => nil).should == v.line(1, 1 => 0)
140
142
  end
141
143
 
144
+ it "assumes nil value means a number field" do
145
+ v = VectorEmbed.new
146
+ v.line(3, 1 => nil) # don't establish it's a number
147
+ v.line(3, 1 => nil).should == v.line(3, 1 => 0)
148
+ v.line(3, 1 => 'null').should == v.line(3, 1 => 0)
149
+ v.line(3, 1 => 'NULL').should == v.line(3, 1 => 0)
150
+ v.line(3, 1 => '\N').should == v.line(3, 1 => 0)
151
+ end
152
+
142
153
  it "stores strings as m-category attributes" do
143
154
  v = VectorEmbed.new
144
155
  v.line(1, 1 => 'sfh').should == "1 #{l_h("1\x00sfh")}:1"
@@ -170,6 +181,17 @@ describe VectorEmbed do
170
181
  v.line(1, 'bar' => ['a','b','c']).should == sortme("1 #{l_h("bar\x001\x00b")}:1 #{l_h("bar\x000\x00a")}:1 #{l_h("bar\x002\x00c")}:1")
171
182
  end
172
183
 
184
+ it "stores arrays with proper indices even if some values are zero" do
185
+ v = VectorEmbed.new
186
+ v.line(1, 'foo' => [0,99]).should == sortme("1 #{l_h("foo\x001")}:99")
187
+ v.line(1, 'foo' => [45,0]).should == sortme("1 #{l_h("foo\x000")}:45")
188
+ v.line(1, 'foo' => [45,99]).should == sortme("1 #{l_h("foo\x000")}:45 #{l_h("foo\x001")}:99")
189
+ v = VectorEmbed.new
190
+ v.line(1, 'foo' => [45,0,99]).should == sortme("1 #{l_h("foo\x000")}:45 #{l_h("foo\x002")}:99")
191
+ v.line(1, 'foo' => [45,0]).should == sortme("1 #{l_h("foo\x000")}:45")
192
+ v.line(1, 'foo' => [45,33,99]).should == sortme("1 #{l_h("foo\x000")}:45 #{l_h("foo\x001")}:33 #{l_h("foo\x002")}:99")
193
+ end
194
+
173
195
  it "in number mode, treats null as 0" do
174
196
  v = VectorEmbed.new
175
197
  v.line(1, 1 => 9).should == "1 #{l_h('1')}:9"
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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seamus Abshere