has_scope 0.6.0.rc → 0.6.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 +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +44 -5
- data/lib/has_scope.rb +33 -28
- data/lib/has_scope/version.rb +1 -1
- data/test/has_scope_test.rb +86 -28
- data/test/test_helper.rb +7 -5
- metadata +18 -24
- data/.gitignore +0 -2
- data/.travis.yml +0 -14
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -48
- data/Rakefile +0 -26
- data/gemfiles/Gemfile-rails.3.2.x +0 -8
- data/has_scope.gemspec +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48513d85f54847d588aec0efc61f818a2ffebefe
|
4
|
+
data.tar.gz: 8c85796fc391a814bbb821f006934ded14bd820f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9648a802b913abb6873ec394d14c3fe22404e788f1a984901439a3c5883351dc9b3223bdb67c4f443351db16e56b9502b3923c8e0c0770448893e5f4eb1c7350
|
7
|
+
data.tar.gz: 49c94cbb4ef1d0376078deb8ac6c81cbc61b1092e0440b36f53dc362240799bf503a8a91338c8b9a5a52425fa4cced774f9965e7c65d03c280eb37546ddc592e
|
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright 2009-
|
1
|
+
Copyright 2009-2015 Plataforma Tecnologia. http://blog.plataformatec.com.br
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -11,6 +11,7 @@ Imagine the following model called graduations:
|
|
11
11
|
class Graduation < ActiveRecord::Base
|
12
12
|
scope :featured, -> { where(:featured => true) }
|
13
13
|
scope :by_degree, -> degree { where(:degree => degree) }
|
14
|
+
scope :by_period, -> started_at, ended_at { where("started_at = ? AND ended_at = ?", started_at, ended_at) }
|
14
15
|
end
|
15
16
|
```
|
16
17
|
|
@@ -29,7 +30,7 @@ Now, if you want to apply them to an specific resource, you just need to call `a
|
|
29
30
|
class GraduationsController < ApplicationController
|
30
31
|
has_scope :featured, :type => :boolean
|
31
32
|
has_scope :by_degree
|
32
|
-
has_scope :by_period, :using => [:started_at, :ended_at]
|
33
|
+
has_scope :by_period, :using => [:started_at, :ended_at], :type => :hash
|
33
34
|
|
34
35
|
def index
|
35
36
|
@graduations = apply_scopes(Graduation).all
|
@@ -46,7 +47,7 @@ Then for each request:
|
|
46
47
|
/graduations?featured=true
|
47
48
|
#=> calls the named scope and bring featured graduations
|
48
49
|
|
49
|
-
/graduations?
|
50
|
+
/graduations?by_period[started_at]=20100701&by_period[ended_at]=20101013
|
50
51
|
#=> brings graduations in the given period
|
51
52
|
|
52
53
|
/graduations?featured=true&by_degree=phd
|
@@ -68,7 +69,11 @@ gem 'has_scope'
|
|
68
69
|
|
69
70
|
HasScope supports several options:
|
70
71
|
|
71
|
-
* `:type` - Checks the type of the parameter sent.
|
72
|
+
* `:type` - Checks the type of the parameter sent.
|
73
|
+
By default, it does not allow hashes or arrays to be given,
|
74
|
+
except if type `:hash` or `:array` are set.
|
75
|
+
Symbols are never permitted to prevent memory leaks, so ensure any routing
|
76
|
+
constraints you have that add parameters use string values.
|
72
77
|
|
73
78
|
* `:only` - In which actions the scope is applied.
|
74
79
|
|
@@ -86,6 +91,25 @@ HasScope supports several options:
|
|
86
91
|
|
87
92
|
* `:allow_blank` - Blank values are not sent to scopes by default. Set to true to overwrite.
|
88
93
|
|
94
|
+
* `:in` - A shortcut for combining the `:using` option with nested hashes.
|
95
|
+
|
96
|
+
## Boolean usage
|
97
|
+
|
98
|
+
If `type: :boolean` is set it just calls the named scope, without any arguments, when parameter
|
99
|
+
is set to a "true" value. `'true'` and `'1'` are parsed as `true`, everything else as `false`.
|
100
|
+
|
101
|
+
When boolean scope is set up with `allow_blank: true`, it will call the scope
|
102
|
+
with the value as usual scope.
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
has_scope :visible, type: :boolean
|
106
|
+
has_scope :active, type: :boolean, allow_blank: true
|
107
|
+
|
108
|
+
# and models with
|
109
|
+
scope :visible, -> { where(visible: true) }
|
110
|
+
scope :active, ->(value = true) { where(active: value) }
|
111
|
+
```
|
112
|
+
|
89
113
|
## Block usage
|
90
114
|
|
91
115
|
`has_scope` also accepts a block. The controller, current scope and value are yielded
|
@@ -98,7 +122,8 @@ has_scope :category do |controller, scope, value|
|
|
98
122
|
end
|
99
123
|
```
|
100
124
|
|
101
|
-
When used with booleans
|
125
|
+
When used with booleans without `:allow_blank`, it just receives two arguments
|
126
|
+
and is just invoked if true is given:
|
102
127
|
|
103
128
|
```ruby
|
104
129
|
has_scope :not_voted_by_me, :type => :boolean do |controller, scope|
|
@@ -106,10 +131,24 @@ has_scope :not_voted_by_me, :type => :boolean do |controller, scope|
|
|
106
131
|
end
|
107
132
|
```
|
108
133
|
|
134
|
+
## Apply scope on every request
|
135
|
+
|
136
|
+
To apply scope on every request set default value and `allow_blank: true`:
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
has_scope :available, default: nil, allow_blank: true, only: :show, unless: :admin?
|
140
|
+
|
141
|
+
# model:
|
142
|
+
scope :available, ->(*) { where(blocked: false) }
|
143
|
+
```
|
144
|
+
|
145
|
+
This will allow usual users to get only available items, but admins will
|
146
|
+
be able to access blocked items too.
|
147
|
+
|
109
148
|
## Bugs and Feedback
|
110
149
|
|
111
150
|
If you discover any bugs or want to drop a line, feel free to create an issue on GitHub.
|
112
151
|
|
113
152
|
http://github.com/plataformatec/has_scope/issues
|
114
153
|
|
115
|
-
MIT License. Copyright 2009-
|
154
|
+
MIT License. Copyright 2009-2015 Plataformatec. http://blog.plataformatec.com.br
|
data/lib/has_scope.rb
CHANGED
@@ -2,16 +2,17 @@ module HasScope
|
|
2
2
|
TRUE_VALUES = ["true", true, "1", 1]
|
3
3
|
|
4
4
|
ALLOWED_TYPES = {
|
5
|
-
:array => [ Array ],
|
6
|
-
:hash => [ Hash ],
|
7
|
-
:boolean => [ Object ],
|
8
|
-
:default => [ String, Numeric ]
|
5
|
+
:array => [[ Array ]],
|
6
|
+
:hash => [[ Hash ]],
|
7
|
+
:boolean => [[ Object ], -> v { TRUE_VALUES.include?(v) }],
|
8
|
+
:default => [[ String, Numeric ]],
|
9
9
|
}
|
10
10
|
|
11
11
|
def self.included(base)
|
12
12
|
base.class_eval do
|
13
13
|
extend ClassMethods
|
14
14
|
class_attribute :scopes_configuration, :instance_writer => false
|
15
|
+
self.scopes_configuration = {}
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
@@ -63,7 +64,12 @@ module HasScope
|
|
63
64
|
def has_scope(*scopes, &block)
|
64
65
|
options = scopes.extract_options!
|
65
66
|
options.symbolize_keys!
|
66
|
-
options.assert_valid_keys(:type, :only, :except, :if, :unless, :default, :as, :using, :allow_blank)
|
67
|
+
options.assert_valid_keys(:type, :only, :except, :if, :unless, :default, :as, :using, :allow_blank, :in)
|
68
|
+
|
69
|
+
if options.key?(:in)
|
70
|
+
options[:as] = options[:in]
|
71
|
+
options[:using] = scopes
|
72
|
+
end
|
67
73
|
|
68
74
|
if options.key?(:using)
|
69
75
|
if options.key?(:type) && options[:type] != :hash
|
@@ -78,11 +84,11 @@ module HasScope
|
|
78
84
|
options[:only] = Array(options[:only])
|
79
85
|
options[:except] = Array(options[:except])
|
80
86
|
|
81
|
-
self.scopes_configuration =
|
87
|
+
self.scopes_configuration = scopes_configuration.dup
|
82
88
|
|
83
89
|
scopes.each do |scope|
|
84
|
-
|
85
|
-
|
90
|
+
scopes_configuration[scope] ||= { :as => scope, :type => :default, :block => block }
|
91
|
+
scopes_configuration[scope] = self.scopes_configuration[scope].merge(options)
|
86
92
|
end
|
87
93
|
end
|
88
94
|
end
|
@@ -101,9 +107,7 @@ module HasScope
|
|
101
107
|
# end
|
102
108
|
#
|
103
109
|
def apply_scopes(target, hash=params)
|
104
|
-
|
105
|
-
|
106
|
-
self.scopes_configuration.each do |scope, options|
|
110
|
+
scopes_configuration.each do |scope, options|
|
107
111
|
next unless apply_scope_to_action?(options)
|
108
112
|
key = options[:as]
|
109
113
|
|
@@ -111,7 +115,9 @@ module HasScope
|
|
111
115
|
value, call_scope = hash[key], true
|
112
116
|
elsif options.key?(:default)
|
113
117
|
value, call_scope = options[:default], true
|
114
|
-
|
118
|
+
if value.is_a?(Proc)
|
119
|
+
value = value.arity == 0 ? value.call : value.call(self)
|
120
|
+
end
|
115
121
|
end
|
116
122
|
|
117
123
|
value = parse_value(options[:type], key, value)
|
@@ -128,19 +134,18 @@ module HasScope
|
|
128
134
|
|
129
135
|
# Set the real value for the current scope if type check.
|
130
136
|
def parse_value(type, key, value) #:nodoc:
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
value
|
137
|
+
klasses, parser = ALLOWED_TYPES[type]
|
138
|
+
if klasses.any? { |klass| value.is_a?(klass) }
|
139
|
+
parser ? parser.call(value) : value
|
135
140
|
end
|
136
141
|
end
|
137
142
|
|
138
143
|
# Screens pseudo-blank params.
|
139
144
|
def normalize_blanks(value) #:nodoc:
|
140
|
-
|
141
|
-
|
145
|
+
case value
|
146
|
+
when Array
|
142
147
|
value.select { |v| v.present? }
|
143
|
-
|
148
|
+
when Hash
|
144
149
|
value.select { |k, v| normalize_blanks(v).present? }.with_indifferent_access
|
145
150
|
else
|
146
151
|
value
|
@@ -151,7 +156,7 @@ module HasScope
|
|
151
156
|
def call_scope_by_type(type, scope, target, value, options) #:nodoc:
|
152
157
|
block = options[:block]
|
153
158
|
|
154
|
-
if type == :boolean
|
159
|
+
if type == :boolean && !options[:allow_blank]
|
155
160
|
block ? block.call(self, target) : target.send(scope)
|
156
161
|
elsif value && options.key?(:using)
|
157
162
|
value = value.values_at(*options[:using])
|
@@ -177,14 +182,14 @@ module HasScope
|
|
177
182
|
# method, or string evals to the expected value.
|
178
183
|
def applicable?(string_proc_or_symbol, expected) #:nodoc:
|
179
184
|
case string_proc_or_symbol
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
185
|
+
when String
|
186
|
+
eval(string_proc_or_symbol) == expected
|
187
|
+
when Proc
|
188
|
+
string_proc_or_symbol.call(self) == expected
|
189
|
+
when Symbol
|
190
|
+
send(string_proc_or_symbol) == expected
|
191
|
+
else
|
192
|
+
true
|
188
193
|
end
|
189
194
|
end
|
190
195
|
|
data/lib/has_scope/version.rb
CHANGED
data/test/has_scope_test.rb
CHANGED
@@ -1,17 +1,23 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
HasScope::ALLOWED_TYPES[:date] = [[String], -> v { Date.parse(v) rescue nil }]
|
4
|
+
|
5
|
+
class Tree; end
|
5
6
|
|
6
7
|
class TreesController < ApplicationController
|
7
8
|
has_scope :color, :unless => :show_all_colors?
|
8
9
|
has_scope :only_tall, :type => :boolean, :only => :index, :if => :restrict_to_only_tall_trees?
|
9
10
|
has_scope :shadown_range, :default => 10, :except => [ :index, :show, :new ]
|
10
11
|
has_scope :root_type, :as => :root, :allow_blank => true
|
12
|
+
has_scope :planted_before, :default => proc { Date.today }
|
13
|
+
has_scope :planted_after, :type => :date
|
11
14
|
has_scope :calculate_height, :default => proc {|c| c.session[:height] || 20 }, :only => :new
|
12
15
|
has_scope :paginate, :type => :hash
|
13
16
|
has_scope :args_paginate, :type => :hash, :using => [:page, :per_page]
|
14
17
|
has_scope :categories, :type => :array
|
18
|
+
has_scope :title, :in => :q
|
19
|
+
has_scope :content, :in => :q
|
20
|
+
has_scope :conifer, type: :boolean, :allow_blank => true
|
15
21
|
|
16
22
|
has_scope :only_short, :type => :boolean do |controller, scope|
|
17
23
|
scope.only_really_short!(controller.object_id)
|
@@ -73,7 +79,31 @@ class HasScopeTest < ActionController::TestCase
|
|
73
79
|
Tree.expects(:all).returns([mock_tree])
|
74
80
|
get :index, :only_tall => 'false'
|
75
81
|
assert_equal([mock_tree], assigns(:trees))
|
76
|
-
assert_equal({}, current_scopes)
|
82
|
+
assert_equal({ }, current_scopes)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_boolean_scope_with_allow_blank_is_called_when_boolean_param_is_true
|
86
|
+
Tree.expects(:conifer).with(true).returns(Tree).in_sequence
|
87
|
+
Tree.expects(:all).returns([mock_tree]).in_sequence
|
88
|
+
get :index, :conifer => 'true'
|
89
|
+
assert_equal([mock_tree], assigns(:trees))
|
90
|
+
assert_equal({ :conifer => true }, current_scopes)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_boolean_scope_with_allow_blank_is_called_when_boolean_param_is_false
|
94
|
+
Tree.expects(:conifer).with(false).returns(Tree).in_sequence
|
95
|
+
Tree.expects(:all).returns([mock_tree]).in_sequence
|
96
|
+
get :index, :conifer => 'not_true'
|
97
|
+
assert_equal([mock_tree], assigns(:trees))
|
98
|
+
assert_equal({ :conifer => false }, current_scopes)
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_boolean_scope_with_allow_blank_is_not_called_when_boolean_param_is_not_present
|
102
|
+
Tree.expects(:conifer).never
|
103
|
+
Tree.expects(:all).returns([mock_tree])
|
104
|
+
get :index
|
105
|
+
assert_equal([mock_tree], assigns(:trees))
|
106
|
+
assert_equal({ }, current_scopes)
|
77
107
|
end
|
78
108
|
|
79
109
|
def test_scope_is_called_only_on_index
|
@@ -103,7 +133,7 @@ class HasScopeTest < ActionController::TestCase
|
|
103
133
|
end
|
104
134
|
|
105
135
|
def test_scope_is_called_except_on_index
|
106
|
-
Tree.expects(:shadown_range).
|
136
|
+
Tree.expects(:shadown_range).never
|
107
137
|
Tree.expects(:all).returns([mock_tree])
|
108
138
|
get :index, :shadown_range => 20
|
109
139
|
assert_equal([mock_tree], assigns(:trees))
|
@@ -209,7 +239,7 @@ class HasScopeTest < ActionController::TestCase
|
|
209
239
|
Tree.expects(:all).returns([mock_tree])
|
210
240
|
get :index, :paginate => "1"
|
211
241
|
assert_equal([mock_tree], assigns(:trees))
|
212
|
-
assert_equal({}, current_scopes)
|
242
|
+
assert_equal({ }, current_scopes)
|
213
243
|
end
|
214
244
|
|
215
245
|
def test_scope_is_called_with_default_value
|
@@ -236,35 +266,63 @@ class HasScopeTest < ActionController::TestCase
|
|
236
266
|
assert_equal({ :root => 'outside' }, current_scopes)
|
237
267
|
end
|
238
268
|
|
239
|
-
def
|
269
|
+
def test_scope_with_default_value_as_a_proc_without_argument
|
270
|
+
Date.expects(:today).returns("today")
|
271
|
+
Tree.expects(:planted_before).with("today").returns(Tree)
|
272
|
+
Tree.expects(:all).returns([mock_tree])
|
273
|
+
get :index
|
274
|
+
assert_equal([mock_tree], assigns(:trees))
|
275
|
+
assert_equal({ :planted_before => "today" }, current_scopes)
|
276
|
+
end
|
277
|
+
|
278
|
+
def test_scope_with_default_value_as_proc_with_argument
|
240
279
|
session[:height] = 100
|
241
280
|
Tree.expects(:calculate_height).with(100).returns(Tree).in_sequence
|
242
281
|
Tree.expects(:new).returns(mock_tree).in_sequence
|
243
282
|
get :new
|
244
283
|
assert_equal(mock_tree, assigns(:tree))
|
245
284
|
assert_equal({ :calculate_height => 100 }, current_scopes)
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
285
|
+
end
|
286
|
+
|
287
|
+
def test_scope_with_custom_type
|
288
|
+
parsed = Date.civil(2014,11,11)
|
289
|
+
Tree.expects(:planted_after).with(parsed).returns(Tree)
|
290
|
+
Tree.expects(:all).returns([mock_tree])
|
291
|
+
get :index, :planted_after => "2014-11-11"
|
292
|
+
assert_equal([mock_tree], assigns(:trees))
|
293
|
+
assert_equal({ :planted_after => parsed }, current_scopes)
|
294
|
+
end
|
295
|
+
|
296
|
+
def test_scope_with_boolean_block
|
297
|
+
Tree.expects(:only_really_short!).with(@controller.object_id).returns(Tree)
|
298
|
+
Tree.expects(:all).returns([mock_tree])
|
299
|
+
get :index, :only_short => 'true'
|
300
|
+
assert_equal([mock_tree], assigns(:trees))
|
301
|
+
assert_equal({ :only_short => true }, current_scopes)
|
302
|
+
end
|
303
|
+
|
304
|
+
def test_scope_with_other_block_types
|
305
|
+
Tree.expects(:by_given_category).with(@controller.object_id, 'for_id').returns(Tree)
|
306
|
+
Tree.expects(:all).returns([mock_tree])
|
307
|
+
get :index, :by_category => 'for'
|
308
|
+
assert_equal([mock_tree], assigns(:trees))
|
309
|
+
assert_equal({ :by_category => 'for' }, current_scopes)
|
310
|
+
end
|
311
|
+
|
312
|
+
def test_scope_with_nested_hash_and_in_option
|
313
|
+
hash = { 'title' => 'the-title', 'content' => 'the-content' }
|
314
|
+
Tree.expects(:title).with('the-title').returns(Tree)
|
315
|
+
Tree.expects(:content).with('the-content').returns(Tree)
|
316
|
+
Tree.expects(:all).returns([mock_tree])
|
317
|
+
get :index, :q => hash
|
318
|
+
assert_equal([mock_tree], assigns(:trees))
|
319
|
+
assert_equal({ :q => hash }, current_scopes)
|
320
|
+
end
|
321
|
+
|
322
|
+
def test_overwritten_scope
|
323
|
+
assert_nil(TreesController.scopes_configuration[:categories][:if])
|
324
|
+
assert_equal(:categories?, BonsaisController.scopes_configuration[:categories][:if])
|
325
|
+
end
|
268
326
|
|
269
327
|
protected
|
270
328
|
|
data/test/test_helper.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
require 'bundler'
|
1
|
+
require 'bundler/setup'
|
2
2
|
|
3
|
-
|
4
|
-
require '
|
5
|
-
require 'mocha/
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'mocha'
|
5
|
+
require 'mocha/mini_test'
|
6
6
|
|
7
7
|
# Configure Rails
|
8
|
-
ENV[
|
8
|
+
ENV['RAILS_ENV'] = 'test'
|
9
9
|
|
10
10
|
require 'active_support'
|
11
11
|
require 'action_controller'
|
@@ -24,6 +24,8 @@ class ApplicationController < ActionController::Base
|
|
24
24
|
end
|
25
25
|
|
26
26
|
class ActiveSupport::TestCase
|
27
|
+
self.test_order = :random if respond_to?(:test_order=)
|
28
|
+
|
27
29
|
setup do
|
28
30
|
@routes = HasScope::Routes
|
29
31
|
end
|
metadata
CHANGED
@@ -1,71 +1,64 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_scope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.0
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- José Valim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.2'
|
20
|
-
- - <
|
20
|
+
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '5'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '3.2'
|
30
|
-
- - <
|
30
|
+
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '5'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: activesupport
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- -
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '3.2'
|
40
|
-
- - <
|
40
|
+
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '5'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '3.2'
|
50
|
-
- - <
|
50
|
+
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '5'
|
53
53
|
description: Maps controller filters to your resource scopes
|
54
|
-
email:
|
54
|
+
email: opensource@plataformatec.com.br
|
55
55
|
executables: []
|
56
56
|
extensions: []
|
57
57
|
extra_rdoc_files:
|
58
58
|
- README.md
|
59
59
|
files:
|
60
|
-
- .gitignore
|
61
|
-
- .travis.yml
|
62
|
-
- Gemfile
|
63
|
-
- Gemfile.lock
|
64
60
|
- MIT-LICENSE
|
65
61
|
- README.md
|
66
|
-
- Rakefile
|
67
|
-
- gemfiles/Gemfile-rails.3.2.x
|
68
|
-
- has_scope.gemspec
|
69
62
|
- lib/has_scope.rb
|
70
63
|
- lib/has_scope/version.rb
|
71
64
|
- test/has_scope_test.rb
|
@@ -76,25 +69,26 @@ licenses:
|
|
76
69
|
metadata: {}
|
77
70
|
post_install_message:
|
78
71
|
rdoc_options:
|
79
|
-
- --charset=UTF-8
|
72
|
+
- "--charset=UTF-8"
|
80
73
|
require_paths:
|
81
74
|
- lib
|
82
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
83
76
|
requirements:
|
84
|
-
- -
|
77
|
+
- - ">="
|
85
78
|
- !ruby/object:Gem::Version
|
86
79
|
version: '0'
|
87
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
81
|
requirements:
|
89
|
-
- -
|
82
|
+
- - ">="
|
90
83
|
- !ruby/object:Gem::Version
|
91
|
-
version:
|
84
|
+
version: '0'
|
92
85
|
requirements: []
|
93
|
-
rubyforge_project:
|
94
|
-
rubygems_version: 2.
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.4.5
|
95
88
|
signing_key:
|
96
89
|
specification_version: 4
|
97
90
|
summary: Maps controller filters to your resource scopes.
|
98
91
|
test_files:
|
99
92
|
- test/has_scope_test.rb
|
100
93
|
- test/test_helper.rb
|
94
|
+
has_rdoc:
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 1.9.3
|
4
|
-
- 2.0.0
|
5
|
-
gemfile:
|
6
|
-
- Gemfile
|
7
|
-
- gemfiles/Gemfile-rails.3.2.x
|
8
|
-
notifications:
|
9
|
-
email: false
|
10
|
-
campfire:
|
11
|
-
on_success: change
|
12
|
-
on_failure: always
|
13
|
-
rooms:
|
14
|
-
- secure: "kysymH2KAtGgNLcWPaNLVENtghORHJC6yUxGzJ5y+JrzUwkr4gTOv0nMyw5k\nsHCN1F1mJtbiXxFOZpxDaWMSGVhP7ThRy0esovkfzkAHihbyPClX241eJcyD\nI3f7/BZN4gfiR+Mbml2frLKHOtEtrm2h0gIEsXJ/YL+Ysf0nxHw="
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
has_scope (0.6.0.rc)
|
5
|
-
actionpack (>= 3.2, < 5)
|
6
|
-
activesupport (>= 3.2, < 5)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
actionpack (4.0.0.rc1)
|
12
|
-
activesupport (= 4.0.0.rc1)
|
13
|
-
builder (~> 3.1.0)
|
14
|
-
erubis (~> 2.7.0)
|
15
|
-
rack (~> 1.5.2)
|
16
|
-
rack-test (~> 0.6.2)
|
17
|
-
activesupport (4.0.0.rc1)
|
18
|
-
i18n (~> 0.6, >= 0.6.4)
|
19
|
-
minitest (~> 4.2)
|
20
|
-
multi_json (~> 1.3)
|
21
|
-
thread_safe (~> 0.1)
|
22
|
-
tzinfo (~> 0.3.37)
|
23
|
-
atomic (1.1.9)
|
24
|
-
builder (3.1.4)
|
25
|
-
erubis (2.7.0)
|
26
|
-
i18n (0.6.4)
|
27
|
-
metaclass (0.0.1)
|
28
|
-
minitest (4.7.4)
|
29
|
-
mocha (0.13.3)
|
30
|
-
metaclass (~> 0.0.1)
|
31
|
-
multi_json (1.7.3)
|
32
|
-
rack (1.5.2)
|
33
|
-
rack-test (0.6.2)
|
34
|
-
rack (>= 1.0)
|
35
|
-
rake (10.0.4)
|
36
|
-
thread_safe (0.1.0)
|
37
|
-
atomic
|
38
|
-
tzinfo (0.3.37)
|
39
|
-
|
40
|
-
PLATFORMS
|
41
|
-
ruby
|
42
|
-
|
43
|
-
DEPENDENCIES
|
44
|
-
actionpack (~> 4.0.0.rc1)
|
45
|
-
activesupport (~> 4.0.0.rc1)
|
46
|
-
has_scope!
|
47
|
-
mocha (~> 0.13.2)
|
48
|
-
rake
|
data/Rakefile
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'bundler/gem_tasks'
|
4
|
-
|
5
|
-
require 'rake/testtask'
|
6
|
-
require 'rdoc/task'
|
7
|
-
|
8
|
-
desc 'Default: run unit tests.'
|
9
|
-
task :default => :test
|
10
|
-
|
11
|
-
desc 'Test HasScope'
|
12
|
-
Rake::TestTask.new(:test) do |t|
|
13
|
-
t.libs << 'lib'
|
14
|
-
t.libs << 'test'
|
15
|
-
t.pattern = 'test/**/*_test.rb'
|
16
|
-
t.verbose = true
|
17
|
-
end
|
18
|
-
|
19
|
-
desc 'Generate documentation for HasScope'
|
20
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
21
|
-
rdoc.rdoc_dir = 'rdoc'
|
22
|
-
rdoc.title = 'HasScope'
|
23
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
24
|
-
rdoc.rdoc_files.include('README.md')
|
25
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
26
|
-
end
|
data/has_scope.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "has_scope/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "has_scope"
|
7
|
-
s.version = HasScope::VERSION.dup
|
8
|
-
s.platform = Gem::Platform::RUBY
|
9
|
-
s.summary = "Maps controller filters to your resource scopes."
|
10
|
-
s.email = "developers@plataformatec.com.br"
|
11
|
-
s.homepage = "http://github.com/plataformatec/has_scope"
|
12
|
-
s.description = "Maps controller filters to your resource scopes"
|
13
|
-
s.authors = ['José Valim']
|
14
|
-
s.license = 'MIT'
|
15
|
-
|
16
|
-
s.rubyforge_project = "has_scope"
|
17
|
-
|
18
|
-
s.files = `git ls-files`.split("\n")
|
19
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
-
s.require_paths = ["lib"]
|
22
|
-
|
23
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
24
|
-
s.extra_rdoc_files = [
|
25
|
-
"README.md"
|
26
|
-
]
|
27
|
-
|
28
|
-
s.add_runtime_dependency "actionpack", ">= 3.2", "< 5"
|
29
|
-
s.add_runtime_dependency "activesupport", ">= 3.2", "< 5"
|
30
|
-
end
|