activeuuid 0.6.0 → 0.6.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: 5a34ea714bbb400c87aa8d865d1f9d6b9d18721e
4
- data.tar.gz: 3571be3cd2b99c70035a061b3ba431433507ff86
3
+ metadata.gz: d15ef1e740f7978061ce1b7fb5806f0087b4232d
4
+ data.tar.gz: 3dc8b818564e59e4b9986a31091337cb87cd293e
5
5
  SHA512:
6
- metadata.gz: f5a48da1daa91b2e1f870aab9bf64d019aa058317dda0e58c5bedf9e9c05ec79314a2bdc2b3ba6027e5df0a27a826fc9e5e04fb3b93af25707f46504946519f5
7
- data.tar.gz: 0293b179642829f7633ec4d1f84de53beaaddf1b17f98e167e003b7269c9119d2c80486e1fd5dbaf689c752ac568cf1b738152d6e76b5afa8957cd346a4fce9e
6
+ metadata.gz: 822ee89119c1efdc50429b2956bfe79b5a2a2c986d69701b0b35234e66e43494a744ddd8b06f8e6163a0cb2275e8ed95139e65638f7442f78ece6a6b15850bd9
7
+ data.tar.gz: a6de0eb4b24f109b701b4dc6033889fcb4fc717753093cf2bf3f42529de4316fbf4bd0931ba4c600092954f8e5d2420a658fc118936160947d88bd0f193af606
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use 2.1.5@activeuuid --create
1
+ rvm use 2.2@activeuuid --create
@@ -8,6 +8,7 @@ rvm:
8
8
  - 2.1.5
9
9
  - 2.2.0
10
10
  - rbx-2
11
+ - jruby
11
12
 
12
13
  gemfile:
13
14
  - Gemfile
@@ -31,3 +32,16 @@ matrix:
31
32
  gemfile: gemfiles/Gemfile.rails-3-1
32
33
  - rvm: 2.2.0
33
34
  gemfile: gemfiles/Gemfile.rails-3-2
35
+ - rvm: jruby
36
+ gemfile: gemfiles/Gemfile.rails-3-1
37
+ env: DB=postgresql
38
+ - rvm: jruby
39
+ gemfile: gemfiles/Gemfile.rails-3-2
40
+ env: DB=postgresql
41
+ - rvm: jruby
42
+ gemfile: gemfiles/Gemfile.rails-4-0
43
+ env: DB=postgresql
44
+ - rvm: jruby
45
+ gemfile: gemfiles/Gemfile.rails-4-1
46
+ env: DB=postgresql
47
+
@@ -23,9 +23,16 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency "database_cleaner"
24
24
  s.add_development_dependency "forgery"
25
25
  s.add_development_dependency "fabrication"
26
- s.add_development_dependency "sqlite3"
27
- s.add_development_dependency "pg"
28
- s.add_development_dependency "mysql2"
26
+
27
+ if RUBY_ENGINE == 'jruby'
28
+ s.add_development_dependency "activerecord-jdbcsqlite3-adapter"
29
+ s.add_development_dependency "activerecord-jdbcpostgresql-adapter"
30
+ s.add_development_dependency "activerecord-jdbcmysql-adapter"
31
+ else
32
+ s.add_development_dependency "sqlite3"
33
+ s.add_development_dependency "pg"
34
+ s.add_development_dependency "mysql2"
35
+ end
29
36
 
30
37
  s.add_runtime_dependency "uuidtools"
31
38
  s.add_runtime_dependency "activerecord", '>= 3.1'
@@ -1,4 +1,4 @@
1
- require "activeuuid/version"
1
+ require 'activeuuid/version'
2
2
  require 'activeuuid/patches'
3
3
  require 'activeuuid/uuid'
4
4
  require 'activeuuid/railtie' if defined?(Rails::Railtie)
@@ -69,6 +69,32 @@ module ActiveUUID
69
69
  end
70
70
  end
71
71
 
72
+ module MysqlJdbcColumn
73
+ extend ActiveSupport::Concern
74
+
75
+ included do
76
+ # This is a really hacky solution, but it's the only way to support the
77
+ # MySql JDBC adapter without breaking backwards compatibility.
78
+ # It would be a lot easier if AR had support for custom defined types.
79
+ #
80
+ # Here's the path of execution:
81
+ # (1) JdbcColumn calls ActiveRecord::ConnectionAdapters::Column super constructor
82
+ # (2) super constructor calls simplified_type from MysqlJdbcColumn, since it's redefined here
83
+ # (3) if it's not a uuid, it calls original_simplified_type from ArJdbc::MySQL::Column module
84
+ # (4) if there's no match ArJdbc::MySQL::Column calls super (ActiveUUID::Column.simplified_type_with_uuid)
85
+ # (5) Since it's no a uuid (see step 3), simplified_type_without_uuid is called,
86
+ # which maps to AR::ConnectionAdapters::Column.simplified_type (which has no super call, so we're good)
87
+ #
88
+ alias_method :original_simplified_type, :simplified_type
89
+
90
+ def simplified_type(field_type)
91
+ return :uuid if field_type == 'binary(16)' || field_type == 'binary(16,0)'
92
+ original_simplified_type(field_type)
93
+ end
94
+ end
95
+ end
96
+
97
+
72
98
  module PostgreSQLColumn
73
99
  extend ActiveSupport::Concern
74
100
 
@@ -162,7 +188,9 @@ module ActiveUUID
162
188
  ActiveRecord::ConnectionAdapters::Column.send :include, Column
163
189
  ActiveRecord::ConnectionAdapters::PostgreSQLColumn.send :include, PostgreSQLColumn if defined? ActiveRecord::ConnectionAdapters::PostgreSQLColumn
164
190
  end
191
+ ArJdbc::MySQL::Column.send :include, MysqlJdbcColumn if defined? ArJdbc::MySQL::Column
165
192
 
193
+ ActiveRecord::ConnectionAdapters::MysqlAdapter.send :include, Quoting if defined? ActiveRecord::ConnectionAdapters::MysqlAdapter
166
194
  ActiveRecord::ConnectionAdapters::Mysql2Adapter.send :include, Quoting if defined? ActiveRecord::ConnectionAdapters::Mysql2Adapter
167
195
  ActiveRecord::ConnectionAdapters::SQLite3Adapter.send :include, Quoting if defined? ActiveRecord::ConnectionAdapters::SQLite3Adapter
168
196
  ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send :include, PostgreSQLQuoting if defined? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
@@ -8,6 +8,10 @@ module UUIDTools
8
8
  # duck typing activerecord 3.1 dirty hack )
9
9
  def gsub *; self; end
10
10
 
11
+ def ==(another_uuid)
12
+ self.to_s == another_uuid.to_s
13
+ end
14
+
11
15
  def next
12
16
  self.class.random_create
13
17
  end
@@ -18,11 +22,11 @@ module UUIDTools
18
22
  end
19
23
 
20
24
  def as_json(options = nil)
21
- hexdigest.upcase
25
+ to_s
22
26
  end
23
27
 
24
28
  def to_param
25
- hexdigest.upcase
29
+ to_s
26
30
  end
27
31
 
28
32
  def self.serialize(value)
@@ -36,6 +40,10 @@ module UUIDTools
36
40
  end
37
41
  end
38
42
 
43
+ def bytesize
44
+ 16
45
+ end
46
+
39
47
  private
40
48
 
41
49
  def self.parse_string(str)
@@ -65,6 +73,12 @@ module Arel
65
73
  end
66
74
  end
67
75
 
76
+ class WhereSql < Arel::Visitors::ToSql
77
+ def visit_UUIDTools_UUID(o)
78
+ o.quoted_id
79
+ end
80
+ end
81
+
68
82
  class SQLite < Arel::Visitors::ToSql
69
83
  def visit_UUIDTools_UUID(o, a = nil)
70
84
  o.quoted_id
@@ -1,3 +1,3 @@
1
1
  module Activeuuid
2
- VERSION = "0.6.0"
2
+ VERSION = '0.6.1'
3
3
  end
@@ -10,8 +10,8 @@ describe UUIDTools::UUID do
10
10
  let(:sql_out) { "x'e4618518cb9f11e1aa7c14dae903e06a'" }
11
11
 
12
12
  its(:quoted_id) {should == sql_out}
13
- its(:as_json) {should == hex}
14
- its(:to_param) {should == hex}
13
+ its(:as_json) {should == uuid.to_s}
14
+ its(:to_param) {should == uuid.to_s}
15
15
  its(:next) {should be_a(described_class)}
16
16
  end
17
17
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeuuid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nate Murray
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-11 00:00:00.000000000 Z
11
+ date: 2015-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -240,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
240
  version: '0'
241
241
  requirements: []
242
242
  rubyforge_project:
243
- rubygems_version: 2.4.5
243
+ rubygems_version: 2.4.5.1
244
244
  signing_key:
245
245
  specification_version: 4
246
246
  summary: Add binary UUIDs to ActiveRecord in MySQL