activerecord-like 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +7 -0
- data/Gemfile +8 -0
- data/README.md +5 -1
- data/activerecord-like.gemspec +0 -3
- data/lib/active_record/like.rb +7 -6
- data/lib/active_record/like/version.rb +1 -1
- data/lib/activerecord-like.rb +1 -0
- metadata +10 -34
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# ActiveRecord::Like
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/ReneB/activerecord-like.png)](https://travis-ci.org/ReneB/activerecord-like)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/ReneB/activerecord-like.png)](https://codeclimate.com/github/ReneB/activerecord-like)
|
5
|
+
[![Dependency Status](https://gemnasium.com/ReneB/activerecord-like.png)](https://gemnasium.com/ReneB/activerecord-like)
|
6
|
+
|
3
7
|
An Active Record Plugin that allows chaining a more DSL-style 'like' or 'not-like' query to an ActiveRecord::Base#where. Requires Rails 4 beta or higher.
|
4
8
|
|
5
9
|
This plugin has been salvaged from the stellar work done by @amatsuda and @claudiob. Most of the code was previously in Active Record master, but was subsequently removed due to, amongst other, scope creep.
|
@@ -33,6 +37,6 @@ and
|
|
33
37
|
1. Fork it
|
34
38
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
39
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
-
4. Make sure the tests run. I will not merge commits that change code without testing the new code.
|
40
|
+
4. Make sure the tests run. I will not merge commits that change code without testing the new code. Running the tests is as easy as running `bundle && rake` - if this does not work, consider it a bug and report it.
|
37
41
|
5. Push to the branch (`git push origin my-new-feature`)
|
38
42
|
6. Create new Pull Request
|
data/activerecord-like.gemspec
CHANGED
@@ -15,8 +15,5 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
|
18
|
-
gem.add_development_dependency "minitest", ">= 3"
|
19
|
-
gem.add_development_dependency "sqlite3", "~> 1.3"
|
20
|
-
|
21
18
|
gem.add_dependency "activerecord", ">= 4.0.0"
|
22
19
|
end
|
data/lib/active_record/like.rb
CHANGED
@@ -4,17 +4,18 @@ module ActiveRecord
|
|
4
4
|
module QueryMethods
|
5
5
|
module Like
|
6
6
|
def like(opts, *rest)
|
7
|
-
|
8
|
-
s.where_values += s.send(:build_where, opts, *rest).map do |r|
|
9
|
-
Arel::Nodes::Matches.new(r.left, r.right)
|
10
|
-
end
|
11
|
-
end
|
7
|
+
chain_node(Arel::Nodes::Matches, opts, *rest)
|
12
8
|
end
|
13
9
|
|
14
10
|
def not_like(opts, *rest)
|
11
|
+
chain_node(Arel::Nodes::DoesNotMatch, opts, *rest)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def chain_node(node_type, opts, *rest)
|
15
16
|
@scope.tap do |s|
|
16
17
|
s.where_values += s.send(:build_where, opts, *rest).map do |r|
|
17
|
-
|
18
|
+
node_type.new(r.left, r.right)
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'active_record/like'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-like
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,40 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: minitest
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '3'
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '3'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: sqlite3
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '1.3'
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '1.3'
|
46
14
|
- !ruby/object:Gem::Dependency
|
47
15
|
name: activerecord
|
48
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,6 +36,7 @@ extensions: []
|
|
68
36
|
extra_rdoc_files: []
|
69
37
|
files:
|
70
38
|
- .gitignore
|
39
|
+
- .travis.yml
|
71
40
|
- Gemfile
|
72
41
|
- LICENSE.txt
|
73
42
|
- README.md
|
@@ -75,6 +44,7 @@ files:
|
|
75
44
|
- activerecord-like.gemspec
|
76
45
|
- lib/active_record/like.rb
|
77
46
|
- lib/active_record/like/version.rb
|
47
|
+
- lib/activerecord-like.rb
|
78
48
|
- test/helper.rb
|
79
49
|
- test/integration/like_test.rb
|
80
50
|
- test/integration/not_like_test.rb
|
@@ -92,12 +62,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
62
|
- - ! '>='
|
93
63
|
- !ruby/object:Gem::Version
|
94
64
|
version: '0'
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
hash: -4576696767238257655
|
95
68
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
69
|
none: false
|
97
70
|
requirements:
|
98
71
|
- - ! '>='
|
99
72
|
- !ruby/object:Gem::Version
|
100
73
|
version: '0'
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
hash: -4576696767238257655
|
101
77
|
requirements: []
|
102
78
|
rubyforge_project:
|
103
79
|
rubygems_version: 1.8.24
|