search_cop 1.0.0

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/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ gemfiles/*.lock
data/.travis.yml ADDED
@@ -0,0 +1,33 @@
1
+
2
+ addons:
3
+ postgresql: "9.3"
4
+
5
+ before_script:
6
+ - mysql -e 'create database search_cop;'
7
+ - psql -c 'create database search_cop;' -U postgres
8
+
9
+ rvm:
10
+ - 1.9.3
11
+ - 2.0.0
12
+ - 2.1.1
13
+ - rbx-2
14
+ - jruby
15
+ env:
16
+ - DATABASE=sqlite
17
+ - DATABASE=mysql
18
+ - DATABASE=postgres
19
+ matrix:
20
+ allow_failures:
21
+ - rvm: rbx-2
22
+ - rvm: jruby
23
+
24
+ gemfile:
25
+ - gemfiles/3.2.gemfile
26
+ - gemfiles/4.0.gemfile
27
+ - gemfiles/4.1.gemfile
28
+
29
+ install:
30
+ - "travis_retry bundle install"
31
+
32
+ script: "bundle exec rake test"
33
+
data/Appraisals ADDED
@@ -0,0 +1,14 @@
1
+ appraise "3.2" do
2
+ gem "activerecord", "~> 3.2.18"
3
+ gem "search_cop", :path => "../"
4
+ end
5
+
6
+ appraise "4.0" do
7
+ gem "activerecord", "~> 4.0.0"
8
+ gem "search_cop", :path => "../"
9
+ end
10
+
11
+ appraise "4.1" do
12
+ gem "activerecord", "~> 4.1.0.beta"
13
+ gem "search_cop", :path => "../"
14
+ end
data/Gemfile ADDED
@@ -0,0 +1,23 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in search_cop.gemspec
4
+ gemspec
5
+
6
+ platforms :jruby do
7
+ gem 'activerecord-jdbcmysql-adapter'
8
+ gem 'activerecord-jdbcsqlite3-adapter'
9
+ gem 'activerecord-jdbcpostgresql-adapter'
10
+ end
11
+
12
+ platforms :ruby do
13
+ gem 'sqlite3'
14
+ gem 'mysql2'
15
+ gem 'pg'
16
+ end
17
+
18
+ platforms :rbx do
19
+ gem 'racc'
20
+ gem 'rubysl', '~> 2.0'
21
+ gem 'psych'
22
+ end
23
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Benjamin Vetter
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/MIGRATION.md ADDED
@@ -0,0 +1,66 @@
1
+
2
+ # AttrSearchable to SearchCop
3
+
4
+ As the set of features of AttrSearchable grew and grew, it has been neccessary
5
+ to change its DSL and name, as no `attr_searchable` method is present anymore.
6
+ The new DSL is cleaner and more concise. Morever, the migration process is
7
+ simple.
8
+
9
+ AttrSearchable:
10
+
11
+ ```ruby
12
+ class Book < ActiveRecord::Base
13
+ include AttrSearchable
14
+
15
+ scope :search_scope, lambda { eager_load :comments, :users, :user }
16
+
17
+ attr_searchable :title, :description
18
+ attr_searchable :comment => ["comments.title", "comments.message"]
19
+ attr_searchable :user => ["users.username", "users_books.username"]
20
+
21
+ attr_searchable_options :title, :type => :fulltext, :default => true
22
+
23
+ attr_searchable_alias :users_books => :user
24
+ end
25
+ ```
26
+
27
+ SearchCop:
28
+
29
+ ```ruby
30
+ class Book < ActiveRecord::Base
31
+ include SearchCop
32
+
33
+ search_scope :search do
34
+ attributes :title, :description
35
+ attributes :comment => ["comments.title", "comments.message"]
36
+ attributes :user => ["users.username", "users_books.username"]
37
+
38
+ options :title, :type => :fulltext, :default => true
39
+
40
+ aliases :users_books => :user
41
+
42
+ scope { eager_load :comments, :users, :user }
43
+ end
44
+ end
45
+ ```
46
+
47
+ # Reflection
48
+
49
+ AttrSearchable:
50
+
51
+ ```ruby
52
+ Book.searchable_attributes
53
+ Book.searchable_attribute_options
54
+ Book.default_searchable_attributes
55
+ Book.searchable_aliases
56
+ ```
57
+
58
+ SearchCop:
59
+
60
+ ```ruby
61
+ Book.search_reflection(:search).attributes
62
+ Book.search_reflection(:search).options
63
+ Book.search_reflection(:search).default_attributes
64
+ Book.search_reflection(:search).aliases
65
+ ```
66
+