searchy 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/lib/searchy/search.rb +19 -0
- data/lib/searchy/version.rb +3 -0
- data/lib/searchy.rb +12 -0
- data/readme.md +9 -0
- data/searchy.gemspec +23 -0
- metadata +89 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3@searchy --create --install
|
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Searchy
|
2
|
+
module Search
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
TYPES = [:string, :text]
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
def search(query = nil)
|
8
|
+
if query.present?
|
9
|
+
fields = columns.select{|c| TYPES.include?(c.type)}.map(&:name)
|
10
|
+
command = fields.map{|f| "#{table_name}.#{f} LIKE ?"}.join(' OR ')
|
11
|
+
|
12
|
+
where([command, *Array.new(fields.length).map{"%#{query}%"}])
|
13
|
+
else
|
14
|
+
scoped
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/searchy.rb
ADDED
data/readme.md
ADDED
data/searchy.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "searchy/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "searchy"
|
7
|
+
s.version = Searchy::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["jimneath@gmail.com"]
|
10
|
+
s.email = ["jimneath@gmail.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{The simplest search gem}
|
13
|
+
s.description = %q{The simplest search gem}
|
14
|
+
|
15
|
+
s.rubyforge_project = "searchy"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency 'activerecord', '>= 3.0.0'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: searchy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- jimneath@gmail.com
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-03-21 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: activerecord
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 7
|
29
|
+
segments:
|
30
|
+
- 3
|
31
|
+
- 0
|
32
|
+
- 0
|
33
|
+
version: 3.0.0
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
description: The simplest search gem
|
37
|
+
email:
|
38
|
+
- jimneath@gmail.com
|
39
|
+
executables: []
|
40
|
+
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files: []
|
44
|
+
|
45
|
+
files:
|
46
|
+
- .gitignore
|
47
|
+
- .rvmrc
|
48
|
+
- Gemfile
|
49
|
+
- Rakefile
|
50
|
+
- lib/searchy.rb
|
51
|
+
- lib/searchy/search.rb
|
52
|
+
- lib/searchy/version.rb
|
53
|
+
- readme.md
|
54
|
+
- searchy.gemspec
|
55
|
+
homepage: ""
|
56
|
+
licenses: []
|
57
|
+
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
hash: 3
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
version: "0"
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 3
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
version: "0"
|
81
|
+
requirements: []
|
82
|
+
|
83
|
+
rubyforge_project: searchy
|
84
|
+
rubygems_version: 1.8.17
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: The simplest search gem
|
88
|
+
test_files: []
|
89
|
+
|