lookup_by 0.11.1 → 0.11.2

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: ecd1d5a836f7058b70e524c02a5ae22072ddcacf
4
- data.tar.gz: 2cbc2fd59837ca832f04e17f20bdcf13326e2f8b
3
+ metadata.gz: 06bc3fdda0734392ba779759569af73b4321cb8e
4
+ data.tar.gz: 19cf6cf802813d5c6b7dbb3c741b26ae044d7f41
5
5
  SHA512:
6
- metadata.gz: 79b99b92afb52b979310de7202dec4ec171a21541606144fc36349c65db1a33b58afa1f870dff45dd61df51bff76cdc512f76ee5685742bb65281834b26e4587
7
- data.tar.gz: 34468ee2bd864940cdd7e63cbc17a020a91f5afdfa6c561330e84092cd3239f34d43e19b614edd3503c53fab304aca43b66dead993a1ffe27ef78f86066fe895
6
+ metadata.gz: 4d556bd84dc5043e976db12c82717dbf51356a7e7f0117ebda196aa12fc6a3dd5d6df33ea5be4070be19b6bfcffbaf5a3f29765073d1f8b569238a7d78af6ef1
7
+ data.tar.gz: e33a6de43a703ee5d8b4570b70f606d594e86df6ff063f822e6f6a845f506de47fd616d5f1590e5600c3707862f7c18ee7982bed2dce018c44d54ffb05ef0fa2
data/Appraisals CHANGED
@@ -1,11 +1,27 @@
1
1
  appraise 'rails-4.1' do
2
2
  gem 'rails', '~> 4.1.0'
3
+
4
+ group :development, :test do
5
+ gem "pg", "~> 0.11", platform: :ruby
6
+ end
3
7
  end
4
8
 
5
9
  appraise 'rails-4.2' do
6
10
  gem 'rails', '~> 4.2.0'
11
+
12
+ group :development, :test do
13
+ gem "pg", "~> 0.11", platform: :ruby
14
+ end
7
15
  end
8
16
 
9
17
  appraise 'rails-5.0' do
10
18
  gem 'rails', '~> 5.0.0'
11
19
  end
20
+
21
+ appraise 'rails-5.1' do
22
+ gem 'rails', '~> 5.1.0'
23
+ end
24
+
25
+ appraise 'rails-5.2' do
26
+ gem 'rails', '~> 5.2.0'
27
+ end
@@ -0,0 +1,50 @@
1
+ ### [v0.11.2](https://github.com/companygardener/lookup_by/compare/v0.11.1...v0.11.2)
2
+
3
+ Merged a few PRs. Shouldn't break anything.
4
+
5
+ * Appraisal: add rails 5.1 and 5.2
6
+ * Appraisal: bundle update
7
+ * Fix: alias_method_chain was deprecated a long time ago
8
+ * Fix: clearing the cache will also clear the reverse lookup cache
9
+ * Dev: .ruby-version 2.6.1
10
+ * Doc: docs for :scope and :inverse_scope options on `lookup_for` method
11
+ * Doc: add changelog
12
+
13
+ ### [v0.11.1](https://github.com/companygardener/lookup_by/compare/v0.11.0...v0.11.1)
14
+
15
+ #### Fix .all on lookup models
16
+
17
+ Version 0.11.0 breaks Model.where(field: 'value').first_or_create! when
18
+ Model is configured with `lookup_by :field, cache: true`.
19
+
20
+ ### [v0.11.0](https://github.com/companygardener/lookup_by/compare/v0.10.9...v0.11.0)
21
+
22
+ #### Rails 5.0.0 support
23
+
24
+ Update .count signature to support Rails 5.
25
+
26
+ - Require ruby 2.2.2+
27
+ - PostgreSQL 9.2+
28
+ - Drop support for JRuby
29
+
30
+ #### Default to a threadsafe cache
31
+
32
+ ### [v0.10.9](https://github.com/companygardener/lookup_by/compare/v0.10.8...v0.10.9)
33
+
34
+ ### [v0.10.8](https://github.com/companygardener/lookup_by/compare/v0.10.7...v0.10.8)
35
+
36
+ ### [v0.10.7](https://github.com/companygardener/lookup_by/compare/v0.10.6...v0.10.7)
37
+
38
+ ### [v0.10.6](https://github.com/companygardener/lookup_by/compare/v0.10.5...v0.10.6)
39
+
40
+ ### [v0.10.5](https://github.com/companygardener/lookup_by/compare/v0.10.4...v0.10.5)
41
+
42
+ ### [v0.10.4](https://github.com/companygardener/lookup_by/compare/v0.10.3...v0.10.4)
43
+
44
+ ### [v0.10.3](https://github.com/companygardener/lookup_by/compare/v0.10.2...v0.10.3)
45
+
46
+ ### [v0.10.2](https://github.com/companygardener/lookup_by/compare/v0.10.1...v0.10.2)
47
+
48
+ ### [v0.10.1](https://github.com/companygardener/lookup_by/compare/v0.10.0...v0.10.1)
49
+
50
+ ### [v0.10.0](https://github.com/companygardener/lookup_by/compare/v0.9.1...v0.10.0)
data/README.md CHANGED
@@ -75,6 +75,11 @@ class ExampleObject < ActiveRecord::Base
75
75
  # Defines #status and #status= instance methods that transparently reference the lookup table.
76
76
  # Defines .with_status(*names) and .without_status(*names) scopes on the model.
77
77
  end
78
+
79
+ class Address < ActiveRecord::Base
80
+ # scopes can be renamed
81
+ lookup_for :city, scope: :inside_city, inverse_scope: :outside_city
82
+ end
78
83
  ```
79
84
 
80
85
  ### Define the lookup model
@@ -10,7 +10,7 @@ group :development, :test do
10
10
  gem "rspec"
11
11
  gem "rspec-its"
12
12
  gem "rspec-rails"
13
- gem "pg", :platform => :ruby
13
+ gem "pg", "~> 0.11", :platform => :ruby
14
14
  gem "simplecov", :require => false
15
15
  gem "coveralls", :require => false
16
16
  gem "pry", :require => false
@@ -10,7 +10,7 @@ group :development, :test do
10
10
  gem "rspec"
11
11
  gem "rspec-its"
12
12
  gem "rspec-rails"
13
- gem "pg", :platform => :ruby
13
+ gem "pg", "~> 0.11", :platform => :ruby
14
14
  gem "simplecov", :require => false
15
15
  gem "coveralls", :require => false
16
16
  gem "pry", :require => false
@@ -0,0 +1,22 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 5.1.0"
6
+
7
+ group :development, :test do
8
+ gem "appraisal", "~> 2.1.0", :require => false
9
+ gem "combustion"
10
+ gem "rspec"
11
+ gem "rspec-its"
12
+ gem "rspec-rails"
13
+ gem "pg", :platform => :ruby
14
+ gem "simplecov", :require => false
15
+ gem "coveralls", :require => false
16
+ gem "pry", :require => false
17
+ gem "colored", :require => false
18
+ gem "racc"
19
+ gem "json"
20
+ end
21
+
22
+ gemspec :path => "../"
@@ -0,0 +1,22 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 5.2.0"
6
+
7
+ group :development, :test do
8
+ gem "appraisal", "~> 2.1.0", :require => false
9
+ gem "combustion"
10
+ gem "rspec"
11
+ gem "rspec-its"
12
+ gem "rspec-rails"
13
+ gem "pg", :platform => :ruby
14
+ gem "simplecov", :require => false
15
+ gem "coveralls", :require => false
16
+ gem "pry", :require => false
17
+ gem "colored", :require => false
18
+ gem "racc"
19
+ gem "json"
20
+ end
21
+
22
+ gemspec :path => "../"
@@ -1,6 +1,6 @@
1
1
  module LookupBy
2
2
  class Cache
3
- attr_reader :cache, :field, :stats
3
+ attr_reader :cache, :reverse, :field, :stats
4
4
 
5
5
  attr_accessor :testing
6
6
 
@@ -69,6 +69,7 @@ module LookupBy
69
69
 
70
70
  def clear
71
71
  @cache.clear
72
+ @reverse.clear
72
73
  end
73
74
 
74
75
  def create(*args, &block)
@@ -6,7 +6,8 @@ module LookupBy
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
9
- alias_method_chain :input, :lookup
9
+ alias_method :input_without_lookup, :input
10
+ alias_method :input, :input_with_lookup
10
11
  end
11
12
 
12
13
  def input_with_lookup(method, options = {})
@@ -6,7 +6,8 @@ module LookupBy
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
9
- alias_method_chain :input, :lookup
9
+ alias_method :input_without_lookup, :input
10
+ alias_method :input, :input_with_lookup
10
11
  end
11
12
 
12
13
  def input_with_lookup(method, options = {}, &block)
@@ -1,3 +1,3 @@
1
1
  module LookupBy
2
- VERSION = "0.11.1"
2
+ VERSION = "0.11.2"
3
3
  end
@@ -9,6 +9,11 @@ describe LookupBy::Cache do
9
9
  expect { subject.clear }.to change(subject.cache, :size).from(1).to(0)
10
10
  expect { subject.clear }.not_to change(subject.cache, :size)
11
11
  end
12
+
13
+ it "clears the reverse cache" do
14
+ expect { subject.clear }.to change(subject.reverse, :size).from(1).to(0)
15
+ expect { subject.clear }.not_to change(subject.reverse, :size)
16
+ end
12
17
  end
13
18
 
14
19
  describe "#reload" do
@@ -18,6 +23,11 @@ describe LookupBy::Cache do
18
23
  expect { subject.reload }.to change(subject.cache, :size).from(0).to(1)
19
24
  expect { subject.reload }.not_to change(subject.cache, :size)
20
25
  end
26
+
27
+ it "loads the reverse cache" do
28
+ expect { subject.reload }.to change(subject.reverse, :size).from(0).to(1)
29
+ expect { subject.reload }.not_to change(subject.reverse, :size)
30
+ end
21
31
  end
22
32
 
23
33
  describe "#disable!" do
@@ -1,6 +1,7 @@
1
1
  ActiveRecord::Schema.define do
2
2
  enable_extension "plpgsql"
3
3
  enable_extension "uuid-ossp"
4
+ enable_extension "pgcrypto"
4
5
 
5
6
  create_lookup_tables :cities, :states, :postal_codes, :streets, :countries
6
7
 
@@ -22,8 +22,10 @@ describe LookupBy do
22
22
  describe ".clear" do
23
23
  it "clears all lookup caches" do
24
24
  Path.lookup.cache[1] = "remove-this"
25
+ Path.lookup.reverse["remove-this"] = "remove-this"
25
26
 
26
- expect { LookupBy.clear }.to change { Path.lookup.cache.size }
27
+ expect { LookupBy.clear }.to change { Path.lookup.cache.size }.
28
+ and change { Path.lookup.reverse.size }
27
29
  end
28
30
  end
29
31
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lookup_by
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.1
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Peterson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-08 00:00:00.000000000 Z
11
+ date: 2019-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -64,6 +64,7 @@ files:
64
64
  - ".travis.yml"
65
65
  - ".yardopts"
66
66
  - Appraisals
67
+ - CHANGELOG.md
67
68
  - Gemfile
68
69
  - MIT-LICENSE
69
70
  - README.md
@@ -73,6 +74,8 @@ files:
73
74
  - gemfiles/rails_4.1.gemfile
74
75
  - gemfiles/rails_4.2.gemfile
75
76
  - gemfiles/rails_5.0.gemfile
77
+ - gemfiles/rails_5.1.gemfile
78
+ - gemfiles/rails_5.2.gemfile
76
79
  - lib/lookup_by.rb
77
80
  - lib/lookup_by/association.rb
78
81
  - lib/lookup_by/cache.rb
@@ -137,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
140
  version: '0'
138
141
  requirements: []
139
142
  rubyforge_project:
140
- rubygems_version: 2.6.10
143
+ rubygems_version: 2.5.2
141
144
  signing_key:
142
145
  specification_version: 4
143
146
  summary: A thread-safe lookup table cache for ActiveRecord