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 +4 -4
- data/Appraisals +16 -0
- data/CHANGELOG.md +50 -0
- data/README.md +5 -0
- data/gemfiles/rails_4.1.gemfile +1 -1
- data/gemfiles/rails_4.2.gemfile +1 -1
- data/gemfiles/rails_5.1.gemfile +22 -0
- data/gemfiles/rails_5.2.gemfile +22 -0
- data/lib/lookup_by/cache.rb +2 -1
- data/lib/lookup_by/hooks/formtastic.rb +2 -1
- data/lib/lookup_by/hooks/simple_form.rb +2 -1
- data/lib/lookup_by/version.rb +1 -1
- data/spec/cache_spec.rb +10 -0
- data/spec/internal/db/schema.rb +1 -0
- data/spec/lookup_by_spec.rb +3 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06bc3fdda0734392ba779759569af73b4321cb8e
|
4
|
+
data.tar.gz: 19cf6cf802813d5c6b7dbb3c741b26ae044d7f41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/CHANGELOG.md
ADDED
@@ -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
|
data/gemfiles/rails_4.1.gemfile
CHANGED
@@ -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
|
data/gemfiles/rails_4.2.gemfile
CHANGED
@@ -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 => "../"
|
data/lib/lookup_by/cache.rb
CHANGED
@@ -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)
|
data/lib/lookup_by/version.rb
CHANGED
data/spec/cache_spec.rb
CHANGED
@@ -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
|
data/spec/internal/db/schema.rb
CHANGED
data/spec/lookup_by_spec.rb
CHANGED
@@ -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.
|
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:
|
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.
|
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
|