lookup_by 0.11.2 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 06bc3fdda0734392ba779759569af73b4321cb8e
4
- data.tar.gz: 19cf6cf802813d5c6b7dbb3c741b26ae044d7f41
2
+ SHA256:
3
+ metadata.gz: 4c1d5aaec4ced07731c227dfb1ae27903fed94b0feb28cecb6f1e3a27e55eb3c
4
+ data.tar.gz: a7185879dbfc9bff84bf7b8795913731f577254925c760e9bc096bc4091493e2
5
5
  SHA512:
6
- metadata.gz: 4d556bd84dc5043e976db12c82717dbf51356a7e7f0117ebda196aa12fc6a3dd5d6df33ea5be4070be19b6bfcffbaf5a3f29765073d1f8b569238a7d78af6ef1
7
- data.tar.gz: e33a6de43a703ee5d8b4570b70f606d594e86df6ff063f822e6f6a845f506de47fd616d5f1590e5600c3707862f7c18ee7982bed2dce018c44d54ffb05ef0fa2
6
+ metadata.gz: abfa6b7b5053fd41e61f419c873a02a05b833ae96f104101858f86331d96d7f598b7d09d4b3812637a964ab23ce89c1ead6137ca0d11220b93af592af7197aa9
7
+ data.tar.gz: 067763d23e4a3e6fa1dfa9b0e27e3fd90bc7f69710a7dd129a2fa00a26131af2632eabe0b208ac9733440fe89240285d273600c787afe235d21a8788bd13a59f
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.3.3
1
+ ruby-3.1.2
data/Appraisals CHANGED
@@ -1,27 +1,11 @@
1
- appraise 'rails-4.1' do
2
- gem 'rails', '~> 4.1.0'
3
-
4
- group :development, :test do
5
- gem "pg", "~> 0.11", platform: :ruby
6
- end
7
- end
8
-
9
- appraise 'rails-4.2' do
10
- gem 'rails', '~> 4.2.0'
11
-
12
- group :development, :test do
13
- gem "pg", "~> 0.11", platform: :ruby
14
- end
15
- end
16
-
17
- appraise 'rails-5.0' do
18
- gem 'rails', '~> 5.0.0'
1
+ appraise 'rails-6.0' do
2
+ gem 'activerecord', '~> 6.0.0'
19
3
  end
20
4
 
21
- appraise 'rails-5.1' do
22
- gem 'rails', '~> 5.1.0'
5
+ appraise 'rails-6.1' do
6
+ gem 'activerecord', '~> 6.1.0'
23
7
  end
24
8
 
25
- appraise 'rails-5.2' do
26
- gem 'rails', '~> 5.2.0'
9
+ appraise 'rails-7.0' do
10
+ gem 'activerecord', '~> 7.0.0'
27
11
  end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### [v0.12.0](https://github.com/companygardener/lookup_by/compare/v0.11.2...v0.12.0)
2
+
3
+ Require ruby 2.7. Support ruby 3.1
4
+
5
+ * Appraisal: remove rails 5.0, 5.1, and 5.2
6
+ * Appraisal: add rails 7.0
7
+ * Dev: .ruby-version 3.1.2
8
+
1
9
  ### [v0.11.2](https://github.com/companygardener/lookup_by/compare/v0.11.1...v0.11.2)
2
10
 
3
11
  Merged a few PRs. Shouldn't break anything.
data/Gemfile CHANGED
@@ -6,23 +6,17 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  group :development, :test do
9
- gem 'appraisal', '~> 2.1.0', require: false
9
+ gem 'appraisal', "~> 2.4.1", require: false
10
10
 
11
11
  gem 'combustion'
12
12
 
13
13
  gem 'rspec'
14
- gem 'rspec-its'
15
14
  gem 'rspec-rails'
16
15
 
17
16
  gem "pg", platform: :ruby
18
17
  # gem "activerecord-jdbcpostgresql-adapter", platform: :jruby
19
18
 
20
- gem "simplecov", require: false
21
- gem 'coveralls', require: false
19
+ gem "simplecov", "~> 0.21.2", require: false
22
20
 
23
- gem "pry", require: false
24
- gem 'colored', require: false
25
-
26
- gem 'racc'
27
- gem 'json'
21
+ gem "pry", require: false
28
22
  end
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright © 2014 Erik Peterson
1
+ Copyright © 2014–2020 Erik Peterson
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,20 +1,11 @@
1
- # LookupBy
2
1
 
3
2
  [![Gem Version](https://badge.fury.io/rb/lookup_by.png)][rubygems]
4
- [![Build Status](https://secure.travis-ci.org/companygardener/lookup_by.png?branch=master)][travis]
5
- [![Dependency Status](https://gemnasium.com/companygardener/lookup_by.png)][gemnasium]
6
- [![Coverage Status](https://coveralls.io/repos/companygardener/lookup_by/badge.png?branch=master)][coveralls]
7
3
  [![Code Climate](https://codeclimate.com/github/companygardener/lookup_by.png)][codeclimate]
8
- [![Gittip](http://img.shields.io/gittip/companygardener.png)][gittip]
9
4
 
10
5
  [rubygems]: https://rubygems.org/gems/lookup_by
11
- [travis]: http://travis-ci.org/companygardener/lookup_by
12
- [gemnasium]: https://gemnasium.com/companygardener/lookup_by
13
- [coveralls]: https://coveralls.io/r/companygardener/lookup_by?branch=master
14
6
  [codeclimate]: https://codeclimate.com/github/companygardener/lookup_by
15
- [gittip]: https://www.gittip.com/companygardener
16
7
 
17
- # Overview
8
+ # LookupBy
18
9
 
19
10
  LookupBy is a thread-safe lookup table cache for ActiveRecord that reduces normalization pains.
20
11
 
@@ -25,9 +16,20 @@ LookupBy is a thread-safe lookup table cache for ActiveRecord that reduces norma
25
16
 
26
17
  ### Dependencies
27
18
 
28
- * Rails 4.1+ (_tested on Rails 4.1, 4.2, and 5.0_)
29
- * Ruby 2.2+ (_tested on Ruby 2.2, 2.3 and Rubinius 3.45_)
30
- * PostgreSQL 9.2+
19
+ * Rails 6.0+ (_tested on Rails 6.0, 6.1, and 7.0_)
20
+ * Ruby 2.7+ (_tested on Ruby 2.7, 3.0, 3.1_)
21
+ * PostgreSQL 9.2+ (tested on 14.2)
22
+
23
+ ### Deprecations
24
+
25
+ - Rails <= 5.2 (5.x breaks test suite on ruby 3.1; 4.x is incompatible with bundler 2.x, too hard to maintain)
26
+ - Ruby <= 2.6 (end of life; may depend on openssl@1.0, which is also end of life)
27
+
28
+ If you must use an old version of Ruby, good luck to you. You could try:
29
+
30
+ brew install rbenv/tap/openssl@1.0
31
+ brew install ruby-install
32
+ ruby-install ruby 2.2.10 --no-install-deps -- --with-openssl-dir=$(brew --prefix openssl@1.0) --disable-install-doc
31
33
 
32
34
  ### Development
33
35
 
@@ -41,7 +43,7 @@ LookupBy is a thread-safe lookup table cache for ActiveRecord that reduces norma
41
43
 
42
44
  Please create [Issues][] to submit bug reports and feature requests. However, I ask that you'd kindly review [these bug reporting guidelines](https://github.com/companygardener/lookup_by/wiki/Bug-Reports) first.
43
45
 
44
- _If you find a security bug, **do not** use the public issue tracker. Instead, send an email to: thecompanygardener@gmail.com._
46
+ _If you find a security bug, **do not** use the public issue tracker. Instead, send an email to: thecompanygardener[removethisifnotspam]@gmail.com._
45
47
 
46
48
  # Installation
47
49
 
@@ -344,7 +346,7 @@ This provides: `Given I reload the cache for $plural_class_name`
344
346
  = f.input :status, :as => :radio
345
347
  ```
346
348
 
347
- ## Testing
349
+ # Testing
348
350
 
349
351
  This plugin uses rspec and pry for testing. Make sure you have them installed:
350
352
 
@@ -367,7 +369,7 @@ A list of authors can be found on the [Contributors][] page.
367
369
 
368
370
  # License
369
371
 
370
- Copyright © 2014 Erik Peterson
372
+ Copyright © 2014–2022 Erik Peterson
371
373
 
372
374
  MIT License
373
375
 
@@ -0,0 +1,17 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 6.0.0"
6
+
7
+ group :development, :test do
8
+ gem "appraisal", "~> 2.4.1", require: false
9
+ gem "combustion"
10
+ gem "rspec"
11
+ gem "rspec-rails"
12
+ gem "pg", platform: :ruby
13
+ gem "simplecov", "~> 0.21.2", require: false
14
+ gem "pry", require: false
15
+ end
16
+
17
+ gemspec path: "../"
@@ -0,0 +1,17 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 6.1.0"
6
+
7
+ group :development, :test do
8
+ gem "appraisal", "~> 2.4.1", require: false
9
+ gem "combustion"
10
+ gem "rspec"
11
+ gem "rspec-rails"
12
+ gem "pg", platform: :ruby
13
+ gem "simplecov", "~> 0.21.2", require: false
14
+ gem "pry", require: false
15
+ end
16
+
17
+ gemspec path: "../"
@@ -0,0 +1,17 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 7.0.0"
6
+
7
+ group :development, :test do
8
+ gem "appraisal", "~> 2.4.1", require: false
9
+ gem "combustion"
10
+ gem "rspec"
11
+ gem "rspec-rails"
12
+ gem "pg", platform: :ruby
13
+ gem "simplecov", "~> 0.21.2", require: false
14
+ gem "pry", require: false
15
+ end
16
+
17
+ gemspec path: "../"
@@ -23,7 +23,7 @@ module LookupBy
23
23
  end
24
24
 
25
25
  options.symbolize_keys!
26
- options.assert_valid_keys(:class_name, :foreign_key, :symbolize, :strict, :scope, :inverse_scope)
26
+ options.assert_valid_keys(:class_name, :foreign_key, :symbolize, :strict, :scope, :inverse_scope, :belongs_to)
27
27
 
28
28
  field = field.to_sym
29
29
 
@@ -80,8 +80,11 @@ module LookupBy
80
80
 
81
81
  Rails.logger.error "foreign key `#{foreign_key}` is required on #{self}" unless attribute_names.include?(foreign_key.to_s)
82
82
 
83
- strict = options[:strict]
84
- strict = true if strict.nil?
83
+ belongs = options[:belongs_to] || false
84
+
85
+ class_eval <<-BELONGS_TO, __FILE__, __LINE__.next if belongs
86
+ belongs_to :#{field}, class_name: "#{class_name}", foreign_key: :#{foreign_key}, autosave: false, optional: true
87
+ BELONGS_TO
85
88
 
86
89
  class_eval <<-SCOPES, __FILE__, __LINE__.next if scope_name
87
90
  scope :#{scope_name}, ->(*names) { where(#{foreign_key}: #{class_name}[*names]) }
@@ -102,6 +105,9 @@ module LookupBy
102
105
  lookup_field = klass.lookup.field
103
106
  lookup_object = "#{class_name}[#{foreign_key}]"
104
107
 
108
+ strict = options[:strict]
109
+ strict = true if strict.nil?
110
+
105
111
  class_eval <<-METHODS, __FILE__, __LINE__.next
106
112
  def raw_#{field}
107
113
  #{lookup_object}
@@ -63,7 +63,7 @@ module LookupBy
63
63
  end
64
64
 
65
65
  module ClassMethods
66
- # Rails 4.1, 4.2, 5.0
66
+ # Rails 4.1, 4.2, 5.0+
67
67
  def all
68
68
  return super if current_scope
69
69
 
@@ -86,7 +86,7 @@ module LookupBy
86
86
  @lookup.cache.size
87
87
  end
88
88
  else
89
- # Rails 5.0
89
+ # Rails 5.0+
90
90
  def count(column_name = nil)
91
91
  return super if @lookup.read_through?
92
92
  return super if column_name
@@ -180,7 +180,7 @@ module LookupBy
180
180
 
181
181
  table_options[:id] = false if options[:small]
182
182
 
183
- create_table name, table_options do |t|
183
+ create_table name, **table_options do |t|
184
184
  t.column table_options[:primary_key], 'smallserial primary key' if options[:small]
185
185
 
186
186
  t.column lookup_column, lookup_type, null: false
@@ -1,3 +1,3 @@
1
1
  module LookupBy
2
- VERSION = "0.11.2"
2
+ VERSION = "0.12.0"
3
3
  end
data/lookup_by.gemspec CHANGED
@@ -22,8 +22,8 @@ Gem::Specification.new do |gem|
22
22
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
23
23
  gem.require_paths = ["lib"]
24
24
 
25
- gem.add_dependency "activerecord", ">= 4.1.0"
25
+ gem.add_dependency "activerecord", ">= 6.0.0"
26
26
 
27
- gem.add_development_dependency "bundler", ">= 1.7.0"
27
+ gem.add_development_dependency "bundler", ">= 2.3.3"
28
28
  gem.add_development_dependency "rake"
29
29
  end
data/spec/rails_helper.rb CHANGED
@@ -9,18 +9,12 @@ require 'spec_helper'
9
9
 
10
10
  if ENV["COVERAGE"]
11
11
  require 'simplecov'
12
- require 'coveralls'
13
-
14
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
15
- Coveralls::SimpleCov::Formatter,
16
- SimpleCov::Formatter::HTMLFormatter
17
- ]
18
12
 
13
+ SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
19
14
  SimpleCov.start
20
15
  end
21
16
 
22
17
  require 'pry'
23
- require 'rspec/its'
24
18
  require 'rspec/rails'
25
19
 
26
20
  # Requires supporting ruby files with custom matchers and macros, etc, in
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.2
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Peterson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-15 00:00:00.000000000 Z
11
+ date: 2022-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.1.0
19
+ version: 6.0.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
- version: 4.1.0
26
+ version: 6.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.7.0
33
+ version: 2.3.3
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
- version: 1.7.0
40
+ version: 2.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -71,11 +71,9 @@ files:
71
71
  - Rakefile
72
72
  - TODO.md
73
73
  - circle.yml
74
- - gemfiles/rails_4.1.gemfile
75
- - gemfiles/rails_4.2.gemfile
76
- - gemfiles/rails_5.0.gemfile
77
- - gemfiles/rails_5.1.gemfile
78
- - gemfiles/rails_5.2.gemfile
74
+ - gemfiles/rails_6.0.gemfile
75
+ - gemfiles/rails_6.1.gemfile
76
+ - gemfiles/rails_7.0.gemfile
79
77
  - lib/lookup_by.rb
80
78
  - lib/lookup_by/association.rb
81
79
  - lib/lookup_by/cache.rb
@@ -124,7 +122,7 @@ homepage: https://www.github.com/companygardener/lookup_by
124
122
  licenses:
125
123
  - MIT
126
124
  metadata: {}
127
- post_install_message:
125
+ post_install_message:
128
126
  rdoc_options: []
129
127
  require_paths:
130
128
  - lib
@@ -139,9 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
137
  - !ruby/object:Gem::Version
140
138
  version: '0'
141
139
  requirements: []
142
- rubyforge_project:
143
- rubygems_version: 2.5.2
144
- signing_key:
140
+ rubygems_version: 3.3.11
141
+ signing_key:
145
142
  specification_version: 4
146
143
  summary: A thread-safe lookup table cache for ActiveRecord
147
144
  test_files:
@@ -1,22 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 4.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", "~> 0.11", :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,22 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 4.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", "~> 0.11", :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,22 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "~> 5.0.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,22 +0,0 @@
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 => "../"
@@ -1,22 +0,0 @@
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 => "../"