active_search 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +69 -0
- data/Rakefile +6 -0
- data/active_search.gemspec +29 -0
- data/lib/active_search.rb +6 -0
- data/lib/active_search/version.rb +3 -0
- metadata +165 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e9c7dd30c9833519ed79bd213892cb61a9377ca5
|
4
|
+
data.tar.gz: c29c291a9e4585979e41f7fbad3e849e9d41a9a3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8c1208749ac67681714764c99bc6924584ebcb8e43dca0d1ede4342b343519d8017b490e9cc2f7d7f94dd5704771f30b03a7e600f289aabc020ca40d577a6d71
|
7
|
+
data.tar.gz: 29db12d2b2d1f2b0d5c903ab1f446d2869a3d45af6be58178e3ef0b81f804079454a8f8b6c0a9fc5fdfbd7b2ef95194c10ac0935b75d6ead11096799886f165a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 zachmokahn
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
## Searchable
|
2
|
+
#### By zachmokahn
|
3
|
+
|
4
|
+
This gem is in very early, very beta release. Please report any and all bugs, as well as any or all desired features. I'd love to make this better, or for you to make it better. Fork it, make pull requests, give me feedback. THANKS!
|
5
|
+
|
6
|
+
#### What does it do?
|
7
|
+
|
8
|
+
Searchable adds some methods to ActiveRecord::Base Objects
|
9
|
+
|
10
|
+
|
11
|
+
```
|
12
|
+
#is_searchable?
|
13
|
+
#searchable?
|
14
|
+
```
|
15
|
+
```is_searchable?``` and it's alias: ```searchable?``` detect whether or not any class that inherits from ActiveRecord::Base is searchable. By default this returns false.
|
16
|
+
|
17
|
+
|
18
|
+
```
|
19
|
+
#searchable_by(:parameters)
|
20
|
+
#findable_by(:parameters)
|
21
|
+
```
|
22
|
+
By adding ```searchable_by``` or it's alias ```findable_by``` to a class inheriting for ActiveRecord::Base it will become searchable by the provided parameters that correspond to columns in the database.
|
23
|
+
When this is included ```#searchable?``` will return true.
|
24
|
+
|
25
|
+
|
26
|
+
```
|
27
|
+
#find_by_value("value")
|
28
|
+
#search_for("value")
|
29
|
+
```
|
30
|
+
By calling ```find_by_value``` or it's alias ```search_for``` on a class it checks all the searchable parameters of the Class the method is being called on for a match. This method will preform partial matches and is case insensitive.
|
31
|
+
|
32
|
+
|
33
|
+
```
|
34
|
+
#find_by_value("value", "association")
|
35
|
+
#search_for("value", "association")
|
36
|
+
```
|
37
|
+
This can also be called on an instance of a Class to search against a collection of ActiveRecord::Associations where the searchable parameters match.
|
38
|
+
|
39
|
+
|
40
|
+
#### How the Heck do you use this?
|
41
|
+
1. Install the Gem
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
gem install searchable
|
45
|
+
```
|
46
|
+
or Require it in your Gemfile
|
47
|
+
```ruby
|
48
|
+
gem 'searchable'
|
49
|
+
```
|
50
|
+
2. Make a class searchable
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
class Model < ActiveRecord::Base
|
54
|
+
searchable_by :first_name, :last_name, :nickname
|
55
|
+
end
|
56
|
+
```
|
57
|
+
3. Find instances of that class
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
Model.search_for("zachmo")
|
61
|
+
=> [#<Model id: 1, first_name: "Zack", last_name: "Mo", nickname: "zachmo", created_at: "2013-12-01 04:00:48", updated_at: "2013-12-01 04:00:48">]
|
62
|
+
```
|
63
|
+
|
64
|
+
===
|
65
|
+
|
66
|
+
##### Are you sure it works?
|
67
|
+
I test drove this whole development, so everything included works.
|
68
|
+
<img align="center" src="img/tests.png" />
|
69
|
+
Is it perfect? No. But it beta. Give me a break.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'active_search/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "active_search"
|
8
|
+
spec.version = ActiveSearch::VERSION
|
9
|
+
spec.authors = ["Zachary J. Davy"]
|
10
|
+
spec.email = ["zachmokahn@gmail.com"]
|
11
|
+
spec.description = "Searchable will allow any model to be 'searched for' in a text field given the 'search' class"
|
12
|
+
spec.summary = "Easily make items searchable inside of your app"
|
13
|
+
spec.homepage = "http://github.com/zachmokahn/searchable"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "activerecord"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "coveralls"
|
26
|
+
spec.add_development_dependency "sqlite3"
|
27
|
+
spec.add_development_dependency "guard"
|
28
|
+
spec.add_development_dependency "guard-rspec"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_search
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zachary J. Davy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sqlite3
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Searchable will allow any model to be 'searched for' in a text field
|
126
|
+
given the 'search' class
|
127
|
+
email:
|
128
|
+
- zachmokahn@gmail.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .gitignore
|
134
|
+
- Gemfile
|
135
|
+
- LICENSE.txt
|
136
|
+
- README.md
|
137
|
+
- Rakefile
|
138
|
+
- active_search.gemspec
|
139
|
+
- lib/active_search.rb
|
140
|
+
- lib/active_search/version.rb
|
141
|
+
homepage: http://github.com/zachmokahn/searchable
|
142
|
+
licenses:
|
143
|
+
- MIT
|
144
|
+
metadata: {}
|
145
|
+
post_install_message:
|
146
|
+
rdoc_options: []
|
147
|
+
require_paths:
|
148
|
+
- lib
|
149
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
requirements: []
|
160
|
+
rubyforge_project:
|
161
|
+
rubygems_version: 2.1.10
|
162
|
+
signing_key:
|
163
|
+
specification_version: 4
|
164
|
+
summary: Easily make items searchable inside of your app
|
165
|
+
test_files: []
|