hstore_accessor 0.6.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +41 -0
- data/Appraisals +11 -0
- data/Gemfile +1 -5
- data/README.md +128 -57
- data/Rakefile +8 -2
- data/gemfiles/activerecord_4.0.gemfile +11 -0
- data/gemfiles/activerecord_4.1.gemfile +11 -0
- data/gemfiles/activerecord_4.2.gemfile +11 -0
- data/hstore_accessor.gemspec +16 -10
- data/lib/hstore_accessor.rb +10 -4
- data/lib/hstore_accessor/active_record_4.2/type_helpers.rb +34 -0
- data/lib/hstore_accessor/{time_helper.rb → active_record_<_4.2/time_helper.rb} +2 -4
- data/lib/hstore_accessor/active_record_<_4.2/type_helpers.rb +42 -0
- data/lib/hstore_accessor/macro.rb +110 -46
- data/lib/hstore_accessor/serialization.rb +39 -27
- data/lib/hstore_accessor/version.rb +1 -1
- data/spec/hstore_accessor_spec.rb +281 -85
- data/spec/spec_helper.rb +14 -0
- metadata +85 -17
- data/lib/hstore_accessor/type_helpers.rb +0 -20
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require "hstore_accessor"
|
2
2
|
require "database_cleaner"
|
3
|
+
require "shoulda-matchers"
|
3
4
|
|
4
5
|
DatabaseCleaner.strategy = :truncation
|
5
6
|
|
6
7
|
RSpec.configure do |config|
|
7
8
|
config.mock_with :rspec
|
9
|
+
config.order = :random
|
8
10
|
|
9
11
|
config.before :suite do
|
10
12
|
create_database
|
@@ -27,5 +29,17 @@ def create_database
|
|
27
29
|
|
28
30
|
ActiveRecord::Base.connection.create_table(:products) do |t|
|
29
31
|
t.hstore :options
|
32
|
+
t.hstore :data
|
33
|
+
|
34
|
+
t.string :string_type
|
35
|
+
t.integer :integer_type
|
36
|
+
t.boolean :boolean_type
|
37
|
+
t.float :float_type
|
38
|
+
t.time :time_type
|
39
|
+
t.string :array_type, array: true
|
40
|
+
t.date :date_type
|
41
|
+
t.datetime :datetime_type
|
42
|
+
t.decimal :decimal_type
|
43
|
+
t.hstore :hash_type
|
30
44
|
end
|
31
45
|
end
|
metadata
CHANGED
@@ -1,61 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hstore_accessor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Hirn
|
8
8
|
- Cory Stephenson
|
9
9
|
- JC Grubbs
|
10
|
+
- Tony Coconate
|
11
|
+
- Michael Crismali
|
10
12
|
autorequire:
|
11
13
|
bindir: bin
|
12
14
|
cert_chain: []
|
13
|
-
date:
|
15
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
14
16
|
dependencies:
|
15
17
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
18
|
+
name: activerecord
|
17
19
|
requirement: !ruby/object:Gem::Requirement
|
18
20
|
requirements:
|
19
21
|
- - ">="
|
20
22
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
23
|
+
version: 4.0.0
|
22
24
|
type: :runtime
|
23
25
|
prerelease: false
|
24
26
|
version_requirements: !ruby/object:Gem::Requirement
|
25
27
|
requirements:
|
26
28
|
- - ">="
|
27
29
|
- !ruby/object:Gem::Version
|
28
|
-
version:
|
30
|
+
version: 4.0.0
|
29
31
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
32
|
+
name: appraisal
|
31
33
|
requirement: !ruby/object:Gem::Requirement
|
32
34
|
requirements:
|
33
35
|
- - ">="
|
34
36
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
37
|
+
version: '0'
|
36
38
|
type: :development
|
37
39
|
prerelease: false
|
38
40
|
version_requirements: !ruby/object:Gem::Requirement
|
39
41
|
requirements:
|
40
42
|
- - ">="
|
41
43
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
44
|
+
version: '0'
|
43
45
|
- !ruby/object:Gem::Dependency
|
44
46
|
name: bundler
|
45
47
|
requirement: !ruby/object:Gem::Requirement
|
46
48
|
requirements:
|
47
49
|
- - "~>"
|
48
50
|
- !ruby/object:Gem::Version
|
49
|
-
version: '1.
|
51
|
+
version: '1.7'
|
50
52
|
type: :development
|
51
53
|
prerelease: false
|
52
54
|
version_requirements: !ruby/object:Gem::Requirement
|
53
55
|
requirements:
|
54
56
|
- - "~>"
|
55
57
|
- !ruby/object:Gem::Version
|
56
|
-
version: '1.
|
58
|
+
version: '1.7'
|
57
59
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
60
|
+
name: database_cleaner
|
59
61
|
requirement: !ruby/object:Gem::Requirement
|
60
62
|
requirements:
|
61
63
|
- - ">="
|
@@ -69,7 +71,7 @@ dependencies:
|
|
69
71
|
- !ruby/object:Gem::Version
|
70
72
|
version: '0'
|
71
73
|
- !ruby/object:Gem::Dependency
|
72
|
-
name:
|
74
|
+
name: pry
|
73
75
|
requirement: !ruby/object:Gem::Requirement
|
74
76
|
requirements:
|
75
77
|
- - ">="
|
@@ -83,7 +85,7 @@ dependencies:
|
|
83
85
|
- !ruby/object:Gem::Version
|
84
86
|
version: '0'
|
85
87
|
- !ruby/object:Gem::Dependency
|
86
|
-
name: pry
|
88
|
+
name: pry-doc
|
87
89
|
requirement: !ruby/object:Gem::Requirement
|
88
90
|
requirements:
|
89
91
|
- - ">="
|
@@ -97,7 +99,63 @@ dependencies:
|
|
97
99
|
- !ruby/object:Gem::Version
|
98
100
|
version: '0'
|
99
101
|
- !ruby/object:Gem::Dependency
|
100
|
-
name:
|
102
|
+
name: pry-nav
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
type: :development
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: rake
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
name: rspec
|
131
|
+
requirement: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - "~>"
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: 3.1.0
|
136
|
+
type: :development
|
137
|
+
prerelease: false
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - "~>"
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 3.1.0
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
name: rubocop
|
145
|
+
requirement: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
- !ruby/object:Gem::Dependency
|
158
|
+
name: shoulda-matchers
|
101
159
|
requirement: !ruby/object:Gem::Requirement
|
102
160
|
requirements:
|
103
161
|
- - ">="
|
@@ -115,21 +173,29 @@ email:
|
|
115
173
|
- joe@devmynd.com
|
116
174
|
- cory@devmynd.com
|
117
175
|
- jc@devmynd.com
|
176
|
+
- me@tonycoconate.com
|
177
|
+
- michael@devmynd.com
|
118
178
|
executables: []
|
119
179
|
extensions: []
|
120
180
|
extra_rdoc_files: []
|
121
181
|
files:
|
122
182
|
- ".gitignore"
|
183
|
+
- ".rubocop.yml"
|
184
|
+
- Appraisals
|
123
185
|
- Gemfile
|
124
186
|
- LICENSE.txt
|
125
187
|
- README.md
|
126
188
|
- Rakefile
|
189
|
+
- gemfiles/activerecord_4.0.gemfile
|
190
|
+
- gemfiles/activerecord_4.1.gemfile
|
191
|
+
- gemfiles/activerecord_4.2.gemfile
|
127
192
|
- hstore_accessor.gemspec
|
128
193
|
- lib/hstore_accessor.rb
|
194
|
+
- lib/hstore_accessor/active_record_4.2/type_helpers.rb
|
195
|
+
- lib/hstore_accessor/active_record_<_4.2/time_helper.rb
|
196
|
+
- lib/hstore_accessor/active_record_<_4.2/type_helpers.rb
|
129
197
|
- lib/hstore_accessor/macro.rb
|
130
198
|
- lib/hstore_accessor/serialization.rb
|
131
|
-
- lib/hstore_accessor/time_helper.rb
|
132
|
-
- lib/hstore_accessor/type_helpers.rb
|
133
199
|
- lib/hstore_accessor/version.rb
|
134
200
|
- spec/hstore_accessor_spec.rb
|
135
201
|
- spec/spec_helper.rb
|
@@ -137,7 +203,8 @@ homepage: http://github.com/devmynd/hstore_accessor
|
|
137
203
|
licenses:
|
138
204
|
- MIT
|
139
205
|
metadata: {}
|
140
|
-
post_install_message:
|
206
|
+
post_install_message: Please note that the `array` and `hash` types will no longer
|
207
|
+
be supported in version 1.0.0
|
141
208
|
rdoc_options: []
|
142
209
|
require_paths:
|
143
210
|
- lib
|
@@ -160,3 +227,4 @@ summary: Adds typed hstore backed fields to an ActiveRecord model.
|
|
160
227
|
test_files:
|
161
228
|
- spec/hstore_accessor_spec.rb
|
162
229
|
- spec/spec_helper.rb
|
230
|
+
has_rdoc:
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module HstoreAccessor
|
2
|
-
module TypeHelpers
|
3
|
-
|
4
|
-
def self.cast(type, value)
|
5
|
-
return nil if value.nil?
|
6
|
-
column_class = ActiveRecord::ConnectionAdapters::Column
|
7
|
-
case type
|
8
|
-
when :string,:hash,:array,
|
9
|
-
:decimal then value
|
10
|
-
when :integer then column_class.value_to_integer(value)
|
11
|
-
when :float then value.to_f
|
12
|
-
when :time then TimeHelper.string_to_time(value)
|
13
|
-
when :date then column_class.value_to_date(value)
|
14
|
-
when :boolean then column_class.value_to_boolean(value)
|
15
|
-
else value
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|