surus 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +11 -0
- data/README.md +9 -2
- data/lib/surus/hstore/serializer.rb +3 -1
- data/lib/surus/version.rb +1 -1
- data/spec/hstore/serializer_spec.rb +3 -1
- metadata +12 -12
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# 0.3.0 (February 16, 2012)
|
2
|
+
|
3
|
+
* Can now round-trip any value YAML can dump and load as an hstore key or value
|
4
|
+
|
5
|
+
# 0.2.0 (February 4, 2012)
|
6
|
+
|
7
|
+
* Added symbol to types that are successfully round-tripped as hstore keys and values
|
8
|
+
* Added synchronous_commit support
|
9
|
+
* Added benchmarks
|
10
|
+
* Added rdoc documentation and expanded readme.
|
11
|
+
|
1
12
|
# 0.1.0 (February 2, 2012)
|
2
13
|
|
3
14
|
* Added array serializers
|
data/README.md
CHANGED
@@ -25,11 +25,18 @@ type that can be indexed for fast searching.
|
|
25
25
|
end
|
26
26
|
|
27
27
|
User.create :properties => { :favorite_color => "green", :results_per_page => 20 }
|
28
|
+
User.create :properties => { :favorite_colors => ["green", "blue", "red"] }
|
28
29
|
|
29
30
|
Even though the underlying hstore can only use strings for keys and values
|
30
31
|
(and NULL for values) Surus can successfully maintain type for integers,
|
31
|
-
floats, bigdecimals, and
|
32
|
-
value pair (or two) to maintain type information.
|
32
|
+
floats, bigdecimals, dates, and any value that YAML can serialize. It does
|
33
|
+
this by storing an extra key value pair (or two) to maintain type information.
|
34
|
+
|
35
|
+
Because it falls back to YAML serialization for complex types, this means that
|
36
|
+
nested data structures can be serialized to an hstore. In other words, any
|
37
|
+
hash that can be serialized with the normal Rails YAML serialization can be
|
38
|
+
serialized with Surus. But you can get the benefits of PostgreSQL indexing
|
39
|
+
on the top level keys and values for free.
|
33
40
|
|
34
41
|
Hstores can be searched with helper scopes.
|
35
42
|
|
@@ -125,7 +125,7 @@ module Surus
|
|
125
125
|
elsif value == nil
|
126
126
|
[nil, "String"] # we don't actually stringify nil because format_value special cases nil
|
127
127
|
else
|
128
|
-
[value
|
128
|
+
[YAML.dump(value), "YAML"]
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
@@ -145,6 +145,8 @@ module Surus
|
|
145
145
|
true
|
146
146
|
when "FalseClass"
|
147
147
|
false
|
148
|
+
when "YAML"
|
149
|
+
YAML.load(value)
|
148
150
|
else
|
149
151
|
raise ArgumentError, "Can't typecast: #{type}"
|
150
152
|
end
|
data/lib/surus/version.rb
CHANGED
@@ -47,7 +47,9 @@ describe Surus::Hstore::Serializer do
|
|
47
47
|
[BigDecimal("-1"), "negative BigDecimal"],
|
48
48
|
[true, "true"],
|
49
49
|
[false, "false"],
|
50
|
-
[Date.today, "date"]
|
50
|
+
[Date.today, "date"],
|
51
|
+
[{"foo" => [1,2,3], "bar" => {"baz" => 42}}, "nested hash"],
|
52
|
+
[[1,2,3], "array"]
|
51
53
|
].each do |value, description|
|
52
54
|
round_trip_examples << [{"foo" => value}, "value is #{description}"]
|
53
55
|
round_trip_examples << [{value => "bar"}, "key is #{description}"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: surus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pg
|
16
|
-
requirement: &
|
16
|
+
requirement: &11662280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *11662280
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activerecord
|
27
|
-
requirement: &
|
27
|
+
requirement: &11661280 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.1.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *11661280
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &11660340 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 2.8.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *11660340
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: guard
|
49
|
-
requirement: &
|
49
|
+
requirement: &11659560 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.10.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *11659560
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: guard-rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &11624780 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 0.6.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *11624780
|
69
69
|
description: Includes serializers and search scopes for hstore and array. Also includes
|
70
70
|
control over synchronous_commit to boost insert and update speed.
|
71
71
|
email:
|