autosuggest-rb 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/README.markdown +130 -0
- data/Rakefile +2 -0
- data/autosuggest-rb.gemspec +27 -0
- data/integration/.gitignore +4 -0
- data/integration/Gemfile +43 -0
- data/integration/README +256 -0
- data/integration/Rakefile +7 -0
- data/integration/app/controllers/application_controller.rb +3 -0
- data/integration/app/helpers/application_helper.rb +2 -0
- data/integration/app/views/layouts/application.html.erb +14 -0
- data/integration/config/application.rb +46 -0
- data/integration/config/boot.rb +6 -0
- data/integration/config/database.yml +22 -0
- data/integration/config/environment.rb +5 -0
- data/integration/config/environments/development.rb +26 -0
- data/integration/config/environments/production.rb +49 -0
- data/integration/config/environments/test.rb +35 -0
- data/integration/config/initializers/backtrace_silencers.rb +7 -0
- data/integration/config/initializers/inflections.rb +10 -0
- data/integration/config/initializers/mime_types.rb +5 -0
- data/integration/config/initializers/secret_token.rb +7 -0
- data/integration/config/initializers/session_store.rb +8 -0
- data/integration/config/locales/en.yml +5 -0
- data/integration/config/routes.rb +58 -0
- data/integration/config.ru +4 -0
- data/integration/db/seeds.rb +7 -0
- data/integration/doc/README_FOR_APP +2 -0
- data/integration/lib/tasks/.gitkeep +0 -0
- data/integration/public/404.html +26 -0
- data/integration/public/422.html +26 -0
- data/integration/public/500.html +26 -0
- data/integration/public/favicon.ico +0 -0
- data/integration/public/images/rails.png +0 -0
- data/integration/public/index.html +239 -0
- data/integration/public/javascripts/application.js +2 -0
- data/integration/public/javascripts/controls.js +965 -0
- data/integration/public/javascripts/dragdrop.js +974 -0
- data/integration/public/javascripts/effects.js +1123 -0
- data/integration/public/javascripts/prototype.js +6001 -0
- data/integration/public/javascripts/rails.js +191 -0
- data/integration/public/robots.txt +5 -0
- data/integration/public/stylesheets/.gitkeep +0 -0
- data/integration/script/rails +6 -0
- data/integration/test/performance/browsing_test.rb +9 -0
- data/integration/test/test_helper.rb +13 -0
- data/integration/vendor/plugins/.gitkeep +0 -0
- data/lib/autosuggest/controller_macros.rb +15 -0
- data/lib/autosuggest/form_helper.rb +35 -0
- data/lib/autosuggest/helpers.rb +12 -0
- data/lib/autosuggest/version.rb +3 -0
- data/lib/autosuggest-rb.rb +8 -0
- data/lib/generators/assets/autoSuggest.css +217 -0
- data/lib/generators/assets/jquery.autoSuggest.js +399 -0
- data/lib/generators/autosuggest_generator.rb +14 -0
- data/spec/lib/class_methods_spec.rb +9 -0
- data/spec/spec_helper.rb +17 -0
- metadata +169 -0
@@ -0,0 +1,399 @@
|
|
1
|
+
/*
|
2
|
+
* AutoSuggest
|
3
|
+
* Copyright 2009-2010 Drew Wilson
|
4
|
+
* www.drewwilson.com
|
5
|
+
* code.drewwilson.com/entry/autosuggest-jquery-plugin
|
6
|
+
*
|
7
|
+
* Version 1.4 - Updated: Mar. 23, 2010
|
8
|
+
*
|
9
|
+
* This Plug-In will auto-complete or auto-suggest completed search queries
|
10
|
+
* for you as you type. You can add multiple selections and remove them on
|
11
|
+
* the fly. It supports keybord navigation (UP + DOWN + RETURN), as well
|
12
|
+
* as multiple AutoSuggest fields on the same page.
|
13
|
+
*
|
14
|
+
* Inspied by the Autocomplete plugin by: J�rn Zaefferer
|
15
|
+
* and the Facelist plugin by: Ian Tearle (iantearle.com)
|
16
|
+
*
|
17
|
+
* This AutoSuggest jQuery plug-in is dual licensed under the MIT and GPL licenses:
|
18
|
+
* http://www.opensource.org/licenses/mit-license.php
|
19
|
+
* http://www.gnu.org/licenses/gpl.html
|
20
|
+
*/
|
21
|
+
|
22
|
+
|
23
|
+
(function($){
|
24
|
+
$.fn.autoSuggest = function(data, options) {
|
25
|
+
var defaults = {
|
26
|
+
asHtmlID: false,
|
27
|
+
asHtmlName: false,
|
28
|
+
newValuesInputName: false,
|
29
|
+
startText: "Enter Name Here",
|
30
|
+
emptyText: "No Results Found",
|
31
|
+
preFill: {},
|
32
|
+
limitText: "No More Selections Are Allowed",
|
33
|
+
selectedItemProp: "value", //name of object property
|
34
|
+
selectedValuesProp: "value", //name of object property
|
35
|
+
searchObjProps: "value", //comma separated list of object property names
|
36
|
+
queryParam: "q",
|
37
|
+
retrieveLimit: false, //number for 'limit' param on ajax request
|
38
|
+
extraParams: "",
|
39
|
+
matchCase: false,
|
40
|
+
minChars: 1,
|
41
|
+
keyDelay: 400,
|
42
|
+
resultsHighlight: true,
|
43
|
+
neverSubmit: false,
|
44
|
+
selectionLimit: false,
|
45
|
+
showResultList: true,
|
46
|
+
start: function(){},
|
47
|
+
selectionClick: function(elem){},
|
48
|
+
selectionAdded: function(elem){},
|
49
|
+
selectionRemoved: function(elem){ elem.remove(); },
|
50
|
+
formatList: false, //callback function
|
51
|
+
beforeRetrieve: function(string){ return string; },
|
52
|
+
retrieveComplete: function(data){ return data; },
|
53
|
+
resultClick: function(data){},
|
54
|
+
resultsComplete: function(){}
|
55
|
+
};
|
56
|
+
var opts = $.extend(defaults, options);
|
57
|
+
|
58
|
+
var d_type = "object";
|
59
|
+
var d_count = 0;
|
60
|
+
if(typeof data == "string") {
|
61
|
+
d_type = "string";
|
62
|
+
var req_string = data;
|
63
|
+
} else {
|
64
|
+
var org_data = data;
|
65
|
+
for (k in data) if (data.hasOwnProperty(k)) d_count++;
|
66
|
+
}
|
67
|
+
if((d_type == "object" && d_count > 0) || d_type == "string"){
|
68
|
+
return this.each(function(x){
|
69
|
+
if(!opts.asHtmlID){
|
70
|
+
x = x+""+Math.floor(Math.random()*100); //this ensures there will be unique IDs on the page if autoSuggest() is called multiple times
|
71
|
+
var x_id = "as-input-"+x;
|
72
|
+
var as_values_name = "as_values_"+x;
|
73
|
+
} else {
|
74
|
+
x = opts.asHtmlID;
|
75
|
+
var x_id = x;
|
76
|
+
var as_values_name = "as_values_"+x;
|
77
|
+
}
|
78
|
+
|
79
|
+
if(opts.asHtmlName){
|
80
|
+
var as_values_name = opts.asHtmlName;
|
81
|
+
}
|
82
|
+
opts.start.call(this);
|
83
|
+
var input = $(this);
|
84
|
+
input.attr("autocomplete","off").addClass("as-input").attr("id",x_id).val(opts.startText);
|
85
|
+
var input_focus = false;
|
86
|
+
|
87
|
+
// Setup basic elements and render them to the DOM
|
88
|
+
input.wrap('<ul class="as-selections" id="as-selections-'+x+'"></ul>').wrap('<li class="as-original" id="as-original-'+x+'"></li>');
|
89
|
+
var count_of_new = 0;
|
90
|
+
var selections_holder = $("#as-selections-"+x);
|
91
|
+
var org_li = $("#as-original-"+x);
|
92
|
+
var results_holder = $('<div class="as-results" id="as-results-'+x+'"></div>').hide();
|
93
|
+
var results_ul = $('<ul class="as-list"></ul>');
|
94
|
+
var values_input = $('<input type="hidden" class="as-values" name="'+as_values_name+'" id="as-values-'+x+'" />');
|
95
|
+
var prefill_value = "";
|
96
|
+
if(typeof opts.preFill == "string"){
|
97
|
+
var vals = opts.preFill.split(",");
|
98
|
+
for(var i=0; i < vals.length; i++){
|
99
|
+
var v_data = {};
|
100
|
+
v_data[opts.selectedValuesProp] = vals[i];
|
101
|
+
if(vals[i] != ""){
|
102
|
+
add_selected_item(v_data, "000"+i);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
prefill_value = opts.preFill;
|
106
|
+
} else {
|
107
|
+
prefill_value = "";
|
108
|
+
var prefill_count = 0;
|
109
|
+
for (k in opts.preFill) if (opts.preFill.hasOwnProperty(k)) prefill_count++;
|
110
|
+
if(prefill_count > 0){
|
111
|
+
for(var i=0; i < prefill_count; i++){
|
112
|
+
var new_v = opts.preFill[i][opts.selectedValuesProp];
|
113
|
+
if(new_v == undefined){ new_v = ""; }
|
114
|
+
prefill_value = prefill_value+new_v+",";
|
115
|
+
if(new_v != ""){
|
116
|
+
add_selected_item(opts.preFill[i], "000"+i);
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}
|
121
|
+
if(prefill_value != ""){
|
122
|
+
input.val("");
|
123
|
+
var lastChar = prefill_value.substring(prefill_value.length-1);
|
124
|
+
if(lastChar != ","){ prefill_value = prefill_value+","; }
|
125
|
+
values_input.val(","+prefill_value);
|
126
|
+
$("li.as-selection-item", selections_holder).addClass("blur").removeClass("selected");
|
127
|
+
}
|
128
|
+
input.after(values_input);
|
129
|
+
selections_holder.click(function(){
|
130
|
+
input_focus = true;
|
131
|
+
input.focus();
|
132
|
+
}).mousedown(function(){ input_focus = false; }).after(results_holder);
|
133
|
+
|
134
|
+
var timeout = null;
|
135
|
+
var prev = "";
|
136
|
+
var totalSelections = 0;
|
137
|
+
var tab_press = false;
|
138
|
+
|
139
|
+
// Handle input field events
|
140
|
+
input.focus(function(){
|
141
|
+
if($(this).val() == opts.startText && values_input.val() == ""){
|
142
|
+
$(this).val("");
|
143
|
+
} else if(input_focus){
|
144
|
+
$("li.as-selection-item", selections_holder).removeClass("blur");
|
145
|
+
if($(this).val() != ""){
|
146
|
+
results_ul.css("width",selections_holder.outerWidth());
|
147
|
+
results_holder.show();
|
148
|
+
}
|
149
|
+
}
|
150
|
+
input_focus = true;
|
151
|
+
return true;
|
152
|
+
}).blur(function(){
|
153
|
+
if($(this).val() == "" && values_input.val() == "" && prefill_value == ""){
|
154
|
+
$(this).val(opts.startText);
|
155
|
+
} else if(input_focus){
|
156
|
+
$("li.as-selection-item", selections_holder).addClass("blur").removeClass("selected");
|
157
|
+
results_holder.hide();
|
158
|
+
}
|
159
|
+
}).keydown(function(e) {
|
160
|
+
// track last key pressed
|
161
|
+
lastKeyPressCode = e.keyCode;
|
162
|
+
first_focus = false;
|
163
|
+
switch(e.keyCode) {
|
164
|
+
case 38: // up
|
165
|
+
e.preventDefault();
|
166
|
+
moveSelection("up");
|
167
|
+
break;
|
168
|
+
case 40: // down
|
169
|
+
e.preventDefault();
|
170
|
+
moveSelection("down");
|
171
|
+
break;
|
172
|
+
case 8: // delete
|
173
|
+
if(input.val() == ""){
|
174
|
+
var last = values_input.val().split(",");
|
175
|
+
last = last[last.length - 2];
|
176
|
+
selections_holder.children().not(org_li.prev()).removeClass("selected");
|
177
|
+
if(org_li.prev().hasClass("selected")){
|
178
|
+
values_input.val(values_input.val().replace(","+last+",",","));
|
179
|
+
opts.selectionRemoved.call(this, org_li.prev());
|
180
|
+
} else {
|
181
|
+
opts.selectionClick.call(this, org_li.prev());
|
182
|
+
org_li.prev().addClass("selected");
|
183
|
+
}
|
184
|
+
}
|
185
|
+
if(input.val().length == 1){
|
186
|
+
results_holder.hide();
|
187
|
+
prev = "";
|
188
|
+
}
|
189
|
+
if($(":visible",results_holder).length > 0){
|
190
|
+
if (timeout){ clearTimeout(timeout); }
|
191
|
+
timeout = setTimeout(function(){ keyChange(); }, opts.keyDelay);
|
192
|
+
}
|
193
|
+
break;
|
194
|
+
case 13: // return
|
195
|
+
tab_press = false;
|
196
|
+
var active = $("li.active:first", results_holder);
|
197
|
+
if(active.length > 0){
|
198
|
+
active.click();
|
199
|
+
results_holder.hide();
|
200
|
+
}
|
201
|
+
if(opts.neverSubmit || active.length > 0){
|
202
|
+
e.preventDefault();
|
203
|
+
}
|
204
|
+
break;
|
205
|
+
default:
|
206
|
+
if(opts.showResultList){
|
207
|
+
if(opts.selectionLimit && $("li.as-selection-item", selections_holder).length >= opts.selectionLimit){
|
208
|
+
updated_results_ul = results_ul.html('<li class="as-message">'+opts.limitText+'</li>');
|
209
|
+
if (results_holder.children().length == 0){
|
210
|
+
results_holder.append(updated_results_ul);
|
211
|
+
results_ul.css("width", selections_holder.outerWidth());
|
212
|
+
}
|
213
|
+
results_holder.show();
|
214
|
+
} else {
|
215
|
+
if (timeout){ clearTimeout(timeout); }
|
216
|
+
timeout = setTimeout(function(){ keyChange(); }, opts.keyDelay);
|
217
|
+
}
|
218
|
+
}
|
219
|
+
break;
|
220
|
+
}
|
221
|
+
});
|
222
|
+
|
223
|
+
function keyChange() {
|
224
|
+
// ignore if the following keys are pressed: [del] [shift] [capslock]
|
225
|
+
if( lastKeyPressCode == 46 || (lastKeyPressCode > 8 && lastKeyPressCode < 32) ){ return results_holder.hide(); }
|
226
|
+
if(opts.selectionLimit && $("li.as-selection-item", selections_holder).length >= opts.selectionLimit){ return; }
|
227
|
+
var string = input.val().replace(/[\\]+|[\/]+/g,"");
|
228
|
+
if (string == prev) return;
|
229
|
+
prev = string;
|
230
|
+
if (string.length >= opts.minChars) {
|
231
|
+
selections_holder.addClass("loading");
|
232
|
+
if(d_type == "string"){
|
233
|
+
var limit = "";
|
234
|
+
if(opts.retrieveLimit){
|
235
|
+
limit = "&limit="+encodeURIComponent(opts.retrieveLimit);
|
236
|
+
}
|
237
|
+
if(opts.beforeRetrieve){
|
238
|
+
string = opts.beforeRetrieve.call(this, string);
|
239
|
+
}
|
240
|
+
$.getJSON(req_string+"?"+opts.queryParam+"="+encodeURIComponent(string)+limit+opts.extraParams, function(data){
|
241
|
+
d_count = 0;
|
242
|
+
var new_data = opts.retrieveComplete.call(this, data);
|
243
|
+
for (k in new_data) if (new_data.hasOwnProperty(k)) d_count++;
|
244
|
+
processData(new_data, string);
|
245
|
+
});
|
246
|
+
} else {
|
247
|
+
if(opts.beforeRetrieve){
|
248
|
+
string = opts.beforeRetrieve.call(this, string);
|
249
|
+
}
|
250
|
+
processData(org_data, string);
|
251
|
+
}
|
252
|
+
} else {
|
253
|
+
selections_holder.removeClass("loading");
|
254
|
+
results_holder.hide();
|
255
|
+
}
|
256
|
+
}
|
257
|
+
var num_count = 0;
|
258
|
+
function processData(data, query){
|
259
|
+
var case_sensitive_query = query;
|
260
|
+
if (!opts.matchCase){ query = query.toLowerCase(); }
|
261
|
+
var matchCount = 0;
|
262
|
+
results_holder.html(results_ul.html("")).hide();
|
263
|
+
for(var i=0;i<d_count;i++){
|
264
|
+
var num = i;
|
265
|
+
num_count++;
|
266
|
+
var forward = false;
|
267
|
+
if(opts.searchObjProps == "value") {
|
268
|
+
var str = data[num].value;
|
269
|
+
} else {
|
270
|
+
var str = "";
|
271
|
+
var names = opts.searchObjProps.split(",");
|
272
|
+
for(var y=0;y<names.length;y++){
|
273
|
+
var name = $.trim(names[y]);
|
274
|
+
str = str+data[num][name]+" ";
|
275
|
+
}
|
276
|
+
}
|
277
|
+
if(str){
|
278
|
+
if (!opts.matchCase){ str = str.toLowerCase(); }
|
279
|
+
if(str.search(query) != -1 && values_input.val().search(","+data[num][opts.selectedValuesProp]+",") == -1){
|
280
|
+
forward = true;
|
281
|
+
}
|
282
|
+
}
|
283
|
+
if('true'){
|
284
|
+
var formatted = $('<li class="as-result-item" id="as-result-item-'+num+'"></li>').click(function(){
|
285
|
+
var raw_data = $(this).data("data");
|
286
|
+
var number = raw_data.num;
|
287
|
+
if($("#as-selection-"+number, selections_holder).length <= 0 && !tab_press){
|
288
|
+
var data = raw_data.attributes;
|
289
|
+
input.val("").focus();
|
290
|
+
prev = "";
|
291
|
+
add_selected_item(data, number);
|
292
|
+
opts.resultClick.call(this, raw_data);
|
293
|
+
results_holder.hide();
|
294
|
+
}
|
295
|
+
tab_press = false;
|
296
|
+
}).mousedown(function(){ input_focus = false; }).mouseover(function(){
|
297
|
+
$("li", results_ul).removeClass("active");
|
298
|
+
$(this).addClass("active");
|
299
|
+
}).data("data",{attributes: data[num], num: num_count});
|
300
|
+
var this_data = $.extend({},data[num]);
|
301
|
+
if (!opts.matchCase){
|
302
|
+
var regx = new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + query + ")(?![^<>]*>)(?![^&;]+;)", "gi");
|
303
|
+
} else {
|
304
|
+
var regx = new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + query + ")(?![^<>]*>)(?![^&;]+;)", "g");
|
305
|
+
}
|
306
|
+
|
307
|
+
if(opts.resultsHighlight){
|
308
|
+
this_data[opts.selectedItemProp] = this_data[opts.selectedItemProp].replace(regx,"<em>$1</em>");
|
309
|
+
}
|
310
|
+
if(!opts.formatList){
|
311
|
+
formatted = formatted.html(this_data[opts.selectedItemProp]);
|
312
|
+
} else {
|
313
|
+
formatted = opts.formatList.call(this, this_data, formatted);
|
314
|
+
}
|
315
|
+
results_ul.append(formatted);
|
316
|
+
delete this_data;
|
317
|
+
matchCount++;
|
318
|
+
if(opts.retrieveLimit && opts.retrieveLimit == matchCount ){ break; }
|
319
|
+
}
|
320
|
+
}
|
321
|
+
selections_holder.removeClass("loading");
|
322
|
+
if(matchCount <= 0){
|
323
|
+
var formatted = $('<li class="as-result-item" id="as-result-item-1"></li>');
|
324
|
+
if(opts.newValuesInputName){
|
325
|
+
count_of_new += 1;
|
326
|
+
formatted.html('Add new: <em>' + case_sensitive_query + '</em>').click(function(){
|
327
|
+
input_focus = false;
|
328
|
+
new_data_item = {};
|
329
|
+
new_data_item[opts.selectedItemProp] = case_sensitive_query;
|
330
|
+
new_data_item[opts.selectedValuesProp] = case_sensitive_query;
|
331
|
+
add_selected_item(new_data_item, count_of_new, true);
|
332
|
+
input.val("");
|
333
|
+
results_holder.hide();
|
334
|
+
}).mousedown(function(){ input_focus = false; }).mouseover(function(){
|
335
|
+
$("li", results_ul).removeClass("active");
|
336
|
+
$(this).addClass("active");
|
337
|
+
});
|
338
|
+
} else {
|
339
|
+
formatted.html('<em>New items not allowed in this field</em>');
|
340
|
+
}
|
341
|
+
results_ul.append('<li class="as-message">'+opts.emptyText+'</li>').append(formatted);
|
342
|
+
}
|
343
|
+
results_ul.css("width", selections_holder.outerWidth());
|
344
|
+
results_holder.show();
|
345
|
+
opts.resultsComplete.call(this);
|
346
|
+
}
|
347
|
+
|
348
|
+
function add_selected_item(data, num, is_new_value){
|
349
|
+
is_new_value = is_new_value || false;
|
350
|
+
if(!is_new_value){
|
351
|
+
values_input.val(values_input.val()+data[opts.selectedValuesProp]+",");
|
352
|
+
} else {
|
353
|
+
values_input.after('<input type="hidden" name="'+opts.newValuesInputName+'" value="'+data[opts.selectedValuesProp]+'">');
|
354
|
+
}
|
355
|
+
var item = $('<li class="as-selection-item" id="as-selection-'+num+'"></li>').click(function(){
|
356
|
+
opts.selectionClick.call(this, $(this));
|
357
|
+
selections_holder.children().removeClass("selected");
|
358
|
+
$(this).addClass("selected");
|
359
|
+
}).mousedown(function(){ input_focus = false; });
|
360
|
+
var close = $('<a class="as-close">×</a>').click(function(){
|
361
|
+
if(!is_new_value){
|
362
|
+
values_input.val(values_input.val().replace(","+data[opts.selectedValuesProp]+",",","));
|
363
|
+
} else {
|
364
|
+
$('input[value='+data[opts.selectedValuesProp]+']').remove();
|
365
|
+
}
|
366
|
+
opts.selectionRemoved.call(this, item);
|
367
|
+
input_focus = true;
|
368
|
+
input.focus();
|
369
|
+
return false;
|
370
|
+
});
|
371
|
+
org_li.before(item.html(data[opts.selectedItemProp]).prepend(close));
|
372
|
+
opts.selectionAdded.call(this, org_li.prev());
|
373
|
+
}
|
374
|
+
|
375
|
+
function moveSelection(direction){
|
376
|
+
if($(":visible",results_holder).length > 0){
|
377
|
+
var lis = $("li", results_holder);
|
378
|
+
if(direction == "down"){
|
379
|
+
var start = lis.eq(0);
|
380
|
+
} else {
|
381
|
+
var start = lis.filter(":last");
|
382
|
+
}
|
383
|
+
var active = $("li.active:first", results_holder);
|
384
|
+
if(active.length > 0){
|
385
|
+
if(direction == "down"){
|
386
|
+
start = active.next();
|
387
|
+
} else {
|
388
|
+
start = active.prev();
|
389
|
+
}
|
390
|
+
}
|
391
|
+
lis.removeClass("active");
|
392
|
+
start.addClass("active");
|
393
|
+
}
|
394
|
+
}
|
395
|
+
|
396
|
+
});
|
397
|
+
}
|
398
|
+
}
|
399
|
+
})(jQuery);
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class AutosuggestGenerator < Rails::Generators::Base
|
4
|
+
def install
|
5
|
+
# Copy the unobtrusive JS file
|
6
|
+
copy_file('jquery.autoSuggest.js', 'public/javascripts/jquery.autoSuggest.js')
|
7
|
+
copy_file('autoSuggest.css', 'public/stylesheets/autoSuggest.css')
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.source_root
|
11
|
+
File.join(File.dirname(__FILE__), 'assets')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
require 'rspec/rails'
|
5
|
+
require 'autosuggest'
|
6
|
+
require 'ruby-debug'
|
7
|
+
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/*.rb"].each { |f| require f }
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.mock_with :mocha
|
12
|
+
end
|
13
|
+
|
14
|
+
Ingredient = Class.new
|
15
|
+
IngredientsController = Class.new(ActionController::Base)
|
16
|
+
IngredientsController.autosuggest(:ingredients, :name)
|
17
|
+
|
metadata
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: autosuggest-rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.2
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Derrick Camerino
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-28 00:00:00 -07:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rails
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "3.0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rspec-rails
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: ruby-debug19
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: mocha
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
type: :development
|
70
|
+
version_requirements: *id005
|
71
|
+
description: This is a gem that wraps the AutoSuggest javascript plugin
|
72
|
+
email:
|
73
|
+
- robustdj@gmail.com
|
74
|
+
executables: []
|
75
|
+
|
76
|
+
extensions: []
|
77
|
+
|
78
|
+
extra_rdoc_files: []
|
79
|
+
|
80
|
+
files:
|
81
|
+
- .gitignore
|
82
|
+
- Gemfile
|
83
|
+
- README.markdown
|
84
|
+
- Rakefile
|
85
|
+
- autosuggest-rb.gemspec
|
86
|
+
- integration/.gitignore
|
87
|
+
- integration/Gemfile
|
88
|
+
- integration/README
|
89
|
+
- integration/Rakefile
|
90
|
+
- integration/app/controllers/application_controller.rb
|
91
|
+
- integration/app/helpers/application_helper.rb
|
92
|
+
- integration/app/views/layouts/application.html.erb
|
93
|
+
- integration/config.ru
|
94
|
+
- integration/config/application.rb
|
95
|
+
- integration/config/boot.rb
|
96
|
+
- integration/config/database.yml
|
97
|
+
- integration/config/environment.rb
|
98
|
+
- integration/config/environments/development.rb
|
99
|
+
- integration/config/environments/production.rb
|
100
|
+
- integration/config/environments/test.rb
|
101
|
+
- integration/config/initializers/backtrace_silencers.rb
|
102
|
+
- integration/config/initializers/inflections.rb
|
103
|
+
- integration/config/initializers/mime_types.rb
|
104
|
+
- integration/config/initializers/secret_token.rb
|
105
|
+
- integration/config/initializers/session_store.rb
|
106
|
+
- integration/config/locales/en.yml
|
107
|
+
- integration/config/routes.rb
|
108
|
+
- integration/db/seeds.rb
|
109
|
+
- integration/doc/README_FOR_APP
|
110
|
+
- integration/lib/tasks/.gitkeep
|
111
|
+
- integration/public/404.html
|
112
|
+
- integration/public/422.html
|
113
|
+
- integration/public/500.html
|
114
|
+
- integration/public/favicon.ico
|
115
|
+
- integration/public/images/rails.png
|
116
|
+
- integration/public/index.html
|
117
|
+
- integration/public/javascripts/application.js
|
118
|
+
- integration/public/javascripts/controls.js
|
119
|
+
- integration/public/javascripts/dragdrop.js
|
120
|
+
- integration/public/javascripts/effects.js
|
121
|
+
- integration/public/javascripts/prototype.js
|
122
|
+
- integration/public/javascripts/rails.js
|
123
|
+
- integration/public/robots.txt
|
124
|
+
- integration/public/stylesheets/.gitkeep
|
125
|
+
- integration/script/rails
|
126
|
+
- integration/test/performance/browsing_test.rb
|
127
|
+
- integration/test/test_helper.rb
|
128
|
+
- integration/vendor/plugins/.gitkeep
|
129
|
+
- lib/autosuggest-rb.rb
|
130
|
+
- lib/autosuggest/controller_macros.rb
|
131
|
+
- lib/autosuggest/form_helper.rb
|
132
|
+
- lib/autosuggest/helpers.rb
|
133
|
+
- lib/autosuggest/version.rb
|
134
|
+
- lib/generators/assets/autoSuggest.css
|
135
|
+
- lib/generators/assets/jquery.autoSuggest.js
|
136
|
+
- lib/generators/autosuggest_generator.rb
|
137
|
+
- spec/lib/class_methods_spec.rb
|
138
|
+
- spec/spec_helper.rb
|
139
|
+
has_rdoc: true
|
140
|
+
homepage: ""
|
141
|
+
licenses: []
|
142
|
+
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
|
146
|
+
require_paths:
|
147
|
+
- lib
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: "0"
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: "0"
|
160
|
+
requirements: []
|
161
|
+
|
162
|
+
rubyforge_project: autosuggest-rb
|
163
|
+
rubygems_version: 1.6.2
|
164
|
+
signing_key:
|
165
|
+
specification_version: 3
|
166
|
+
summary: This is a gem that wraps the AutoSuggest javascript plugin
|
167
|
+
test_files:
|
168
|
+
- spec/lib/class_methods_spec.rb
|
169
|
+
- spec/spec_helper.rb
|