wherex 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -20
- data/Gemfile.lock +25 -17
- data/bin/rake +16 -0
- data/bin/rcov +16 -0
- data/bin/rg +16 -0
- data/bin/turn +16 -0
- data/lib/wherex/version.rb +1 -1
- data/lib/wherex/visitor.rb +3 -3
- data/lib/wherex.rb +1 -0
- data/test/db/test.sqlite3 +0 -0
- data/test/helper.rb +2 -2
- data/test/test_wherex.rb +2 -2
- data/wherex.gemspec +15 -0
- metadata +84 -5
data/Gemfile
CHANGED
@@ -1,22 +1,4 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
gem 'arel', '~> 2.0'
|
5
|
-
gem 'activerecord', '~> 3.0'
|
6
|
-
|
7
|
-
case ENV["RAILS_DB"]
|
8
|
-
when "postgres"
|
9
|
-
gem 'pg'
|
10
|
-
when "mysql"
|
11
|
-
gem 'mysql2', '~>0.2.11'
|
12
|
-
else
|
13
|
-
gem 'sqlite3'
|
14
|
-
end
|
15
|
-
|
16
|
-
group :test do
|
17
|
-
gem 'redgreen'
|
18
|
-
gem 'turn'
|
19
|
-
gem "rcov", ">= 0"
|
20
|
-
gem 'rake', '>= 0.8.3'
|
21
|
-
end
|
22
2
|
|
3
|
+
# Specify your gem's dependencies in activerecord_enum.gemspec
|
4
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,36 +1,44 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
wherex (1.0.6)
|
5
|
+
activerecord (>= 3.0)
|
6
|
+
arel (>= 2.0)
|
7
|
+
|
1
8
|
GEM
|
2
9
|
remote: http://rubygems.org/
|
3
10
|
specs:
|
4
|
-
activemodel (3.
|
5
|
-
activesupport (= 3.
|
6
|
-
builder (~>
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
activemodel (3.2.3)
|
12
|
+
activesupport (= 3.2.3)
|
13
|
+
builder (~> 3.0.0)
|
14
|
+
activerecord (3.2.3)
|
15
|
+
activemodel (= 3.2.3)
|
16
|
+
activesupport (= 3.2.3)
|
17
|
+
arel (~> 3.0.2)
|
18
|
+
tzinfo (~> 0.3.29)
|
19
|
+
activesupport (3.2.3)
|
20
|
+
i18n (~> 0.6)
|
21
|
+
multi_json (~> 1.0)
|
14
22
|
ansi (1.2.2)
|
15
|
-
arel (
|
16
|
-
builder (
|
17
|
-
i18n (0.
|
23
|
+
arel (3.0.2)
|
24
|
+
builder (3.0.0)
|
25
|
+
i18n (0.6.0)
|
26
|
+
multi_json (1.2.0)
|
18
27
|
rake (0.8.7)
|
19
28
|
rcov (0.9.9)
|
20
29
|
redgreen (1.2.2)
|
21
|
-
sqlite3 (1.3.
|
30
|
+
sqlite3 (1.3.5)
|
22
31
|
turn (0.8.2)
|
23
32
|
ansi (>= 1.2.2)
|
24
|
-
tzinfo (0.3.
|
33
|
+
tzinfo (0.3.32)
|
25
34
|
|
26
35
|
PLATFORMS
|
27
36
|
ruby
|
28
37
|
|
29
38
|
DEPENDENCIES
|
30
|
-
activerecord (~> 3.0)
|
31
|
-
arel (~> 2.0)
|
32
39
|
rake (>= 0.8.3)
|
33
40
|
rcov
|
34
41
|
redgreen
|
35
42
|
sqlite3
|
36
43
|
turn
|
44
|
+
wherex!
|
data/bin/rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rake', 'rake')
|
data/bin/rcov
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rcov' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rcov', 'rcov')
|
data/bin/rg
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rg' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('redgreen', 'rg')
|
data/bin/turn
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'turn' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('turn', 'turn')
|
data/lib/wherex/version.rb
CHANGED
data/lib/wherex/visitor.rb
CHANGED
@@ -11,7 +11,7 @@ module Wherex
|
|
11
11
|
def visit_Arel_Nodes_Equality_with_wherex o
|
12
12
|
right = o.right
|
13
13
|
if right.present? and right.is_a? Regexp
|
14
|
-
|
14
|
+
::ActiveRecord::Base.connection.regexp visit(o.left), visit(right)
|
15
15
|
else
|
16
16
|
visit_Arel_Nodes_Equality_without_wherex o
|
17
17
|
end
|
@@ -20,13 +20,13 @@ module Wherex
|
|
20
20
|
def visit_Arel_Nodes_NotEqual_with_wherex o
|
21
21
|
right = o.right
|
22
22
|
if right.present? and right.is_a? Regexp
|
23
|
-
|
23
|
+
::ActiveRecord::Base.connection.regexp_not visit(o.left), visit(right)
|
24
24
|
else
|
25
25
|
visit_Arel_Nodes_NotEqual_without_wherex o
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
def visit_Regexp o;
|
29
|
+
def visit_Regexp o; ::ActiveRecord::Base.connection.regexp_quote(o.source) end
|
30
30
|
|
31
31
|
end
|
32
32
|
end
|
data/lib/wherex.rb
CHANGED
data/test/db/test.sqlite3
CHANGED
Binary file
|
data/test/helper.rb
CHANGED
@@ -30,13 +30,13 @@ ActiveRecord::Base.silence do
|
|
30
30
|
load File.join(FIXTURES_PATH, 'schema.rb')
|
31
31
|
end
|
32
32
|
|
33
|
-
Fixtures.create_fixtures(FIXTURES_PATH, ActiveRecord::Base.connection.tables)
|
33
|
+
ActiveRecord::Fixtures.create_fixtures(FIXTURES_PATH, ActiveRecord::Base.connection.tables)
|
34
34
|
|
35
35
|
class Test::Unit::TestCase
|
36
36
|
def method_missing method, *args
|
37
37
|
candidate = method.to_s.classify
|
38
38
|
begin
|
39
|
-
candidate.constantize.find( Fixtures.identify args[0] )
|
39
|
+
candidate.constantize.find( ActiveRecord::Fixtures.identify args[0] )
|
40
40
|
rescue NameError
|
41
41
|
raise NameError.new "undefined local variable or method `#{method}`"
|
42
42
|
end
|
data/test/test_wherex.rb
CHANGED
@@ -3,7 +3,7 @@ require 'helper'
|
|
3
3
|
class TestWherex < Test::Unit::TestCase
|
4
4
|
def test_user_example
|
5
5
|
assert u = User.where( :zipcode => /^9[345][0-9]{3}$/ )
|
6
|
-
assert_equal 3, u.count
|
6
|
+
assert_equal 3, u.count
|
7
7
|
[:two, :three, :four ].each do |id|
|
8
8
|
assert u.include?( users(id) )
|
9
9
|
end
|
@@ -21,7 +21,7 @@ class TestWherex < Test::Unit::TestCase
|
|
21
21
|
def test_student_example
|
22
22
|
assert s = Student.all( :conditions => { :name => /[^a-zA-Z ]/ } )
|
23
23
|
assert_equal 3, s.count
|
24
|
-
[ :two, :three, :four ].each do |id|
|
24
|
+
[ :two, :three, :four ].each do |id|
|
25
25
|
assert s.include?( students(id) )
|
26
26
|
end
|
27
27
|
end
|
data/wherex.gemspec
CHANGED
@@ -21,4 +21,19 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.add_dependency 'arel', '>= 2.0'
|
23
23
|
s.add_dependency 'activerecord', '>= 3.0'
|
24
|
+
|
25
|
+
case ENV["RAILS_DB"]
|
26
|
+
when "postgres"
|
27
|
+
s.add_development_dependency 'pg'
|
28
|
+
when "mysql"
|
29
|
+
s.add_development_dependency 'mysql2'
|
30
|
+
else
|
31
|
+
s.add_development_dependency 'sqlite3'
|
32
|
+
end
|
33
|
+
|
34
|
+
s.add_development_dependency 'redgreen'
|
35
|
+
s.add_development_dependency 'turn'
|
36
|
+
s.add_development_dependency "rcov", ">= 0"
|
37
|
+
s.add_development_dependency 'rake', '>= 0.8.3'
|
38
|
+
|
24
39
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wherex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 7
|
10
|
+
version: 1.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jason King
|
@@ -47,11 +47,86 @@ dependencies:
|
|
47
47
|
version: "3.0"
|
48
48
|
type: :runtime
|
49
49
|
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: sqlite3
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
type: :development
|
63
|
+
version_requirements: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: redgreen
|
66
|
+
prerelease: false
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
type: :development
|
77
|
+
version_requirements: *id004
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: turn
|
80
|
+
prerelease: false
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
type: :development
|
91
|
+
version_requirements: *id005
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
name: rcov
|
94
|
+
prerelease: false
|
95
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
hash: 3
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
version: "0"
|
104
|
+
type: :development
|
105
|
+
version_requirements: *id006
|
106
|
+
- !ruby/object:Gem::Dependency
|
107
|
+
name: rake
|
108
|
+
prerelease: false
|
109
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
hash: 57
|
115
|
+
segments:
|
116
|
+
- 0
|
117
|
+
- 8
|
118
|
+
- 3
|
119
|
+
version: 0.8.3
|
120
|
+
type: :development
|
121
|
+
version_requirements: *id007
|
50
122
|
description: This gem allows you to pass a Regexp as the value for any finder in ActiveRecord - Rails3 only
|
51
123
|
email:
|
52
124
|
- jk@handle.it
|
53
|
-
executables:
|
54
|
-
|
125
|
+
executables:
|
126
|
+
- rake
|
127
|
+
- rcov
|
128
|
+
- rg
|
129
|
+
- turn
|
55
130
|
extensions: []
|
56
131
|
|
57
132
|
extra_rdoc_files: []
|
@@ -63,6 +138,10 @@ files:
|
|
63
138
|
- LICENSE.txt
|
64
139
|
- README.md
|
65
140
|
- Rakefile
|
141
|
+
- bin/rake
|
142
|
+
- bin/rcov
|
143
|
+
- bin/rg
|
144
|
+
- bin/turn
|
66
145
|
- lib/wherex.rb
|
67
146
|
- lib/wherex/adapters.rb
|
68
147
|
- lib/wherex/connection.rb
|