Permalink
Browse files

Merge pull request #15 from pyromaniac/master

Full activerecord >= 3.1 compatible
  • Loading branch information...
jashmenn committed Oct 10, 2012
2 parents 70f8c4e + 1a2d684 commit 66c7bfbcc2d1235d5dc5ccd2e427c697683c91e6
Showing with 54 additions and 8 deletions.
  1. +35 −0 .travis.yml
  2. +11 −0 Gemfile
  3. +1 −1 lib/activeuuid/patches.rb
  4. +5 −2 lib/activeuuid/uuid.rb
  5. +2 −5 spec/support/database.yml
View
@@ -0,0 +1,35 @@
+before_script:
+ - mysql -e 'create database activeuuid_test;'
+ - psql -c 'create database activeuuid_test;' -U postgres
+
+rvm:
+ - 1.9.2
+ - 1.9.3
+ #- ruby-head
+ #- rbx-19mode
+
+env:
+ - RAILS_VERSION='~>3.1.0'
+ - RAILS_VERSION='~>3.1.0' DB=mysql
+ - RAILS_VERSION='~>3.1.0' DB=postgresql
+ - RAILS_VERSION='~>3.2.0'
+ - RAILS_VERSION='~>3.2.0' DB=mysql
+ - RAILS_VERSION='~>3.2.0' DB=postgresql
+ - RAILS_VERSION=3-1-stable
+ - RAILS_VERSION=3-1-stable DB=mysql
+ - RAILS_VERSION=3-1-stable DB=postgresql
+ - RAILS_VERSION=3-2-stable
+ - RAILS_VERSION=3-2-stable DB=mysql
+ - RAILS_VERSION=3-2-stable DB=postgresql
+ - RAILS_VERSION=master
+ - RAILS_VERSION=master DB=mysql
+ - RAILS_VERSION=master DB=postgresql
+
+matrix:
+ exclude:
+ - rvm: 1.9.2
+ env: RAILS_VERSION=master
+ - rvm: 1.9.2
+ env: RAILS_VERSION=master DB=mysql
+ - rvm: 1.9.2
+ env: RAILS_VERSION=master DB=postgresql
View
11 Gemfile
@@ -2,3 +2,14 @@ source "http://rubygems.org"
# Specify your gem's dependencies in activeuuid.gemspec
gemspec
+
+case version = ENV['ACTIVERECORD_VERSION'] || '~> 3.2'
+when /master/
+ gem "activerecord", :github => "rails/rails"
+when /3-1-stable/
+ gem "activerecord", :github => "rails/rails", :branch => "3-1-stable"
+when /3-2-stable/
+ gem "activerecord", :github => "rails/rails", :branch => "3-2-stable"
+else
+ gem "activerecord", version
+end
@@ -52,7 +52,7 @@ def type_cast_with_visiting(value, column = nil)
def self.apply!
ActiveRecord::ConnectionAdapters::Table.send :include, Migrations if defined? ActiveRecord::ConnectionAdapters::Table
ActiveRecord::ConnectionAdapters::TableDefinition.send :include, Migrations if defined? ActiveRecord::ConnectionAdapters::TableDefinition
- ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.send :include, Quoting if defined? ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter
+ ActiveRecord::ConnectionAdapters::Mysql2Adapter.send :include, Quoting if defined? ActiveRecord::ConnectionAdapters::Mysql2Adapter
ActiveRecord::ConnectionAdapters::SQLite3Adapter.send :include, Quoting if defined? ActiveRecord::ConnectionAdapters::SQLite3Adapter
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send :include, PostgreSQLQuoting if defined? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
end
View
@@ -1,8 +1,8 @@
require 'uuidtools'
+# monkey-patch Friendly::UUID to serialize UUIDs
module UUIDTools
class UUID
- # monkey-patch Friendly::UUID to serialize UUIDs to MySQL
alias_method :id, :raw
def quoted_id
@@ -17,6 +17,9 @@ def as_json(options = nil)
def to_param
hexdigest.upcase
end
+
+ # duck typing activerecord 3.1 dirty hack )
+ def gsub *; self; end
end
end
@@ -75,7 +78,7 @@ def dump(uuid)
private
def parse_string str
- return nil if str.blank?
+ return nil if str.length == 0
if str.length == 36
UUIDTools::UUID.parse str
elsif str.length == 32
@@ -4,12 +4,9 @@ sqlite3:
postgresql:
adapter: postgresql
username: postgres
- password:
database: activeuuid_test
- min_messages: ERROR
mysql:
adapter: mysql2
- host: localhost
username: root
- password:
- database: activeuuid_test
+ database: activeuuid_test
+ encoding: utf8

0 comments on commit 66c7bfb

Please sign in to comment.