g_named_scope_filters 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +19 -0
- data/Manifest.txt +15 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +113 -0
- data/Rakefile +30 -0
- data/g_named_scope_filters.gemspec +44 -0
- data/lib/g_named_scope_filters.rb +12 -0
- data/lib/g_named_scope_filters/view_helpers.rb +151 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/g_named_scope_filters_spec.rb +11 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/rspec.rake +21 -0
- metadata +116 -0
data/History.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
== 1.0.4 2009-10-11
|
2
|
+
|
3
|
+
* Added ability to pass in record counts for the filters to override the control's way of calculating
|
4
|
+
the available record counts.
|
5
|
+
|
6
|
+
|
7
|
+
== 1.0.3 2009-04-17
|
8
|
+
|
9
|
+
* Fixed bug with resources scoped more than 1 level deep
|
10
|
+
|
11
|
+
|
12
|
+
== 1.0.1 2009-04-16
|
13
|
+
|
14
|
+
* Added namespace option
|
15
|
+
|
16
|
+
|
17
|
+
== 1.0.0 2009-03-12
|
18
|
+
|
19
|
+
* Initial release (ported from plugin)
|
data/Manifest.txt
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
PostInstall.txt
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
g_named_scope_filters.gemspec
|
7
|
+
lib/g_named_scope_filters.rb
|
8
|
+
lib/g_named_scope_filters/view_helpers.rb
|
9
|
+
script/console
|
10
|
+
script/destroy
|
11
|
+
script/generate
|
12
|
+
spec/g_named_scope_filters_spec.rb
|
13
|
+
spec/spec.opts
|
14
|
+
spec/spec_helper.rb
|
15
|
+
tasks/rspec.rake
|
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
= g_named_scope_filters
|
2
|
+
|
3
|
+
http://github.com/midas/g_named_scope_filters/tree/master
|
4
|
+
|
5
|
+
|
6
|
+
== DESCRIPTION:
|
7
|
+
|
8
|
+
This is an unordered list of filters that use named scopes within an ActiveRecord model
|
9
|
+
to filter a list. It is not tied to a table or list specifically as it simply manipulates the url, resulting
|
10
|
+
in a manipulation of any collection (list, table, etc.) it may be coupled with.
|
11
|
+
|
12
|
+
|
13
|
+
== FEATURES
|
14
|
+
|
15
|
+
* Generates unordered list of links that will filter based on defined named scopes in an ActiveRecord model
|
16
|
+
|
17
|
+
|
18
|
+
== PLANNED FEATURES
|
19
|
+
|
20
|
+
* Automatically use all named scopes defined in model if :only or :except options are not used
|
21
|
+
* Obey the :except option if :only option not present
|
22
|
+
|
23
|
+
|
24
|
+
== REQUIREMENTS:
|
25
|
+
|
26
|
+
* Rails >= 2.2.0
|
27
|
+
* Guilded >= 0.0.8 (http://github.com/midas/guilded/tree/master)
|
28
|
+
|
29
|
+
|
30
|
+
== INSTALL:
|
31
|
+
|
32
|
+
sudo gem install midas-g_named_scope_filters
|
33
|
+
|
34
|
+
In your Rails environment.rb file:
|
35
|
+
|
36
|
+
config.gem 'midas-g_named_scope_filters', :version => '1.0.0', :lib => 'g_named_scope_filters', :source => 'http://gems.github.com'
|
37
|
+
|
38
|
+
|
39
|
+
== USAGE:
|
40
|
+
|
41
|
+
Model:
|
42
|
+
|
43
|
+
class Item < ActiveRecord::Base
|
44
|
+
named_scope :recent, lambda { { :conditions => [ "date_of_offense BETWEEN ? AND ?",
|
45
|
+
31.days.ago.utc, Time.zone.now.end_of_day.utc ] } }
|
46
|
+
named_scope :inactive, :conditions => { :is_active => false }
|
47
|
+
end
|
48
|
+
|
49
|
+
View:
|
50
|
+
<%= g_named_scope_filters Item, :only => [:recent, :inactive], :scoped_by => @account, :include_count => true,
|
51
|
+
:id => 'item_filters' %>
|
52
|
+
|
53
|
+
You currently must use the :only option to specify which named scopes to use. It is planned to use all named scopes if
|
54
|
+
:only or :except are not present, however it is not yet implemented.
|
55
|
+
|
56
|
+
Results in:
|
57
|
+
|
58
|
+
<ul id="doc-filters" class="filters">
|
59
|
+
<li>
|
60
|
+
<a class="selected" href="/accounts/2/items">
|
61
|
+
All
|
62
|
+
<span>2</span>
|
63
|
+
</a>
|
64
|
+
</li>
|
65
|
+
<li>
|
66
|
+
<a class="" href="/accounts/2/items?filter=recent">
|
67
|
+
Recent
|
68
|
+
<span>1</span>
|
69
|
+
</a>
|
70
|
+
</li>
|
71
|
+
<li>
|
72
|
+
<a class="" href="/accounts/2/items?filter=inactive">
|
73
|
+
Inactive
|
74
|
+
<span>0</span>
|
75
|
+
</a>
|
76
|
+
</li>
|
77
|
+
</ul>
|
78
|
+
|
79
|
+
In order to override how the counts are calculated, simply pass a hash into the g_named_scope_filters :record_counts
|
80
|
+
option:
|
81
|
+
|
82
|
+
<%= g_named_scope_filters Item, :only => [:recent, :inactive], :scoped_by => @account, :include_count => true,
|
83
|
+
:record_counts => @record_counts, :id => 'item_filters' %>
|
84
|
+
|
85
|
+
The hash should contain symbols and integers representing the filter name and the number of available records:
|
86
|
+
|
87
|
+
{ :all => 4, :recent => 2, :inactive => 2 }
|
88
|
+
|
89
|
+
|
90
|
+
== LICENSE:
|
91
|
+
|
92
|
+
(The MIT License)
|
93
|
+
|
94
|
+
Copyright (c) 2009 C. Jason Harrelson (midas)
|
95
|
+
|
96
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
97
|
+
a copy of this software and associated documentation files (the
|
98
|
+
'Software'), to deal in the Software without restriction, including
|
99
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
100
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
101
|
+
permit persons to whom the Software is furnished to do so, subject to
|
102
|
+
the following conditions:
|
103
|
+
|
104
|
+
The above copyright notice and this permission notice shall be
|
105
|
+
included in all copies or substantial portions of the Software.
|
106
|
+
|
107
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
108
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
109
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
110
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
111
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
112
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
113
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
2
|
+
require File.dirname(__FILE__) + '/lib/g_named_scope_filters'
|
3
|
+
|
4
|
+
# Generate all the Rake tasks
|
5
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
+
$hoe = Hoe.new('g_named_scope_filters', GNamedScopeFilters::VERSION) do |p|
|
7
|
+
p.developer('C. Jason Harrelson (midas)', 'jason@lookforwardenterprises.com')
|
8
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
9
|
+
p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
10
|
+
p.rubyforge_name = p.name # TODO this is default value
|
11
|
+
# p.extra_deps = [
|
12
|
+
# ['activesupport','>= 2.0.2'],
|
13
|
+
# ]
|
14
|
+
p.extra_dev_deps = [
|
15
|
+
['newgem', ">= #{::Newgem::VERSION}"],
|
16
|
+
['rails', ">= 2.2.0"],
|
17
|
+
['midas-guilded', ">=0.0.6"]
|
18
|
+
]
|
19
|
+
|
20
|
+
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
21
|
+
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
22
|
+
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
23
|
+
p.rsync_args = '-av --delete --ignore-errors'
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'newgem/tasks' # load /tasks/*.rake
|
27
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
28
|
+
|
29
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
30
|
+
# task :default => [:spec, :features]
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{g_named_scope_filters}
|
5
|
+
s.version = "1.0.4"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["C. Jason Harrelson (midas)"]
|
9
|
+
s.date = %q{2009-10-11}
|
10
|
+
s.description = %q{This is an unordered list of filters that use named scopes within an ActiveRecord model to filter a list. It is not tied to a table or list specifically as it simply manipulates the url, resulting in a manipulation of any collection (list, table, etc.) it may be coupled with.}
|
11
|
+
s.email = ["jason@lookforwardenterprises.com"]
|
12
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc"]
|
13
|
+
s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "g_named_scope_filters.gemspec", "lib/g_named_scope_filters.rb", "lib/g_named_scope_filters/view_helpers.rb", "script/console", "script/destroy", "script/generate", "spec/g_named_scope_filters_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/rspec.rake"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{http://github.com/midas/g_named_scope_filters/tree/master}
|
16
|
+
s.post_install_message = %q{PostInstall.txt}
|
17
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
s.rubyforge_project = %q{g_named_scope_filters}
|
20
|
+
s.rubygems_version = %q{1.3.1}
|
21
|
+
s.summary = %q{This is an unordered list of filters that use named scopes within an ActiveRecord model to filter a list}
|
22
|
+
|
23
|
+
if s.respond_to? :specification_version then
|
24
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
|
+
s.specification_version = 2
|
26
|
+
|
27
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
|
+
s.add_development_dependency(%q<newgem>, [">= 1.3.0"])
|
29
|
+
s.add_development_dependency(%q<rails>, [">= 2.2.0"])
|
30
|
+
s.add_development_dependency(%q<midas-guilded>, [">= 0.0.6"])
|
31
|
+
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
|
32
|
+
else
|
33
|
+
s.add_dependency(%q<newgem>, [">= 1.3.0"])
|
34
|
+
s.add_dependency(%q<rails>, [">= 2.2.0"])
|
35
|
+
s.add_dependency(%q<midas-guilded>, [">= 0.0.6"])
|
36
|
+
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
37
|
+
end
|
38
|
+
else
|
39
|
+
s.add_dependency(%q<newgem>, [">= 1.3.0"])
|
40
|
+
s.add_dependency(%q<rails>, [">= 2.2.0"])
|
41
|
+
s.add_dependency(%q<midas-guilded>, [">= 0.0.6"])
|
42
|
+
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require 'g_named_scope_filters/view_helpers'
|
5
|
+
|
6
|
+
module GNamedScopeFilters
|
7
|
+
VERSION = '1.0.4'
|
8
|
+
end
|
9
|
+
|
10
|
+
if defined?( ActionView::Base )
|
11
|
+
ActionView::Base.send( :include, GNamedScopeFilters::ViewHelpers ) unless ActionView::Base.include?( GNamedScopeFilters::ViewHelpers )
|
12
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
module GNamedScopeFilters
|
2
|
+
module ViewHelpers
|
3
|
+
|
4
|
+
# Guilded component. This is an unordered list of filters that use named scopes within an ActiveRecord model
|
5
|
+
# to filter a list. It is not tied to a table or list specifically as it simply manipulates the url, resulting
|
6
|
+
# in a manipulation of a list or table.
|
7
|
+
#
|
8
|
+
# === Parameters
|
9
|
+
# :ar_obj_col_or_class:: The ActiveRecord object, collection or class to make the filters from. Warning:
|
10
|
+
# if you use anything but the class and the collection or object comes up nil or empty, then you will
|
11
|
+
# not have filters renderred. The prefferred way is to use the class unless you cannot due to dynamic reasons.
|
12
|
+
#
|
13
|
+
# === Options
|
14
|
+
# +id+ - (Required) This will be the id of the ul returned that wraps the filters.
|
15
|
+
# +class+ - This will be the id of the ul returned that wraps the filters. Defaults to 'filters.'
|
16
|
+
# +selected_class+ - This will be the class that is used to show whih filter is selected. Defaults to 'selected.'
|
17
|
+
# +only+ - This is the filters to include. Can be an array or string (for one filter).
|
18
|
+
# +include_count+ - True if you would like a span created within each filter list item containg the count for
|
19
|
+
# items in that filter.
|
20
|
+
# +scoped_by+ - This is the ActiveRecord object that this list is scoped by. For instance, if an account
|
21
|
+
# has many users and this is the user list for said acccount, then you would use :scoped_by => @account.
|
22
|
+
# This will scope the user list with filter to that account. It will also change the path helper from
|
23
|
+
# users_path to account_users_path, unless you overrode the path helper with :list_path_helper.
|
24
|
+
# +namespace+ - The name of the namespace being used for this resource.
|
25
|
+
# +polymorphic_type+ - A string representing the name of the type to use if the current type is just a polymorphic
|
26
|
+
# association table, etc. For instance
|
27
|
+
# +polymorphic_as+ -
|
28
|
+
#
|
29
|
+
def g_named_scope_filters( ar_obj_col_or_class, *args )
|
30
|
+
options = args.extract_options!
|
31
|
+
options.merge! :class => "filters" unless options.include?( :class )
|
32
|
+
options.merge! :selected_class => "selected" unless options.include?( :selected_class )
|
33
|
+
options.merge! :exclude_css => true, :exclude_js => true
|
34
|
+
|
35
|
+
if options[:only]
|
36
|
+
if options[:only].is_a?( String ) || options[:only].is_a?( Symbol )
|
37
|
+
filters = Array.new << options[:only]
|
38
|
+
else
|
39
|
+
filters = options[:only]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
options[:filters] = filters
|
43
|
+
|
44
|
+
scoped_by = options[:scoped_by]
|
45
|
+
polymorphic_type = options[:polymorphic_type]
|
46
|
+
polymorphic_as = options[:polymorphic_as]
|
47
|
+
record_counts = options[:record_counts]
|
48
|
+
|
49
|
+
raise "You must provide the 'polymorphic_as' option if you provide the 'polymorphic_type' option." if polymorphic_type && !polymorphic_as
|
50
|
+
|
51
|
+
Guilded::Guilder.instance.add( :named_scope_filters, options )
|
52
|
+
|
53
|
+
# Resolve the class of the ActiveRecord descendant type
|
54
|
+
if ar_obj_col_or_class.is_a?( Array )
|
55
|
+
return '' if ar_obj_col_or_class.empty?
|
56
|
+
klass = ar_obj_col_or_class[0].class
|
57
|
+
elsif ar_obj_col_or_class.is_a?( Class )
|
58
|
+
klass = ar_obj_col_or_class
|
59
|
+
elsif ar_obj_col_or_class.is_a?( ActiveRecord::Base )
|
60
|
+
klass = ar_obj_col_or_class.class
|
61
|
+
else
|
62
|
+
throw 'You must provide either an ActiveRecord object, collection or type in order to generate filters.'
|
63
|
+
end
|
64
|
+
|
65
|
+
path_helpers = Guilded::Rails::Helpers.resolve_rest_path_helpers( ar_obj_col_or_class, options )
|
66
|
+
list_path_helper = path_helpers[:index_rest_helper]
|
67
|
+
|
68
|
+
html = ''
|
69
|
+
|
70
|
+
return html if filters.empty?
|
71
|
+
|
72
|
+
# Resolve scoped by if it is an array
|
73
|
+
if scoped_by.is_a?( Array )
|
74
|
+
scoped_by = scoped_by.last
|
75
|
+
end
|
76
|
+
|
77
|
+
html << "<ul id=\"#{options[:id].to_s}\" class=\"#{options[:class].to_s}\">"
|
78
|
+
|
79
|
+
# Handle the all filter
|
80
|
+
link_text = "All"
|
81
|
+
|
82
|
+
if options[:include_count]
|
83
|
+
if record_counts
|
84
|
+
link_text << " <span>#{record_counts[:all]}</span>"
|
85
|
+
elsif scoped_by
|
86
|
+
if polymorphic_type
|
87
|
+
poly_scoped_finder = polymorphic_type.to_s.tableize
|
88
|
+
link_text << " <span>#{scoped_by.send( poly_scoped_finder.to_sym ).count}</span>"
|
89
|
+
else
|
90
|
+
scoped_finder = klass.to_s.tableize
|
91
|
+
link_text << " <span>#{scoped_by.send( scoped_finder.to_sym ).count}</span>"
|
92
|
+
end
|
93
|
+
else
|
94
|
+
link_text << " <span>#{klass.count}</span>"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
filter_options = Array.new
|
99
|
+
filter_options.push( :order => params[:order] ) if params[:order]
|
100
|
+
|
101
|
+
html << "<li>"
|
102
|
+
html << link_to( link_text, @controller.send( list_path_helper, *(path_helpers[:index_rest_args] + filter_options) ),
|
103
|
+
:class => "#{params[:filter].nil? ? options[:selected_class] : ''}" )
|
104
|
+
|
105
|
+
filters.each do |filter|
|
106
|
+
throw "You must define a named scope of '#{filter.to_s}' in order to render a named scope filter for it" unless klass.respond_to?( filter.to_sym )
|
107
|
+
link_text = filter.to_s.humanize
|
108
|
+
|
109
|
+
if options[:include_count]
|
110
|
+
|
111
|
+
if record_counts
|
112
|
+
link_text << " <span>#{record_counts[filter.to_sym]}</span>"
|
113
|
+
elsif scoped_by
|
114
|
+
scoped_finder = klass.to_s.tableize if scoped_finder.nil? || scoped_finder.empty?
|
115
|
+
|
116
|
+
if polymorphic_type
|
117
|
+
# If there is a named scope finder defined on the root klass that can get the
|
118
|
+
# polymorpic associated objects, the use it
|
119
|
+
if klass.respond_to?( poly_scoped_finder )
|
120
|
+
link_text << " <span>#{scoped_by.send( scoped_finder.to_sym ).send( poly_scoped_finder.to_sym ).send( filter.to_sym ).count}</span>"
|
121
|
+
else #otherwise, just use a AR's find
|
122
|
+
link_text << " <span>#{scoped_by.send( scoped_finder.to_sym ).send( filter.to_sym ).find(:all, :conditions => { "#{polymorphic_as}_type".to_sym => polymorphic_type } ).size}</span>"
|
123
|
+
end
|
124
|
+
else
|
125
|
+
link_text << " <span>#{scoped_by.send( scoped_finder.to_sym ).send( filter.to_sym ).count}</span>"
|
126
|
+
end
|
127
|
+
else
|
128
|
+
link_text << " <span>#{klass.send( filter.to_sym ).count}</span>"
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
#filter_options.merge!( :filter => filter )
|
134
|
+
if filter_options[filter_options.size-1].is_a?( Hash )
|
135
|
+
filter_options[filter_options.size-1].merge!( :filter => filter )
|
136
|
+
else
|
137
|
+
filter_options.push( :filter => filter )
|
138
|
+
end
|
139
|
+
|
140
|
+
html << "<li>"
|
141
|
+
html << link_to( link_text, @controller.send( list_path_helper, *(path_helpers[:index_rest_args] + filter_options) ),
|
142
|
+
:class => "#{params[:filter] == filter.to_s ? options[:selected_class] : ''}" )
|
143
|
+
html << "</li>"
|
144
|
+
end
|
145
|
+
|
146
|
+
html << "</ul>"
|
147
|
+
html
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
151
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/g_named_scope_filters.rb'}"
|
9
|
+
puts "Loading g_named_scope_filters gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: g_named_scope_filters
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- C. Jason Harrelson (midas)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-12 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: newgem
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.3.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rails
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.2.0
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: midas-guilded
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.0.6
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: hoe
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.8.0
|
54
|
+
version:
|
55
|
+
description: |-
|
56
|
+
This is an unordered list of filters that use named scopes within an ActiveRecord model
|
57
|
+
to filter a list. It is not tied to a table or list specifically as it simply manipulates the url, resulting
|
58
|
+
in a manipulation of any collection (list, table, etc.) it may be coupled with.
|
59
|
+
email:
|
60
|
+
- jason@lookforwardenterprises.com
|
61
|
+
executables: []
|
62
|
+
|
63
|
+
extensions: []
|
64
|
+
|
65
|
+
extra_rdoc_files:
|
66
|
+
- History.txt
|
67
|
+
- Manifest.txt
|
68
|
+
- PostInstall.txt
|
69
|
+
- README.rdoc
|
70
|
+
files:
|
71
|
+
- History.txt
|
72
|
+
- Manifest.txt
|
73
|
+
- PostInstall.txt
|
74
|
+
- README.rdoc
|
75
|
+
- Rakefile
|
76
|
+
- g_named_scope_filters.gemspec
|
77
|
+
- lib/g_named_scope_filters.rb
|
78
|
+
- lib/g_named_scope_filters/view_helpers.rb
|
79
|
+
- script/console
|
80
|
+
- script/destroy
|
81
|
+
- script/generate
|
82
|
+
- spec/g_named_scope_filters_spec.rb
|
83
|
+
- spec/spec.opts
|
84
|
+
- spec/spec_helper.rb
|
85
|
+
- tasks/rspec.rake
|
86
|
+
has_rdoc: true
|
87
|
+
homepage: http://github.com/midas/g_named_scope_filters/tree/master
|
88
|
+
licenses: []
|
89
|
+
|
90
|
+
post_install_message: PostInstall.txt
|
91
|
+
rdoc_options:
|
92
|
+
- --main
|
93
|
+
- README.rdoc
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: "0"
|
101
|
+
version:
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: "0"
|
107
|
+
version:
|
108
|
+
requirements: []
|
109
|
+
|
110
|
+
rubyforge_project: g_named_scope_filters
|
111
|
+
rubygems_version: 1.3.5
|
112
|
+
signing_key:
|
113
|
+
specification_version: 3
|
114
|
+
summary: This is an unordered list of filters that use named scopes within an ActiveRecord model to filter a list
|
115
|
+
test_files: []
|
116
|
+
|