wherex 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06f7931fb087e7901a750ae933265bcb110adeae
4
- data.tar.gz: dbd498b628d94789801361f8cc44219a2507a4cf
3
+ metadata.gz: 08b47f8bb7b2485cde76210e5d69a85928849db9
4
+ data.tar.gz: d372d37d005fab5e117cb6cf63a187944354337f
5
5
  SHA512:
6
- metadata.gz: d2f59b336978596eeec1230a6b09d58dfc784bf41238bfc94a1c4ad70805494a4a5b20e03a7c0459167cfcc09617bf8bcdaa5c7fcb618a8b04c0e0a71faf5167
7
- data.tar.gz: 33741b3669e61fa0e5e3c563d4e941688796afa923fcf38c15c9a5945fb6fc3b2f11d1876c190ff669bd2129a3c2f8d6c9a0630fe4035a4ad9d8d766a43bfe76
6
+ metadata.gz: 356bb9ba52355cb5d47f69f0c3d9364dea13b40a97adb1689ff8115cf50c2c795ed0796ff582ad4814f282626a60bf79f8f4bf8970f9bfa54abc3f18e654695b
7
+ data.tar.gz: 07f020e23f65c9c3371d79bf802e6104accaff381e0b867a00451dcfc10f91bd0c8150a72c90ae67529e677930146456e51ba95121b9d1da0596481e80c1312d
@@ -2,8 +2,8 @@ cache: bundler
2
2
  language: ruby
3
3
 
4
4
  before_script:
5
- - mysql -e 'create database wherex_test;'
6
- - psql -c 'create database wherex_test;' -U postgres
5
+ - if [[ "$DB" == "mysql" ]]; then mysql -e 'create database wherex_test;'; fi
6
+ - if [[ "$DB" == "postgres" ]]; then psql -c 'create database wherex_test;' -U postgres; fi
7
7
 
8
8
  rvm:
9
9
  - 2.0.0
@@ -11,22 +11,22 @@ rvm:
11
11
  - ruby-head
12
12
 
13
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
14
+ - gemfiles/ar_3.1.gemfile
15
+ - gemfiles/ar_3.2.gemfile
16
+ - gemfiles/ar_4.0.gemfile
17
+ - gemfiles/ar_4.1.gemfile
18
+ - gemfiles/ar_4.2.gemfile
19
19
 
20
20
  env:
21
- - RAILS_DB=sqlite
22
- - RAILS_DB=mysql
23
- - RAILS_DB=postgres
21
+ - DB=sqlite
22
+ - DB=mysql
23
+ - DB=postgres
24
24
 
25
25
  matrix:
26
26
  fast_finish: true
27
27
  allow_failures:
28
28
  - rvm: ruby-head
29
- - gemfile: gemfiles/activerecord_4.2.gemfile
29
+ - gemfile: gemfiles/ar_4.2.gemfile
30
30
 
31
31
  addons:
32
32
  code_climate:
data/Appraisals CHANGED
@@ -1,19 +1,19 @@
1
- appraise "activerecord-3.1" do
1
+ appraise "ar-3.1" do
2
2
  gem "activerecord", "~> 3.1.0"
3
3
  end
4
4
 
5
- appraise "activerecord-3.2" do
5
+ appraise "ar-3.2" do
6
6
  gem "activerecord", "~> 3.2.0"
7
7
  end
8
8
 
9
- appraise "activerecord-4.0" do
9
+ appraise "ar-4.0" do
10
10
  gem "activerecord", "~> 4.0.0"
11
11
  end
12
12
 
13
- appraise "activerecord-4.1" do
13
+ appraise "ar-4.1" do
14
14
  gem "activerecord", "~> 4.1.0"
15
15
  end
16
16
 
17
- appraise "activerecord-4.2" do
17
+ appraise "ar-4.2" do
18
18
  gem "activerecord", "~> 4.2.0.rc1"
19
19
  end
@@ -1,20 +1,20 @@
1
- Copyright (c) 2011 Jason King
1
+ The MIT License (MIT)
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
3
+ Copyright (c) 2014 Jason King
10
4
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
13
11
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -14,18 +14,22 @@ you can just use this in your `Gemfile`:
14
14
  gem 'wherex', '~> 1.0'
15
15
  ```
16
16
 
17
- ## What the?
17
+ Only works with Rails >= 3.1
18
18
 
19
- # find users in 93, 94 and 95 (5 digit) zipcodes (new style finder)
20
- User.where :zipcode => /^9[345][0-9]{3}$/
19
+ ## Examples
21
20
 
22
- # find students with invalid characters in their names (old style finder)
23
- Student.all :conditions => { :name => /[^a-zA-Z ]/ }
21
+ ```ruby
22
+ # find users in 93, 94 and 95 (5 digit) zipcodes (new style finder)
23
+ User.where :zipcode => /^9[345][0-9]{3}$/
24
+
25
+ # find students with invalid characters in their names (old style finder)
26
+ Student.all :conditions => { :name => /[^a-zA-Z ]/ }
24
27
 
25
- # find products with a complex code structure (dynamic finders)
26
- Product.find_by_code /^[NRW][^-]+-[456]/
28
+ # find products with a complex code structure (dynamic finders)
29
+ Product.find_by_code /^[NRW][^-]+-[456]/
30
+ ```
27
31
 
28
- ## Limitations?
32
+ ## Be Aware
29
33
 
30
34
  ### POSIX Only (mostly)
31
35
 
@@ -61,19 +65,21 @@ RE one actually).
61
65
 
62
66
  Here's how I'd add in Oracle support:
63
67
 
64
- # config/initializers/wherex.rb
65
- module Wherex
66
- module OracleEnhancedAdapter
67
- def regexp left, right
68
- "REGEXP_LIKE( #{left}, #{right} )"
69
- end
70
-
71
- def regexp_not left, right
72
- "NOT #{regexp left, right}"
73
- end
74
- end
68
+ ```ruby
69
+ # config/initializers/wherex.rb
70
+ module Wherex
71
+ module OracleEnhancedAdapter
72
+ def regexp left, right
73
+ "REGEXP_LIKE( #{left}, #{right} )"
75
74
  end
76
75
 
76
+ def regexp_not left, right
77
+ "NOT #{regexp left, right}"
78
+ end
79
+ end
80
+ end
81
+ ```
82
+
77
83
  That's it (and the 'NOT' is only necessary if you use meta_where or something
78
84
  that enables negative Arel statements to be generated). You just have to make
79
85
  sure it is named correctly (needs to be the same as your actual adapter, so if
@@ -85,26 +91,64 @@ Wherex will pick this module up, and add it into the right place. Just see
85
91
 
86
92
  ## Testing
87
93
 
94
+ With the latest 1.1 I have added [Appraisal](//github.com/thoughtbot/appraisal)
95
+ for testing multiple versions of ActiveRecord. Check that out for how it works, but
96
+ basically you can run tests for all supported AR versions with:
97
+
98
+ ```bash
99
+ appraisal rake
100
+ ```
101
+
102
+ or you can pick one of the names from the `Appraisals` file and run just one, eg:
103
+
104
+ ```bash
105
+ appraisal ar-4.0 rake
106
+ ```
107
+
108
+ ### Databases
109
+
88
110
  There are test suites for all three database engines that ship with Rails, the
89
111
  default is SQLite and requires no preconfiguration. So you can just clone the
90
112
  repo and run `rake` and it will run the tests against SQLite
91
113
 
92
114
  If you want to run the tests against MySQL or PostgreSQL then you will first
93
- need to create a `wherex_test` database in your local machine. Then you will
94
- need to provide the `DB` environment variable to rake, eg:
115
+ need to create a `wherex_test` database in your local machine for the given DB.
116
+ Then you will need to `bundle install` for the given DB by using the `DB`
117
+ environment variable, eg:
118
+
119
+ ```bash
120
+ DB=mysql bundle
121
+ ```
95
122
 
96
- DB=mysql rake
123
+ ...or...
97
124
 
98
- …or…
125
+ ```bash
126
+ DB=postgres bundle
127
+ ```
128
+
129
+ You do the same thing when you're running the tests, eg:
130
+
131
+ ```bash
132
+ DB=mysql rake
133
+ ```
99
134
 
100
- DB=postgres rake
135
+ ...or...
136
+
137
+ ```bash
138
+ DB=postgres rake
139
+ ```
101
140
 
102
141
  These will use a default user of `root` for MySQL and `postgres` for PostgreSQL.
103
142
  If you want to use different usernames or passwords then take a look in the
104
143
  `config/database.yml` file and either provide the appropriate environment
105
144
  variables, or edit the file itself.
106
145
 
107
- ## Copyright
146
+ You can also run an appraisal, or all appraisals through the same thing:
108
147
 
109
- Copyright © 2011 Jason King. See LICENSE.txt for further details.
148
+ ```bash
149
+ DB=mysql appraisal rake
150
+ ```
151
+
152
+ ## Copyright
110
153
 
154
+ Copyright © 2014 Jason King. See LICENSE.txt for further details.
@@ -1,3 +1,3 @@
1
1
  module Wherex
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.homepage = "http://github.com/smathy/wherex"
11
11
  s.license = "MIT"
12
12
  s.summary = %q{Regexp for ActiveRecord finders}
13
- s.description = %q{This gem allows you to pass a Regexp as the value for any finder in ActiveRecord - Rails3 only}
13
+ s.description = %q{This gem allows you to pass a Regexp as the value for any finder in ActiveRecord}
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = s.files.grep /^test/
@@ -18,9 +18,14 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_dependency 'activerecord', '>= 3.1'
20
20
 
21
- s.add_development_dependency 'pg'
22
- s.add_development_dependency 'mysql2'
23
- s.add_development_dependency 'sqlite3', ">= 1.3.7"
21
+ case ENV["DB"]
22
+ when "postgres", "postgresql", "pg"
23
+ s.add_development_dependency 'pg'
24
+ when "mysql", "mysql2"
25
+ s.add_development_dependency 'mysql2'
26
+ else
27
+ s.add_development_dependency 'sqlite3', ">= 1.3.7"
28
+ end
24
29
 
25
30
  s.add_development_dependency 'rake', '>= 1.0'
26
31
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wherex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason King
@@ -24,34 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.1'
27
- - !ruby/object:Gem::Dependency
28
- name: pg
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: mysql2
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
27
  - !ruby/object:Gem::Dependency
56
28
  name: sqlite3
57
29
  requirement: !ruby/object:Gem::Requirement
@@ -81,7 +53,6 @@ dependencies:
81
53
  - !ruby/object:Gem::Version
82
54
  version: '1.0'
83
55
  description: This gem allows you to pass a Regexp as the value for any finder in ActiveRecord
84
- - Rails3 only
85
56
  email:
86
57
  - jk@handle.it
87
58
  executables: []
@@ -104,11 +75,11 @@ files:
104
75
  - bin/tapout
105
76
  - bin/thor
106
77
  - 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
78
+ - gemfiles/ar_3.1.gemfile
79
+ - gemfiles/ar_3.2.gemfile
80
+ - gemfiles/ar_4.0.gemfile
81
+ - gemfiles/ar_4.1.gemfile
82
+ - gemfiles/ar_4.2.gemfile
112
83
  - lib/wherex.rb
113
84
  - lib/wherex/adapters.rb
114
85
  - lib/wherex/connection.rb