scopelist 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +16 -0
- data/.rubocop.yml +18 -0
- data/.travis.yml +15 -4
- data/CHANGELOG.md +7 -1
- data/Gemfile +2 -0
- data/README.md +4 -2
- data/Rakefile +8 -14
- data/gemfiles/4.0.gemfile +5 -5
- data/gemfiles/4.1.gemfile +5 -5
- data/gemfiles/4.2.gemfile +7 -0
- data/gemfiles/5.0.gemfile +7 -0
- data/lib/scopelist.rb +17 -10
- data/lib/scopelist/version.rb +1 -1
- data/scopelist.gemspec +16 -18
- metadata +9 -41
- data/spec/models.rb +0 -14
- data/spec/schema.rb +0 -15
- data/spec/scopelist_spec.rb +0 -27
- data/spec/spec_helper.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 951e59adb473069cf9103b92662591c91d34c649
|
4
|
+
data.tar.gz: 79942a5996950923ac5f337fb452f3df49452f44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd5236a517bff93b2c05f2c15688176a3fb2bfeeeed834ed6a7087e9036f8fef290eb5a3e93b3fc8c48a896a407a7b9da2967c8cf7920d0a3f788c30caaa94cc
|
7
|
+
data.tar.gz: 7f7e9b44cba554396208279d982499c6fa5b254b709327ce12894ca50d31f95b7bc2cc374f1a51447f1691e730803327c3dcce57f87da5aa7d05674f20bb42c2
|
data/.codeclimate.yml
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
CHANGED
@@ -1,9 +1,20 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
-
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
|
3
|
+
- 2.0
|
4
|
+
- 2.1
|
5
|
+
- 2.2
|
6
|
+
- 2.3.1
|
7
7
|
gemfile:
|
8
8
|
- gemfiles/4.0.gemfile
|
9
9
|
- gemfiles/4.1.gemfile
|
10
|
+
- gemfiles/4.2.gemfile
|
11
|
+
- gemfiles/5.0.gemfile
|
12
|
+
matrix:
|
13
|
+
exclude:
|
14
|
+
- rvm: 2.0
|
15
|
+
gemfile: gemfiles/5.0.gemfile
|
16
|
+
- rvm: 2.1
|
17
|
+
gemfile: gemfiles/5.0.gemfile
|
18
|
+
- rvm: 2.2
|
19
|
+
gemfile: gemfiles/5.0.gemfile
|
20
|
+
sudo: false
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
|
+
#### 0.0.4 (2016-09-01)
|
2
|
+
* Only support Ruby 2.0 and later
|
3
|
+
* Support ActiveRecord 4.2 and 5.0
|
4
|
+
* Use `Module.prepend` instead of `alias_method_chain`
|
5
|
+
* Scopes are inherited from parent classes
|
6
|
+
|
1
7
|
#### 0.0.3 (2014-07-27)
|
2
|
-
* Donot allow
|
8
|
+
* Donot allow `.available_scopes` to be directly mutatable
|
3
9
|
|
4
10
|
#### 0.0.2 (2014-07-08)
|
5
11
|
* Fixed compatability for Ruby 2.0
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# Scopelist
|
2
2
|
|
3
|
-
A simple way to track scopes in ActiveRecord 4.0
|
3
|
+
A simple way to track scopes in ActiveRecord 4.0, 4.1, 4.2, and 5.0.
|
4
4
|
|
5
|
-
NOTE: Only Ruby
|
5
|
+
NOTE: Only Ruby 2.0 and later are supported
|
6
6
|
|
7
7
|
[![Build Status](https://travis-ci.org/t27duck/scopelist.svg?branch=master)](https://travis-ci.org/t27duck/scopelist)
|
8
|
+
[![Code Climate](https://codeclimate.com/github/t27duck/scopelist/badges/gpa.svg)](https://codeclimate.com/github/t27duck/scopelist)
|
9
|
+
[![Test Coverage](https://codeclimate.com/github/t27duck/scopelist/badges/coverage.svg)](https://codeclimate.com/github/t27duck/scopelist/coverage)
|
8
10
|
|
9
11
|
## Installation
|
10
12
|
|
data/Rakefile
CHANGED
@@ -1,16 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require '
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
task :console do
|
10
|
-
require 'irb'
|
11
|
-
require 'irb/completion'
|
12
|
-
require 'active_record'
|
13
|
-
require 'scopelist'
|
14
|
-
ARGV.clear
|
15
|
-
IRB.start
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << 'test'
|
6
|
+
t.libs << 'lib'
|
7
|
+
t.test_files = FileList['test/**/*_test.rb']
|
16
8
|
end
|
9
|
+
|
10
|
+
task default: :test
|
data/gemfiles/4.0.gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem
|
4
|
-
gem
|
5
|
-
gem
|
3
|
+
gem 'activerecord', '~> 4.0.0'
|
4
|
+
gem 'activesupport', '~> 4.0.0'
|
5
|
+
gem 'codeclimate-test-reporter', require: nil
|
6
6
|
|
7
|
-
gemspec :path=>
|
7
|
+
gemspec :path=>'../'
|
data/gemfiles/4.1.gemfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem
|
4
|
-
gem
|
5
|
-
gem
|
3
|
+
gem 'activerecord', '~> 4.1.0'
|
4
|
+
gem 'activesupport', '~> 4.1.0'
|
5
|
+
gem 'codeclimate-test-reporter', require: nil
|
6
6
|
|
7
|
-
gemspec :path=>
|
7
|
+
gemspec :path=>'../'
|
data/lib/scopelist.rb
CHANGED
@@ -1,33 +1,40 @@
|
|
1
|
-
require
|
1
|
+
require 'scopelist/version'
|
2
2
|
|
3
3
|
module Scopelist
|
4
|
-
|
5
4
|
def self.included(base)
|
6
5
|
base.class_eval do
|
7
6
|
extend ClassMethods
|
8
|
-
class << self
|
9
|
-
alias_method_chain :scope, :scopelist
|
10
|
-
end
|
11
7
|
end
|
12
8
|
end
|
13
9
|
|
14
|
-
|
15
|
-
|
10
|
+
def self.prepended(base)
|
11
|
+
class << base
|
12
|
+
prepend PrependedClassMethods
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module PrependedClassMethods
|
17
|
+
def scope(name, body, &block)
|
16
18
|
additional_available_scope name
|
17
|
-
|
19
|
+
super
|
18
20
|
end
|
21
|
+
end
|
19
22
|
|
23
|
+
module ClassMethods
|
20
24
|
def available_scopes
|
21
25
|
@available_scopes ||= []
|
22
|
-
|
26
|
+
if superclass.respond_to?(:available_scopes)
|
27
|
+
@available_scopes += superclass.available_scopes
|
28
|
+
end
|
29
|
+
@available_scopes.uniq.dup
|
23
30
|
end
|
24
31
|
|
25
32
|
def additional_available_scope(name)
|
26
33
|
@available_scopes ||= []
|
27
34
|
@available_scopes << name.to_sym
|
28
35
|
end
|
29
|
-
|
30
36
|
end
|
31
37
|
end
|
32
38
|
|
33
39
|
ActiveRecord::Base.send(:include, Scopelist)
|
40
|
+
ActiveRecord::Base.send(:prepend, Scopelist)
|
data/lib/scopelist/version.rb
CHANGED
data/scopelist.gemspec
CHANGED
@@ -4,25 +4,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'scopelist/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'scopelist'
|
8
8
|
spec.version = Scopelist::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['Tony Drake']
|
10
|
+
spec.email = ['t27duck@gmail.com']
|
11
|
+
spec.summary = 'Adds ability to track scopes on ActiveRecord models'
|
12
|
+
spec.description = 'Adds ability to track scopes on ActiveRecord models'
|
13
|
+
spec.homepage = 'https://github.com/t27duck/scopelist'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.
|
18
|
-
spec.
|
19
|
-
spec.require_paths = [
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency
|
22
|
-
spec.add_dependency
|
23
|
-
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency "rspec"
|
27
|
-
spec.add_development_dependency "sqlite3"
|
21
|
+
spec.add_dependency 'activerecord', '>= 4.0.0'
|
22
|
+
spec.add_dependency 'activesupport', '>= 4.0.0'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
25
|
+
spec.add_development_dependency 'rake'
|
28
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scopelist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Drake
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -66,34 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: sqlite3
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
69
|
description: Adds ability to track scopes on ActiveRecord models
|
98
70
|
email:
|
99
71
|
- t27duck@gmail.com
|
@@ -101,7 +73,9 @@ executables: []
|
|
101
73
|
extensions: []
|
102
74
|
extra_rdoc_files: []
|
103
75
|
files:
|
76
|
+
- ".codeclimate.yml"
|
104
77
|
- ".gitignore"
|
78
|
+
- ".rubocop.yml"
|
105
79
|
- ".travis.yml"
|
106
80
|
- CHANGELOG.md
|
107
81
|
- Gemfile
|
@@ -110,13 +84,11 @@ files:
|
|
110
84
|
- Rakefile
|
111
85
|
- gemfiles/4.0.gemfile
|
112
86
|
- gemfiles/4.1.gemfile
|
87
|
+
- gemfiles/4.2.gemfile
|
88
|
+
- gemfiles/5.0.gemfile
|
113
89
|
- lib/scopelist.rb
|
114
90
|
- lib/scopelist/version.rb
|
115
91
|
- scopelist.gemspec
|
116
|
-
- spec/models.rb
|
117
|
-
- spec/schema.rb
|
118
|
-
- spec/scopelist_spec.rb
|
119
|
-
- spec/spec_helper.rb
|
120
92
|
homepage: https://github.com/t27duck/scopelist
|
121
93
|
licenses:
|
122
94
|
- MIT
|
@@ -137,12 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
109
|
version: '0'
|
138
110
|
requirements: []
|
139
111
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.4.5.1
|
141
113
|
signing_key:
|
142
114
|
specification_version: 4
|
143
115
|
summary: Adds ability to track scopes on ActiveRecord models
|
144
|
-
test_files:
|
145
|
-
- spec/models.rb
|
146
|
-
- spec/schema.rb
|
147
|
-
- spec/scopelist_spec.rb
|
148
|
-
- spec/spec_helper.rb
|
116
|
+
test_files: []
|
data/spec/models.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
class SomeThing < ActiveRecord::Base
|
2
|
-
scope :scope1, -> {where(nil)}
|
3
|
-
end
|
4
|
-
|
5
|
-
class SomeOtherThing < ActiveRecord::Base
|
6
|
-
end
|
7
|
-
|
8
|
-
class OneMoreThing < ActiveRecord::Base
|
9
|
-
scope :scope2, -> {where(nil)}
|
10
|
-
|
11
|
-
def self.class_method_as_a_scope
|
12
|
-
end
|
13
|
-
additional_available_scope :class_method_as_a_scope
|
14
|
-
end
|
data/spec/schema.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
ActiveRecord::Schema.define do
|
2
|
-
self.verbose = false
|
3
|
-
|
4
|
-
create_table :some_things, :force => true do |t|
|
5
|
-
t.timestamps
|
6
|
-
end
|
7
|
-
|
8
|
-
create_table :some_other_things, :force => true do |t|
|
9
|
-
t.timestamps
|
10
|
-
end
|
11
|
-
|
12
|
-
create_table :one_more_things, :force => true do |t|
|
13
|
-
t.timestamps
|
14
|
-
end
|
15
|
-
end
|
data/spec/scopelist_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe '.available_scopes' do
|
4
|
-
it 'should be an array' do
|
5
|
-
expect(SomeThing.available_scopes).to be_a_kind_of(Array)
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should contain an array of scope names' do
|
9
|
-
expect(SomeThing.available_scopes).to eq([:scope1])
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'does not bleed into other models' do
|
13
|
-
expect(SomeOtherThing.available_scopes).to eq([])
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'cannot be mutated' do
|
17
|
-
expected = SomeThing.available_scopes.dup
|
18
|
-
SomeThing.available_scopes << :scope2
|
19
|
-
expect(SomeThing.available_scopes).to eq(expected)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '.additonal_available_scope' do
|
24
|
-
it 'appends to the available scope list' do
|
25
|
-
expect(OneMoreThing.available_scopes).to eq([:scope2, :class_method_as_a_scope])
|
26
|
-
end
|
27
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
Bundler.setup
|
3
|
-
|
4
|
-
require 'active_record'
|
5
|
-
require 'active_support'
|
6
|
-
require 'scopelist'
|
7
|
-
|
8
|
-
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
|
9
|
-
|
10
|
-
load File.dirname(__FILE__) + '/schema.rb'
|
11
|
-
require File.dirname(__FILE__) + '/models.rb'
|
12
|
-
|
13
|
-
RSpec.configure do |config|
|
14
|
-
# some (optional) config here
|
15
|
-
end
|