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 +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +1 -0
- data/Appraisals +7 -0
- data/Gemfile +4 -2
- data/README.md +1 -1
- data/Rakefile +2 -1
- data/bin/console +1 -0
- data/db/schema.rb +12 -12
- data/gemfiles/activerecord_5.0.0.gemfile +2 -1
- data/gemfiles/activerecord_5.0.0.gemfile.lock +7 -6
- data/gemfiles/activerecord_5.1.0.gemfile +9 -0
- data/gemfiles/activerecord_5.1.0.gemfile.lock +141 -0
- data/jsonb_accessor.gemspec +8 -6
- data/lib/jsonb_accessor.rb +1 -0
- data/lib/jsonb_accessor/macro.rb +14 -5
- data/lib/jsonb_accessor/query_builder.rb +1 -0
- data/lib/jsonb_accessor/version.rb +2 -1
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a66f5adf90e5c66c0cacb04698102c37fbd69b27
|
4
|
+
data.tar.gz: dcee9f04338256069b16e0078bbd21ee34264b7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb1b146937ec6624866dc4f8594d25889eb9fd7a92de1610242048e6c5488050b0be7cbe8e9f2f887a07ed45eeb97308071c3889023eb2a3074f8e01928c91a6
|
7
|
+
data.tar.gz: f8d8fad1f5adea8b6d71b8512991a838f4a8dde52c4b9ca83b03facfab2d00f946d3a2a9e402c18d0f3f44bc2de53fa624e57e2531e2fe1b095c2766561c2ed6
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/Appraisals
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
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: [
|
14
|
+
task(default: %i[rubocop spec])
|
data/bin/console
CHANGED
data/db/schema.rb
CHANGED
@@ -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
|
24
|
-
t.jsonb
|
25
|
-
t.string
|
26
|
-
t.integer
|
27
|
-
t.integer
|
28
|
-
t.boolean
|
29
|
-
t.float
|
30
|
-
t.time
|
31
|
-
t.date
|
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
|
33
|
+
t.decimal "decimal_type"
|
34
34
|
end
|
35
35
|
|
36
36
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
jsonb_accessor (1.0.0.beta.
|
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.
|
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.
|
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
|
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.
|
136
|
+
rubocop (~> 0.48.1)
|
136
137
|
shoulda-matchers
|
137
138
|
standalone_migrations
|
138
139
|
|
@@ -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
|
data/jsonb_accessor.gemspec
CHANGED
@@ -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
|
12
|
+
spec.email = ["michael@crismali.com", "joe@devmynd.com", "jason@haruska.com"]
|
11
13
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
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(
|
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.
|
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
|
data/lib/jsonb_accessor.rb
CHANGED
data/lib/jsonb_accessor/macro.rb
CHANGED
@@ -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
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
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
|
+
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-
|
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:
|
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:
|
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:
|
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:
|
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
|
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
|