Permalink
Browse files

Getting there

  • Loading branch information...
1 parent 870f691 commit 4f1906b748703d3f03225ad28362fb677dacaa9d @EnriqueVidal EnriqueVidal committed with Jason King Apr 6, 2012
Showing with 50 additions and 44 deletions.
  1. +2 −20 Gemfile
  2. +25 −17 Gemfile.lock
  3. +1 −0 lib/wherex.rb
  4. +3 −3 lib/wherex/visitor.rb
  5. +2 −2 test/helper.rb
  6. +2 −2 test/test_wherex.rb
  7. +15 −0 wherex.gemspec
View
@@ -1,22 +1,4 @@
source "http://rubygems.org"
-# Add dependencies required to use your gem here.
-# Example:
-gem 'arel', '~> 2.0'
-gem 'activerecord', '~> 3.0'
-
-case ENV["RAILS_DB"]
-when "postgres"
- gem 'pg'
-when "mysql"
- gem 'mysql2', '~>0.2.11'
-else
- gem 'sqlite3'
-end
-
-group :test do
- gem 'redgreen'
- gem 'turn'
- gem "rcov", ">= 0"
- gem 'rake', '>= 0.8.3'
-end
+# Specify your gem's dependencies in activerecord_enum.gemspec
+gemspec
View
@@ -1,36 +1,44 @@
+PATH
+ remote: .
+ specs:
+ wherex (1.0.6)
+ activerecord (>= 3.0)
+ arel (>= 2.0)
+
GEM
remote: http://rubygems.org/
specs:
- activemodel (3.0.6)
- activesupport (= 3.0.6)
- builder (~> 2.1.2)
- i18n (~> 0.5.0)
- activerecord (3.0.6)
- activemodel (= 3.0.6)
- activesupport (= 3.0.6)
- arel (~> 2.0.2)
- tzinfo (~> 0.3.23)
- activesupport (3.0.6)
+ activemodel (3.2.3)
+ activesupport (= 3.2.3)
+ builder (~> 3.0.0)
+ activerecord (3.2.3)
+ activemodel (= 3.2.3)
+ activesupport (= 3.2.3)
+ arel (~> 3.0.2)
+ tzinfo (~> 0.3.29)
+ activesupport (3.2.3)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
ansi (1.2.2)
- arel (2.0.9)
- builder (2.1.2)
- i18n (0.5.0)
+ arel (3.0.2)
+ builder (3.0.0)
+ i18n (0.6.0)
+ multi_json (1.2.0)
rake (0.8.7)
rcov (0.9.9)
redgreen (1.2.2)
- sqlite3 (1.3.3)
+ sqlite3 (1.3.5)
turn (0.8.2)
ansi (>= 1.2.2)
- tzinfo (0.3.26)
+ tzinfo (0.3.32)
PLATFORMS
ruby
DEPENDENCIES
- activerecord (~> 3.0)
- arel (~> 2.0)
rake (>= 0.8.3)
rcov
redgreen
sqlite3
turn
+ wherex!
View
@@ -6,5 +6,6 @@
require 'wherex/connection'
module Wherex
::Arel::Visitors::ToSql.send :include, Visitor
+ ::Arel::Visitors::DepthFirst.send :include, Visitor
::ActiveRecord::Base.send :extend, ActiveRecord
end
@@ -11,7 +11,7 @@ def self.included base
def visit_Arel_Nodes_Equality_with_wherex o
right = o.right
if right.present? and right.is_a? Regexp
- @connection.regexp visit(o.left), visit(right)
+ ::ActiveRecord::Base.connection.regexp visit(o.left), visit(right)
else
visit_Arel_Nodes_Equality_without_wherex o
end
@@ -20,13 +20,13 @@ def visit_Arel_Nodes_Equality_with_wherex o
def visit_Arel_Nodes_NotEqual_with_wherex o
right = o.right
if right.present? and right.is_a? Regexp
- @connection.regexp_not visit(o.left), visit(right)
+ ::ActiveRecord::Base.connection.regexp_not visit(o.left), visit(right)
else
visit_Arel_Nodes_NotEqual_without_wherex o
end
end
- def visit_Regexp o; @connection.regexp_quote(o.source) end
+ def visit_Regexp o; ::ActiveRecord::Base.connection.regexp_quote(o.source) end
end
end
View
@@ -30,13 +30,13 @@
load File.join(FIXTURES_PATH, 'schema.rb')
end
-Fixtures.create_fixtures(FIXTURES_PATH, ActiveRecord::Base.connection.tables)
+ActiveRecord::Fixtures.create_fixtures(FIXTURES_PATH, ActiveRecord::Base.connection.tables)
class Test::Unit::TestCase
def method_missing method, *args
candidate = method.to_s.classify
begin
- candidate.constantize.find( Fixtures.identify args[0] )
+ candidate.constantize.find( ActiveRecord::Fixtures.identify args[0] )
rescue NameError
raise NameError.new "undefined local variable or method `#{method}`"
end
View
@@ -3,7 +3,7 @@
class TestWherex < Test::Unit::TestCase
def test_user_example
assert u = User.where( :zipcode => /^9[345][0-9]{3}$/ )
- assert_equal 3, u.count
+ assert_equal 3, u.count
[:two, :three, :four ].each do |id|
assert u.include?( users(id) )
end
@@ -21,7 +21,7 @@ def test_product_example
def test_student_example
assert s = Student.all( :conditions => { :name => /[^a-zA-Z ]/ } )
assert_equal 3, s.count
- [ :two, :three, :four ].each do |id|
+ [ :two, :three, :four ].each do |id|
assert s.include?( students(id) )
end
end
View
@@ -21,4 +21,19 @@ Gem::Specification.new do |s|
s.add_dependency 'arel', '>= 2.0'
s.add_dependency 'activerecord', '>= 3.0'
+
+ case ENV["RAILS_DB"]
+ when "postgres"
+ s.add_development_dependency 'pg'
+ when "mysql"
+ s.add_development_dependency 'mysql2'
+ else
+ s.add_development_dependency 'sqlite3'
+ end
+
+ s.add_development_dependency 'redgreen'
+ s.add_development_dependency 'turn'
+ s.add_development_dependency "rcov", ">= 0"
+ s.add_development_dependency 'rake', '>= 0.8.3'
+
end

0 comments on commit 4f1906b

Please sign in to comment.