superstore 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +7 -17
- data/CHANGELOG.md +8 -0
- data/Gemfile +1 -1
- data/Gemfile-rails4.2 +11 -0
- data/README.md +20 -19
- data/lib/superstore/adapters/abstract_adapter.rb +1 -0
- data/lib/superstore/associations.rb +4 -0
- data/lib/superstore/attribute_methods.rb +13 -2
- data/lib/superstore/scope/query_methods.rb +1 -1
- data/superstore.gemspec +5 -5
- data/test/test_helper.rb +3 -7
- data/test/unit/attribute_methods/dirty_test.rb +0 -1
- data/test/unit/attribute_methods_test.rb +6 -6
- data/test/unit/inspect_test.rb +3 -3
- data/test/unit/persistence_test.rb +2 -2
- data/test/unit/scope/finder_methods_test.rb +1 -1
- data/test/unit/scope/query_methods_test.rb +1 -1
- data/test/unit/types/integer_type_test.rb +3 -3
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5684a72108f25316fd6cfc5b187f1f637cf86ed6
|
4
|
+
data.tar.gz: 8ec22cebf483751984796e2b5ab9f6f4ca312ffe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c6e4a89c79f90fa7c79eba4fdf42fbf10fba8c85a92a23643dd6bbb717ff30d90983a399202fb7889a6399bf393a426fe01a87dde9d9a64404269e21b860f46
|
7
|
+
data.tar.gz: 0cd0147c2951aae69c0e340c91d91da881a5c19ce2402fbaefb460316b946f735d2a0765c63780d72d5d77bf02bb9e20c287220709fbc956a09964da8ad8189e
|
data/.gitignore
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
Gemfile
|
1
|
+
Gemfile*.lock
|
2
2
|
*.gem
|
data/.travis.yml
CHANGED
@@ -1,23 +1,13 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.1.10
|
4
|
-
- 2.2.5
|
5
3
|
- 2.3.1
|
6
4
|
sudo: required
|
7
5
|
dist: trusty
|
8
6
|
cache: bundler
|
9
|
-
|
10
|
-
|
11
|
-
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
-
|
16
|
-
- for version in 9.1 9.2 9.3 9.4; do sudo pg_dropcluster --stop $version main; done
|
17
|
-
- sudo apt-get remove --purge --yes postgresql-9.[1234]
|
18
|
-
- sudo apt-get install --no-install-recommends --yes postgresql-client-9.5 postgresql-9.5
|
19
|
-
- sudo apt-get autoremove --yes
|
20
|
-
- sudo cp /tmp/pg_hba.conf /etc/postgresql/9.5/main/
|
21
|
-
- sudo service postgresql restart
|
22
|
-
- sudo -u postgres createuser -s travis
|
23
|
-
- sudo -u postgres createdb -O travis travis
|
7
|
+
gemfile:
|
8
|
+
- Gemfile
|
9
|
+
- Gemfile-rails4.2
|
10
|
+
addons:
|
11
|
+
postgresql: 9.5
|
12
|
+
services:
|
13
|
+
- postgresql
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile-rails4.2
ADDED
data/README.md
CHANGED
@@ -1,15 +1,33 @@
|
|
1
1
|
# Superstore
|
2
|
-
[](http://travis-ci.org/data-axle/superstore)
|
2
|
+
[](http://travis-ci.org/data-axle/superstore)
|
3
|
+
[](https://codeclimate.com/github/data-axle/superstore)
|
4
|
+
[](https://rubygems.org/gems/superstore)
|
3
5
|
|
4
|
-
Superstore uses ActiveModel to mimic much of the behavior
|
6
|
+
Superstore is a PostgreSQL JSONB document store which uses ActiveModel to mimic much of the behavior
|
7
|
+
in ActiveRecord.
|
8
|
+
|
9
|
+
## Requirements
|
10
|
+
|
11
|
+
Superstore requires PostgreSQL 9.5 or above.
|
5
12
|
|
6
13
|
## Installation
|
7
14
|
|
8
15
|
Add the following to the `Gemfile`:
|
16
|
+
|
9
17
|
```ruby
|
18
|
+
gem 'pg'
|
10
19
|
gem 'superstore'
|
11
20
|
```
|
12
21
|
|
22
|
+
Add a `config/superstore.yml`:
|
23
|
+
|
24
|
+
```yaml
|
25
|
+
development:
|
26
|
+
adapter: jsonb
|
27
|
+
```
|
28
|
+
|
29
|
+
Superstore will share the existing ActiveRecord database connection.
|
30
|
+
|
13
31
|
## Defining Models
|
14
32
|
|
15
33
|
```ruby
|
@@ -36,23 +54,6 @@ class MyWidget < Superstore::Base
|
|
36
54
|
end
|
37
55
|
```
|
38
56
|
|
39
|
-
## Using the PostgreSQL JSONB adapter
|
40
|
-
|
41
|
-
Add the `pg` gem to the `Gemfile`:
|
42
|
-
|
43
|
-
```ruby
|
44
|
-
gem 'pg'
|
45
|
-
```
|
46
|
-
|
47
|
-
Add a `config/superstore.yml`:
|
48
|
-
|
49
|
-
```yaml
|
50
|
-
development:
|
51
|
-
adapter: jsonb
|
52
|
-
```
|
53
|
-
|
54
|
-
Superstore will share the existing ActiveRecord database connection.
|
55
|
-
|
56
57
|
## Creating and updating records
|
57
58
|
|
58
59
|
Superstore has equivalent methods to ActiveRecord:
|
@@ -37,6 +37,10 @@ module Superstore
|
|
37
37
|
def dangerous_attribute_method?(name)
|
38
38
|
false
|
39
39
|
end
|
40
|
+
|
41
|
+
def has_attribute?(attr_name)
|
42
|
+
attribute_definitions.key?(attr_name.to_s)
|
43
|
+
end
|
40
44
|
end
|
41
45
|
|
42
46
|
def write_attribute(name, value)
|
@@ -59,9 +63,10 @@ module Superstore
|
|
59
63
|
!value.nil? && !(value.respond_to?(:empty?) && value.empty?)
|
60
64
|
end
|
61
65
|
|
62
|
-
def
|
66
|
+
def has_attribute?(name)
|
63
67
|
@attributes.key?(name.to_s)
|
64
68
|
end
|
69
|
+
alias_method :attribute_exists?, :has_attribute?
|
65
70
|
|
66
71
|
def attributes
|
67
72
|
results = {}
|
@@ -80,7 +85,13 @@ module Superstore
|
|
80
85
|
def method_missing(method_id, *args, &block)
|
81
86
|
self.class.define_attribute_methods unless self.class.attribute_methods_generated?
|
82
87
|
|
83
|
-
match =
|
88
|
+
match = if ActiveRecord.version >= Gem::Version.new('5.0')
|
89
|
+
# Active Record 5.0
|
90
|
+
matched_attribute_method(method_id.to_s)
|
91
|
+
else
|
92
|
+
# Active Record 4.2
|
93
|
+
match_attribute_method?(method_id.to_s)
|
94
|
+
end
|
84
95
|
match ? attribute_missing(match, *args, &block) : super
|
85
96
|
end
|
86
97
|
|
data/superstore.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'superstore'
|
5
|
-
s.version = '2.
|
6
|
-
s.description = 'ActiveModel
|
7
|
-
s.summary = 'JSONB
|
8
|
-
s.authors = [
|
5
|
+
s.version = '2.4.0'
|
6
|
+
s.description = 'ActiveModel-based JSONB document store'
|
7
|
+
s.summary = 'ActiveModel for JSONB documents'
|
8
|
+
s.authors = ['Michael Koziarski', 'Infogroup']
|
9
9
|
s.email = 'developer@matthewhiggins.com'
|
10
10
|
s.homepage = 'http://github.com/data-axle/superstore'
|
11
11
|
|
12
12
|
s.required_ruby_version = '>= 2.0.0'
|
13
13
|
s.required_rubygems_version = '>= 1.3.5'
|
14
14
|
|
15
|
-
s.extra_rdoc_files = [
|
15
|
+
s.extra_rdoc_files = ['README.md']
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test}/*`.split("\n")
|
18
18
|
s.require_paths = ['lib']
|
data/test/test_helper.rb
CHANGED
@@ -1,22 +1,18 @@
|
|
1
|
-
require '
|
2
|
-
Bundler.require(:default, :test)
|
1
|
+
require 'rails'
|
3
2
|
|
4
3
|
I18n.config.enforce_available_locales = false
|
4
|
+
ActiveSupport::TestCase.test_order = :random
|
5
5
|
|
6
6
|
require 'active_record'
|
7
7
|
require 'rails/test_help'
|
8
8
|
require 'mocha/setup'
|
9
9
|
|
10
|
-
|
10
|
+
require 'superstore'
|
11
11
|
|
12
12
|
require 'support/pg'
|
13
13
|
require 'support/jsonb'
|
14
14
|
require 'support/models'
|
15
15
|
|
16
|
-
def MiniTest.filter_backtrace(bt)
|
17
|
-
bt
|
18
|
-
end
|
19
|
-
|
20
16
|
module Superstore
|
21
17
|
class TestCase < ActiveSupport::TestCase
|
22
18
|
def temp_object(&block)
|
@@ -56,10 +56,10 @@ class Superstore::AttributeMethodsTest < Superstore::TestCase
|
|
56
56
|
assert_equal 'hello', r.system
|
57
57
|
end
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
test 'has_attribute?' do
|
60
|
+
refute Issue.new.attribute_exists?(:description)
|
61
|
+
assert Issue.new(description: nil).has_attribute?(:description)
|
62
|
+
assert Issue.new(description: false).has_attribute?(:description)
|
63
|
+
assert Issue.new(description: 'hey').has_attribute?(:description)
|
64
|
+
end
|
65
65
|
end
|
data/test/unit/inspect_test.rb
CHANGED
@@ -19,8 +19,8 @@ class Superstore::InspectTest < Superstore::TestCase
|
|
19
19
|
integer :price
|
20
20
|
end.new(description: "yeah buddy", price: nil)
|
21
21
|
|
22
|
-
assert_match
|
23
|
-
assert_match
|
24
|
-
assert_no_match
|
22
|
+
assert_match(/id/, object.inspect)
|
23
|
+
assert_match(/description/, object.inspect)
|
24
|
+
assert_no_match(/price/, object.inspect)
|
25
25
|
end
|
26
26
|
end
|
@@ -43,8 +43,8 @@ class Superstore::PersistenceTest < Superstore::TestCase
|
|
43
43
|
end
|
44
44
|
|
45
45
|
assert !Issue.batching?
|
46
|
-
assert_nothing_raised
|
47
|
-
assert_nothing_raised
|
46
|
+
assert_nothing_raised { Issue.find(first_issue.id) }
|
47
|
+
assert_nothing_raised { Issue.find(second_issue.id) }
|
48
48
|
end
|
49
49
|
|
50
50
|
test 'persistence inquiries' do
|
@@ -21,7 +21,7 @@ class Superstore::FinderMethodsTest < Superstore::TestCase
|
|
21
21
|
test 'find with ids' do
|
22
22
|
first_issue = Issue.create
|
23
23
|
second_issue = Issue.create
|
24
|
-
|
24
|
+
Issue.create
|
25
25
|
|
26
26
|
assert_equal [], Issue.find([])
|
27
27
|
assert_equal [first_issue, second_issue], Issue.find([first_issue.id, second_issue.id])
|
@@ -22,7 +22,7 @@ class Superstore::Scope::QueryMethodsTest < Superstore::TestCase
|
|
22
22
|
|
23
23
|
test "select with block" do
|
24
24
|
foo_issue = Issue.create title: 'foo'
|
25
|
-
|
25
|
+
Issue.create title: 'bar'
|
26
26
|
|
27
27
|
assert_equal [foo_issue], Issue.select { |issue| issue.title == 'foo' }
|
28
28
|
end
|
@@ -14,8 +14,8 @@ class Superstore::Types::IntegerTypeTest < Superstore::Types::TestCase
|
|
14
14
|
|
15
15
|
test 'decode' do
|
16
16
|
assert_nil type.decode('')
|
17
|
-
assert_equal
|
18
|
-
assert_equal
|
19
|
-
assert_equal
|
17
|
+
assert_equal(0, type.decode('abc'))
|
18
|
+
assert_equal(3, type.decode('3'))
|
19
|
+
assert_equal(-3, type.decode('-3'))
|
20
20
|
end
|
21
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superstore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Koziarski
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
|
-
description: ActiveModel
|
70
|
+
description: ActiveModel-based JSONB document store
|
71
71
|
email: developer@matthewhiggins.com
|
72
72
|
executables: []
|
73
73
|
extensions: []
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- ".travis.yml"
|
79
79
|
- CHANGELOG.md
|
80
80
|
- Gemfile
|
81
|
+
- Gemfile-rails4.2
|
81
82
|
- LICENSE
|
82
83
|
- MIT-LICENSE
|
83
84
|
- README.md
|
@@ -193,5 +194,5 @@ rubyforge_project:
|
|
193
194
|
rubygems_version: 2.5.1
|
194
195
|
signing_key:
|
195
196
|
specification_version: 4
|
196
|
-
summary: JSONB
|
197
|
+
summary: ActiveModel for JSONB documents
|
197
198
|
test_files: []
|