filterrific 0.0.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.
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/design/ideas.txt +102 -0
- data/lib/filterrific.rb +0 -0
- data/test/helper.rb +10 -0
- data/test/test_filterrific.rb +7 -0
- metadata +94 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Jo Hund
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= filterrific
|
2
|
+
|
3
|
+
Add filter controls to your ActiveRecord lists and persist filter settings via session or DB.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Jo Hund. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "filterrific"
|
8
|
+
gem.summary = %Q{Add filter controls to your ActiveRecord lists and persist filter settings via session or DB}
|
9
|
+
gem.description = %Q{Add filter controls to your ActiveRecord lists and persist filter settings via session or DB}
|
10
|
+
gem.email = "jhund@clearcove.ca"
|
11
|
+
gem.homepage = "http://github.com/jhund/filterrific"
|
12
|
+
gem.authors = ["Jo Hund"]
|
13
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
|
+
gem.add_development_dependency "yard", ">= 0"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
26
|
+
test.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
task :rcov do
|
38
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
task :test => :check_dependencies
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
begin
|
47
|
+
require 'yard'
|
48
|
+
YARD::Rake::YardocTask.new
|
49
|
+
rescue LoadError
|
50
|
+
task :yardoc do
|
51
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
52
|
+
end
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/design/ideas.txt
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
Glean specific code from these projects:
|
2
|
+
|
3
|
+
20100224 CVIMS
|
4
|
+
201001 cando
|
5
|
+
201001 PTS
|
6
|
+
201001 Quentin-rails-backend
|
7
|
+
stratadocs (list starts with self as AR proxy)
|
8
|
+
|
9
|
+
MODEL
|
10
|
+
=====
|
11
|
+
|
12
|
+
filterrific do
|
13
|
+
associations do
|
14
|
+
person # creates a scope for filterrific
|
15
|
+
state, :default => [1,2,3,4], :label => "Publishing state", :as => :select, :multiple => 4
|
16
|
+
end
|
17
|
+
|
18
|
+
scopes do
|
19
|
+
active_only, :default => true # refers to already defined scope
|
20
|
+
sorted_by, :default => "created_at_desc"
|
21
|
+
end
|
22
|
+
|
23
|
+
persist_in_session false # overrides global filterrific settings
|
24
|
+
end
|
25
|
+
|
26
|
+
Only filters defined in filterrific will be exposed via URL. Other scopes will not be accessible
|
27
|
+
|
28
|
+
view
|
29
|
+
(skip these for now?)
|
30
|
+
apply all relevant options from formtastic
|
31
|
+
integrate with formtastic?
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
CONTROLLER
|
36
|
+
==========
|
37
|
+
|
38
|
+
def index
|
39
|
+
init_filterrific(Publication, :publications_list)
|
40
|
+
@publications = Publication.filterrific(@filter_options).paginate...
|
41
|
+
...
|
42
|
+
end
|
43
|
+
|
44
|
+
def init_filterrific(klass, scope = nil)
|
45
|
+
scope_name ||= klass.to_s.underscore # use resource class name as default scope name
|
46
|
+
filter_options_hash = params[:filter_options]
|
47
|
+
filter_options_hash ||= session[scope_name] if filterrific.persist_in_session
|
48
|
+
@filter_options = Filterrific.new(Publication, params[:filter_options])
|
49
|
+
session[scope_name] = @filter_options.to_hash if filterrific.persist_in_session # (store sanitized options). Maybe just define marshal dump? skip to_hash
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
Filterrific CONFIG
|
54
|
+
==================
|
55
|
+
|
56
|
+
Settings:
|
57
|
+
* persist_in_session
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
SAVED SEARCHES
|
62
|
+
==============
|
63
|
+
|
64
|
+
See cando for implementation
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
CONTENT FOR README
|
70
|
+
==================
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
This Rails plugin makes it super simple to add filtering to your rails list views.
|
76
|
+
|
77
|
+
Some of the features:
|
78
|
+
---------------------
|
79
|
+
|
80
|
+
* RESTful
|
81
|
+
* conditions, sorting, maybe grouping?
|
82
|
+
* works with pagination
|
83
|
+
* settings can be persisted in session or via database for saved searches
|
84
|
+
* works with ActiveRecord
|
85
|
+
* gets along well with will_paginate
|
86
|
+
|
87
|
+
Possibilities:
|
88
|
+
-------------
|
89
|
+
|
90
|
+
* integrate with thinking_sphinx
|
91
|
+
* integrate with formtastic
|
92
|
+
* integrate with will_paginate
|
93
|
+
* integrate with make_resourceful
|
94
|
+
|
95
|
+
Here is how it works:
|
96
|
+
---------------------
|
97
|
+
|
98
|
+
Filterrific relies heavily on scopes. Each filter dimension has its own scope. Filterrific makes it
|
99
|
+
easy to shuttle user settings to your controllers and models for queries, and back to the views.
|
100
|
+
|
101
|
+
|
102
|
+
|
data/lib/filterrific.rb
ADDED
File without changes
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: filterrific
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 0.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Jo Hund
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-07-30 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: thoughtbot-shoulda
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: yard
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
version: "0"
|
42
|
+
type: :development
|
43
|
+
version_requirements: *id002
|
44
|
+
description: Add filter controls to your ActiveRecord lists and persist filter settings via session or DB
|
45
|
+
email: jhund@clearcove.ca
|
46
|
+
executables: []
|
47
|
+
|
48
|
+
extensions: []
|
49
|
+
|
50
|
+
extra_rdoc_files:
|
51
|
+
- LICENSE
|
52
|
+
- README.rdoc
|
53
|
+
files:
|
54
|
+
- LICENSE
|
55
|
+
- README.rdoc
|
56
|
+
- Rakefile
|
57
|
+
- VERSION
|
58
|
+
- design/ideas.txt
|
59
|
+
- lib/filterrific.rb
|
60
|
+
- test/helper.rb
|
61
|
+
- test/test_filterrific.rb
|
62
|
+
has_rdoc: true
|
63
|
+
homepage: http://github.com/jhund/filterrific
|
64
|
+
licenses: []
|
65
|
+
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options:
|
68
|
+
- --charset=UTF-8
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
requirements: []
|
86
|
+
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 1.3.6
|
89
|
+
signing_key:
|
90
|
+
specification_version: 3
|
91
|
+
summary: Add filter controls to your ActiveRecord lists and persist filter settings via session or DB
|
92
|
+
test_files:
|
93
|
+
- test/helper.rb
|
94
|
+
- test/test_filterrific.rb
|