store_attribute 0.5.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +35 -0
- data/{MIT-LICENSE → LICENSE.txt} +1 -1
- data/README.md +19 -13
- data/lib/store_attribute.rb +4 -2
- data/lib/store_attribute/active_record.rb +3 -1
- data/lib/store_attribute/active_record/store.rb +121 -16
- data/lib/store_attribute/active_record/type/typed_store.rb +41 -19
- data/lib/store_attribute/version.rb +3 -1
- metadata +32 -45
- data/.gitignore +0 -37
- data/.rspec +0 -1
- data/.rubocop.yml +0 -51
- data/.travis.yml +0 -19
- data/Gemfile +0 -11
- data/Rakefile +0 -6
- data/bench/bench.rb +0 -38
- data/bench/setup.rb +0 -67
- data/bin/console +0 -7
- data/bin/setup +0 -8
- data/gemfiles/rails5.gemfile +0 -5
- data/gemfiles/railsmaster.rb +0 -6
- data/spec/cases/store_attribute_spec.rb +0 -171
- data/spec/spec_helper.rb +0 -43
- data/spec/store_attribute/typed_store_spec.rb +0 -107
- data/spec/support/money_type.rb +0 -12
- data/spec/support/user.rb +0 -17
- data/store_attribute.gemspec +0 -27
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: store_attribute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- palkan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '5.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pg
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0.18'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.18'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rubocop-md
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.3
|
61
|
+
version: '0.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.3
|
68
|
+
version: '0.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: standard
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 0.2.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 0.2.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 3.5.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 3.5.0
|
97
97
|
description: ActiveRecord extension which adds typecasting to store accessors
|
@@ -101,35 +101,23 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
-
|
105
|
-
-
|
106
|
-
- ".rubocop.yml"
|
107
|
-
- ".travis.yml"
|
108
|
-
- Gemfile
|
109
|
-
- MIT-LICENSE
|
104
|
+
- CHANGELOG.md
|
105
|
+
- LICENSE.txt
|
110
106
|
- README.md
|
111
|
-
- Rakefile
|
112
|
-
- bench/bench.rb
|
113
|
-
- bench/setup.rb
|
114
|
-
- bin/console
|
115
|
-
- bin/setup
|
116
|
-
- gemfiles/rails5.gemfile
|
117
|
-
- gemfiles/railsmaster.rb
|
118
107
|
- lib/store_attribute.rb
|
119
108
|
- lib/store_attribute/active_record.rb
|
120
109
|
- lib/store_attribute/active_record/store.rb
|
121
110
|
- lib/store_attribute/active_record/type/typed_store.rb
|
122
111
|
- lib/store_attribute/version.rb
|
123
|
-
- spec/cases/store_attribute_spec.rb
|
124
|
-
- spec/spec_helper.rb
|
125
|
-
- spec/store_attribute/typed_store_spec.rb
|
126
|
-
- spec/support/money_type.rb
|
127
|
-
- spec/support/user.rb
|
128
|
-
- store_attribute.gemspec
|
129
112
|
homepage: http://github.com/palkan/store_attribute
|
130
113
|
licenses:
|
131
114
|
- MIT
|
132
|
-
metadata:
|
115
|
+
metadata:
|
116
|
+
bug_tracker_uri: http://github.com/palkan/store_attribute/issues
|
117
|
+
changelog_uri: https://github.com/palkan/store_attribute/blob/master/CHANGELOG.md
|
118
|
+
documentation_uri: http://github.com/palkan/store_attribute
|
119
|
+
homepage_uri: http://github.com/palkan/store_attribute
|
120
|
+
source_code_uri: http://github.com/palkan/store_attribute
|
133
121
|
post_install_message:
|
134
122
|
rdoc_options: []
|
135
123
|
require_paths:
|
@@ -138,15 +126,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
126
|
requirements:
|
139
127
|
- - ">="
|
140
128
|
- !ruby/object:Gem::Version
|
141
|
-
version:
|
129
|
+
version: 2.4.0
|
142
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
131
|
requirements:
|
144
132
|
- - ">="
|
145
133
|
- !ruby/object:Gem::Version
|
146
134
|
version: '0'
|
147
135
|
requirements: []
|
148
|
-
|
149
|
-
rubygems_version: 2.6.13
|
136
|
+
rubygems_version: 3.0.6
|
150
137
|
signing_key:
|
151
138
|
specification_version: 4
|
152
139
|
summary: ActiveRecord extension which adds typecasting to store accessors
|
data/.gitignore
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# Numerous always-ignore extensions
|
2
|
-
*.diff
|
3
|
-
*.err
|
4
|
-
*.orig
|
5
|
-
*.log
|
6
|
-
*.rej
|
7
|
-
*.swo
|
8
|
-
*.swp
|
9
|
-
*.vi
|
10
|
-
*~
|
11
|
-
*.sass-cache
|
12
|
-
*.iml
|
13
|
-
.idea/
|
14
|
-
|
15
|
-
# Sublime
|
16
|
-
*.sublime-project
|
17
|
-
*.sublime-workspace
|
18
|
-
|
19
|
-
# OS or Editor folders
|
20
|
-
.DS_Store
|
21
|
-
.cache
|
22
|
-
.project
|
23
|
-
.settings
|
24
|
-
.tmproj
|
25
|
-
Thumbs.db
|
26
|
-
coverage/
|
27
|
-
|
28
|
-
.bundle/
|
29
|
-
*.log
|
30
|
-
*.gem
|
31
|
-
pkg/
|
32
|
-
spec/dummy/log/*.log
|
33
|
-
spec/dummy/tmp/
|
34
|
-
spec/dummy/.sass-cache
|
35
|
-
Gemfile.local
|
36
|
-
Gemfile.lock
|
37
|
-
tmp/
|
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/.rubocop.yml
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
# Include gemspec and Rakefile
|
3
|
-
Include:
|
4
|
-
- 'lib/**/*.rb'
|
5
|
-
- 'lib/**/*.rake'
|
6
|
-
- 'spec/**/*.rb'
|
7
|
-
Exclude:
|
8
|
-
- 'bin/**/*'
|
9
|
-
- 'spec/dummy/**/*'
|
10
|
-
- 'tmp/**/*'
|
11
|
-
- 'bench/**/*'
|
12
|
-
DisplayCopNames: true
|
13
|
-
StyleGuideCopsOnly: false
|
14
|
-
|
15
|
-
Style/AccessorMethodName:
|
16
|
-
Enabled: false
|
17
|
-
|
18
|
-
Style/TrivialAccessors:
|
19
|
-
Enabled: false
|
20
|
-
|
21
|
-
Style/Documentation:
|
22
|
-
Exclude:
|
23
|
-
- 'spec/**/*.rb'
|
24
|
-
|
25
|
-
Style/StringLiterals:
|
26
|
-
Enabled: false
|
27
|
-
|
28
|
-
Style/SpaceInsideStringInterpolation:
|
29
|
-
EnforcedStyle: no_space
|
30
|
-
|
31
|
-
Style/BlockDelimiters:
|
32
|
-
Exclude:
|
33
|
-
- 'spec/**/*.rb'
|
34
|
-
|
35
|
-
Lint/AmbiguousRegexpLiteral:
|
36
|
-
Enabled: false
|
37
|
-
|
38
|
-
Metrics/MethodLength:
|
39
|
-
Exclude:
|
40
|
-
- 'spec/**/*.rb'
|
41
|
-
|
42
|
-
Metrics/LineLength:
|
43
|
-
Max: 100
|
44
|
-
Exclude:
|
45
|
-
- 'spec/**/*.rb'
|
46
|
-
|
47
|
-
Rails/Date:
|
48
|
-
Enabled: false
|
49
|
-
|
50
|
-
Rails/TimeZone:
|
51
|
-
Enabled: false
|
data/.travis.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
|
4
|
-
addons:
|
5
|
-
postgresql: "9.4"
|
6
|
-
|
7
|
-
before_script:
|
8
|
-
- createdb store_attribute_test
|
9
|
-
- psql -U postgres -d store_attribute_test -c 'CREATE EXTENSION IF NOT EXISTS hstore;'
|
10
|
-
|
11
|
-
matrix:
|
12
|
-
include:
|
13
|
-
- rvm: 2.4.1
|
14
|
-
gemfile: gemfiles/rails5.gemfile
|
15
|
-
- rvm: ruby-head
|
16
|
-
gemfile: gemfiles/railsmaster.gemfile
|
17
|
-
allow_failures:
|
18
|
-
- rvm: ruby-head
|
19
|
-
gemfile: gemfiles/railsmaster.gemfile
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/bench/bench.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'benchmark/ips'
|
2
|
-
require './setup'
|
3
|
-
|
4
|
-
Benchmark.ips do |x|
|
5
|
-
x.report('SA initialize') do
|
6
|
-
User.new(public: '1', published_at: '2016-01-01', age: '23')
|
7
|
-
end
|
8
|
-
|
9
|
-
x.report('AR-T initialize') do
|
10
|
-
Looser.new(public: '1', published_at: '2016-01-01', age: '23')
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
Benchmark.ips do |x|
|
15
|
-
x.report('SA accessors') do
|
16
|
-
u = User.new
|
17
|
-
u.public = '1'
|
18
|
-
u.published_at = '2016-01-01'
|
19
|
-
u.age = '23'
|
20
|
-
end
|
21
|
-
|
22
|
-
x.report('AR-T accessors') do
|
23
|
-
u = Looser.new
|
24
|
-
u.public = '1'
|
25
|
-
u.published_at = '2016-01-01'
|
26
|
-
u.age = '23'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
Benchmark.ips do |x|
|
31
|
-
x.report('SA create') do
|
32
|
-
User.create!(public: '1', published_at: '2016-01-01', age: '23')
|
33
|
-
end
|
34
|
-
|
35
|
-
x.report('AR-T create') do
|
36
|
-
Looser.create(public: '1', published_at: '2016-01-01', age: '23')
|
37
|
-
end
|
38
|
-
end
|
data/bench/setup.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'bundler/inline'
|
3
|
-
rescue LoadError => e
|
4
|
-
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
|
5
|
-
raise e
|
6
|
-
end
|
7
|
-
|
8
|
-
gemfile(true) do
|
9
|
-
source 'https://rubygems.org'
|
10
|
-
gem 'activerecord', '~>4.2'
|
11
|
-
gem 'pg'
|
12
|
-
gem 'activerecord-typedstore', require: false
|
13
|
-
gem 'pry-byebug'
|
14
|
-
gem 'benchmark-ips'
|
15
|
-
gem 'memory_profiler'
|
16
|
-
end
|
17
|
-
|
18
|
-
DB_NAME = ENV['DB_NAME'] || 'sa_bench'
|
19
|
-
|
20
|
-
begin
|
21
|
-
system("createdb #{DB_NAME}")
|
22
|
-
rescue
|
23
|
-
$stdout.puts "DB already exists"
|
24
|
-
end
|
25
|
-
|
26
|
-
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
27
|
-
|
28
|
-
require 'active_record'
|
29
|
-
require 'logger'
|
30
|
-
require 'store_attribute'
|
31
|
-
require 'activerecord-typedstore'
|
32
|
-
|
33
|
-
ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: DB_NAME)
|
34
|
-
|
35
|
-
at_exit do
|
36
|
-
ActiveRecord::Base.connection.disconnect!
|
37
|
-
end
|
38
|
-
|
39
|
-
module Bench
|
40
|
-
module_function
|
41
|
-
def setup_db
|
42
|
-
ActiveRecord::Schema.define do
|
43
|
-
create_table :users, force: true do |t|
|
44
|
-
t.jsonb :data
|
45
|
-
end
|
46
|
-
|
47
|
-
create_table :loosers, force: true do |t|
|
48
|
-
t.jsonb :data
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class User < ActiveRecord::Base
|
55
|
-
store_accessor :data, public: :boolean, published_at: :datetime, age: :integer
|
56
|
-
end
|
57
|
-
|
58
|
-
class Looser < ActiveRecord::Base
|
59
|
-
typed_store :data, coder: JSON do |s|
|
60
|
-
s.boolean :public
|
61
|
-
s.datetime :published_at
|
62
|
-
s.integer :age
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# Run migration only if neccessary
|
67
|
-
Bench.setup_db if ENV['FORCE'].present? || !ActiveRecord::Base.connection.tables.include?('users')
|
data/bin/console
DELETED