with_filters 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/.gitignore +8 -0
  2. data/.yardopts +1 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +22 -0
  5. data/README.md +63 -0
  6. data/Rakefile +1 -0
  7. data/app/views/with_filters/_filter_form.html.erb +14 -0
  8. data/app/views/with_filters/filter/_check_box.html.erb +2 -0
  9. data/app/views/with_filters/filter/_check_boxes.html.erb +5 -0
  10. data/app/views/with_filters/filter/_radio.html.erb +5 -0
  11. data/app/views/with_filters/filter/_select.html.erb +2 -0
  12. data/app/views/with_filters/filter/_select_range.html.erb +4 -0
  13. data/app/views/with_filters/filter/_text.html.erb +2 -0
  14. data/app/views/with_filters/filter/_text_range.html.erb +4 -0
  15. data/changelog.md +2 -0
  16. data/lib/generators/with_filters/theme/theme_generator.rb +43 -0
  17. data/lib/with_filters/action_view_extension.rb +110 -0
  18. data/lib/with_filters/active_record_extension.rb +26 -0
  19. data/lib/with_filters/active_record_model_extension.rb +163 -0
  20. data/lib/with_filters/engine.rb +5 -0
  21. data/lib/with_filters/hash_extraction.rb +31 -0
  22. data/lib/with_filters/models/action.rb +14 -0
  23. data/lib/with_filters/models/filter/base.rb +36 -0
  24. data/lib/with_filters/models/filter/base_range.rb +42 -0
  25. data/lib/with_filters/models/filter/check_box.rb +20 -0
  26. data/lib/with_filters/models/filter/choice.rb +23 -0
  27. data/lib/with_filters/models/filter/collection.rb +28 -0
  28. data/lib/with_filters/models/filter/filter.rb +59 -0
  29. data/lib/with_filters/models/filter/radio.rb +7 -0
  30. data/lib/with_filters/models/filter/select.rb +22 -0
  31. data/lib/with_filters/models/filter/select_range.rb +15 -0
  32. data/lib/with_filters/models/filter/text.rb +30 -0
  33. data/lib/with_filters/models/filter/text_range.rb +15 -0
  34. data/lib/with_filters/models/filter_form.rb +93 -0
  35. data/lib/with_filters/value_prep/boolean_prep.rb +10 -0
  36. data/lib/with_filters/value_prep/date_prep.rb +10 -0
  37. data/lib/with_filters/value_prep/date_time_prep.rb +51 -0
  38. data/lib/with_filters/value_prep/default_prep.rb +88 -0
  39. data/lib/with_filters/value_prep/value_prep.rb +28 -0
  40. data/lib/with_filters/version.rb +3 -0
  41. data/lib/with_filters.rb +32 -0
  42. data/spec/active_record_model_extension_spec.rb +435 -0
  43. data/spec/dummy/README.rdoc +261 -0
  44. data/spec/dummy/Rakefile +7 -0
  45. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  46. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  47. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  48. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  49. data/spec/dummy/app/mailers/.gitkeep +0 -0
  50. data/spec/dummy/app/models/.gitkeep +0 -0
  51. data/spec/dummy/app/models/date_time_tester.rb +2 -0
  52. data/spec/dummy/app/models/field_format_tester.rb +2 -0
  53. data/spec/dummy/app/models/nobel_prize.rb +3 -0
  54. data/spec/dummy/app/models/nobel_prize_winner.rb +3 -0
  55. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  56. data/spec/dummy/config/application.rb +56 -0
  57. data/spec/dummy/config/boot.rb +10 -0
  58. data/spec/dummy/config/database.yml +25 -0
  59. data/spec/dummy/config/environment.rb +5 -0
  60. data/spec/dummy/config/environments/development.rb +37 -0
  61. data/spec/dummy/config/environments/production.rb +67 -0
  62. data/spec/dummy/config/environments/test.rb +37 -0
  63. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  64. data/spec/dummy/config/initializers/inflections.rb +15 -0
  65. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  66. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  67. data/spec/dummy/config/initializers/session_store.rb +8 -0
  68. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  69. data/spec/dummy/config/locales/en.yml +5 -0
  70. data/spec/dummy/config/routes.rb +58 -0
  71. data/spec/dummy/config.ru +4 -0
  72. data/spec/dummy/db/migrate/20111227224959_additional_columns.rb +73 -0
  73. data/spec/dummy/db/migrate/20120127203225_create_nobel_prize_winners.rb +30 -0
  74. data/spec/dummy/db/migrate/20120203212237_create_nobel_prizes.rb +34 -0
  75. data/spec/dummy/db/migrate/20120209051208_modify_updated_at.rb +13 -0
  76. data/spec/dummy/db/migrate/20120210163052_change_created_at.rb +17 -0
  77. data/spec/dummy/db/migrate/20120214172946_fix_einstein.rb +9 -0
  78. data/spec/dummy/db/migrate/20120227200013_create_date_time_testers.rb +25 -0
  79. data/spec/dummy/db/migrate/20120309202722_create_field_format_testers.rb +22 -0
  80. data/spec/dummy/db/migrate/20120310195447_update_field_format_testers.rb +15 -0
  81. data/spec/dummy/db/schema.rb +51 -0
  82. data/spec/dummy/db/test.sqlite3 +0 -0
  83. data/spec/dummy/lib/assets/.gitkeep +0 -0
  84. data/spec/dummy/log/.gitkeep +0 -0
  85. data/spec/dummy/public/404.html +26 -0
  86. data/spec/dummy/public/422.html +26 -0
  87. data/spec/dummy/public/500.html +25 -0
  88. data/spec/dummy/public/favicon.ico +0 -0
  89. data/spec/dummy/script/rails +6 -0
  90. data/spec/generators/with_filters_theme_spec.rb +33 -0
  91. data/spec/hash_extraction_spec.rb +51 -0
  92. data/spec/helpers/action_view_extension_spec.rb +345 -0
  93. data/spec/models/action.rb +20 -0
  94. data/spec/models/filter/base_range_spec.rb +32 -0
  95. data/spec/models/filter/base_spec.rb +76 -0
  96. data/spec/models/filter/check_box_spec.rb +36 -0
  97. data/spec/models/filter/choice_spec.rb +24 -0
  98. data/spec/models/filter/collection_spec.rb +72 -0
  99. data/spec/models/filter/filter_spec.rb +35 -0
  100. data/spec/models/filter/select_spec.rb +12 -0
  101. data/spec/models/filter/text_spec.rb +16 -0
  102. data/spec/models/filter_form_spec.rb +212 -0
  103. data/spec/spec_helper.rb +12 -0
  104. data/spec/value_prep/boolean_prep_spec.rb +13 -0
  105. data/spec/value_prep/date_prep_spec.rb +28 -0
  106. data/spec/value_prep/date_time_prep_spec.rb +106 -0
  107. data/spec/value_prep/default_prep_spec.rb +43 -0
  108. data/with_filters.gemspec +27 -0
  109. metadata +280 -0
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe WithFilters::ValuePrep::DefaultPrep do
4
+ describe '#value' do
5
+ context '#initialize value is a String' do
6
+ it 'trims whitespace' do
7
+ described_class.new(' Albert ').value.should == 'Albert'
8
+ end
9
+
10
+ context '#initialize options' do
11
+ context ':match' do
12
+ it 'returns an :exact match' do
13
+ described_class.new('a', {match: :exact}).value.should == 'a'
14
+ end
15
+
16
+ it 'returns a :contains match' do
17
+ described_class.new('a', {match: :contains}).value.should == '%a%'
18
+ end
19
+
20
+ it 'returns a :begins_with match' do
21
+ described_class.new('a', {match: :begins_with}).value.should == 'a%'
22
+ end
23
+
24
+ it 'returns an :ends_with match' do
25
+ described_class.new('a', {match: :ends_with}).value.should == '%a'
26
+ end
27
+ end
28
+
29
+ context 'no :match' do
30
+ it 'defaults to :exact' do
31
+ described_class.new('a').value.should == 'a'
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ context '#initialize value is an Array' do
38
+ it 'returns a string if only one value exists' do
39
+ described_class.new(['Albert']).value.should == 'Albert'
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/with_filters/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'with_filters'
6
+ gem.version = WithFilters::VERSION
7
+
8
+ gem.authors = ['Aaron Lasseigne']
9
+ gem.email = ['aaron.lasseigne@gmail.com']
10
+ gem.summary = %q{Add filtering to lists, tables, etc.}
11
+ gem.description = %q{Add filtering to lists, tables, etc.}
12
+ gem.homepage = 'https://github.com/AaronLasseigne/with_filters'
13
+
14
+ gem.rubyforge_project = 'with_filters'
15
+
16
+ gem.files = `git ls-files`.split("\n")
17
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ gem.require_paths = ['lib']
20
+
21
+ gem.add_dependency 'rails', '>= 3.1'
22
+
23
+ gem.add_development_dependency 'rspec-rails'
24
+ gem.add_development_dependency 'sqlite3'
25
+ gem.add_development_dependency 'genspec'
26
+ gem.add_development_dependency 'capybara'
27
+ end
metadata ADDED
@@ -0,0 +1,280 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: with_filters
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Aaron Lasseigne
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &70092264546940 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70092264546940
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec-rails
27
+ requirement: &70092264545600 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70092264545600
36
+ - !ruby/object:Gem::Dependency
37
+ name: sqlite3
38
+ requirement: &70092264544020 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70092264544020
47
+ - !ruby/object:Gem::Dependency
48
+ name: genspec
49
+ requirement: &70092264534380 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70092264534380
58
+ - !ruby/object:Gem::Dependency
59
+ name: capybara
60
+ requirement: &70092264532500 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70092264532500
69
+ description: Add filtering to lists, tables, etc.
70
+ email:
71
+ - aaron.lasseigne@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .yardopts
78
+ - Gemfile
79
+ - LICENSE
80
+ - README.md
81
+ - Rakefile
82
+ - app/views/with_filters/_filter_form.html.erb
83
+ - app/views/with_filters/filter/_check_box.html.erb
84
+ - app/views/with_filters/filter/_check_boxes.html.erb
85
+ - app/views/with_filters/filter/_radio.html.erb
86
+ - app/views/with_filters/filter/_select.html.erb
87
+ - app/views/with_filters/filter/_select_range.html.erb
88
+ - app/views/with_filters/filter/_text.html.erb
89
+ - app/views/with_filters/filter/_text_range.html.erb
90
+ - changelog.md
91
+ - lib/generators/with_filters/theme/theme_generator.rb
92
+ - lib/with_filters.rb
93
+ - lib/with_filters/action_view_extension.rb
94
+ - lib/with_filters/active_record_extension.rb
95
+ - lib/with_filters/active_record_model_extension.rb
96
+ - lib/with_filters/engine.rb
97
+ - lib/with_filters/hash_extraction.rb
98
+ - lib/with_filters/models/action.rb
99
+ - lib/with_filters/models/filter/base.rb
100
+ - lib/with_filters/models/filter/base_range.rb
101
+ - lib/with_filters/models/filter/check_box.rb
102
+ - lib/with_filters/models/filter/choice.rb
103
+ - lib/with_filters/models/filter/collection.rb
104
+ - lib/with_filters/models/filter/filter.rb
105
+ - lib/with_filters/models/filter/radio.rb
106
+ - lib/with_filters/models/filter/select.rb
107
+ - lib/with_filters/models/filter/select_range.rb
108
+ - lib/with_filters/models/filter/text.rb
109
+ - lib/with_filters/models/filter/text_range.rb
110
+ - lib/with_filters/models/filter_form.rb
111
+ - lib/with_filters/value_prep/boolean_prep.rb
112
+ - lib/with_filters/value_prep/date_prep.rb
113
+ - lib/with_filters/value_prep/date_time_prep.rb
114
+ - lib/with_filters/value_prep/default_prep.rb
115
+ - lib/with_filters/value_prep/value_prep.rb
116
+ - lib/with_filters/version.rb
117
+ - spec/active_record_model_extension_spec.rb
118
+ - spec/dummy/README.rdoc
119
+ - spec/dummy/Rakefile
120
+ - spec/dummy/app/assets/javascripts/application.js
121
+ - spec/dummy/app/assets/stylesheets/application.css
122
+ - spec/dummy/app/controllers/application_controller.rb
123
+ - spec/dummy/app/helpers/application_helper.rb
124
+ - spec/dummy/app/mailers/.gitkeep
125
+ - spec/dummy/app/models/.gitkeep
126
+ - spec/dummy/app/models/date_time_tester.rb
127
+ - spec/dummy/app/models/field_format_tester.rb
128
+ - spec/dummy/app/models/nobel_prize.rb
129
+ - spec/dummy/app/models/nobel_prize_winner.rb
130
+ - spec/dummy/app/views/layouts/application.html.erb
131
+ - spec/dummy/config.ru
132
+ - spec/dummy/config/application.rb
133
+ - spec/dummy/config/boot.rb
134
+ - spec/dummy/config/database.yml
135
+ - spec/dummy/config/environment.rb
136
+ - spec/dummy/config/environments/development.rb
137
+ - spec/dummy/config/environments/production.rb
138
+ - spec/dummy/config/environments/test.rb
139
+ - spec/dummy/config/initializers/backtrace_silencers.rb
140
+ - spec/dummy/config/initializers/inflections.rb
141
+ - spec/dummy/config/initializers/mime_types.rb
142
+ - spec/dummy/config/initializers/secret_token.rb
143
+ - spec/dummy/config/initializers/session_store.rb
144
+ - spec/dummy/config/initializers/wrap_parameters.rb
145
+ - spec/dummy/config/locales/en.yml
146
+ - spec/dummy/config/routes.rb
147
+ - spec/dummy/db/migrate/20111227224959_additional_columns.rb
148
+ - spec/dummy/db/migrate/20120127203225_create_nobel_prize_winners.rb
149
+ - spec/dummy/db/migrate/20120203212237_create_nobel_prizes.rb
150
+ - spec/dummy/db/migrate/20120209051208_modify_updated_at.rb
151
+ - spec/dummy/db/migrate/20120210163052_change_created_at.rb
152
+ - spec/dummy/db/migrate/20120214172946_fix_einstein.rb
153
+ - spec/dummy/db/migrate/20120227200013_create_date_time_testers.rb
154
+ - spec/dummy/db/migrate/20120309202722_create_field_format_testers.rb
155
+ - spec/dummy/db/migrate/20120310195447_update_field_format_testers.rb
156
+ - spec/dummy/db/schema.rb
157
+ - spec/dummy/db/test.sqlite3
158
+ - spec/dummy/lib/assets/.gitkeep
159
+ - spec/dummy/log/.gitkeep
160
+ - spec/dummy/public/404.html
161
+ - spec/dummy/public/422.html
162
+ - spec/dummy/public/500.html
163
+ - spec/dummy/public/favicon.ico
164
+ - spec/dummy/script/rails
165
+ - spec/generators/with_filters_theme_spec.rb
166
+ - spec/hash_extraction_spec.rb
167
+ - spec/helpers/action_view_extension_spec.rb
168
+ - spec/models/action.rb
169
+ - spec/models/filter/base_range_spec.rb
170
+ - spec/models/filter/base_spec.rb
171
+ - spec/models/filter/check_box_spec.rb
172
+ - spec/models/filter/choice_spec.rb
173
+ - spec/models/filter/collection_spec.rb
174
+ - spec/models/filter/filter_spec.rb
175
+ - spec/models/filter/select_spec.rb
176
+ - spec/models/filter/text_spec.rb
177
+ - spec/models/filter_form_spec.rb
178
+ - spec/spec_helper.rb
179
+ - spec/value_prep/boolean_prep_spec.rb
180
+ - spec/value_prep/date_prep_spec.rb
181
+ - spec/value_prep/date_time_prep_spec.rb
182
+ - spec/value_prep/default_prep_spec.rb
183
+ - with_filters.gemspec
184
+ homepage: https://github.com/AaronLasseigne/with_filters
185
+ licenses: []
186
+ post_install_message:
187
+ rdoc_options: []
188
+ require_paths:
189
+ - lib
190
+ required_ruby_version: !ruby/object:Gem::Requirement
191
+ none: false
192
+ requirements:
193
+ - - ! '>='
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ segments:
197
+ - 0
198
+ hash: -161425369091946249
199
+ required_rubygems_version: !ruby/object:Gem::Requirement
200
+ none: false
201
+ requirements:
202
+ - - ! '>='
203
+ - !ruby/object:Gem::Version
204
+ version: '0'
205
+ segments:
206
+ - 0
207
+ hash: -161425369091946249
208
+ requirements: []
209
+ rubyforge_project: with_filters
210
+ rubygems_version: 1.8.11
211
+ signing_key:
212
+ specification_version: 3
213
+ summary: Add filtering to lists, tables, etc.
214
+ test_files:
215
+ - spec/active_record_model_extension_spec.rb
216
+ - spec/dummy/README.rdoc
217
+ - spec/dummy/Rakefile
218
+ - spec/dummy/app/assets/javascripts/application.js
219
+ - spec/dummy/app/assets/stylesheets/application.css
220
+ - spec/dummy/app/controllers/application_controller.rb
221
+ - spec/dummy/app/helpers/application_helper.rb
222
+ - spec/dummy/app/mailers/.gitkeep
223
+ - spec/dummy/app/models/.gitkeep
224
+ - spec/dummy/app/models/date_time_tester.rb
225
+ - spec/dummy/app/models/field_format_tester.rb
226
+ - spec/dummy/app/models/nobel_prize.rb
227
+ - spec/dummy/app/models/nobel_prize_winner.rb
228
+ - spec/dummy/app/views/layouts/application.html.erb
229
+ - spec/dummy/config.ru
230
+ - spec/dummy/config/application.rb
231
+ - spec/dummy/config/boot.rb
232
+ - spec/dummy/config/database.yml
233
+ - spec/dummy/config/environment.rb
234
+ - spec/dummy/config/environments/development.rb
235
+ - spec/dummy/config/environments/production.rb
236
+ - spec/dummy/config/environments/test.rb
237
+ - spec/dummy/config/initializers/backtrace_silencers.rb
238
+ - spec/dummy/config/initializers/inflections.rb
239
+ - spec/dummy/config/initializers/mime_types.rb
240
+ - spec/dummy/config/initializers/secret_token.rb
241
+ - spec/dummy/config/initializers/session_store.rb
242
+ - spec/dummy/config/initializers/wrap_parameters.rb
243
+ - spec/dummy/config/locales/en.yml
244
+ - spec/dummy/config/routes.rb
245
+ - spec/dummy/db/migrate/20111227224959_additional_columns.rb
246
+ - spec/dummy/db/migrate/20120127203225_create_nobel_prize_winners.rb
247
+ - spec/dummy/db/migrate/20120203212237_create_nobel_prizes.rb
248
+ - spec/dummy/db/migrate/20120209051208_modify_updated_at.rb
249
+ - spec/dummy/db/migrate/20120210163052_change_created_at.rb
250
+ - spec/dummy/db/migrate/20120214172946_fix_einstein.rb
251
+ - spec/dummy/db/migrate/20120227200013_create_date_time_testers.rb
252
+ - spec/dummy/db/migrate/20120309202722_create_field_format_testers.rb
253
+ - spec/dummy/db/migrate/20120310195447_update_field_format_testers.rb
254
+ - spec/dummy/db/schema.rb
255
+ - spec/dummy/db/test.sqlite3
256
+ - spec/dummy/lib/assets/.gitkeep
257
+ - spec/dummy/log/.gitkeep
258
+ - spec/dummy/public/404.html
259
+ - spec/dummy/public/422.html
260
+ - spec/dummy/public/500.html
261
+ - spec/dummy/public/favicon.ico
262
+ - spec/dummy/script/rails
263
+ - spec/generators/with_filters_theme_spec.rb
264
+ - spec/hash_extraction_spec.rb
265
+ - spec/helpers/action_view_extension_spec.rb
266
+ - spec/models/action.rb
267
+ - spec/models/filter/base_range_spec.rb
268
+ - spec/models/filter/base_spec.rb
269
+ - spec/models/filter/check_box_spec.rb
270
+ - spec/models/filter/choice_spec.rb
271
+ - spec/models/filter/collection_spec.rb
272
+ - spec/models/filter/filter_spec.rb
273
+ - spec/models/filter/select_spec.rb
274
+ - spec/models/filter/text_spec.rb
275
+ - spec/models/filter_form_spec.rb
276
+ - spec/spec_helper.rb
277
+ - spec/value_prep/boolean_prep_spec.rb
278
+ - spec/value_prep/date_prep_spec.rb
279
+ - spec/value_prep/date_time_prep_spec.rb
280
+ - spec/value_prep/default_prep_spec.rb