superstore 2.3.0 → 2.4.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: efa28ad8771bdcf6a918cf33a4d81f3e6945581a
4
- data.tar.gz: 732be1d35bf085bc141c1772d7beef1e1655f397
3
+ metadata.gz: 5684a72108f25316fd6cfc5b187f1f637cf86ed6
4
+ data.tar.gz: 8ec22cebf483751984796e2b5ab9f6f4ca312ffe
5
5
  SHA512:
6
- metadata.gz: c8f18bbcabe090e89e0ff5a19058689b7e2002488be9332c666e62cc556e78a58573918e27081c48f13eb9ed30c26a60cab90d6c39abe0f0e2522f6e90770786
7
- data.tar.gz: bfc9b5f6637f4955ad45753f0a2996be1f5892aba8ac15646ee9deb4194237b2300c1d57ef42c22e310f8e6e261aedc7c75bcdca58fc40a5fad36395a0f2c0da
6
+ metadata.gz: 5c6e4a89c79f90fa7c79eba4fdf42fbf10fba8c85a92a23643dd6bbb717ff30d90983a399202fb7889a6399bf393a426fe01a87dde9d9a64404269e21b860f46
7
+ data.tar.gz: 0cd0147c2951aae69c0e340c91d91da881a5c19ce2402fbaefb460316b946f735d2a0765c63780d72d5d77bf02bb9e20c287220709fbc956a09964da8ad8189e
data/.gitignore CHANGED
@@ -1,2 +1,2 @@
1
- Gemfile.lock
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
- before_install:
10
- # https://github.com/travis-ci/travis-ci/issues/4264
11
- - sudo cp /etc/postgresql/9.4/main/pg_hba.conf /tmp
12
- - sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg 9.5"
13
- - sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 7FCC7D46ACCC4CF8
14
- - sudo apt-get update
15
- - sudo service postgresql stop
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
@@ -1,3 +1,11 @@
1
+ # 2.3.0
2
+
3
+ Released 2016-06-29.
4
+
5
+ ## Changed
6
+
7
+ * Superstore requires PostgreSQL 9.5, since it uses the JSONB operators introduced in that version.
8
+
1
9
  # 2.2.0
2
10
 
3
11
  Released 2016-06-02.
data/Gemfile CHANGED
@@ -6,6 +6,6 @@ gem 'rake'
6
6
  group :test do
7
7
  gem 'rails'
8
8
  gem 'pg'
9
- gem 'activerecord', '~> 4.2.0'
9
+ gem 'activerecord', '~> 5.0.0'
10
10
  gem 'mocha', require: false
11
11
  end
data/Gemfile-rails4.2 ADDED
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+ gemspec
3
+
4
+ gem 'rake'
5
+
6
+ group :test do
7
+ gem 'rails'
8
+ gem 'pg'
9
+ gem 'activerecord', '~> 4.2.0'
10
+ gem 'mocha', require: false
11
+ end
data/README.md CHANGED
@@ -1,15 +1,33 @@
1
1
  # Superstore
2
- [![Build Status](https://secure.travis-ci.org/data-axle/superstore.png?rvm=2.0.0)](http://travis-ci.org/data-axle/superstore) [![Code Climate](https://codeclimate.com/github/data-axle/superstore/badges/gpa.svg)](https://codeclimate.com/github/data-axle/superstore)
2
+ [![Build Status](https://secure.travis-ci.org/data-axle/superstore.png?rvm=2.0.0)](http://travis-ci.org/data-axle/superstore)
3
+ [![Code Climate](https://codeclimate.com/github/data-axle/superstore/badges/gpa.svg)](https://codeclimate.com/github/data-axle/superstore)
4
+ [![Gem](https://img.shields.io/gem/v/superstore.svg?maxAge=2592000)](https://rubygems.org/gems/superstore)
3
5
 
4
- Superstore uses ActiveModel to mimic much of the behavior in ActiveRecord.
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:
@@ -4,6 +4,7 @@ module Superstore
4
4
  attr_reader :config
5
5
  def initialize(config)
6
6
  @config = config
7
+ @batch_statements = nil
7
8
  end
8
9
 
9
10
  # Read records from a instance of Superstore::Scope
@@ -36,6 +36,10 @@ module Superstore
36
36
  super
37
37
  end
38
38
  end
39
+
40
+ def belongs_to_required_by_default
41
+ false
42
+ end
39
43
  end
40
44
 
41
45
  end
@@ -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 attribute_exists?(name)
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 = match_attribute_method?(method_id.to_s)
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
 
@@ -9,7 +9,7 @@ module Superstore
9
9
  if block_given?
10
10
  to_a.select(&block)
11
11
  else
12
- clone.select! *values
12
+ clone.select!(*values)
13
13
  end
14
14
  end
15
15
 
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.3.0'
6
- s.description = 'ActiveModel for many attributes'
7
- s.summary = 'JSONB ActiveModel'
8
- s.authors = ["Michael Koziarski", "Infogroup"]
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 = ["README.md"]
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 'bundler/setup'
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
- ActiveSupport::TestCase.test_order = :random
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)
@@ -91,7 +91,6 @@ class Superstore::AttributeMethods::DirtyTest < Superstore::TestCase
91
91
  assert_equal({}, record.changes)
92
92
 
93
93
  record.name = 'bar'
94
- expected = {'name'=>[nil, 'foo']}
95
94
  assert_equal({'name' => ['foo', 'bar']}, record.changes)
96
95
 
97
96
  record.name = 'foo'
@@ -56,10 +56,10 @@ class Superstore::AttributeMethodsTest < Superstore::TestCase
56
56
  assert_equal 'hello', r.system
57
57
  end
58
58
 
59
- # test 'attribute_exists' do
60
- # assert !Issue.new.attribute_exists?(:description)
61
- # assert Issue.new(description: nil).attribute_exists?(:description)
62
- # assert Issue.new(description: false).attribute_exists?(:description)
63
- # assert Issue.new(description: 'hey').attribute_exists?(:description)
64
- # end
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
@@ -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 /id/, object.inspect
23
- assert_match /description/, object.inspect
24
- assert_no_match /price/, object.inspect
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(Superstore::RecordNotFound) { Issue.find(first_issue.id) }
47
- assert_nothing_raised(Superstore::RecordNotFound) { Issue.find(second_issue.id) }
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
- third_issue = Issue.create
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
- bar_issue = Issue.create title: 'bar'
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 0, type.decode('abc')
18
- assert_equal 3, type.decode('3')
19
- assert_equal -3, type.decode('-3')
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.3.0
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-06-29 00:00:00.000000000 Z
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 for many attributes
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 ActiveModel
197
+ summary: ActiveModel for JSONB documents
197
198
  test_files: []