wherex 1.0.8 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -2
- data/.ruby-version +1 -0
- data/.travis.yml +33 -0
- data/Appraisals +19 -0
- data/Gemfile +7 -1
- data/Gemfile.lock +58 -30
- data/README.md +13 -9
- data/Rakefile +2 -15
- data/bin/appraisal +16 -0
- data/bin/tapout +16 -0
- data/bin/thor +16 -0
- data/gemfiles/activerecord_3.1.gemfile +14 -0
- data/gemfiles/activerecord_3.2.gemfile +14 -0
- data/gemfiles/activerecord_4.0.gemfile +14 -0
- data/gemfiles/activerecord_4.1.gemfile +14 -0
- data/gemfiles/activerecord_4.2.gemfile +14 -0
- data/lib/wherex/version.rb +1 -1
- data/lib/wherex/visitor.rb +10 -5
- data/test/config/database.yml +12 -5
- data/test/fixtures/schema.rb +3 -3
- data/test/test_helper.rb +57 -0
- data/test/{test_wherex.rb → wherex_test.rb} +4 -4
- data/wherex.gemspec +6 -17
- metadata +44 -78
- data/test/db/test.sqlite3 +0 -0
- data/test/helper.rb +0 -44
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 06f7931fb087e7901a750ae933265bcb110adeae
|
4
|
+
data.tar.gz: dbd498b628d94789801361f8cc44219a2507a4cf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d2f59b336978596eeec1230a6b09d58dfc784bf41238bfc94a1c4ad70805494a4a5b20e03a7c0459167cfcc09617bf8bcdaa5c7fcb618a8b04c0e0a71faf5167
|
7
|
+
data.tar.gz: 33741b3669e61fa0e5e3c563d4e941688796afa923fcf38c15c9a5945fb6fc3b2f11d1876c190ff669bd2129a3c2f8d6c9a0630fe4035a4ad9d8d766a43bfe76
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.5
|
data/.travis.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
cache: bundler
|
2
|
+
language: ruby
|
3
|
+
|
4
|
+
before_script:
|
5
|
+
- mysql -e 'create database wherex_test;'
|
6
|
+
- psql -c 'create database wherex_test;' -U postgres
|
7
|
+
|
8
|
+
rvm:
|
9
|
+
- 2.0.0
|
10
|
+
- 2.1.5
|
11
|
+
- ruby-head
|
12
|
+
|
13
|
+
gemfile:
|
14
|
+
- gemfiles/activerecord_3.1.gemfile
|
15
|
+
- gemfiles/activerecord_3.2.gemfile
|
16
|
+
- gemfiles/activerecord_4.0.gemfile
|
17
|
+
- gemfiles/activerecord_4.1.gemfile
|
18
|
+
- gemfiles/activerecord_4.2.gemfile
|
19
|
+
|
20
|
+
env:
|
21
|
+
- RAILS_DB=sqlite
|
22
|
+
- RAILS_DB=mysql
|
23
|
+
- RAILS_DB=postgres
|
24
|
+
|
25
|
+
matrix:
|
26
|
+
fast_finish: true
|
27
|
+
allow_failures:
|
28
|
+
- rvm: ruby-head
|
29
|
+
- gemfile: gemfiles/activerecord_4.2.gemfile
|
30
|
+
|
31
|
+
addons:
|
32
|
+
code_climate:
|
33
|
+
repo_token: cd0a2d249ae3b4ba63161597f985fedb01d208d2fece3da0ca3cce379c5bc3b8
|
data/Appraisals
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
appraise "activerecord-3.1" do
|
2
|
+
gem "activerecord", "~> 3.1.0"
|
3
|
+
end
|
4
|
+
|
5
|
+
appraise "activerecord-3.2" do
|
6
|
+
gem "activerecord", "~> 3.2.0"
|
7
|
+
end
|
8
|
+
|
9
|
+
appraise "activerecord-4.0" do
|
10
|
+
gem "activerecord", "~> 4.0.0"
|
11
|
+
end
|
12
|
+
|
13
|
+
appraise "activerecord-4.1" do
|
14
|
+
gem "activerecord", "~> 4.1.0"
|
15
|
+
end
|
16
|
+
|
17
|
+
appraise "activerecord-4.2" do
|
18
|
+
gem "activerecord", "~> 4.2.0.rc1"
|
19
|
+
end
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,44 +1,72 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
wherex (1.0.
|
5
|
-
activerecord (>= 3.
|
6
|
-
arel (>= 2.0)
|
4
|
+
wherex (1.0.8)
|
5
|
+
activerecord (>= 3.1)
|
7
6
|
|
8
7
|
GEM
|
9
8
|
remote: http://rubygems.org/
|
10
9
|
specs:
|
11
|
-
activemodel (
|
12
|
-
activesupport (=
|
13
|
-
builder (~> 3.
|
14
|
-
activerecord (
|
15
|
-
activemodel (=
|
16
|
-
activesupport (=
|
17
|
-
arel (~>
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
activemodel (4.1.8)
|
11
|
+
activesupport (= 4.1.8)
|
12
|
+
builder (~> 3.1)
|
13
|
+
activerecord (4.1.8)
|
14
|
+
activemodel (= 4.1.8)
|
15
|
+
activesupport (= 4.1.8)
|
16
|
+
arel (~> 5.0.0)
|
17
|
+
activesupport (4.1.8)
|
18
|
+
i18n (~> 0.6, >= 0.6.9)
|
19
|
+
json (~> 1.7, >= 1.7.7)
|
20
|
+
minitest (~> 5.1)
|
21
|
+
thread_safe (~> 0.1)
|
22
|
+
tzinfo (~> 1.1)
|
23
|
+
ansi (1.4.3)
|
24
|
+
appraisal (1.0.2)
|
25
|
+
bundler
|
26
|
+
rake
|
27
|
+
thor (>= 0.14.0)
|
28
|
+
arel (5.0.1.20140414130214)
|
29
|
+
builder (3.2.2)
|
30
|
+
codeclimate-test-reporter (0.4.1)
|
31
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
32
|
+
docile (1.1.5)
|
33
|
+
i18n (0.6.11)
|
34
|
+
json (1.8.1)
|
35
|
+
minitap (0.5.3)
|
36
|
+
minitest (~> 5.0)
|
37
|
+
minitest-reporter-api (>= 0.0.2)
|
38
|
+
tapout (>= 0.3.0)
|
39
|
+
minitest (5.4.3)
|
40
|
+
minitest-reporter-api (0.0.5)
|
41
|
+
minitest (~> 5.0)
|
42
|
+
multi_json (1.10.1)
|
43
|
+
mysql2 (0.3.13)
|
44
|
+
pg (0.17.1)
|
45
|
+
rake (10.4.0)
|
46
|
+
simplecov (0.9.1)
|
47
|
+
docile (~> 1.1.0)
|
21
48
|
multi_json (~> 1.0)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
ansi (>= 1.2.2)
|
33
|
-
tzinfo (0.3.32)
|
49
|
+
simplecov-html (~> 0.8.0)
|
50
|
+
simplecov-html (0.8.0)
|
51
|
+
sqlite3 (1.3.10)
|
52
|
+
tapout (0.4.5)
|
53
|
+
ansi
|
54
|
+
json
|
55
|
+
thor (0.19.1)
|
56
|
+
thread_safe (0.3.4)
|
57
|
+
tzinfo (1.2.2)
|
58
|
+
thread_safe (~> 0.1)
|
34
59
|
|
35
60
|
PLATFORMS
|
36
61
|
ruby
|
37
62
|
|
38
63
|
DEPENDENCIES
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
64
|
+
appraisal
|
65
|
+
codeclimate-test-reporter
|
66
|
+
minitap
|
67
|
+
mysql2
|
68
|
+
pg
|
69
|
+
rake (>= 1.0)
|
70
|
+
sqlite3 (>= 1.3.7)
|
71
|
+
tapout
|
44
72
|
wherex!
|
data/README.md
CHANGED
@@ -1,14 +1,18 @@
|
|
1
|
-
# wherex
|
1
|
+
# wherex
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/smathy/wherex.svg?branch=master)](https://travis-ci.org/smathy/wherex) [![Code Climate](https://codeclimate.com/github/smathy/wherex/badges/gpa.svg)](https://codeclimate.com/github/smathy/wherex) [![Test Coverage](https://codeclimate.com/github/smathy/wherex/badges/coverage.svg)](https://codeclimate.com/github/smathy/wherex)
|
4
4
|
|
5
|
-
|
5
|
+
Regexp support to ActiveRecord finders.
|
6
6
|
|
7
|
-
|
7
|
+
## Installation
|
8
8
|
|
9
|
-
|
9
|
+
Wherex is [Semantically Versioned](http://semver.org/), meaning that we will
|
10
|
+
always indicate a backwardly incompatible change with a MAJOR version bump, so
|
11
|
+
you can just use this in your `Gemfile`:
|
10
12
|
|
11
|
-
|
13
|
+
```ruby
|
14
|
+
gem 'wherex', '~> 1.0'
|
15
|
+
```
|
12
16
|
|
13
17
|
## What the?
|
14
18
|
|
@@ -87,13 +91,13 @@ repo and run `rake` and it will run the tests against SQLite
|
|
87
91
|
|
88
92
|
If you want to run the tests against MySQL or PostgreSQL then you will first
|
89
93
|
need to create a `wherex_test` database in your local machine. Then you will
|
90
|
-
need to provide the `
|
94
|
+
need to provide the `DB` environment variable to rake, eg:
|
91
95
|
|
92
|
-
|
96
|
+
DB=mysql rake
|
93
97
|
|
94
98
|
…or…
|
95
99
|
|
96
|
-
|
100
|
+
DB=postgres rake
|
97
101
|
|
98
102
|
These will use a default user of `root` for MySQL and `postgres` for PostgreSQL.
|
99
103
|
If you want to use different usernames or passwords then take a look in the
|
data/Rakefile
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'bundler'
|
3
2
|
begin
|
4
3
|
Bundler.setup(:default, :development)
|
@@ -7,25 +6,13 @@ rescue Bundler::BundlerError => e
|
|
7
6
|
$stderr.puts "Run `bundle install` to install missing gems"
|
8
7
|
exit e.status_code
|
9
8
|
end
|
10
|
-
require 'rake'
|
11
|
-
|
12
|
-
spec = Gem::Specification.load( File.join( File.dirname(__FILE__), 'wherex.gemspec' ) )
|
13
|
-
|
14
|
-
$:.push File.expand_path("../lib", __FILE__)
|
15
|
-
require "wherex/version"
|
16
9
|
|
17
10
|
require 'rake/testtask'
|
18
11
|
Rake::TestTask.new(:test) do |test|
|
19
12
|
test.libs << 'lib' << 'test'
|
20
|
-
test.pattern = 'test
|
21
|
-
test.verbose = true
|
22
|
-
end
|
23
|
-
|
24
|
-
require 'rcov/rcovtask'
|
25
|
-
Rcov::RcovTask.new do |test|
|
26
|
-
test.libs << 'test'
|
27
|
-
test.pattern = 'test/**/test_*.rb'
|
13
|
+
test.pattern = 'test/**/*_test.rb'
|
28
14
|
test.verbose = true
|
15
|
+
test.options = ' | tapout runtime'
|
29
16
|
end
|
30
17
|
|
31
18
|
task :default => :test
|
data/bin/appraisal
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'appraisal' 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('appraisal', 'appraisal')
|
data/bin/tapout
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'tapout' 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('tapout', 'tapout')
|
data/bin/thor
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'thor' 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('thor', 'thor')
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
5
|
+
gem "activerecord", "~> 3.1.0"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "appraisal"
|
9
|
+
gem "tapout"
|
10
|
+
gem "minitap"
|
11
|
+
gem "codeclimate-test-reporter", :require => nil
|
12
|
+
end
|
13
|
+
|
14
|
+
gemspec :path => "../"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
5
|
+
gem "activerecord", "~> 3.2.0"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "appraisal"
|
9
|
+
gem "tapout"
|
10
|
+
gem "minitap"
|
11
|
+
gem "codeclimate-test-reporter", :require => nil
|
12
|
+
end
|
13
|
+
|
14
|
+
gemspec :path => "../"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
5
|
+
gem "activerecord", "~> 4.0.0"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "appraisal"
|
9
|
+
gem "tapout"
|
10
|
+
gem "minitap"
|
11
|
+
gem "codeclimate-test-reporter", :require => nil
|
12
|
+
end
|
13
|
+
|
14
|
+
gemspec :path => "../"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
5
|
+
gem "activerecord", "~> 4.1.0"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "appraisal"
|
9
|
+
gem "tapout"
|
10
|
+
gem "minitap"
|
11
|
+
gem "codeclimate-test-reporter", :require => nil
|
12
|
+
end
|
13
|
+
|
14
|
+
gemspec :path => "../"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "http://rubygems.org"
|
4
|
+
|
5
|
+
gem "activerecord", "~> 4.2.0.rc1"
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "appraisal"
|
9
|
+
gem "tapout"
|
10
|
+
gem "minitap"
|
11
|
+
gem "codeclimate-test-reporter", :require => nil
|
12
|
+
end
|
13
|
+
|
14
|
+
gemspec :path => "../"
|
data/lib/wherex/version.rb
CHANGED
data/lib/wherex/visitor.rb
CHANGED
@@ -8,25 +8,30 @@ module Wherex
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def visit_Arel_Nodes_Equality_with_wherex
|
11
|
+
def visit_Arel_Nodes_Equality_with_wherex *args
|
12
|
+
o = args.first
|
12
13
|
right = o.right
|
13
14
|
if right.present? and right.is_a? Regexp
|
14
15
|
::ActiveRecord::Base.connection.regexp visit(o.left), visit(right)
|
15
16
|
else
|
16
|
-
visit_Arel_Nodes_Equality_without_wherex
|
17
|
+
visit_Arel_Nodes_Equality_without_wherex *args
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
20
|
-
def visit_Arel_Nodes_NotEqual_with_wherex
|
21
|
+
def visit_Arel_Nodes_NotEqual_with_wherex *args
|
22
|
+
o = args.first
|
21
23
|
right = o.right
|
22
24
|
if right.present? and right.is_a? Regexp
|
23
25
|
::ActiveRecord::Base.connection.regexp_not visit(o.left), visit(right)
|
24
26
|
else
|
25
|
-
visit_Arel_Nodes_NotEqual_without_wherex
|
27
|
+
visit_Arel_Nodes_NotEqual_without_wherex *args
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
|
-
def visit_Regexp
|
31
|
+
def visit_Regexp *args
|
32
|
+
o = args.first
|
33
|
+
::ActiveRecord::Base.connection.regexp_quote(o.source)
|
34
|
+
end
|
30
35
|
|
31
36
|
end
|
32
37
|
end
|
data/test/config/database.yml
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
test:
|
2
|
-
postgres:
|
2
|
+
postgres: &postgres
|
3
3
|
adapter: postgresql
|
4
4
|
encoding: unicode
|
5
5
|
database: wherex_test
|
6
6
|
pool: 5
|
7
7
|
username: <%= ENV['POSTGRESQL_USERNAME'] || 'postgres' %>
|
8
8
|
password: <%= ENV['POSTGRESQL_PASSWORD'] || '' %>
|
9
|
-
|
9
|
+
postgresql:
|
10
|
+
<<: *postgres
|
11
|
+
pg:
|
12
|
+
<<: *postgres
|
13
|
+
mysql: &mysql
|
10
14
|
adapter: mysql2
|
11
15
|
encoding: utf8
|
12
16
|
reconnect: false
|
@@ -14,9 +18,12 @@ test:
|
|
14
18
|
pool: 5
|
15
19
|
username: <%= ENV['MYSQL_USERNAME'] || 'root' %>
|
16
20
|
password: <%= ENV['MYSQL_PASSWORD'] || '' %>
|
17
|
-
|
18
|
-
|
21
|
+
mysql2:
|
22
|
+
<<: *mysql
|
23
|
+
sqlite: &sqlite
|
19
24
|
adapter: sqlite3
|
20
|
-
database:
|
25
|
+
database: ':memory:'
|
21
26
|
pool: 5
|
22
27
|
timeout: 5000
|
28
|
+
sqlite3:
|
29
|
+
<<: *sqlite
|
data/test/fixtures/schema.rb
CHANGED
@@ -2,17 +2,17 @@ ActiveRecord::Schema.define do
|
|
2
2
|
|
3
3
|
create_table "users", :force => true do |t|
|
4
4
|
t.string "zipcode"
|
5
|
-
t.timestamps
|
5
|
+
t.timestamps null: false
|
6
6
|
end
|
7
7
|
|
8
8
|
create_table "students", :force => true do |t|
|
9
9
|
t.string "name"
|
10
|
-
t.timestamps
|
10
|
+
t.timestamps null: false
|
11
11
|
end
|
12
12
|
|
13
13
|
create_table "products", :force => true do |t|
|
14
14
|
t.string "code"
|
15
|
-
t.timestamps
|
15
|
+
t.timestamps null: false
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require "codeclimate-test-reporter"
|
2
|
+
CodeClimate::TestReporter.start
|
3
|
+
|
4
|
+
ENV['DB'] = ( ENV['DB'] || 'sqlite' ).downcase
|
5
|
+
|
6
|
+
require 'minitest/autorun'
|
7
|
+
require 'minitap'
|
8
|
+
|
9
|
+
if defined? Minitap
|
10
|
+
Minitest.reporter = Minitap::TapY
|
11
|
+
else
|
12
|
+
MiniTest::Unit.runner = MiniTest::TapY.new
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'wherex'
|
16
|
+
require 'active_record/fixtures'
|
17
|
+
|
18
|
+
ROOT_PATH = File.expand_path( File.join( File.dirname(__FILE__) ))
|
19
|
+
|
20
|
+
config = YAML::load(ERB.new(IO.read(File.join( ROOT_PATH, 'config', 'database.yml'))).result)['test'][ENV['DB']]
|
21
|
+
|
22
|
+
ActiveRecord::Base.establish_connection config
|
23
|
+
|
24
|
+
dep = defined?(ActiveSupport::Dependencies) ? ActiveSupport::Dependencies : ::Dependencies
|
25
|
+
dep.autoload_paths.unshift File.join( ROOT_PATH, 'app/models' )
|
26
|
+
|
27
|
+
FIXTURES_PATH = File.join(File.dirname(__FILE__), 'fixtures')
|
28
|
+
dep.autoload_paths.unshift FIXTURES_PATH
|
29
|
+
|
30
|
+
ActiveRecord::Migration.verbose = false
|
31
|
+
load File.join(FIXTURES_PATH, 'schema.rb')
|
32
|
+
|
33
|
+
FIXTURE_CLASS =
|
34
|
+
begin
|
35
|
+
ActiveRecord::FixtureSet
|
36
|
+
rescue NameError
|
37
|
+
begin
|
38
|
+
ActiveRecord::Fixtures
|
39
|
+
rescue NameError
|
40
|
+
Fixtures
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
FIXTURE_CLASS.create_fixtures(FIXTURES_PATH, ActiveRecord::Base.connection.tables)
|
45
|
+
|
46
|
+
TEST_CLASS = defined?(Minitest::Test) ? Minitest::Test : MiniTest::Unit::TestCase
|
47
|
+
|
48
|
+
class TEST_CLASS
|
49
|
+
def method_missing method, *args
|
50
|
+
candidate = method.to_s.classify
|
51
|
+
begin
|
52
|
+
candidate.constantize.find( FIXTURE_CLASS.identify args[0] )
|
53
|
+
rescue NameError
|
54
|
+
raise NameError.new "undefined local variable or method `#{method}`"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class WherexTest < TEST_CLASS
|
4
4
|
def test_user_example
|
5
5
|
assert u = User.where( :zipcode => /^9[345][0-9]{3}$/ )
|
6
6
|
assert_equal 3, u.count
|
@@ -13,13 +13,13 @@ class TestWherex < Test::Unit::TestCase
|
|
13
13
|
assert p = Product.find_by_code( /^[NRW][^-]+-[456]/ )
|
14
14
|
assert_equal products(:one), p
|
15
15
|
|
16
|
-
assert p = Product.
|
16
|
+
assert p = Product.where( code: /^[NRW][^-]+-[456]/ )
|
17
17
|
assert_equal 1, p.count
|
18
18
|
assert_equal products(:one), p.first
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_student_example
|
22
|
-
assert s = Student.
|
22
|
+
assert s = Student.where( :name => /[^a-zA-Z ]/ )
|
23
23
|
assert_equal 3, s.count
|
24
24
|
[ :two, :three, :four ].each do |id|
|
25
25
|
assert s.include?( students(id) )
|
data/wherex.gemspec
CHANGED
@@ -12,27 +12,16 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = %q{Regexp for ActiveRecord finders}
|
13
13
|
s.description = %q{This gem allows you to pass a Regexp as the value for any finder in ActiveRecord - Rails3 only}
|
14
14
|
|
15
|
-
s.rubyforge_project = "wherex"
|
16
|
-
|
17
15
|
s.files = `git ls-files`.split("\n")
|
18
|
-
s.test_files =
|
16
|
+
s.test_files = s.files.grep /^test/
|
19
17
|
s.require_paths = ["lib"]
|
20
18
|
|
21
|
-
s.add_dependency '
|
22
|
-
s.add_dependency 'activerecord', '>= 3.0'
|
19
|
+
s.add_dependency 'activerecord', '>= 3.1'
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
when "mysql"
|
28
|
-
s.add_development_dependency 'mysql2'
|
29
|
-
else
|
30
|
-
s.add_development_dependency 'sqlite3'
|
31
|
-
end
|
21
|
+
s.add_development_dependency 'pg'
|
22
|
+
s.add_development_dependency 'mysql2'
|
23
|
+
s.add_development_dependency 'sqlite3', ">= 1.3.7"
|
32
24
|
|
33
|
-
s.add_development_dependency '
|
34
|
-
s.add_development_dependency 'turn'
|
35
|
-
s.add_development_dependency "rcov", ">= 0"
|
36
|
-
s.add_development_dependency 'rake', '>= 0.8.3'
|
25
|
+
s.add_development_dependency 'rake', '>= 1.0'
|
37
26
|
|
38
27
|
end
|
metadata
CHANGED
@@ -1,128 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wherex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jason King
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-11-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: arel
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '2.0'
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '2.0'
|
30
13
|
- !ruby/object:Gem::Dependency
|
31
14
|
name: activerecord
|
32
15
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
16
|
requirements:
|
35
|
-
- -
|
17
|
+
- - ">="
|
36
18
|
- !ruby/object:Gem::Version
|
37
|
-
version: '3.
|
19
|
+
version: '3.1'
|
38
20
|
type: :runtime
|
39
21
|
prerelease: false
|
40
22
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '3.0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: sqlite3
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
23
|
requirements:
|
59
|
-
- -
|
24
|
+
- - ">="
|
60
25
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
26
|
+
version: '3.1'
|
62
27
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
28
|
+
name: pg
|
64
29
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
30
|
requirements:
|
67
|
-
- -
|
31
|
+
- - ">="
|
68
32
|
- !ruby/object:Gem::Version
|
69
33
|
version: '0'
|
70
34
|
type: :development
|
71
35
|
prerelease: false
|
72
36
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
37
|
requirements:
|
75
|
-
- -
|
38
|
+
- - ">="
|
76
39
|
- !ruby/object:Gem::Version
|
77
40
|
version: '0'
|
78
41
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
42
|
+
name: mysql2
|
80
43
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
44
|
requirements:
|
83
|
-
- -
|
45
|
+
- - ">="
|
84
46
|
- !ruby/object:Gem::Version
|
85
47
|
version: '0'
|
86
48
|
type: :development
|
87
49
|
prerelease: false
|
88
50
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
51
|
requirements:
|
91
|
-
- -
|
52
|
+
- - ">="
|
92
53
|
- !ruby/object:Gem::Version
|
93
54
|
version: '0'
|
94
55
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
56
|
+
name: sqlite3
|
96
57
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
58
|
requirements:
|
99
|
-
- -
|
59
|
+
- - ">="
|
100
60
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
61
|
+
version: 1.3.7
|
102
62
|
type: :development
|
103
63
|
prerelease: false
|
104
64
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
65
|
requirements:
|
107
|
-
- -
|
66
|
+
- - ">="
|
108
67
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
68
|
+
version: 1.3.7
|
110
69
|
- !ruby/object:Gem::Dependency
|
111
70
|
name: rake
|
112
71
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
72
|
requirements:
|
115
|
-
- -
|
73
|
+
- - ">="
|
116
74
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0
|
75
|
+
version: '1.0'
|
118
76
|
type: :development
|
119
77
|
prerelease: false
|
120
78
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
79
|
requirements:
|
123
|
-
- -
|
80
|
+
- - ">="
|
124
81
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0
|
82
|
+
version: '1.0'
|
126
83
|
description: This gem allows you to pass a Regexp as the value for any finder in ActiveRecord
|
127
84
|
- Rails3 only
|
128
85
|
email:
|
@@ -131,16 +88,27 @@ executables: []
|
|
131
88
|
extensions: []
|
132
89
|
extra_rdoc_files: []
|
133
90
|
files:
|
134
|
-
- .gitignore
|
91
|
+
- ".gitignore"
|
92
|
+
- ".ruby-version"
|
93
|
+
- ".travis.yml"
|
94
|
+
- Appraisals
|
135
95
|
- Gemfile
|
136
96
|
- Gemfile.lock
|
137
97
|
- LICENSE.txt
|
138
98
|
- README.md
|
139
99
|
- Rakefile
|
100
|
+
- bin/appraisal
|
140
101
|
- bin/rake
|
141
102
|
- bin/rcov
|
142
103
|
- bin/rg
|
104
|
+
- bin/tapout
|
105
|
+
- bin/thor
|
143
106
|
- bin/turn
|
107
|
+
- gemfiles/activerecord_3.1.gemfile
|
108
|
+
- gemfiles/activerecord_3.2.gemfile
|
109
|
+
- gemfiles/activerecord_4.0.gemfile
|
110
|
+
- gemfiles/activerecord_4.1.gemfile
|
111
|
+
- gemfiles/activerecord_4.2.gemfile
|
144
112
|
- lib/wherex.rb
|
145
113
|
- lib/wherex/adapters.rb
|
146
114
|
- lib/wherex/connection.rb
|
@@ -150,48 +118,46 @@ files:
|
|
150
118
|
- test/app/models/student.rb
|
151
119
|
- test/app/models/user.rb
|
152
120
|
- test/config/database.yml
|
153
|
-
- test/db/test.sqlite3
|
154
121
|
- test/fixtures/products.yml
|
155
122
|
- test/fixtures/schema.rb
|
156
123
|
- test/fixtures/students.yml
|
157
124
|
- test/fixtures/users.yml
|
158
|
-
- test/
|
159
|
-
- test/
|
125
|
+
- test/test_helper.rb
|
126
|
+
- test/wherex_test.rb
|
160
127
|
- wherex.gemspec
|
161
128
|
homepage: http://github.com/smathy/wherex
|
162
129
|
licenses:
|
163
130
|
- MIT
|
131
|
+
metadata: {}
|
164
132
|
post_install_message:
|
165
133
|
rdoc_options: []
|
166
134
|
require_paths:
|
167
135
|
- lib
|
168
136
|
required_ruby_version: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
137
|
requirements:
|
171
|
-
- -
|
138
|
+
- - ">="
|
172
139
|
- !ruby/object:Gem::Version
|
173
140
|
version: '0'
|
174
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
-
none: false
|
176
142
|
requirements:
|
177
|
-
- -
|
143
|
+
- - ">="
|
178
144
|
- !ruby/object:Gem::Version
|
179
145
|
version: '0'
|
180
146
|
requirements: []
|
181
|
-
rubyforge_project:
|
182
|
-
rubygems_version:
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 2.2.2
|
183
149
|
signing_key:
|
184
|
-
specification_version:
|
150
|
+
specification_version: 4
|
185
151
|
summary: Regexp for ActiveRecord finders
|
186
152
|
test_files:
|
187
153
|
- test/app/models/product.rb
|
188
154
|
- test/app/models/student.rb
|
189
155
|
- test/app/models/user.rb
|
190
156
|
- test/config/database.yml
|
191
|
-
- test/db/test.sqlite3
|
192
157
|
- test/fixtures/products.yml
|
193
158
|
- test/fixtures/schema.rb
|
194
159
|
- test/fixtures/students.yml
|
195
160
|
- test/fixtures/users.yml
|
196
|
-
- test/
|
197
|
-
- test/
|
161
|
+
- test/test_helper.rb
|
162
|
+
- test/wherex_test.rb
|
163
|
+
has_rdoc:
|
data/test/db/test.sqlite3
DELETED
Binary file
|
data/test/helper.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
ENV['RAILS_DB'] = ( ENV['RAILS_DB'] || 'sqlite' ).downcase
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler'
|
5
|
-
Bundler.setup
|
6
|
-
require 'test/unit'
|
7
|
-
begin; require 'redgreen'; rescue LoadError; end
|
8
|
-
begin; require 'turn'; rescue LoadError; end
|
9
|
-
|
10
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
11
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
12
|
-
|
13
|
-
require 'wherex'
|
14
|
-
require 'active_record/fixtures'
|
15
|
-
|
16
|
-
ROOT_PATH = File.expand_path( File.join( File.dirname(__FILE__) ))
|
17
|
-
FIXTURES_PATH = File.join(File.dirname(__FILE__), 'fixtures')
|
18
|
-
|
19
|
-
config = YAML::load(ERB.new(IO.read(File.join( ROOT_PATH, 'config', 'database.yml'))).result)['test'][ENV['RAILS_DB']]
|
20
|
-
|
21
|
-
ActiveRecord::Base.establish_connection config
|
22
|
-
|
23
|
-
dep = defined?(ActiveSupport::Dependencies) ? ActiveSupport::Dependencies : ::Dependencies
|
24
|
-
dep.autoload_paths.unshift File.join( ROOT_PATH, 'app/models' )
|
25
|
-
|
26
|
-
dep.autoload_paths.unshift FIXTURES_PATH
|
27
|
-
|
28
|
-
ActiveRecord::Base.silence do
|
29
|
-
ActiveRecord::Migration.verbose = false
|
30
|
-
load File.join(FIXTURES_PATH, 'schema.rb')
|
31
|
-
end
|
32
|
-
|
33
|
-
ActiveRecord::Fixtures.create_fixtures(FIXTURES_PATH, ActiveRecord::Base.connection.tables)
|
34
|
-
|
35
|
-
class Test::Unit::TestCase
|
36
|
-
def method_missing method, *args
|
37
|
-
candidate = method.to_s.classify
|
38
|
-
begin
|
39
|
-
candidate.constantize.find( ActiveRecord::Fixtures.identify args[0] )
|
40
|
-
rescue NameError
|
41
|
-
raise NameError.new "undefined local variable or method `#{method}`"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|