hstore_accessor 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d1d9d199923f0290f48ead646d03e1be0f0b009
4
- data.tar.gz: ffc1ee0d3cd7a29c0805d3e92dcb627ce0077a8f
3
+ metadata.gz: 125cfa4bc2b4858787a2ebffe05b762c8c84eed6
4
+ data.tar.gz: 953d60cd270bbda806bc58543945b17d0994db13
5
5
  SHA512:
6
- metadata.gz: 40623599c41d3321f48291f5dad8ad8fd38597883e100b8493efe279446ba7da1d4de6c7c2f4d5a77c0c3ff32fcd092229b412e3dd400f1ef02a808649e70359
7
- data.tar.gz: 6043b45908543deed165f6817d9c6c8ee4109b68ab7e6bd932f10fe07b18c312f77f00e2673a104f12dde4fd325e90a9784a72923e180e353029e4b2c6caf0fa
6
+ metadata.gz: 4ae46b954d55b60185a6e737544dc2700833b00157274de920d72dcb42199166f3cd4a116cffd993269bbffb8de35b252aec236d95c190c7e64698eef9f35972
7
+ data.tar.gz: 291392514a75b48ba4d0ac00bbfa81deab3211583ed96babe6232b0f426c923fde3d0207f79dcd1cfece517d4dde83ac90bba87c92acf22f0b2a86ec1e76782b
@@ -1 +1 @@
1
- 2.1.5
1
+ 2.3.3
data/Appraisals CHANGED
@@ -1,11 +1,19 @@
1
+ appraise "activerecord-5.1" do
2
+ gem "activerecord", "~> 5.1.0"
3
+ end
4
+
5
+ appraise "activerecord-5.0" do
6
+ gem "activerecord", "~> 5.0.0"
7
+ end
8
+
1
9
  appraise "activerecord-4.2" do
2
- gem "activerecord", "4.2.0"
10
+ gem "activerecord", "~> 4.2.0"
3
11
  end
4
12
 
5
13
  appraise "activerecord-4.1" do
6
- gem "activerecord", "4.1.0"
14
+ gem "activerecord", "~> 4.1.0"
7
15
  end
8
16
 
9
17
  appraise "activerecord-4.0" do
10
- gem "activerecord", "4.0.0"
18
+ gem "activerecord", "~> 4.0.0"
11
19
  end
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
- ![Codeship](https://www.codeship.io/projects/db3ce4f0-c3c8-0130-9c44-167bc618456a/status?branch=master)
2
-
3
1
  # HstoreAccessor
4
2
 
5
3
  Hstore Accessor allows you to treat fields on an hstore column as though they were actual columns being picked up by ActiveRecord. This is especially handy when trying to avoid sparse columns while making use of [single table inheritence](#single-table-inheritance). Hstore Accessor currently supports ActiveRecord versions 4.0, 4.1, and 4.2.
6
4
 
5
+ Starting a new project or just not a fan of hstore? Check out [Jsonb Accessor](https://github.com/devmynd/jsonb_accessor)!
6
+
7
7
  ## Table of Contents
8
8
 
9
9
  * [Installation](#installation)
@@ -2,10 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "4.0.0"
5
+ gem "activerecord", "~> 4.0.0"
6
6
 
7
7
  group :test do
8
8
  gem "pg", ">= 0.14.1"
9
9
  end
10
10
 
11
- gemspec :path => "../"
11
+ gemspec path: "../"
@@ -2,10 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "4.1.0"
5
+ gem "activerecord", "~> 4.1.0"
6
6
 
7
7
  group :test do
8
8
  gem "pg", ">= 0.14.1"
9
9
  end
10
10
 
11
- gemspec :path => "../"
11
+ gemspec path: "../"
@@ -2,10 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "4.2.0"
5
+ gem "activerecord", "~> 4.2.0"
6
6
 
7
7
  group :test do
8
8
  gem "pg", ">= 0.14.1"
9
9
  end
10
10
 
11
- gemspec :path => "../"
11
+ gemspec path: "../"
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 5.0.0"
6
+
7
+ group :test do
8
+ gem "pg", ">= 0.14.1"
9
+ end
10
+
11
+ gemspec path: "../"
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 5.1.0"
6
+
7
+ group :test do
8
+ gem "pg", ">= 0.14.1"
9
+ end
10
+
11
+ gemspec path: "../"
@@ -26,10 +26,10 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "pry"
27
27
  spec.add_development_dependency "pry-doc"
28
28
  spec.add_development_dependency "pry-nav"
29
- spec.add_development_dependency "rake"
29
+ spec.add_development_dependency "rake", "< 11.0"
30
30
  spec.add_development_dependency "rspec", "~> 3.1.0"
31
31
  spec.add_development_dependency "rubocop"
32
- spec.add_development_dependency "shoulda-matchers"
32
+ spec.add_development_dependency "shoulda-matchers", "~> 3.1"
33
33
 
34
34
  spec.post_install_message = "Please note that the `array` and `hash` types are no longer supported in version 1.0.0"
35
35
  end
@@ -2,7 +2,9 @@ require "active_support"
2
2
  require "active_record"
3
3
  require "hstore_accessor/version"
4
4
 
5
- if ::ActiveRecord::VERSION::STRING.to_f >= 4.2
5
+ if ::ActiveRecord::VERSION::STRING.to_f >= 5.0
6
+ require "hstore_accessor/active_record_5.0/type_helpers"
7
+ elsif ::ActiveRecord::VERSION::STRING.to_f >= 4.2 && ::ActiveRecord::VERSION::STRING.to_f < 5.0
6
8
  require "hstore_accessor/active_record_4.2/type_helpers"
7
9
  else
8
10
  require "hstore_accessor/active_record_pre_4.2/type_helpers"
@@ -0,0 +1,34 @@
1
+ module HstoreAccessor
2
+ module TypeHelpers
3
+ TYPES = {
4
+ boolean: ActiveRecord::Type::Boolean,
5
+ date: ActiveRecord::Type::Date,
6
+ datetime: ActiveRecord::Type::DateTime,
7
+ decimal: ActiveRecord::Type::Decimal,
8
+ float: ActiveRecord::Type::Float,
9
+ integer: ActiveRecord::Type::Integer,
10
+ string: ActiveRecord::Type::String
11
+ }
12
+
13
+ TYPES.default = ActiveRecord::Type::Value
14
+
15
+ class << self
16
+ def column_type_for(attribute, data_type)
17
+ ActiveRecord::ConnectionAdapters::Column.new(attribute.to_s, nil, TYPES[data_type].new)
18
+ end
19
+
20
+ def cast(type, value)
21
+ return nil if value.nil?
22
+
23
+ case type
24
+ when :string, :decimal
25
+ value
26
+ when :integer, :float, :datetime, :date, :boolean
27
+ TYPES[type].new.cast(value)
28
+ else value
29
+ # Nothing.
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,3 +1,3 @@
1
1
  module HstoreAccessor
2
- VERSION = "1.0.3"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -323,7 +323,26 @@ describe HstoreAccessor do
323
323
  end
324
324
 
325
325
  describe "#column_for_attribute" do
326
- if ActiveRecord::VERSION::STRING.to_f >= 4.2
326
+ if ActiveRecord::VERSION::STRING.to_f >= 5.0
327
+ def self.it_returns_the_properly_typed_column(type, attribute_name, cast_type_class)
328
+ context "#{type}" do
329
+ subject { SuperProduct.column_for_attribute(attribute_name) }
330
+ it "returns a column with a #{type} cast type" do
331
+ expect(subject).to be_a(ActiveRecord::ConnectionAdapters::Column)
332
+ expect(subject.sql_type_metadata).to eq(cast_type_class.new)
333
+ end
334
+ end
335
+ end
336
+
337
+ it_returns_the_properly_typed_column :string, :color, ActiveRecord::Type::String
338
+ it_returns_the_properly_typed_column :integer, :price, ActiveRecord::Type::Integer
339
+ it_returns_the_properly_typed_column :boolean, :published, ActiveRecord::Type::Boolean
340
+ it_returns_the_properly_typed_column :float, :weight, ActiveRecord::Type::Float
341
+ it_returns_the_properly_typed_column :datetime, :build_timestamp, ActiveRecord::Type::DateTime
342
+ it_returns_the_properly_typed_column :date, :released_at, ActiveRecord::Type::Date
343
+ it_returns_the_properly_typed_column :decimal, :miles, ActiveRecord::Type::Decimal
344
+
345
+ elsif ActiveRecord::VERSION::STRING.to_f >= 4.2
327
346
 
328
347
  def self.it_returns_the_properly_typed_column(type, attribute_name, cast_type_class)
329
348
  context "#{type}" do
@@ -516,7 +535,7 @@ describe HstoreAccessor do
516
535
  end
517
536
 
518
537
  it "type casts boolean values" do
519
- ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.each do |value|
538
+ [true, 1, "t"].each do |value|
520
539
  product.popular = value
521
540
  expect(product.popular).to be true
522
541
 
@@ -524,7 +543,7 @@ describe HstoreAccessor do
524
543
  expect(product.published).to be true
525
544
  end
526
545
 
527
- ActiveRecord::ConnectionAdapters::Column::FALSE_VALUES.each do |value|
546
+ [false, 0, "f"].each do |value|
528
547
  product.popular = value
529
548
  expect(product.popular).to be false
530
549
 
@@ -4,6 +4,13 @@ require "shoulda-matchers"
4
4
 
5
5
  DatabaseCleaner.strategy = :truncation
6
6
 
7
+ Shoulda::Matchers.configure do |config|
8
+ config.integrate do |with|
9
+ with.test_framework :rspec
10
+ with.library :active_record
11
+ end
12
+ end
13
+
7
14
  RSpec.configure do |config|
8
15
  config.mock_with :rspec
9
16
  config.order = :random
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hstore_accessor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Hirn
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-04-22 00:00:00.000000000 Z
15
+ date: 2017-05-18 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activerecord
@@ -116,16 +116,16 @@ dependencies:
116
116
  name: rake
117
117
  requirement: !ruby/object:Gem::Requirement
118
118
  requirements:
119
- - - ">="
119
+ - - "<"
120
120
  - !ruby/object:Gem::Version
121
- version: '0'
121
+ version: '11.0'
122
122
  type: :development
123
123
  prerelease: false
124
124
  version_requirements: !ruby/object:Gem::Requirement
125
125
  requirements:
126
- - - ">="
126
+ - - "<"
127
127
  - !ruby/object:Gem::Version
128
- version: '0'
128
+ version: '11.0'
129
129
  - !ruby/object:Gem::Dependency
130
130
  name: rspec
131
131
  requirement: !ruby/object:Gem::Requirement
@@ -158,16 +158,16 @@ dependencies:
158
158
  name: shoulda-matchers
159
159
  requirement: !ruby/object:Gem::Requirement
160
160
  requirements:
161
- - - ">="
161
+ - - "~>"
162
162
  - !ruby/object:Gem::Version
163
- version: '0'
163
+ version: '3.1'
164
164
  type: :development
165
165
  prerelease: false
166
166
  version_requirements: !ruby/object:Gem::Requirement
167
167
  requirements:
168
- - - ">="
168
+ - - "~>"
169
169
  - !ruby/object:Gem::Version
170
- version: '0'
170
+ version: '3.1'
171
171
  description: Adds typed hstore backed fields to an ActiveRecord model.
172
172
  email:
173
173
  - joe@devmynd.com
@@ -190,9 +190,12 @@ files:
190
190
  - gemfiles/activerecord_4.0.gemfile
191
191
  - gemfiles/activerecord_4.1.gemfile
192
192
  - gemfiles/activerecord_4.2.gemfile
193
+ - gemfiles/activerecord_5.0.gemfile
194
+ - gemfiles/activerecord_5.1.gemfile
193
195
  - hstore_accessor.gemspec
194
196
  - lib/hstore_accessor.rb
195
197
  - lib/hstore_accessor/active_record_4.2/type_helpers.rb
198
+ - lib/hstore_accessor/active_record_5.0/type_helpers.rb
196
199
  - lib/hstore_accessor/active_record_pre_4.2/time_helper.rb
197
200
  - lib/hstore_accessor/active_record_pre_4.2/type_helpers.rb
198
201
  - lib/hstore_accessor/macro.rb
@@ -221,11 +224,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
224
  version: '0'
222
225
  requirements: []
223
226
  rubyforge_project:
224
- rubygems_version: 2.2.2
227
+ rubygems_version: 2.5.2
225
228
  signing_key:
226
229
  specification_version: 4
227
230
  summary: Adds typed hstore backed fields to an ActiveRecord model.
228
231
  test_files:
229
232
  - spec/hstore_accessor_spec.rb
230
233
  - spec/spec_helper.rb
231
- has_rdoc: