mm_uses_uuid 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module MmUsesUuid
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
data/lib/mm_uses_uuid.rb CHANGED
@@ -103,55 +103,53 @@ module MmUsesUuid
103
103
 
104
104
  end
105
105
 
106
- module InstanceMethods
106
+
107
+ def find_new_uuid(options = {})
107
108
 
108
- def find_new_uuid(options = {})
109
+ options = {force_safe: false}.merge(options)
109
110
 
110
- options = {force_safe: false}.merge(options)
111
-
112
- if not options[:ensure_unique_in]
113
- @_id, variant = make_uuid
114
- #puts "assuming #{variant} UUID #{@_id} is available"
115
- return
116
- else
117
- find_new_uuid_safely(options[:ensure_unique_in])
118
- end
119
-
111
+ if not options[:ensure_unique_in]
112
+ @_id, variant = make_uuid
113
+ #puts "assuming #{variant} UUID #{@_id} is available"
114
+ return
115
+ else
116
+ find_new_uuid_safely(options[:ensure_unique_in])
120
117
  end
121
-
122
- def find_new_uuid_safely(coll)
123
118
 
124
- @_id = nil
125
- begin
126
- trial_id, variant = make_uuid
127
- #puts "CHECKING #{coll} collection for availability of #{variant} UUID: #{trial_id}"
128
- if coll.where(:_id => trial_id).fields(:_id).first.nil?
129
- @_id = trial_id
130
- end
131
- end while @_id.nil?
119
+ end
120
+
121
+ def find_new_uuid_safely(coll)
132
122
 
133
- end
134
-
135
- def make_uuid
136
- uuid = SecureRandom.uuid.gsub!('-', '')
137
- lsn_class = UuidModel.class_variable_get('@@lsn_class')
138
- if replacement_lsn = lsn_class.index(self.class)
139
- uuid[-1] = replacement_lsn.to_s(16)
123
+ @_id = nil
124
+ begin
125
+ trial_id, variant = make_uuid
126
+ #puts "CHECKING #{coll} collection for availability of #{variant} UUID: #{trial_id}"
127
+ if coll.where(:_id => trial_id).fields(:_id).first.nil?
128
+ @_id = trial_id
140
129
  end
141
- bson_encoded_uuid = BSON::Binary.new(uuid, BSON::Binary::SUBTYPE_UUID)
142
- return bson_encoded_uuid, 'random'
143
- end
144
-
145
- def id_to_s!
146
- @_id = @_id.to_s
147
- self
148
- end
149
-
150
- def id_to_s
151
- copy = self.clone
152
- copy.instance_variable_set '@_id', @_id.to_s
153
- copy
130
+ end while @_id.nil?
131
+
132
+ end
133
+
134
+ def make_uuid
135
+ uuid = SecureRandom.uuid.gsub!('-', '')
136
+ lsn_class = UuidModel.class_variable_get('@@lsn_class')
137
+ if replacement_lsn = lsn_class.index(self.class)
138
+ uuid[-1] = replacement_lsn.to_s(16)
154
139
  end
155
-
140
+ bson_encoded_uuid = BSON::Binary.new(uuid, BSON::Binary::SUBTYPE_UUID)
141
+ return bson_encoded_uuid, 'random'
156
142
  end
143
+
144
+ def id_to_s!
145
+ @_id = @_id.to_s
146
+ self
147
+ end
148
+
149
+ def id_to_s
150
+ copy = self.clone
151
+ copy.instance_variable_set '@_id', @_id.to_s
152
+ copy
153
+ end
154
+
157
155
  end
data/mm_uses_uuid.gemspec CHANGED
@@ -16,8 +16,8 @@ Gem::Specification.new do |gem|
16
16
  gem.version = MmUsesUuid::VERSION
17
17
  gem.license = 'MIT'
18
18
 
19
- gem.add_development_dependency "rspec", "~> 2.7"
20
- gem.add_development_dependency "bson_ext", "~> 1.5.0"
21
- gem.add_dependency "mongo_mapper", "~> 0.10.1"
19
+ gem.add_development_dependency "rspec", ">= 2.7"
20
+ gem.add_development_dependency "bson_ext", ">= 1.5.0"
21
+ gem.add_dependency "mongo_mapper", ">= 0.10.1"
22
22
 
23
23
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 10
9
- version: 0.0.10
8
+ - 11
9
+ version: 0.0.11
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jonathan Chambers
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-02-27 00:00:00 +00:00
17
+ date: 2012-03-03 00:00:00 +00:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -23,7 +23,7 @@ dependencies:
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
26
- - - ~>
26
+ - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  segments:
29
29
  - 2
@@ -37,7 +37,7 @@ dependencies:
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
38
  none: false
39
39
  requirements:
40
- - - ~>
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  segments:
43
43
  - 1
@@ -52,7 +52,7 @@ dependencies:
52
52
  requirement: &id003 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
- - - ~>
55
+ - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  segments:
58
58
  - 0