scoped_search 2.4.0 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -0
- data/README.rdoc +1 -1
- data/lib/scoped_search.rb +13 -1
- data/lib/scoped_search/definition.rb +1 -1
- data/lib/scoped_search/engine.rb +6 -0
- data/scoped_search.gemspec +3 -3
- data/vendor/assets/images/spinner.gif +0 -0
- data/vendor/assets/javascripts/scoped_search.js +55 -0
- data/vendor/assets/stylesheets/scoped_search.scss +51 -0
- metadata +77 -56
data/.travis.yml
CHANGED
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= Scoped search
|
1
|
+
= Scoped search {<img src="https://secure.travis-ci.org/wvanbergen/scoped_search.png" />}[http://travis-ci.org/wvanbergen/scoped_search]
|
2
2
|
|
3
3
|
The <b>scoped_search</b> Rails plugin makes it easy to search your ActiveRecord
|
4
4
|
models. Searching is performed using a query string, which should be passed to
|
data/lib/scoped_search.rb
CHANGED
@@ -14,7 +14,7 @@ module ScopedSearch
|
|
14
14
|
|
15
15
|
# The current scoped_search version. Do not change thisvalue by hand,
|
16
16
|
# because it will be updated automatically by the gem release script.
|
17
|
-
VERSION = "2.4.
|
17
|
+
VERSION = "2.4.1"
|
18
18
|
|
19
19
|
# The ClassMethods module will be included into the ActiveRecord::Base class
|
20
20
|
# to add the <tt>ActiveRecord::Base.scoped_search</tt> method and the
|
@@ -97,3 +97,15 @@ if defined?(ActionController)
|
|
97
97
|
require "scoped_search/rails_helper"
|
98
98
|
ActionController::Base.helper(ScopedSearch::RailsHelper)
|
99
99
|
end
|
100
|
+
|
101
|
+
#asset pipeline
|
102
|
+
if defined?(::Sprockets)
|
103
|
+
require 'scoped_search/engine'
|
104
|
+
end
|
105
|
+
|
106
|
+
#Compass
|
107
|
+
if defined?(::Compass)
|
108
|
+
base = File.join(File.dirname(__FILE__), '..')
|
109
|
+
styles = File.join(base, 'vendor', 'assets', 'stylesheets')
|
110
|
+
::Compass::Frameworks.register('scoped_search', :path => base, :stylesheets_directory => styles)
|
111
|
+
end
|
@@ -176,7 +176,7 @@ module ScopedSearch
|
|
176
176
|
field = fields[name.to_sym] unless name.blank?
|
177
177
|
if field.nil?
|
178
178
|
dotted = name.to_s.split('.')[0]
|
179
|
-
field = fields[dotted.to_sym] unless dotted.
|
179
|
+
field = fields[dotted.to_sym] unless dotted.blank?
|
180
180
|
end
|
181
181
|
field
|
182
182
|
end
|
data/scoped_search.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
|
4
4
|
# Do not change the version and date fields by hand. This will be done
|
5
5
|
# automatically by the gem release script.
|
6
|
-
s.version = "2.4.
|
7
|
-
s.date = "
|
6
|
+
s.version = "2.4.1"
|
7
|
+
s.date = "2013-03-06"
|
8
8
|
|
9
9
|
s.summary = "Easily search you ActiveRecord models with a simple query language using a named scope."
|
10
10
|
s.description = <<-EOS
|
@@ -33,6 +33,6 @@ Gem::Specification.new do |s|
|
|
33
33
|
|
34
34
|
# Do not change the files and test_files fields by hand. This will be done
|
35
35
|
# automatically by the gem release script.
|
36
|
-
s.files = %w(.gitignore .infinity_test .travis.yml Gemfile Gemfile.activerecord2 Gemfile.activerecord3 LICENSE README.rdoc Rakefile init.rb lib/scoped_search.rb lib/scoped_search/auto_complete_builder.rb lib/scoped_search/definition.rb lib/scoped_search/query_builder.rb lib/scoped_search/query_language.rb lib/scoped_search/query_language/ast.rb lib/scoped_search/query_language/parser.rb lib/scoped_search/query_language/tokenizer.rb lib/scoped_search/rails_helper.rb scoped_search.gemspec spec/database.jruby.yml spec/database.ruby.yml spec/integration/api_spec.rb spec/integration/auto_complete_spec.rb spec/integration/key_value_querying_spec.rb spec/integration/ordinal_querying_spec.rb spec/integration/profile_querying_spec.rb spec/integration/relation_querying_spec.rb spec/integration/set_query_spec.rb spec/integration/string_querying_spec.rb spec/lib/database.rb spec/lib/matchers.rb spec/lib/mocks.rb spec/spec_helper.rb spec/unit/ast_spec.rb spec/unit/auto_complete_builder_spec.rb spec/unit/definition_spec.rb spec/unit/parser_spec.rb spec/unit/query_builder_spec.rb spec/unit/tokenizer_spec.rb tasks/github-gem.rake)
|
36
|
+
s.files = %w(.gitignore .infinity_test .travis.yml Gemfile Gemfile.activerecord2 Gemfile.activerecord3 LICENSE README.rdoc Rakefile init.rb lib/scoped_search.rb lib/scoped_search/auto_complete_builder.rb lib/scoped_search/definition.rb lib/scoped_search/engine.rb lib/scoped_search/query_builder.rb lib/scoped_search/query_language.rb lib/scoped_search/query_language/ast.rb lib/scoped_search/query_language/parser.rb lib/scoped_search/query_language/tokenizer.rb lib/scoped_search/rails_helper.rb scoped_search.gemspec spec/database.jruby.yml spec/database.ruby.yml spec/integration/api_spec.rb spec/integration/auto_complete_spec.rb spec/integration/key_value_querying_spec.rb spec/integration/ordinal_querying_spec.rb spec/integration/profile_querying_spec.rb spec/integration/relation_querying_spec.rb spec/integration/set_query_spec.rb spec/integration/string_querying_spec.rb spec/lib/database.rb spec/lib/matchers.rb spec/lib/mocks.rb spec/spec_helper.rb spec/unit/ast_spec.rb spec/unit/auto_complete_builder_spec.rb spec/unit/definition_spec.rb spec/unit/parser_spec.rb spec/unit/query_builder_spec.rb spec/unit/tokenizer_spec.rb tasks/github-gem.rake vendor/assets/images/spinner.gif vendor/assets/javascripts/scoped_search.js vendor/assets/stylesheets/scoped_search.scss)
|
37
37
|
s.test_files = %w(spec/integration/api_spec.rb spec/integration/auto_complete_spec.rb spec/integration/key_value_querying_spec.rb spec/integration/ordinal_querying_spec.rb spec/integration/profile_querying_spec.rb spec/integration/relation_querying_spec.rb spec/integration/set_query_spec.rb spec/integration/string_querying_spec.rb spec/unit/ast_spec.rb spec/unit/auto_complete_builder_spec.rb spec/unit/definition_spec.rb spec/unit/parser_spec.rb spec/unit/query_builder_spec.rb spec/unit/tokenizer_spec.rb)
|
38
38
|
end
|
Binary file
|
@@ -0,0 +1,55 @@
|
|
1
|
+
//extend ui auto-complete to include categories and errors
|
2
|
+
$.widget( "custom.catcomplete", $.ui.autocomplete, {
|
3
|
+
_renderMenu: function( ul, items ) {
|
4
|
+
var self = this, currentCategory = "";
|
5
|
+
$.each( items, function( index, item ) {
|
6
|
+
if ( item.category != undefined && item.category != currentCategory ) {
|
7
|
+
ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
|
8
|
+
currentCategory = item.category;
|
9
|
+
}
|
10
|
+
if ( item.error != undefined ) {
|
11
|
+
ul.append( "<li class='ui-autocomplete-error'>" + item.error + "</li>" );
|
12
|
+
}
|
13
|
+
self._renderItemData( ul, item );
|
14
|
+
});
|
15
|
+
},
|
16
|
+
_renderItem: function( ul, item ) {
|
17
|
+
return $( "<li>" )
|
18
|
+
.append( "<a> <i class='ui-autocomplete-completed'>" + item.completed + "</i>" + item.part + "</a>" )
|
19
|
+
.appendTo( ul );
|
20
|
+
}
|
21
|
+
});
|
22
|
+
|
23
|
+
|
24
|
+
$.fn.scopedSearch = function(){
|
25
|
+
var options = arguments[0] || {};
|
26
|
+
$(this).each(function(i,el){
|
27
|
+
var target = $(el);
|
28
|
+
|
29
|
+
target.catcomplete({
|
30
|
+
source: options.source || function( request, response ) {
|
31
|
+
$.getJSON( target.data("url"), { search: request.term }, response );
|
32
|
+
},
|
33
|
+
minLength: options.minLength || 0,
|
34
|
+
delay: options.delay || 100,
|
35
|
+
select: function(event, ui) {
|
36
|
+
target.val( ui.item.value );
|
37
|
+
},
|
38
|
+
search: function(event, ui) {
|
39
|
+
$(".autocomplete-clear").hide();
|
40
|
+
},
|
41
|
+
response: function(event, ui) {
|
42
|
+
$(".autocomplete-clear").show();
|
43
|
+
},
|
44
|
+
close: function(event, ui) {
|
45
|
+
$(".autocomplete-input:focus").catcomplete( target.attr('id'));
|
46
|
+
}
|
47
|
+
});
|
48
|
+
|
49
|
+
target.bind("focus", function( event ){
|
50
|
+
$(this).catcomplete( target.attr('id'));
|
51
|
+
});
|
52
|
+
target.after('<a class="autocomplete-clear" tabindex="-1" title="Clear">×</a>')
|
53
|
+
target.next().on("click",function(){ target.val(''); })
|
54
|
+
})
|
55
|
+
};
|
@@ -0,0 +1,51 @@
|
|
1
|
+
// Opacity
|
2
|
+
@mixin opacity($opacity) {
|
3
|
+
opacity: $opacity / 100;
|
4
|
+
filter: alpha(opacity=$opacity);
|
5
|
+
}
|
6
|
+
|
7
|
+
.autocomplete-input {
|
8
|
+
width: 98%;
|
9
|
+
margin-right: -12px;
|
10
|
+
}
|
11
|
+
|
12
|
+
.autocomplete-clear {
|
13
|
+
font-size: 16px;
|
14
|
+
font-weight: bold;
|
15
|
+
color: black;
|
16
|
+
display: inline-block;
|
17
|
+
width: 14px;
|
18
|
+
height: 14px;
|
19
|
+
margin-left: -6px;
|
20
|
+
margin-bottom: -5px;
|
21
|
+
text-shadow: 0 1px 0 rgba(255,255,255,1);
|
22
|
+
@include opacity(20);
|
23
|
+
&:hover,
|
24
|
+
&:focus {
|
25
|
+
text-decoration: none;
|
26
|
+
cursor: pointer;
|
27
|
+
@include opacity(40);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
.ui-autocomplete-loading {
|
31
|
+
background: white url('/images/spinner.gif') 98% 50% no-repeat;
|
32
|
+
}
|
33
|
+
.ui-autocomplete-completed {
|
34
|
+
color: #aaa;
|
35
|
+
font-weight: lighter;
|
36
|
+
padding: .2em .4em;
|
37
|
+
margin: .3em 0 .2em;
|
38
|
+
line-height: 1.5;
|
39
|
+
}
|
40
|
+
.ui-autocomplete-category {
|
41
|
+
font-weight: bold;
|
42
|
+
padding: .2em .4em;
|
43
|
+
margin: .3em 0 .2em;
|
44
|
+
line-height: 1.5;
|
45
|
+
}
|
46
|
+
.ui-autocomplete-error {
|
47
|
+
color: red;
|
48
|
+
padding: .2em .4em;
|
49
|
+
margin: .3em 0 .2em;
|
50
|
+
line-height: 1.5;
|
51
|
+
}
|
metadata
CHANGED
@@ -1,71 +1,81 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: scoped_search
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 4
|
9
|
+
- 1
|
10
|
+
version: 2.4.1
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Amos Benari
|
9
14
|
- Willem van Bergen
|
10
15
|
- Wes Hays
|
11
16
|
autorequire:
|
12
17
|
bindir: bin
|
13
18
|
cert_chain: []
|
14
|
-
|
15
|
-
|
16
|
-
|
19
|
+
|
20
|
+
date: 2013-03-06 00:00:00 Z
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
prerelease: false
|
17
24
|
name: activerecord
|
18
|
-
|
25
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
19
26
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 11
|
31
|
+
segments:
|
32
|
+
- 2
|
33
|
+
- 1
|
34
|
+
- 0
|
23
35
|
version: 2.1.0
|
36
|
+
requirement: *id001
|
24
37
|
type: :runtime
|
38
|
+
- !ruby/object:Gem::Dependency
|
25
39
|
prerelease: false
|
26
|
-
version_requirements: *70188989608520
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
40
|
name: rspec
|
29
|
-
|
41
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
30
42
|
none: false
|
31
|
-
requirements:
|
43
|
+
requirements:
|
32
44
|
- - ~>
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
hash: 3
|
47
|
+
segments:
|
48
|
+
- 2
|
49
|
+
- 0
|
50
|
+
version: "2.0"
|
51
|
+
requirement: *id002
|
35
52
|
type: :development
|
53
|
+
- !ruby/object:Gem::Dependency
|
36
54
|
prerelease: false
|
37
|
-
version_requirements: *70188989607800
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
55
|
name: rake
|
40
|
-
|
56
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
41
57
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
requirement: *id003
|
46
66
|
type: :development
|
47
|
-
|
48
|
-
|
49
|
-
description: ! " Scoped search makes it easy to search your ActiveRecord-based
|
50
|
-
models.\n \n It will create a named scope :search_for that can be called with
|
51
|
-
a query string. It will build an SQL query using\n the provided query string
|
52
|
-
and a definition that specifies on what fields to search. Because the functionality
|
53
|
-
is\n built on named_scope, the result of the search_for call can be used like
|
54
|
-
any other named_scope, so it can be\n chained with another scope or combined
|
55
|
-
with will_paginate.\n \n Because it uses standard SQL, it does not require
|
56
|
-
any setup, indexers or daemons. This makes scoped_search\n suitable to quickly
|
57
|
-
add basic search functionality to your application with little hassle. On the other
|
58
|
-
hand,\n it may not be the best choice if it is going to be used on very large
|
59
|
-
datasets or by a large user base.\n"
|
60
|
-
email:
|
67
|
+
description: " Scoped search makes it easy to search your ActiveRecord-based models.\n \n It will create a named scope :search_for that can be called with a query string. It will build an SQL query using\n the provided query string and a definition that specifies on what fields to search. Because the functionality is\n built on named_scope, the result of the search_for call can be used like any other named_scope, so it can be\n chained with another scope or combined with will_paginate.\n \n Because it uses standard SQL, it does not require any setup, indexers or daemons. This makes scoped_search\n suitable to quickly add basic search functionality to your application with little hassle. On the other hand,\n it may not be the best choice if it is going to be used on very large datasets or by a large user base.\n"
|
68
|
+
email:
|
61
69
|
- abenari@redhat.com
|
62
70
|
- willem@railsdoctors.com
|
63
71
|
- weshays@gbdev.com
|
64
72
|
executables: []
|
73
|
+
|
65
74
|
extensions: []
|
66
|
-
|
75
|
+
|
76
|
+
extra_rdoc_files:
|
67
77
|
- README.rdoc
|
68
|
-
files:
|
78
|
+
files:
|
69
79
|
- .gitignore
|
70
80
|
- .infinity_test
|
71
81
|
- .travis.yml
|
@@ -79,6 +89,7 @@ files:
|
|
79
89
|
- lib/scoped_search.rb
|
80
90
|
- lib/scoped_search/auto_complete_builder.rb
|
81
91
|
- lib/scoped_search/definition.rb
|
92
|
+
- lib/scoped_search/engine.rb
|
82
93
|
- lib/scoped_search/query_builder.rb
|
83
94
|
- lib/scoped_search/query_language.rb
|
84
95
|
- lib/scoped_search/query_language/ast.rb
|
@@ -107,38 +118,48 @@ files:
|
|
107
118
|
- spec/unit/query_builder_spec.rb
|
108
119
|
- spec/unit/tokenizer_spec.rb
|
109
120
|
- tasks/github-gem.rake
|
121
|
+
- vendor/assets/images/spinner.gif
|
122
|
+
- vendor/assets/javascripts/scoped_search.js
|
123
|
+
- vendor/assets/stylesheets/scoped_search.scss
|
110
124
|
homepage: http://github.com/wvanbergen/scoped_search/wiki
|
111
125
|
licenses: []
|
126
|
+
|
112
127
|
post_install_message:
|
113
|
-
rdoc_options:
|
128
|
+
rdoc_options:
|
114
129
|
- --title
|
115
130
|
- scoped_search
|
116
131
|
- --main
|
117
132
|
- README.rdoc
|
118
133
|
- --line-numbers
|
119
134
|
- --inline-source
|
120
|
-
require_paths:
|
135
|
+
require_paths:
|
121
136
|
- lib
|
122
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
138
|
none: false
|
124
|
-
requirements:
|
125
|
-
- -
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
|
128
|
-
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
hash: 3
|
143
|
+
segments:
|
144
|
+
- 0
|
145
|
+
version: "0"
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
147
|
none: false
|
130
|
-
requirements:
|
131
|
-
- -
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
hash: 3
|
152
|
+
segments:
|
153
|
+
- 0
|
154
|
+
version: "0"
|
134
155
|
requirements: []
|
156
|
+
|
135
157
|
rubyforge_project:
|
136
|
-
rubygems_version: 1.8.
|
158
|
+
rubygems_version: 1.8.24
|
137
159
|
signing_key:
|
138
160
|
specification_version: 3
|
139
|
-
summary: Easily search you ActiveRecord models with a simple query language using
|
140
|
-
|
141
|
-
test_files:
|
161
|
+
summary: Easily search you ActiveRecord models with a simple query language using a named scope.
|
162
|
+
test_files:
|
142
163
|
- spec/integration/api_spec.rb
|
143
164
|
- spec/integration/auto_complete_spec.rb
|
144
165
|
- spec/integration/key_value_querying_spec.rb
|