jsonb_accessor 1.0.0.beta.4 → 1.0.0.beta.5

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: 9342c69dc4817b5f014149d149fd8fb92ad650ff
4
- data.tar.gz: d3b5f27e415c190f63b9275cc28c648fc2510023
3
+ metadata.gz: a66f5adf90e5c66c0cacb04698102c37fbd69b27
4
+ data.tar.gz: dcee9f04338256069b16e0078bbd21ee34264b7a
5
5
  SHA512:
6
- metadata.gz: 2b2e8d7ffbc17b5b8455c8e95f686a1ad24a2f3cbd7f6166d7bcf2300922316221248617dd021fb0d3f59db45f5b9bb4ff912540c4876f0b3a92484d688fc29a
7
- data.tar.gz: 6e1453d01c791b69cf5ec9c0f525819bc8eed173fdbb4f914c8e190f7a5f6b7ae0ad8e966707a023299d69f2e33df1cb0af74b3ef7374053127cbe8c430a14dd
6
+ metadata.gz: eb1b146937ec6624866dc4f8594d25889eb9fd7a92de1610242048e6c5488050b0be7cbe8e9f2f887a07ed45eeb97308071c3889023eb2a3074f8e01928c91a6
7
+ data.tar.gz: f8d8fad1f5adea8b6d71b8512991a838f4a8dde52c4b9ca83b03facfab2d00f946d3a2a9e402c18d0f3f44bc2de53fa624e57e2531e2fe1b095c2766561c2ed6
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ gemfiles/.bundle
@@ -59,3 +59,5 @@ Style/SpaceAroundEqualsInParameterDefault:
59
59
  Enabled: false
60
60
  Style/StringLiterals:
61
61
  EnforcedStyle: double_quotes
62
+ Performance/EndWith:
63
+ Enabled: false
@@ -14,3 +14,4 @@ before_script:
14
14
  cache: bundler
15
15
  gemfile:
16
16
  - gemfiles/activerecord_5.0.0.gemfile
17
+ - gemfiles/activerecord_5.1.0.gemfile
data/Appraisals CHANGED
@@ -1,4 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  appraise "activerecord-5.0.0" do
2
4
  gemspec
3
5
  gem "activerecord", "~> 5.0.0"
4
6
  end
7
+
8
+ appraise "activerecord-5.1.0" do
9
+ gemspec
10
+ gem "activerecord", "~> 5.1.0"
11
+ end
data/Gemfile CHANGED
@@ -1,7 +1,9 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
2
4
 
3
5
  # Specify your gem's dependencies in jsonb_accessor.gemspec
4
6
  gemspec
5
7
 
6
8
  # Travis CI requires in Gemfile
7
- gem 'pg'
9
+ gem "pg"
data/README.md CHANGED
@@ -29,7 +29,7 @@ This README reflects the most recent 1.0 beta. Method names and interfaces may s
29
29
  Add this line to your application's `Gemfile`:
30
30
 
31
31
  ```ruby
32
- gem "jsonb_accessor", "1.0.0.beta.4"
32
+ gem "jsonb_accessor", "1.0.0.beta.5"
33
33
  ```
34
34
 
35
35
  And then execute:
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "rubygems"
3
4
  require "bundler/setup"
4
5
  require "bundler/gem_tasks"
@@ -10,4 +11,4 @@ StandaloneMigrations::Tasks.load_tasks
10
11
  RSpec::Core::RakeTask.new
11
12
  RuboCop::RakeTask.new
12
13
 
13
- task(default: [:rubocop, :spec])
14
+ task(default: %i[rubocop spec])
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
+
3
4
  # rubocop:disable Lint/UselessAssignment
4
5
 
5
6
  require "bundler/setup"
@@ -15,22 +15,22 @@ ActiveRecord::Schema.define(version: 20150407031737) do
15
15
  # These are extensions that must be enabled in order to support this database
16
16
  enable_extension "plpgsql"
17
17
 
18
- create_table "product_categories", force: :cascade do |t|
18
+ create_table "product_categories", id: :serial, force: :cascade do |t|
19
19
  t.jsonb "options"
20
20
  end
21
21
 
22
- create_table "products", force: :cascade do |t|
23
- t.jsonb "options"
24
- t.jsonb "data"
25
- t.string "string_type"
26
- t.integer "integer_type"
27
- t.integer "product_category_id"
28
- t.boolean "boolean_type"
29
- t.float "float_type"
30
- t.time "time_type"
31
- t.date "date_type"
22
+ create_table "products", id: :serial, force: :cascade do |t|
23
+ t.jsonb "options"
24
+ t.jsonb "data"
25
+ t.string "string_type"
26
+ t.integer "integer_type"
27
+ t.integer "product_category_id"
28
+ t.boolean "boolean_type"
29
+ t.float "float_type"
30
+ t.time "time_type"
31
+ t.date "date_type"
32
32
  t.datetime "datetime_type"
33
- t.decimal "decimal_type"
33
+ t.decimal "decimal_type"
34
34
  end
35
35
 
36
36
  end
@@ -5,4 +5,5 @@ source "https://rubygems.org"
5
5
  gem "pg"
6
6
  gem "activerecord", "~> 5.0.0"
7
7
 
8
- gemspec :path => "../"
8
+ gemspec path: "../"
9
+ gemspec path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- jsonb_accessor (1.0.0.beta.4)
4
+ jsonb_accessor (1.0.0.beta.5)
5
5
  activerecord (>= 5.0)
6
6
  pg (>= 0.18.1)
7
7
 
@@ -80,7 +80,8 @@ GEM
80
80
  method_source
81
81
  rake (>= 0.8.7)
82
82
  thor (>= 0.18.1, < 2.0)
83
- rainbow (2.2.1)
83
+ rainbow (2.2.2)
84
+ rake
84
85
  rake (10.5.0)
85
86
  rspec (3.5.0)
86
87
  rspec-core (~> 3.5.0)
@@ -95,7 +96,7 @@ GEM
95
96
  diff-lcs (>= 1.2.0, < 2.0)
96
97
  rspec-support (~> 3.5.0)
97
98
  rspec-support (3.5.0)
98
- rubocop (0.47.1)
99
+ rubocop (0.48.1)
99
100
  parser (>= 2.3.3.1, < 3.0)
100
101
  powerpack (~> 0.1)
101
102
  rainbow (>= 1.99.1, < 3.0)
@@ -113,7 +114,7 @@ GEM
113
114
  thread_safe (0.3.6)
114
115
  tzinfo (1.2.2)
115
116
  thread_safe (~> 0.1)
116
- unicode-display_width (1.1.3)
117
+ unicode-display_width (1.2.1)
117
118
  yard (0.9.8)
118
119
 
119
120
  PLATFORMS
@@ -124,7 +125,7 @@ DEPENDENCIES
124
125
  appraisal
125
126
  awesome_print
126
127
  bundler (~> 1.9)
127
- database_cleaner
128
+ database_cleaner (~> 1.5.3)
128
129
  jsonb_accessor!
129
130
  pg
130
131
  pry
@@ -132,7 +133,7 @@ DEPENDENCIES
132
133
  pry-nav
133
134
  rake (~> 10.0)
134
135
  rspec (~> 3.2)
135
- rubocop (~> 0.31)
136
+ rubocop (~> 0.48.1)
136
137
  shoulda-matchers
137
138
  standalone_migrations
138
139
 
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "pg"
6
+ gem "activerecord", "~> 5.1.0"
7
+
8
+ gemspec path: "../"
9
+ gemspec path: "../"
@@ -0,0 +1,141 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ jsonb_accessor (1.0.0.beta.5)
5
+ activerecord (>= 5.0)
6
+ pg (>= 0.18.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionpack (5.1.0)
12
+ actionview (= 5.1.0)
13
+ activesupport (= 5.1.0)
14
+ rack (~> 2.0)
15
+ rack-test (~> 0.6.3)
16
+ rails-dom-testing (~> 2.0)
17
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
18
+ actionview (5.1.0)
19
+ activesupport (= 5.1.0)
20
+ builder (~> 3.1)
21
+ erubi (~> 1.4)
22
+ rails-dom-testing (~> 2.0)
23
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
24
+ activemodel (5.1.0)
25
+ activesupport (= 5.1.0)
26
+ activerecord (5.1.0)
27
+ activemodel (= 5.1.0)
28
+ activesupport (= 5.1.0)
29
+ arel (~> 8.0)
30
+ activesupport (5.1.0)
31
+ concurrent-ruby (~> 1.0, >= 1.0.2)
32
+ i18n (~> 0.7)
33
+ minitest (~> 5.1)
34
+ tzinfo (~> 1.1)
35
+ appraisal (2.2.0)
36
+ bundler
37
+ rake
38
+ thor (>= 0.14.0)
39
+ arel (8.0.0)
40
+ ast (2.3.0)
41
+ awesome_print (1.7.0)
42
+ builder (3.2.3)
43
+ coderay (1.1.1)
44
+ concurrent-ruby (1.0.5)
45
+ database_cleaner (1.5.3)
46
+ diff-lcs (1.3)
47
+ erubi (1.6.0)
48
+ i18n (0.8.1)
49
+ loofah (2.0.3)
50
+ nokogiri (>= 1.5.9)
51
+ method_source (0.8.2)
52
+ mini_portile2 (2.1.0)
53
+ minitest (5.10.1)
54
+ nokogiri (1.7.1)
55
+ mini_portile2 (~> 2.1.0)
56
+ parser (2.4.0.0)
57
+ ast (~> 2.2)
58
+ pg (0.20.0)
59
+ powerpack (0.1.1)
60
+ pry (0.10.4)
61
+ coderay (~> 1.1.0)
62
+ method_source (~> 0.8.1)
63
+ slop (~> 3.4)
64
+ pry-doc (0.10.0)
65
+ pry (~> 0.9)
66
+ yard (~> 0.9)
67
+ pry-nav (0.2.4)
68
+ pry (>= 0.9.10, < 0.11.0)
69
+ rack (2.0.1)
70
+ rack-test (0.6.3)
71
+ rack (>= 1.0)
72
+ rails-dom-testing (2.0.2)
73
+ activesupport (>= 4.2.0, < 6.0)
74
+ nokogiri (~> 1.6)
75
+ rails-html-sanitizer (1.0.3)
76
+ loofah (~> 2.0)
77
+ railties (5.1.0)
78
+ actionpack (= 5.1.0)
79
+ activesupport (= 5.1.0)
80
+ method_source
81
+ rake (>= 0.8.7)
82
+ thor (>= 0.18.1, < 2.0)
83
+ rainbow (2.2.2)
84
+ rake
85
+ rake (10.5.0)
86
+ rspec (3.5.0)
87
+ rspec-core (~> 3.5.0)
88
+ rspec-expectations (~> 3.5.0)
89
+ rspec-mocks (~> 3.5.0)
90
+ rspec-core (3.5.4)
91
+ rspec-support (~> 3.5.0)
92
+ rspec-expectations (3.5.0)
93
+ diff-lcs (>= 1.2.0, < 2.0)
94
+ rspec-support (~> 3.5.0)
95
+ rspec-mocks (3.5.0)
96
+ diff-lcs (>= 1.2.0, < 2.0)
97
+ rspec-support (~> 3.5.0)
98
+ rspec-support (3.5.0)
99
+ rubocop (0.48.1)
100
+ parser (>= 2.3.3.1, < 3.0)
101
+ powerpack (~> 0.1)
102
+ rainbow (>= 1.99.1, < 3.0)
103
+ ruby-progressbar (~> 1.7)
104
+ unicode-display_width (~> 1.0, >= 1.0.1)
105
+ ruby-progressbar (1.8.1)
106
+ shoulda-matchers (3.1.1)
107
+ activesupport (>= 4.0.0)
108
+ slop (3.6.0)
109
+ standalone_migrations (5.2.1)
110
+ activerecord (>= 4.2.7, < 5.2.0)
111
+ railties (>= 4.2.7, < 5.2.0)
112
+ rake (~> 10.0)
113
+ thor (0.19.4)
114
+ thread_safe (0.3.6)
115
+ tzinfo (1.2.3)
116
+ thread_safe (~> 0.1)
117
+ unicode-display_width (1.2.1)
118
+ yard (0.9.9)
119
+
120
+ PLATFORMS
121
+ ruby
122
+
123
+ DEPENDENCIES
124
+ activerecord (~> 5.1.0)
125
+ appraisal
126
+ awesome_print
127
+ bundler (~> 1.9)
128
+ database_cleaner (~> 1.5.3)
129
+ jsonb_accessor!
130
+ pg
131
+ pry
132
+ pry-doc
133
+ pry-nav
134
+ rake (~> 10.0)
135
+ rspec (~> 3.2)
136
+ rubocop (~> 0.48.1)
137
+ shoulda-matchers
138
+ standalone_migrations
139
+
140
+ BUNDLED WITH
141
+ 1.14.6
@@ -1,4 +1,6 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  lib = File.expand_path("../lib", __FILE__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
  require "jsonb_accessor/version"
@@ -7,15 +9,15 @@ Gem::Specification.new do |spec|
7
9
  spec.name = "jsonb_accessor"
8
10
  spec.version = JsonbAccessor::VERSION
9
11
  spec.authors = ["Michael Crismali", "Joe Hirn", "Jason Haruska"]
10
- spec.email = ["michael.crismali@gmail.com", "joe@devmynd.com", "jason@haruska.com"]
12
+ spec.email = ["michael@crismali.com", "joe@devmynd.com", "jason@haruska.com"]
11
13
 
12
- spec.summary = %q{Adds typed jsonb backed fields to your ActiveRecord models.}
13
- spec.description = %q{Adds typed jsonb backed fields to your ActiveRecord models.}
14
+ spec.summary = "Adds typed jsonb backed fields to your ActiveRecord models."
15
+ spec.description = "Adds typed jsonb backed fields to your ActiveRecord models."
14
16
  spec.homepage = "https://github.com/devmynd/jsonb_accessor"
15
17
  spec.license = "MIT"
16
18
  spec.required_ruby_version = "~> 2.0"
17
19
 
18
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) || f.match(%r{png\z}) }
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) || f.match(/png\z/) }
19
21
  spec.bindir = "exe"
20
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
23
  spec.require_paths = ["lib"]
@@ -25,14 +27,14 @@ Gem::Specification.new do |spec|
25
27
 
26
28
  spec.add_development_dependency "appraisal"
27
29
  spec.add_development_dependency "bundler", "~> 1.9"
28
- spec.add_development_dependency "database_cleaner"
30
+ spec.add_development_dependency "database_cleaner", "~> 1.5.3"
29
31
  spec.add_development_dependency "awesome_print"
30
32
  spec.add_development_dependency "pry"
31
33
  spec.add_development_dependency "pry-doc"
32
34
  spec.add_development_dependency "pry-nav"
33
35
  spec.add_development_dependency "rake", "~> 10.0"
34
36
  spec.add_development_dependency "rspec", "~> 3.2"
35
- spec.add_development_dependency "rubocop", "~> 0.31"
37
+ spec.add_development_dependency "rubocop", "~> 0.48.1"
36
38
  spec.add_development_dependency "shoulda-matchers"
37
39
  spec.add_development_dependency "standalone_migrations"
38
40
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "active_record"
3
4
 
4
5
  require "active_record/connection_adapters/postgresql_adapter"
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module JsonbAccessor
3
4
  module Macro
4
5
  module ClassMethods
@@ -76,12 +77,14 @@ module JsonbAccessor
76
77
 
77
78
  # Makes sure new objects have the appropriate values in their jsonb fields.
78
79
  after_initialize do
79
- jsonb_values = public_send(jsonb_attribute) || {}
80
- jsonb_values.each do |store_key, value|
81
- name = names_and_store_keys.key(store_key)
82
- write_attribute(name, value) if name
80
+ if has_attribute?(jsonb_attribute)
81
+ jsonb_values = public_send(jsonb_attribute) || {}
82
+ jsonb_values.each do |store_key, value|
83
+ name = names_and_store_keys.key(store_key)
84
+ write_attribute(name, value) if name
85
+ end
86
+ clear_changes_information if persisted?
83
87
  end
84
- clear_changes_information if persisted?
85
88
  end
86
89
 
87
90
  # <jsonb_attribute>_where scope
@@ -95,6 +98,12 @@ module JsonbAccessor
95
98
  store_key_attributes = ::JsonbAccessor::QueryBuilder.convert_keys_to_store_keys(attributes, all.model.public_send(store_key_mapping_method_name))
96
99
  jsonb_where_not(jsonb_attribute, store_key_attributes)
97
100
  end)
101
+
102
+ # <jsonb_attribute>_order scope
103
+ scope("#{jsonb_attribute}_order", lambda do |attribute, direction = nil|
104
+ key = all.model.public_send(store_key_mapping_method_name)[attribute.to_s]
105
+ jsonb_order(jsonb_attribute, key, direction || :asc)
106
+ end)
98
107
  end
99
108
  end
100
109
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module JsonbAccessor
3
4
  GREATER_THAN = ">"
4
5
  GREATER_THAN_OR_EQUAL_TO = ">="
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module JsonbAccessor
3
- VERSION = "1.0.0.beta.4"
4
+ VERSION = "1.0.0.beta.5"
4
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonb_accessor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta.4
4
+ version: 1.0.0.beta.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Crismali
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2017-04-28 00:00:00.000000000 Z
13
+ date: 2017-05-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -72,16 +72,16 @@ dependencies:
72
72
  name: database_cleaner
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ">="
75
+ - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: '0'
77
+ version: 1.5.3
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - ">="
82
+ - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: '0'
84
+ version: 1.5.3
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: awesome_print
87
87
  requirement: !ruby/object:Gem::Requirement
@@ -172,14 +172,14 @@ dependencies:
172
172
  requirements:
173
173
  - - "~>"
174
174
  - !ruby/object:Gem::Version
175
- version: '0.31'
175
+ version: 0.48.1
176
176
  type: :development
177
177
  prerelease: false
178
178
  version_requirements: !ruby/object:Gem::Requirement
179
179
  requirements:
180
180
  - - "~>"
181
181
  - !ruby/object:Gem::Version
182
- version: '0.31'
182
+ version: 0.48.1
183
183
  - !ruby/object:Gem::Dependency
184
184
  name: shoulda-matchers
185
185
  requirement: !ruby/object:Gem::Requirement
@@ -210,7 +210,7 @@ dependencies:
210
210
  version: '0'
211
211
  description: Adds typed jsonb backed fields to your ActiveRecord models.
212
212
  email:
213
- - michael.crismali@gmail.com
213
+ - michael@crismali.com
214
214
  - joe@devmynd.com
215
215
  - jason@haruska.com
216
216
  executables: []
@@ -236,6 +236,8 @@ files:
236
236
  - db/schema.rb
237
237
  - gemfiles/activerecord_5.0.0.gemfile
238
238
  - gemfiles/activerecord_5.0.0.gemfile.lock
239
+ - gemfiles/activerecord_5.1.0.gemfile
240
+ - gemfiles/activerecord_5.1.0.gemfile.lock
239
241
  - jsonb_accessor.gemspec
240
242
  - lib/jsonb_accessor.rb
241
243
  - lib/jsonb_accessor/macro.rb