searchgasm 1.0.0 → 1.0.1
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/CHANGELOG.rdoc +64 -0
- data/Manifest +3 -1
- data/README.rdoc +19 -29
- data/lib/searchgasm/active_record/associations.rb +10 -1
- data/lib/searchgasm/active_record/base.rb +60 -10
- data/lib/searchgasm/active_record.rb +8 -0
- data/lib/searchgasm/conditions/base.rb +66 -19
- data/lib/searchgasm/core_ext/hash.rb +22 -0
- data/lib/searchgasm/helpers/control_types/links.rb +65 -31
- data/lib/searchgasm/helpers/control_types/select.rb +1 -1
- data/lib/searchgasm/helpers/control_types.rb +18 -2
- data/lib/searchgasm/helpers/form.rb +10 -4
- data/lib/searchgasm/helpers/utilities.rb +27 -2
- data/lib/searchgasm/helpers.rb +7 -1
- data/lib/searchgasm/search/base.rb +38 -9
- data/lib/searchgasm/search/conditions.rb +26 -6
- data/lib/searchgasm/search/ordering.rb +14 -3
- data/lib/searchgasm/search/pagination.rb +52 -7
- data/lib/searchgasm/search/protection.rb +25 -3
- data/lib/searchgasm/version.rb +1 -1
- data/lib/searchgasm.rb +3 -0
- data/searchgasm.gemspec +9 -5
- data/test/test_condition_base.rb +4 -0
- data/test/test_conditions_base.rb +10 -10
- data/test/test_search_base.rb +13 -9
- data/test/test_search_conditions.rb +2 -2
- data/test/test_search_ordering.rb +2 -2
- data/test/test_search_pagination.rb +3 -3
- metadata +8 -4
- data/CHANGELOG +0 -23
data/lib/searchgasm.rb
CHANGED
data/searchgasm.gemspec
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Searchgasm-1.0.
|
2
|
+
# Gem::Specification for Searchgasm-1.0.1
|
3
3
|
# Originally generated by Echoe
|
4
4
|
|
5
5
|
--- !ruby/object:Gem::Specification
|
6
6
|
name: searchgasm
|
7
7
|
version: !ruby/object:Gem::Version
|
8
|
-
version: 1.0.
|
8
|
+
version: 1.0.1
|
9
9
|
platform: ruby
|
10
10
|
authors:
|
11
11
|
- Ben Johnson of Binary Logic
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
|
15
|
-
date: 2008-09-
|
15
|
+
date: 2008-09-11 00:00:00 -04:00
|
16
16
|
default_executable:
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
@@ -52,9 +52,10 @@ executables: []
|
|
52
52
|
extensions: []
|
53
53
|
|
54
54
|
extra_rdoc_files:
|
55
|
-
- CHANGELOG
|
55
|
+
- CHANGELOG.rdoc
|
56
56
|
- lib/searchgasm/active_record/associations.rb
|
57
57
|
- lib/searchgasm/active_record/base.rb
|
58
|
+
- lib/searchgasm/active_record.rb
|
58
59
|
- lib/searchgasm/condition/base.rb
|
59
60
|
- lib/searchgasm/condition/begins_with.rb
|
60
61
|
- lib/searchgasm/condition/child_of.rb
|
@@ -74,6 +75,7 @@ extra_rdoc_files:
|
|
74
75
|
- lib/searchgasm/conditions/base.rb
|
75
76
|
- lib/searchgasm/conditions/protection.rb
|
76
77
|
- lib/searchgasm/config.rb
|
78
|
+
- lib/searchgasm/core_ext/hash.rb
|
77
79
|
- lib/searchgasm/helpers/control_types/link.rb
|
78
80
|
- lib/searchgasm/helpers/control_types/links.rb
|
79
81
|
- lib/searchgasm/helpers/control_types/remote_link.rb
|
@@ -94,11 +96,12 @@ extra_rdoc_files:
|
|
94
96
|
- lib/searchgasm.rb
|
95
97
|
- README.rdoc
|
96
98
|
files:
|
97
|
-
- CHANGELOG
|
99
|
+
- CHANGELOG.rdoc
|
98
100
|
- examples/README.rdoc
|
99
101
|
- init.rb
|
100
102
|
- lib/searchgasm/active_record/associations.rb
|
101
103
|
- lib/searchgasm/active_record/base.rb
|
104
|
+
- lib/searchgasm/active_record.rb
|
102
105
|
- lib/searchgasm/condition/base.rb
|
103
106
|
- lib/searchgasm/condition/begins_with.rb
|
104
107
|
- lib/searchgasm/condition/child_of.rb
|
@@ -118,6 +121,7 @@ files:
|
|
118
121
|
- lib/searchgasm/conditions/base.rb
|
119
122
|
- lib/searchgasm/conditions/protection.rb
|
120
123
|
- lib/searchgasm/config.rb
|
124
|
+
- lib/searchgasm/core_ext/hash.rb
|
121
125
|
- lib/searchgasm/helpers/control_types/link.rb
|
122
126
|
- lib/searchgasm/helpers/control_types/links.rb
|
123
127
|
- lib/searchgasm/helpers/control_types/remote_link.rb
|
data/test/test_condition_base.rb
CHANGED
@@ -22,7 +22,7 @@ class TestConditionsBase < Test::Unit::TestCase
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_initialize
|
25
|
-
conditions =
|
25
|
+
conditions = Account.new_conditions(:name_contains => "Binary")
|
26
26
|
assert_equal conditions.klass, Account
|
27
27
|
assert_equal conditions.name_contains, "Binary"
|
28
28
|
end
|
@@ -34,7 +34,7 @@ class TestConditionsBase < Test::Unit::TestCase
|
|
34
34
|
def test_setting_conditions
|
35
35
|
[Account, User, Order].each do |klass|
|
36
36
|
conditions = klass.new_conditions
|
37
|
-
conditions.
|
37
|
+
conditions.class.condition_names.each do |condition_name|
|
38
38
|
conditions.send("#{condition_name}=", 1)
|
39
39
|
assert_equal 1, conditions.send(condition_name)
|
40
40
|
end
|
@@ -43,7 +43,7 @@ class TestConditionsBase < Test::Unit::TestCase
|
|
43
43
|
|
44
44
|
def test_accessible_protected_conditions
|
45
45
|
#Account.conditions_accessible << :name_contains
|
46
|
-
#conditions =
|
46
|
+
#conditions = Account.new_conditions
|
47
47
|
#conditions.conditions = {:created_after => Time.now, :name_contains => "Binary"}
|
48
48
|
#assert({:name_contains => "Binary"}, conditions.value)
|
49
49
|
end
|
@@ -56,7 +56,7 @@ class TestConditionsBase < Test::Unit::TestCase
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_setting_associations
|
59
|
-
conditions =
|
59
|
+
conditions = Account.new_conditions(:users => {:first_name_like => "Ben"})
|
60
60
|
assert_equal conditions.users.first_name_like, "Ben"
|
61
61
|
|
62
62
|
conditions.users.last_name_begins_with = "Ben"
|
@@ -64,7 +64,7 @@ class TestConditionsBase < Test::Unit::TestCase
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_includes
|
67
|
-
conditions =
|
67
|
+
conditions = Account.new_conditions
|
68
68
|
assert_equal conditions.includes, nil
|
69
69
|
|
70
70
|
conditions.name_like = "Binary"
|
@@ -78,7 +78,7 @@ class TestConditionsBase < Test::Unit::TestCase
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def test_objects
|
81
|
-
conditions =
|
81
|
+
conditions = Account.new_conditions
|
82
82
|
assert_equal conditions.send(:objects), []
|
83
83
|
|
84
84
|
conditions.name_contains = "Binary"
|
@@ -89,7 +89,7 @@ class TestConditionsBase < Test::Unit::TestCase
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def test_reset
|
92
|
-
conditions =
|
92
|
+
conditions = Account.new_conditions
|
93
93
|
|
94
94
|
conditions.name_contains = "Binary"
|
95
95
|
assert_equal 1, conditions.send(:objects).size
|
@@ -115,7 +115,7 @@ class TestConditionsBase < Test::Unit::TestCase
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def test_sanitize
|
118
|
-
conditions =
|
118
|
+
conditions = Account.new_conditions
|
119
119
|
conditions.name_contains = "Binary"
|
120
120
|
conditions.id_gt = 5
|
121
121
|
now = Time.now
|
@@ -130,7 +130,7 @@ class TestConditionsBase < Test::Unit::TestCase
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def test_conditions
|
133
|
-
conditions =
|
133
|
+
conditions = Account.new_conditions!
|
134
134
|
now = Time.now
|
135
135
|
v = {:name_contains => "Binary", :created_at_greater_than => now}
|
136
136
|
conditions.conditions = v
|
@@ -151,7 +151,7 @@ class TestConditionsBase < Test::Unit::TestCase
|
|
151
151
|
end
|
152
152
|
|
153
153
|
def test_searching
|
154
|
-
conditions =
|
154
|
+
conditions = Account.new_conditions
|
155
155
|
conditions.name_contains = "Binary"
|
156
156
|
assert_equal Account.find(1, 3), conditions.all
|
157
157
|
assert_equal Account.find(1, 3), conditions.find(:all)
|
data/test/test_search_base.rb
CHANGED
@@ -21,8 +21,8 @@ class TestSearchBase < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_initialize
|
24
|
-
assert_nothing_raised {
|
25
|
-
search =
|
24
|
+
assert_nothing_raised { Account.new_search }
|
25
|
+
search = Account.new_search!(:conditions => {:name_like => "binary"}, :page => 2, :limit => 10, :readonly => true)
|
26
26
|
assert_equal Account, search.klass
|
27
27
|
assert_equal "binary", search.conditions.name_like
|
28
28
|
assert_equal 2, search.page
|
@@ -31,7 +31,7 @@ class TestSearchBase < Test::Unit::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_setting_first_level_options
|
34
|
-
search =
|
34
|
+
search = Account.new_search
|
35
35
|
|
36
36
|
search.include = :users
|
37
37
|
assert_equal :users, search.include
|
@@ -90,7 +90,7 @@ class TestSearchBase < Test::Unit::TestCase
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def test_include
|
93
|
-
search =
|
93
|
+
search = Account.new_search
|
94
94
|
assert_equal nil, search.include
|
95
95
|
search.conditions.name_contains = "Binary"
|
96
96
|
assert_equal nil, search.include
|
@@ -106,7 +106,7 @@ class TestSearchBase < Test::Unit::TestCase
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def test_limit
|
109
|
-
search =
|
109
|
+
search = Account.new_search
|
110
110
|
search.limit = 10
|
111
111
|
assert_equal 10, search.limit
|
112
112
|
search.page = 2
|
@@ -125,7 +125,7 @@ class TestSearchBase < Test::Unit::TestCase
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def test_sanitize
|
128
|
-
search =
|
128
|
+
search = Account.new_search
|
129
129
|
search.per_page = 2
|
130
130
|
search.conditions.name_like = "Binary"
|
131
131
|
search.conditions.users.id_greater_than = 2
|
@@ -136,7 +136,7 @@ class TestSearchBase < Test::Unit::TestCase
|
|
136
136
|
end
|
137
137
|
|
138
138
|
def test_scope
|
139
|
-
search =
|
139
|
+
search = Account.new_search!
|
140
140
|
search.conditions = "some scope"
|
141
141
|
assert_equal "some scope", search.conditions.scope
|
142
142
|
search.conditions = nil
|
@@ -148,7 +148,7 @@ class TestSearchBase < Test::Unit::TestCase
|
|
148
148
|
end
|
149
149
|
|
150
150
|
def test_searching
|
151
|
-
search =
|
151
|
+
search = Account.new_search
|
152
152
|
search.conditions.name_like = "Binary"
|
153
153
|
assert_equal search.all, [Account.find(1), Account.find(3)]
|
154
154
|
assert_equal search.find(:all), [Account.find(1), Account.find(3)]
|
@@ -174,7 +174,7 @@ class TestSearchBase < Test::Unit::TestCase
|
|
174
174
|
end
|
175
175
|
|
176
176
|
def test_calculations
|
177
|
-
search =
|
177
|
+
search = Account.new_search
|
178
178
|
search.conditions.name_like = "Binary"
|
179
179
|
assert_equal 2, search.average('id')
|
180
180
|
assert_equal 2, search.calculate(:avg, 'id')
|
@@ -184,4 +184,8 @@ class TestSearchBase < Test::Unit::TestCase
|
|
184
184
|
assert_equal 1, search.minimum('id')
|
185
185
|
assert_equal 4, search.sum('id')
|
186
186
|
end
|
187
|
+
|
188
|
+
def test_method_creation_in_scope
|
189
|
+
# test ot make sure methods are not created across the board for all models
|
190
|
+
end
|
187
191
|
end
|
@@ -13,14 +13,14 @@ class TestSearchConditions < Test::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_conditions
|
16
|
-
search =
|
16
|
+
search = Account.new_search
|
17
17
|
assert_kind_of Searchgasm::Conditions::Base, search.conditions
|
18
18
|
assert_equal search.conditions.klass, Account
|
19
19
|
|
20
20
|
search.conditions = {:name_like => "Binary"}
|
21
21
|
assert_kind_of Searchgasm::Conditions::Base, search.conditions
|
22
22
|
|
23
|
-
conditions =
|
23
|
+
conditions = Account.new_conditions(:id_greater_than => 8)
|
24
24
|
search.conditions = conditions
|
25
25
|
assert_equal conditions, search.conditions
|
26
26
|
end
|
@@ -13,7 +13,7 @@ class TestSearchOrdering < Test::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_order_as
|
16
|
-
search =
|
16
|
+
search = Account.new_search
|
17
17
|
assert_equal nil, search.order
|
18
18
|
assert_equal "ASC", search.order_as
|
19
19
|
assert search.asc?
|
@@ -40,7 +40,7 @@ class TestSearchOrdering < Test::Unit::TestCase
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_order_by
|
43
|
-
search =
|
43
|
+
search = Account.new_search
|
44
44
|
assert_equal nil, search.order
|
45
45
|
assert_equal "id", search.order_by
|
46
46
|
|
@@ -13,7 +13,7 @@ class TestSearchPagination < Test::Unit::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_limit
|
16
|
-
search =
|
16
|
+
search = Account.new_search
|
17
17
|
search.limit = 10
|
18
18
|
assert_equal 10, search.limit
|
19
19
|
search.page = 2
|
@@ -29,7 +29,7 @@ class TestSearchPagination < Test::Unit::TestCase
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_page
|
32
|
-
search =
|
32
|
+
search = Account.new_search
|
33
33
|
search.page = 2
|
34
34
|
assert_equal 1, search.page
|
35
35
|
search.per_page = 20
|
@@ -43,7 +43,7 @@ class TestSearchPagination < Test::Unit::TestCase
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_per_page
|
46
|
-
search =
|
46
|
+
search = Account.new_search
|
47
47
|
search.per_page = 10
|
48
48
|
assert_equal 10, search.per_page
|
49
49
|
search.per_page = ""
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: searchgasm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Johnson of Binary Logic
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-11 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -49,9 +49,10 @@ executables: []
|
|
49
49
|
extensions: []
|
50
50
|
|
51
51
|
extra_rdoc_files:
|
52
|
-
- CHANGELOG
|
52
|
+
- CHANGELOG.rdoc
|
53
53
|
- lib/searchgasm/active_record/associations.rb
|
54
54
|
- lib/searchgasm/active_record/base.rb
|
55
|
+
- lib/searchgasm/active_record.rb
|
55
56
|
- lib/searchgasm/condition/base.rb
|
56
57
|
- lib/searchgasm/condition/begins_with.rb
|
57
58
|
- lib/searchgasm/condition/child_of.rb
|
@@ -71,6 +72,7 @@ extra_rdoc_files:
|
|
71
72
|
- lib/searchgasm/conditions/base.rb
|
72
73
|
- lib/searchgasm/conditions/protection.rb
|
73
74
|
- lib/searchgasm/config.rb
|
75
|
+
- lib/searchgasm/core_ext/hash.rb
|
74
76
|
- lib/searchgasm/helpers/control_types/link.rb
|
75
77
|
- lib/searchgasm/helpers/control_types/links.rb
|
76
78
|
- lib/searchgasm/helpers/control_types/remote_link.rb
|
@@ -91,11 +93,12 @@ extra_rdoc_files:
|
|
91
93
|
- lib/searchgasm.rb
|
92
94
|
- README.rdoc
|
93
95
|
files:
|
94
|
-
- CHANGELOG
|
96
|
+
- CHANGELOG.rdoc
|
95
97
|
- examples/README.rdoc
|
96
98
|
- init.rb
|
97
99
|
- lib/searchgasm/active_record/associations.rb
|
98
100
|
- lib/searchgasm/active_record/base.rb
|
101
|
+
- lib/searchgasm/active_record.rb
|
99
102
|
- lib/searchgasm/condition/base.rb
|
100
103
|
- lib/searchgasm/condition/begins_with.rb
|
101
104
|
- lib/searchgasm/condition/child_of.rb
|
@@ -115,6 +118,7 @@ files:
|
|
115
118
|
- lib/searchgasm/conditions/base.rb
|
116
119
|
- lib/searchgasm/conditions/protection.rb
|
117
120
|
- lib/searchgasm/config.rb
|
121
|
+
- lib/searchgasm/core_ext/hash.rb
|
118
122
|
- lib/searchgasm/helpers/control_types/link.rb
|
119
123
|
- lib/searchgasm/helpers/control_types/links.rb
|
120
124
|
- lib/searchgasm/helpers/control_types/remote_link.rb
|
data/CHANGELOG
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
v1.0.0. Major changes in the helpers, they were completely re-engineered. Much nicer and cleaner now. I established a pattern between all helpers giving you complete flexibility as to how they are used. All helpers are called differently now (see documentation).
|
2
|
-
|
3
|
-
v0.9.10. Hardened more tests, fixed bug with setting the per_page configuration to only take effect on protected searches, thus staying out of the way of normal searching.
|
4
|
-
|
5
|
-
v0.9.9. Fixed setting per_page to nil, false, or ''. This is done to "show all" results.
|
6
|
-
|
7
|
-
v0.9.8. Fixed order_by helper bug when determing the text with arrays. Should use the first value instead of last. Added in per_page config option.
|
8
|
-
|
9
|
-
v0.9.7. Complete class restructure, much more organized, added in documentation, added in helpers for using searchgasm in a rails app, updated readme with link to documentation as well as a live example, some bug fixes, more tests
|
10
|
-
|
11
|
-
v0.9.6. Fixed bug when instantiating with nil options
|
12
|
-
|
13
|
-
v0.9.5. Enhanced searching with conditions only. Updated read me to include example on adding your own conditions.
|
14
|
-
|
15
|
-
v0.9.4. Cleaned up search methods, removed reset! method for base and conditions.
|
16
|
-
|
17
|
-
v0.9.3. Changed structure of conditions to have their own class. Making it easier to add your own conditions.
|
18
|
-
|
19
|
-
v0.9.2. Enhanced protection
|
20
|
-
|
21
|
-
v0.9.1. Added aliases for datetime, date, time, and timestamp attrs. You could call created_at_after, mow you can also call created_after.
|
22
|
-
|
23
|
-
v0.9.0. First release
|