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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65a84c44246b2c3a0afd99270ca15a548b7c3f79
4
- data.tar.gz: e73c35ca2cea404fd2ce8b51dd74564ec67751c2
3
+ metadata.gz: 951e59adb473069cf9103b92662591c91d34c649
4
+ data.tar.gz: 79942a5996950923ac5f337fb452f3df49452f44
5
5
  SHA512:
6
- metadata.gz: 2d6e54c03dd9bd85dfb6a980fbe62a8fdc9400098f2dcaeea82d46740d4d28b6e3b20783d5b415808d8e95db057f8e4847bfc6b4bfc277282798664b953a07a3
7
- data.tar.gz: a3660ed398bf5508f037233eb0f085e31bd72a1c4cfc71d6165dc038faee967b0d1b57fe2144294a3e4b9d8088cc59f592f930fac85ff8c35590c78fd3c44d02
6
+ metadata.gz: bd5236a517bff93b2c05f2c15688176a3fb2bfeeeed834ed6a7087e9036f8fef290eb5a3e93b3fc8c48a896a407a7b9da2967c8cf7920d0a3f788c30caaa94cc
7
+ data.tar.gz: 7f7e9b44cba554396208279d982499c6fa5b254b709327ce12894ca50d31f95b7bc2cc374f1a51447f1691e730803327c3dcce57f87da5aa7d05674f20bb42c2
@@ -0,0 +1,16 @@
1
+ ---
2
+ engines:
3
+ duplication:
4
+ enabled: true
5
+ config:
6
+ languages:
7
+ - ruby
8
+ fixme:
9
+ enabled: true
10
+ rubocop:
11
+ enabled: true
12
+ ratings:
13
+ paths:
14
+ - "**.rb"
15
+ exclude_paths:
16
+ - test/
@@ -0,0 +1,18 @@
1
+ AllCops:
2
+ Exclude:
3
+ - test/**/*
4
+
5
+ Metrics/LineLength:
6
+ Max: 120
7
+
8
+ MethodLength:
9
+ Max: 20
10
+
11
+ Style/ClassAndModuleChildren:
12
+ Enabled: false
13
+
14
+ Style/Documentation:
15
+ Enabled: false
16
+
17
+ Style/PredicateName:
18
+ Enabled: false
@@ -1,9 +1,20 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.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
@@ -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 .available_scopes to be directly mutatable
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
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in scope-list.gemspec
4
4
  gemspec
5
+
6
+ gem 'codeclimate-test-reporter', require: nil
data/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # Scopelist
2
2
 
3
- A simple way to track scopes in ActiveRecord 4.0 and 4.1.
3
+ A simple way to track scopes in ActiveRecord 4.0, 4.1, 4.2, and 5.0.
4
4
 
5
- NOTE: Only Ruby 1.9.3 and later are supported
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 "bundler/gem_tasks"
2
- require 'rspec/core/rake_task'
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
3
 
4
- RSpec::Core::RakeTask.new('spec')
5
-
6
- # If you want to make this the default task
7
- task :default => :spec
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
@@ -1,7 +1,7 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gem "sqlite3", :platforms=>:ruby
4
- gem "activerecord", "~> 4.0.0"
5
- gem "activesupport", "~> 4.0.0"
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=>'../'
@@ -1,7 +1,7 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gem "sqlite3", :platforms=>:ruby
4
- gem "activerecord", "~> 4.1.0"
5
- gem "activesupport", "~> 4.1.0"
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=>'../'
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activerecord', '~> 4.2.0'
4
+ gem 'activesupport', '~> 4.2.0'
5
+ gem 'codeclimate-test-reporter', require: nil
6
+
7
+ gemspec :path=>'../'
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'activerecord', '~> 5.0.0'
4
+ gem 'activesupport', '~> 5.0.0'
5
+ gem 'codeclimate-test-reporter', require: nil
6
+
7
+ gemspec :path=>'../'
@@ -1,33 +1,40 @@
1
- require "scopelist/version"
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
- module ClassMethods
15
- def scope_with_scopelist(name, body, &block)
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
- scope_without_scopelist(name, body, &block)
19
+ super
18
20
  end
21
+ end
19
22
 
23
+ module ClassMethods
20
24
  def available_scopes
21
25
  @available_scopes ||= []
22
- @available_scopes.dup
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)
@@ -1,3 +1,3 @@
1
1
  module Scopelist
2
- VERSION = "0.0.3"
2
+ VERSION = '0.0.4'.freeze
3
3
  end
@@ -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 = "scopelist"
7
+ spec.name = 'scopelist'
8
8
  spec.version = Scopelist::VERSION
9
- spec.authors = ["Tony Drake"]
10
- spec.email = ["t27duck@gmail.com"]
11
- spec.summary = %q{Adds ability to track scopes on ActiveRecord models}
12
- spec.description = %q{Adds ability to track scopes on ActiveRecord models}
13
- spec.homepage = "https://github.com/t27duck/scopelist"
14
- spec.license = "MIT"
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.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
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 "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"
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Drake
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2014-07-27 00:00:00.000000000 Z
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.2.0
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: []
@@ -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
@@ -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
@@ -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
@@ -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