activerecord-missing 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 744b5ad23183c7d6ecb77f9c420889fc40c8242faf559fd3b938b5ed72cda07c
4
+ data.tar.gz: 580914511056e5e1d89bd3f5ede220f1ebadc2bbf74cff3555fb20fbe34d30eb
5
+ SHA512:
6
+ metadata.gz: 5759d06f77f49fec8975cd7facb209f5a6a9a596617acb941a29e13bc70c69ad88a33ce0451748fe40639cc71fd3dece1aa70edbf3682066d7a5b3dfb05aefdf
7
+ data.tar.gz: bf3a03022ffe4c2e2b019ee11bb5873b112880f5b09232b927588cd085f2c946aeff44077c418316508862e5f081b97087c41935f15acc64324893573f9d2322
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /Gemfile.lock
5
+ /coverage/
6
+ /doc/
7
+ /gemfiles/*.gemfile.lock
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+
12
+ # rspec failure tracking
13
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,34 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rails
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.3
7
+
8
+ Style/AsciiComments:
9
+ Enabled: false
10
+
11
+ Style/Documentation:
12
+ Enabled: false
13
+
14
+ Style/RedundantSelf:
15
+ Enabled: false
16
+
17
+ Style/StringLiterals:
18
+ Enabled: true
19
+ EnforcedStyle: double_quotes
20
+
21
+ Layout/EndOfLine:
22
+ Enabled: true
23
+ EnforcedStyle: lf
24
+
25
+ Layout/LineLength:
26
+ Max: 128
27
+
28
+ Metrics/BlockLength:
29
+ Exclude:
30
+ - spec/**/*
31
+
32
+ Metrics/MethodLength:
33
+ Exclude:
34
+ - spec/**/*
@@ -0,0 +1,26 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.3.8
6
+ - 2.4.9
7
+ - 2.5.7
8
+ - 2.6.5
9
+ - 2.7.0
10
+ gemfile:
11
+ - gemfiles/activerecord_5.0.gemfile
12
+ - gemfiles/activerecord_5.1.gemfile
13
+ - gemfiles/activerecord_5.2.gemfile
14
+ - gemfiles/activerecord_6.0.gemfile
15
+ matrix:
16
+ exclude:
17
+ - rvm: 2.3.8
18
+ gemfile: gemfiles/activerecord_6.0.gemfile
19
+ - rvm: 2.4.9
20
+ gemfile: gemfiles/activerecord_6.0.gemfile
21
+ - rvm: 2.7.0
22
+ gemfile: gemfiles/activerecord_5.0.gemfile
23
+ - rvm: 2.7.0
24
+ gemfile: gemfiles/activerecord_5.1.gemfile
25
+ - rvm: 2.7.0
26
+ gemfile: gemfiles/activerecord_5.2.gemfile
@@ -0,0 +1,6 @@
1
+ ## Unreleased
2
+
3
+
4
+ ## 0.1.0 (2020-01-15)
5
+
6
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in activerecord-missing.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 12.0"
9
+ gem "rspec", "~> 3.0"
10
+ gem "sqlite3", "~> 1.4"
11
+
12
+ gem "rubocop", ">= 0.78.0"
13
+ gem "rubocop-performance", ">= 1.3.0"
14
+ gem "rubocop-rails", ">= 2.0.1"
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Yuji Hanamura
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,46 @@
1
+ # ActiveRecord::Missing
2
+
3
+ Backport of `ActiveRecord::QueryMethods::WhereChain#missing` for Rails 6.0 and 5.x applications.
4
+ https://github.com/rails/rails/pull/34727
5
+
6
+ [![Gem Version](https://badge.fury.io/rb/activemodel-ip_address_validator.svg)](https://badge.fury.io/rb/activerecord-missing)
7
+ [![Build Status](https://travis-ci.com/yujideveloper/activerecord-missing.svg?branch=master)](https://travis-ci.com/yujideveloper/activerecord-missing)
8
+ [![Maintainability](https://api.codeclimate.com/v1/badges/d2c29bf85f80bd50a564/maintainability)](https://codeclimate.com/github/yujideveloper/activerecord-missing/maintainability)
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'activerecord-missing'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle install
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install activerecord-missing
25
+
26
+ ## Usage
27
+
28
+ ``` ruby
29
+ Post.where.missing(:author)
30
+ Post.where.missing(:author, :comments)
31
+ ```
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/yujideveloper/activerecord-missing.
42
+
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/activerecord/missing/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "activerecord-missing"
7
+ spec.version = ActiveRecord::Missing::VERSION
8
+ spec.authors = ["Yuji Hanamura"]
9
+ spec.email = ["yuji.developer@gmail.com"]
10
+
11
+ spec.summary =
12
+ "This gem provides the functionality of ActiveRecord::QueryMethods::WhereChain#missing for Rails 6.0 and 5.x apps."
13
+ spec.description = spec.summary
14
+ spec.homepage = "https://github.com/yujideveloper/activerecord-missing"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
17
+
18
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = spec.homepage
22
+ spec.metadata["changelog_uri"] = "https://github.com/yujideveloper/activerecord-missing/blob/master/CHANGELOG.md"
23
+
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency "activerecord", ">= 5.0", "< 6.1"
32
+ spec.add_dependency "activesupport", ">= 5.0", "< 6.1"
33
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "activerecord/missing"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org/"
4
+
5
+ gemspec path: "../"
6
+
7
+ gem "activerecord", "~> 5.0.7", ">= 5.0.7.2"
8
+ gem "activesupport", "~> 5.0.7", ">= 5.0.7.2"
9
+
10
+ gem "rake", "~> 12.0"
11
+ gem "rspec", "~> 3.0"
12
+ gem "sqlite3", "~> 1.3.6"
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org/"
4
+
5
+ gemspec path: "../"
6
+
7
+ gem "activerecord", "~> 5.1.7"
8
+ gem "activesupport", "~> 5.1.7"
9
+
10
+ gem "rake", "~> 12.0"
11
+ gem "rspec", "~> 3.0"
12
+ gem "sqlite3", "~> 1.3", ">= 1.3.6"
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org/"
4
+
5
+ gemspec path: "../"
6
+
7
+ gem "activerecord", "~> 5.2.4", ">= 5.2.4.1"
8
+ gem "activesupport", "~> 5.2.4", ">= 5.2.4.1"
9
+
10
+ gem "rake", "~> 12.0"
11
+ gem "rspec", "~> 3.0"
12
+ gem "sqlite3", "~> 1.3", ">= 1.3.6"
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org/"
4
+
5
+ gemspec path: "../"
6
+
7
+ gem "activerecord", "~> 6.0.2", ">= 6.0.2.1"
8
+ gem "activesupport", "~> 6.0.2", ">= 6.0.2.1"
9
+
10
+ gem "rake", "~> 12.0"
11
+ gem "rspec", "~> 3.0"
12
+ gem "sqlite3", "~> 1.4"
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "activerecord/missing/version"
4
+ require "active_support/lazy_load_hooks"
5
+
6
+ ActiveSupport.on_load(:active_record) do
7
+ require "activerecord/missing/relation/query_methods"
8
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_record"
4
+ require "active_record/relation"
5
+ require "active_record/relation/query_methods"
6
+
7
+ module ActiveRecord
8
+ module QueryMethods
9
+ class WhereChain
10
+ def missing(*args)
11
+ args.each do |arg|
12
+ reflection = @scope.klass._reflect_on_association(arg)
13
+ opts = { reflection.table_name => { reflection.association_primary_key => nil } }
14
+ @scope.left_outer_joins!(arg)
15
+ @scope.where!(opts)
16
+ end
17
+
18
+ @scope
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ module Missing
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activerecord-missing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yuji Hanamura
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-01-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '6.1'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '5.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '6.1'
33
+ - !ruby/object:Gem::Dependency
34
+ name: activesupport
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '5.0'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '6.1'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '5.0'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '6.1'
53
+ description: This gem provides the functionality of ActiveRecord::QueryMethods::WhereChain#missing
54
+ for Rails 6.0 and 5.x apps.
55
+ email:
56
+ - yuji.developer@gmail.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - ".gitignore"
62
+ - ".rspec"
63
+ - ".rubocop.yml"
64
+ - ".travis.yml"
65
+ - CHANGELOG.md
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - activerecord-missing.gemspec
71
+ - bin/console
72
+ - bin/setup
73
+ - gemfiles/activerecord_5.0.gemfile
74
+ - gemfiles/activerecord_5.1.gemfile
75
+ - gemfiles/activerecord_5.2.gemfile
76
+ - gemfiles/activerecord_6.0.gemfile
77
+ - lib/activerecord/missing.rb
78
+ - lib/activerecord/missing/relation/query_methods.rb
79
+ - lib/activerecord/missing/version.rb
80
+ homepage: https://github.com/yujideveloper/activerecord-missing
81
+ licenses:
82
+ - MIT
83
+ metadata:
84
+ allowed_push_host: https://rubygems.org
85
+ homepage_uri: https://github.com/yujideveloper/activerecord-missing
86
+ source_code_uri: https://github.com/yujideveloper/activerecord-missing
87
+ changelog_uri: https://github.com/yujideveloper/activerecord-missing/blob/master/CHANGELOG.md
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.3.0
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubygems_version: 3.1.2
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: This gem provides the functionality of ActiveRecord::QueryMethods::WhereChain#missing
107
+ for Rails 6.0 and 5.x apps.
108
+ test_files: []