activeuuid 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/.rspec +3 -0
- data/.rvmrc +1 -0
- data/README.mkd +19 -3
- data/Rakefile +5 -0
- data/activeuuid.gemspec +11 -1
- data/lib/activeuuid.rb +5 -2
- data/lib/activeuuid/patches.rb +60 -0
- data/lib/activeuuid/railtie.rb +2 -10
- data/lib/activeuuid/uuid.rb +74 -31
- data/lib/activeuuid/version.rb +1 -1
- data/spec/fabricators/article_fabricator.rb +4 -0
- data/spec/fabricators/uuid_article_fabricator.rb +4 -0
- data/spec/lib/activerecord_spec.rb +63 -0
- data/spec/lib/serializer_spec.rb +76 -0
- data/spec/lib/uuid_mokeypatch_spec.rb +37 -0
- data/spec/spec_helper.rb +41 -0
- data/spec/support/database.yml +15 -0
- data/spec/support/migrate/20111117081813_create_articles.rb +10 -0
- data/spec/support/migrate/20120817081813_create_uuid_articles.rb +11 -0
- data/spec/support/models/article.rb +3 -0
- data/spec/support/models/uuid_article.rb +4 -0
- metadata +202 -7
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3@activeuuid --create
|
data/README.mkd
CHANGED
@@ -12,7 +12,7 @@ Add `binary(16)` UUIDs to ActiveRecord.
|
|
12
12
|
class CreateEmails < ActiveRecord::Migration
|
13
13
|
def self.up
|
14
14
|
create_table :emails, :id => false do |t|
|
15
|
-
t.uuid :id, :
|
15
|
+
t.uuid :id, :primary_key => true
|
16
16
|
t.uuid :sender_id # belongs_to :sender
|
17
17
|
|
18
18
|
t.string :subject
|
@@ -114,6 +114,24 @@ Add this to your `Gemfile`
|
|
114
114
|
|
115
115
|
Or get the code here: https://github.com/jashmenn/activeuuid
|
116
116
|
|
117
|
+
## Notes
|
118
|
+
|
119
|
+
### Fixtures
|
120
|
+
|
121
|
+
You can use `activeuuid` in fixtures by using the `!!binary` directive in YAML.
|
122
|
+
The trick is to base64 encode the raw bytes of the hexdigest.
|
123
|
+
|
124
|
+
```yaml
|
125
|
+
devin_ifttt_new_tweet:
|
126
|
+
id: !!binary "<%= Base64.encode64(UUIDTools::UUID.parse_hexdigest('2D79B402CBA811E1AA7C14DAE903E06A').raw) %>"
|
127
|
+
data:
|
128
|
+
user_id: 1
|
129
|
+
source_id: 1
|
130
|
+
recipe_id: 1
|
131
|
+
created_at: Mon, 09 Jul 2012 14:06:21 -0700
|
132
|
+
body: Nice blog entry!
|
133
|
+
```
|
134
|
+
|
117
135
|
## References
|
118
136
|
* [1] http://bret.appspot.com/entry/how-friendfeed-uses-mysql
|
119
137
|
* [2] http://kekoav.com/blog/36-computers/58-uuids-as-primary-keys-in-mysql.html
|
@@ -126,8 +144,6 @@ Or get the code here: https://github.com/jashmenn/activeuuid
|
|
126
144
|
Rails ~> 3.1.0 - It uses the custom column serialization Aaron
|
127
145
|
Patterson introduced in Rails 3.1.
|
128
146
|
|
129
|
-
I'm using JRuby 1.9 (1.6.3) but this should work under MRI (YMMV).
|
130
|
-
|
131
147
|
## Author
|
132
148
|
|
133
149
|
Nate Murray <nate@xcombinator.com>
|
data/Rakefile
CHANGED
data/activeuuid.gemspec
CHANGED
@@ -16,6 +16,16 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
|
-
|
19
|
+
s.add_development_dependency "rake"
|
20
|
+
s.add_development_dependency "rspec"
|
21
|
+
s.add_development_dependency "activesupport"
|
22
|
+
s.add_development_dependency "database_cleaner"
|
23
|
+
s.add_development_dependency "forgery"
|
24
|
+
s.add_development_dependency "fabrication"
|
25
|
+
s.add_development_dependency "sqlite3"
|
26
|
+
s.add_development_dependency "pg"
|
27
|
+
s.add_development_dependency "mysql2"
|
28
|
+
|
20
29
|
s.add_runtime_dependency "uuidtools"
|
30
|
+
s.add_runtime_dependency "activerecord"
|
21
31
|
end
|
data/lib/activeuuid.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require "activeuuid/version"
|
2
|
+
require 'activeuuid/patches'
|
3
|
+
require 'activeuuid/uuid'
|
4
|
+
require 'activeuuid/railtie' if defined?(Rails::Railtie)
|
2
5
|
|
3
6
|
module ActiveUUID
|
4
|
-
require 'activeuuid/railtie' if defined?(Rails::Railtie)
|
5
|
-
require 'activeuuid/uuid'
|
6
7
|
end
|
8
|
+
|
9
|
+
ActiveUUID::Patches.apply!
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module ActiveUUID
|
2
|
+
module Patches
|
3
|
+
module Migrations
|
4
|
+
def uuid(*args)
|
5
|
+
options = args.extract_options!
|
6
|
+
column_names = args
|
7
|
+
column_names.each do |name|
|
8
|
+
type = @base.adapter_name.downcase == 'postgresql' ? 'uuid' : 'binary(16)'
|
9
|
+
column(name, "#{type}#{' PRIMARY KEY' if options.delete(:primary_key)}", options)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Quoting
|
15
|
+
extend ActiveSupport::Concern
|
16
|
+
|
17
|
+
included do
|
18
|
+
def quote_with_visiting(value, column = nil)
|
19
|
+
value = ActiveUUID::UUIDSerializer.new.load(value) if column && column.sql_type == 'binary(16)'
|
20
|
+
quote_without_visiting(value, column)
|
21
|
+
end
|
22
|
+
|
23
|
+
def type_cast_with_visiting(value, column = nil)
|
24
|
+
value = ActiveUUID::UUIDSerializer.new.load(value) if column && column.sql_type == 'binary(16)'
|
25
|
+
type_cast_without_visiting(value, column)
|
26
|
+
end
|
27
|
+
|
28
|
+
alias_method_chain :quote, :visiting
|
29
|
+
alias_method_chain :type_cast, :visiting
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
module PostgreSQLQuoting
|
34
|
+
extend ActiveSupport::Concern
|
35
|
+
|
36
|
+
included do
|
37
|
+
def quote_with_visiting(value, column = nil)
|
38
|
+
value = ActiveUUID::UUIDSerializer.new.load(value).to_s if column && column.sql_type == 'uuid'
|
39
|
+
quote_without_visiting(value, column)
|
40
|
+
end
|
41
|
+
|
42
|
+
def type_cast_with_visiting(value, column = nil)
|
43
|
+
value = ActiveUUID::UUIDSerializer.new.load(value).to_s if column && column.sql_type == 'uuid'
|
44
|
+
type_cast_without_visiting(value, column)
|
45
|
+
end
|
46
|
+
|
47
|
+
alias_method_chain :quote, :visiting
|
48
|
+
alias_method_chain :type_cast, :visiting
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.apply!
|
53
|
+
ActiveRecord::ConnectionAdapters::Table.send :include, Migrations if defined? ActiveRecord::ConnectionAdapters::Table
|
54
|
+
ActiveRecord::ConnectionAdapters::TableDefinition.send :include, Migrations if defined? ActiveRecord::ConnectionAdapters::TableDefinition
|
55
|
+
ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.send :include, Quoting if defined? ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter
|
56
|
+
ActiveRecord::ConnectionAdapters::SQLite3Adapter.send :include, Quoting if defined? ActiveRecord::ConnectionAdapters::SQLite3Adapter
|
57
|
+
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send :include, PostgreSQLQuoting if defined? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/activeuuid/railtie.rb
CHANGED
@@ -4,17 +4,9 @@ require 'rails'
|
|
4
4
|
module ActiveUUID
|
5
5
|
class Railtie < Rails::Railtie
|
6
6
|
railtie_name :activeuuid
|
7
|
-
initializer "activeuuid.configure_rails_initialization" do
|
8
|
-
module ActiveRecord::ConnectionAdapters
|
9
|
-
class Table
|
10
|
-
def uuid (*args)
|
11
|
-
options = args.extract_options!
|
12
|
-
column_names = args
|
13
|
-
column_names.each { |name| column(name, 'binary(16)', options) }
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
7
|
|
8
|
+
config.to_prepare do
|
9
|
+
ActiveUUID::Patches.apply!
|
18
10
|
end
|
19
11
|
end
|
20
12
|
end
|
data/lib/activeuuid/uuid.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
require 'uuidtools'
|
2
|
+
|
1
3
|
module UUIDTools
|
2
4
|
class UUID
|
3
5
|
# monkey-patch Friendly::UUID to serialize UUIDs to MySQL
|
6
|
+
alias_method :id, :raw
|
7
|
+
|
4
8
|
def quoted_id
|
5
9
|
s = raw.unpack("H*")[0]
|
6
10
|
"x'#{s}'"
|
@@ -23,6 +27,7 @@ module Arel
|
|
23
27
|
o.quoted_id
|
24
28
|
end
|
25
29
|
end
|
30
|
+
|
26
31
|
class MySQL < Arel::Visitors::ToSql
|
27
32
|
def visit_UUIDTools_UUID(o)
|
28
33
|
o.quoted_id
|
@@ -34,6 +39,12 @@ module Arel
|
|
34
39
|
o.quoted_id
|
35
40
|
end
|
36
41
|
end
|
42
|
+
|
43
|
+
class PostgreSQL < Arel::Visitors::ToSql
|
44
|
+
def visit_UUIDTools_UUID(o)
|
45
|
+
"'#{o.to_s}'"
|
46
|
+
end
|
47
|
+
end
|
37
48
|
end
|
38
49
|
end
|
39
50
|
|
@@ -41,13 +52,37 @@ module ActiveUUID
|
|
41
52
|
class UUIDSerializer
|
42
53
|
def load(binary)
|
43
54
|
case binary
|
44
|
-
|
45
|
-
|
46
|
-
|
55
|
+
when UUIDTools::UUID
|
56
|
+
binary
|
57
|
+
when String
|
58
|
+
parse_string(binary)
|
59
|
+
else
|
60
|
+
nil
|
47
61
|
end
|
48
62
|
end
|
63
|
+
|
49
64
|
def dump(uuid)
|
50
|
-
|
65
|
+
case uuid
|
66
|
+
when UUIDTools::UUID
|
67
|
+
uuid.raw
|
68
|
+
when String
|
69
|
+
parse_string(uuid).try(:raw)
|
70
|
+
else
|
71
|
+
nil
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def parse_string str
|
78
|
+
return nil if str.blank?
|
79
|
+
if str.length == 36
|
80
|
+
UUIDTools::UUID.parse str
|
81
|
+
elsif str.length == 32
|
82
|
+
UUIDTools::UUID.parse_hexdigest str
|
83
|
+
else
|
84
|
+
UUIDTools::UUID.parse_raw str
|
85
|
+
end
|
51
86
|
end
|
52
87
|
end
|
53
88
|
|
@@ -55,28 +90,9 @@ module ActiveUUID
|
|
55
90
|
extend ActiveSupport::Concern
|
56
91
|
|
57
92
|
included do
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
serialize :id, ActiveUUID::UUIDSerializer.new
|
62
|
-
|
63
|
-
def generate_uuid_if_needed
|
64
|
-
generate_uuid unless self.id
|
65
|
-
end
|
66
|
-
|
67
|
-
def to_param
|
68
|
-
id.to_param
|
69
|
-
end
|
70
|
-
|
71
|
-
def generate_uuid
|
72
|
-
if nka = self.class.natural_key_attributes
|
73
|
-
# TODO if all the attributes return nil you might want to warn about this
|
74
|
-
chained = nka.collect{|a| self.send(a).to_s}.join("-")
|
75
|
-
self.id = UUIDTools::UUID.sha1_create(UUIDTools::UUID_OID_NAMESPACE, chained)
|
76
|
-
else
|
77
|
-
self.id = UUIDTools::UUID.timestamp_create
|
78
|
-
end
|
79
|
-
end
|
93
|
+
class_attribute :uuid_attributes, :instance_writer => true
|
94
|
+
uuids :id
|
95
|
+
before_create :generate_uuids_if_needed
|
80
96
|
end
|
81
97
|
|
82
98
|
module ClassMethods
|
@@ -88,20 +104,47 @@ module ActiveUUID
|
|
88
104
|
@_activeuuid_natural_key_attributes = attributes
|
89
105
|
end
|
90
106
|
|
107
|
+
def uuid_generator(generator_name=nil)
|
108
|
+
@_activeuuid_kind = generator_name if generator_name
|
109
|
+
@_activeuuid_kind || :random
|
110
|
+
end
|
111
|
+
|
91
112
|
def uuids(*attributes)
|
92
|
-
|
93
|
-
serialize attribute
|
113
|
+
self.uuid_attributes = attributes.collect(&:intern).each do |attribute|
|
114
|
+
serialize attribute, ActiveUUID::UUIDSerializer.new
|
115
|
+
# serializing attributes on the fly
|
116
|
+
define_method "#{attribute}=" do |value|
|
117
|
+
write_attribute attribute, serialized_attributes[attribute.to_s].load(value)
|
118
|
+
end
|
119
|
+
end
|
94
120
|
#class_eval <<-eos
|
95
121
|
# # def #{@association_name}
|
96
122
|
# # @_#{@association_name} ||= self.class.associations[:#{@association_name}].new_proxy(self)
|
97
123
|
# # end
|
98
124
|
#eos
|
99
|
-
end
|
100
125
|
end
|
101
126
|
end
|
102
127
|
|
103
|
-
|
128
|
+
def create_uuid
|
129
|
+
if nka = self.class.natural_key_attributes
|
130
|
+
# TODO if all the attributes return nil you might want to warn about this
|
131
|
+
chained = nka.collect{|a| self.send(a).to_s}.join("-")
|
132
|
+
UUIDTools::UUID.sha1_create(UUIDTools::UUID_OID_NAMESPACE, chained)
|
133
|
+
else
|
134
|
+
case self.class.uuid_generator
|
135
|
+
when :random
|
136
|
+
UUIDTools::UUID.random_create
|
137
|
+
when :time
|
138
|
+
UUIDTools::UUID.timestamp_create
|
139
|
+
end
|
140
|
+
end
|
104
141
|
end
|
105
|
-
|
142
|
+
|
143
|
+
def generate_uuids_if_needed
|
144
|
+
(uuid_attributes & [self.class.primary_key.intern]).each do |attr|
|
145
|
+
self.send("#{attr}=", create_uuid) unless self.send(attr)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
106
149
|
end
|
107
150
|
end
|
data/lib/activeuuid/version.rb
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Article do
|
4
|
+
let!(:article) { Fabricate :article }
|
5
|
+
let(:id) { article.id }
|
6
|
+
let(:model) { Article }
|
7
|
+
|
8
|
+
context 'existance' do
|
9
|
+
specify { article.id.should be_a Integer }
|
10
|
+
it "should create record" do
|
11
|
+
model.all.should == [article]
|
12
|
+
model.first.should == article
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context '.find' do
|
17
|
+
specify { model.find(id).should == article }
|
18
|
+
end
|
19
|
+
|
20
|
+
context '.where' do
|
21
|
+
specify { model.where(:id => id).first.should == article }
|
22
|
+
end
|
23
|
+
|
24
|
+
context '.destroy' do
|
25
|
+
specify { article.delete.should be_true }
|
26
|
+
specify { article.destroy.should be_true }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe UuidArticle do
|
31
|
+
let!(:article) { Fabricate :uuid_article }
|
32
|
+
let(:id) { article.id }
|
33
|
+
let(:model) { UuidArticle }
|
34
|
+
|
35
|
+
specify { model.primary_key.should == 'id' }
|
36
|
+
|
37
|
+
context 'existance' do
|
38
|
+
specify { article.id.should be_a UUIDTools::UUID }
|
39
|
+
it "should create record" do
|
40
|
+
model.all.should == [article]
|
41
|
+
model.first.should == article
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context '.find' do
|
46
|
+
specify { model.find(article).should == article }
|
47
|
+
specify { model.find(id).should == article }
|
48
|
+
specify { model.find(id.to_s).should == article }
|
49
|
+
specify { model.find(id.raw).should == article }
|
50
|
+
end
|
51
|
+
|
52
|
+
context '.where' do
|
53
|
+
specify { model.where(:id => article).first.should == article }
|
54
|
+
specify { model.where(:id => id).first.should == article }
|
55
|
+
specify { model.where(:id => id.to_s).first.should == article }
|
56
|
+
specify { model.where(:id => id.raw).first.should == article }
|
57
|
+
end
|
58
|
+
|
59
|
+
context '.destroy' do
|
60
|
+
specify { article.delete.should be_true }
|
61
|
+
specify { article.destroy.should be_true }
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveUUID::UUIDSerializer do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@input = "2d79b402-cba8-11e1-aa7c-14dae903e06a"
|
7
|
+
@hex = "2D79B402CBA811E1AA7C14DAE903E06A"
|
8
|
+
@uuid = UUIDTools::UUID.parse @input
|
9
|
+
@raw = @uuid.raw
|
10
|
+
@serializer = ActiveUUID::UUIDSerializer.new
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#load' do
|
14
|
+
it 'returns a UUID type verbatim' do
|
15
|
+
@serializer.load(@uuid).should eql(@uuid)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'loads a given uuid' do
|
19
|
+
it 'handles uuid string' do
|
20
|
+
@serializer.load(@input).should eql(@uuid)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'handles uuid hexdigest string' do
|
24
|
+
@serializer.load(@hex).should eql(@uuid)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'handles raw uuid data' do
|
28
|
+
@serializer.load(@raw).should eql(@uuid)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'returns nil for nil' do
|
33
|
+
@serializer.load(nil).should be_nil
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'returns nil for ""' do
|
37
|
+
@serializer.load('').should be_nil
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'returns nil for other types' do
|
41
|
+
@serializer.load(5).should be_nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#dump' do
|
46
|
+
it 'returns the raw value of a passed uuid' do
|
47
|
+
@serializer.dump(@uuid).should eql(@raw)
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'loads a given uuid' do
|
51
|
+
it 'handles uuid string' do
|
52
|
+
@serializer.dump(@input).should eql(@raw)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'handles uuid hexdigest string' do
|
56
|
+
@serializer.dump(@hex).should eql(@raw)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'handles raw uuid data' do
|
60
|
+
@serializer.dump(@raw).should eql(@raw)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'returns nil for nil' do
|
65
|
+
@serializer.dump(nil).should be_nil
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'returns nil for ""' do
|
69
|
+
@serializer.dump('').should be_nil
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'returns nil for other types' do
|
73
|
+
@serializer.dump(5).should be_nil
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe UUIDTools::UUID do
|
4
|
+
|
5
|
+
before do
|
6
|
+
input = "e4618518-cb9f-11e1-aa7c-14dae903e06a"
|
7
|
+
@sql_out = "x'e4618518cb9f11e1aa7c14dae903e06a'"
|
8
|
+
@param_out = "E4618518CB9F11E1AA7C14DAE903E06A"
|
9
|
+
|
10
|
+
@uuid = UUIDTools::UUID.parse input
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'adds methods to the UUID class' do
|
14
|
+
[:quoted_id, :as_json, :to_param].each do |meth|
|
15
|
+
@uuid.should respond_to(meth)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#quoted_id' do
|
20
|
+
it 'returns the SQL binary representation for the uuid' do
|
21
|
+
@uuid.quoted_id.should eql(@sql_out)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#as_json' do
|
26
|
+
it 'returns the uppercase hexdigest' do
|
27
|
+
@uuid.as_json.should eql(@param_out)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#to_param' do
|
32
|
+
it 'also returns the uppercase hexdigest' do
|
33
|
+
@uuid.to_param.should eql(@param_out)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
Bundler.require :development
|
5
|
+
|
6
|
+
require 'active_record'
|
7
|
+
require 'active_support/all'
|
8
|
+
|
9
|
+
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
|
10
|
+
ActiveRecord::Base.configurations = YAML::load(File.read(File.dirname(__FILE__) + "/support/database.yml"))
|
11
|
+
ActiveRecord::Base.establish_connection(ENV["DB"] || "sqlite3")
|
12
|
+
|
13
|
+
require 'activeuuid'
|
14
|
+
|
15
|
+
ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + "/support/migrate")
|
16
|
+
|
17
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
18
|
+
Dir["#{File.dirname(__FILE__)}/fabricators/**/*.rb"].each { |f| require f }
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
# Remove this line if you don't want RSpec's should and should_not
|
22
|
+
# methods or matchers
|
23
|
+
require 'rspec/expectations'
|
24
|
+
config.include RSpec::Matchers
|
25
|
+
|
26
|
+
# == Mock Framework
|
27
|
+
config.mock_with :rspec
|
28
|
+
|
29
|
+
config.before(:suite) do
|
30
|
+
DatabaseCleaner.clean_with(:truncation)
|
31
|
+
DatabaseCleaner.strategy = :transaction
|
32
|
+
end
|
33
|
+
|
34
|
+
config.before(:each) do
|
35
|
+
DatabaseCleaner.start
|
36
|
+
end
|
37
|
+
|
38
|
+
config.after(:each) do
|
39
|
+
DatabaseCleaner.clean
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
sqlite3:
|
2
|
+
adapter: sqlite3
|
3
|
+
database: ":memory:"
|
4
|
+
postgresql:
|
5
|
+
adapter: postgresql
|
6
|
+
username: postgres
|
7
|
+
password:
|
8
|
+
database: activeuuid_test
|
9
|
+
min_messages: ERROR
|
10
|
+
mysql:
|
11
|
+
adapter: mysql2
|
12
|
+
host: localhost
|
13
|
+
username: root
|
14
|
+
password:
|
15
|
+
database: activeuuid_test
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeuuid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,155 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05
|
12
|
+
date: 2012-10-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: activesupport
|
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
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: database_cleaner
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: forgery
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: fabrication
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: sqlite3
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: pg
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: mysql2
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
14
158
|
- !ruby/object:Gem::Dependency
|
15
159
|
name: uuidtools
|
16
|
-
requirement:
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
17
161
|
none: false
|
18
162
|
requirements:
|
19
163
|
- - ! '>='
|
@@ -21,7 +165,28 @@ dependencies:
|
|
21
165
|
version: '0'
|
22
166
|
type: :runtime
|
23
167
|
prerelease: false
|
24
|
-
version_requirements:
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: activerecord
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
none: false
|
178
|
+
requirements:
|
179
|
+
- - ! '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
type: :runtime
|
183
|
+
prerelease: false
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
25
190
|
description: Add binary (not string) UUIDs to ActiveRecord in MySQL
|
26
191
|
email:
|
27
192
|
- nate@natemurray.com
|
@@ -30,14 +195,28 @@ extensions: []
|
|
30
195
|
extra_rdoc_files: []
|
31
196
|
files:
|
32
197
|
- .gitignore
|
198
|
+
- .rspec
|
199
|
+
- .rvmrc
|
33
200
|
- Gemfile
|
34
201
|
- README.mkd
|
35
202
|
- Rakefile
|
36
203
|
- activeuuid.gemspec
|
37
204
|
- lib/activeuuid.rb
|
205
|
+
- lib/activeuuid/patches.rb
|
38
206
|
- lib/activeuuid/railtie.rb
|
39
207
|
- lib/activeuuid/uuid.rb
|
40
208
|
- lib/activeuuid/version.rb
|
209
|
+
- spec/fabricators/article_fabricator.rb
|
210
|
+
- spec/fabricators/uuid_article_fabricator.rb
|
211
|
+
- spec/lib/activerecord_spec.rb
|
212
|
+
- spec/lib/serializer_spec.rb
|
213
|
+
- spec/lib/uuid_mokeypatch_spec.rb
|
214
|
+
- spec/spec_helper.rb
|
215
|
+
- spec/support/database.yml
|
216
|
+
- spec/support/migrate/20111117081813_create_articles.rb
|
217
|
+
- spec/support/migrate/20120817081813_create_uuid_articles.rb
|
218
|
+
- spec/support/models/article.rb
|
219
|
+
- spec/support/models/uuid_article.rb
|
41
220
|
homepage: http://www.eigenjoy.com
|
42
221
|
licenses: []
|
43
222
|
post_install_message:
|
@@ -50,17 +229,33 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
229
|
- - ! '>='
|
51
230
|
- !ruby/object:Gem::Version
|
52
231
|
version: '0'
|
232
|
+
segments:
|
233
|
+
- 0
|
234
|
+
hash: -2357852166137688430
|
53
235
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
236
|
none: false
|
55
237
|
requirements:
|
56
238
|
- - ! '>='
|
57
239
|
- !ruby/object:Gem::Version
|
58
240
|
version: '0'
|
241
|
+
segments:
|
242
|
+
- 0
|
243
|
+
hash: -2357852166137688430
|
59
244
|
requirements: []
|
60
245
|
rubyforge_project:
|
61
|
-
rubygems_version: 1.8.
|
246
|
+
rubygems_version: 1.8.24
|
62
247
|
signing_key:
|
63
248
|
specification_version: 3
|
64
249
|
summary: Add binary UUIDs to ActiveRecord in MySQL
|
65
|
-
test_files:
|
66
|
-
|
250
|
+
test_files:
|
251
|
+
- spec/fabricators/article_fabricator.rb
|
252
|
+
- spec/fabricators/uuid_article_fabricator.rb
|
253
|
+
- spec/lib/activerecord_spec.rb
|
254
|
+
- spec/lib/serializer_spec.rb
|
255
|
+
- spec/lib/uuid_mokeypatch_spec.rb
|
256
|
+
- spec/spec_helper.rb
|
257
|
+
- spec/support/database.yml
|
258
|
+
- spec/support/migrate/20111117081813_create_articles.rb
|
259
|
+
- spec/support/migrate/20120817081813_create_uuid_articles.rb
|
260
|
+
- spec/support/models/article.rb
|
261
|
+
- spec/support/models/uuid_article.rb
|