uuid_it 0.1.0 → 0.1.1
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/README.md +27 -5
- data/lib/tasks/uuid_it_tasks.rake +4 -0
- data/lib/uuid_it.rb +4 -0
- data/test/test_helper.rb +2 -2
- data/test/uuid_it_test.rb +13 -0
- metadata +4 -3
data/README.md
CHANGED
@@ -2,29 +2,49 @@
|
|
2
2
|
|
3
3
|
You need to assign UUIDs to your Model? UuidIt makes it as simple as adding one line of code to the according models.
|
4
4
|
|
5
|
-
For actually generating the uuids this plugin uses spectra's ruby-uuid (http://github.com/spectra/ruby-uuid)
|
5
|
+
For actually generating the uuids this plugin uses spectra's ruby-uuid (http://github.com/spectra/ruby-uuid) which is
|
6
6
|
based on ruby-uuid (http://raa.ruby-lang.org/project/ruby-uuid/).
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
10
|
-
###
|
10
|
+
### Rails 2.3.x
|
11
|
+
|
12
|
+
#### As a plugin
|
11
13
|
|
12
14
|
script/plugin install git://github.com/aduffeck/uuid_it.git
|
13
15
|
script/generate uuid_it
|
14
16
|
rake db:migrate
|
15
17
|
|
16
|
-
|
17
|
-
gem install uuid_it
|
18
|
-
|
18
|
+
#### As a gem
|
19
19
|
Add the following line to your config/environment.rb file:
|
20
20
|
|
21
21
|
config.gem "uuid_it"
|
22
22
|
|
23
23
|
Then
|
24
24
|
|
25
|
+
gem install uuid_it
|
25
26
|
script/generate uuid_it
|
26
27
|
rake db:migrate
|
27
28
|
|
29
|
+
### Rails 3
|
30
|
+
#### As a plugin
|
31
|
+
|
32
|
+
rails plugin install git://github.com/aduffeck/uuid_it.git
|
33
|
+
rails generate uuid_it
|
34
|
+
rake db:migrate
|
35
|
+
|
36
|
+
#### As a gem
|
37
|
+
Add the following line to your Gemfile:
|
38
|
+
|
39
|
+
gem "uuid_it"
|
40
|
+
|
41
|
+
Then
|
42
|
+
|
43
|
+
bundle install
|
44
|
+
rails generate uuid_it
|
45
|
+
rake db:migrate
|
46
|
+
|
47
|
+
|
28
48
|
## Usage
|
29
49
|
|
30
50
|
class Car < ActiveRecord::Base
|
@@ -33,6 +53,8 @@ Then
|
|
33
53
|
|
34
54
|
@car.uuid # "9e5edacc-7163-11df-92bb-2d0a2c4dcb1c"
|
35
55
|
|
56
|
+
Car.find_by_uuid("9e5edacc-7163-11df-92bb-2d0a2c4dcb1c") # => @car
|
57
|
+
|
36
58
|
UUIDs will be assigned to new objects when they are created. Already existing objects will get a UUID when it is accessed
|
37
59
|
for the first time.
|
38
60
|
|
data/lib/uuid_it.rb
CHANGED
data/test/test_helper.rb
CHANGED
data/test/uuid_it_test.rb
CHANGED
@@ -7,6 +7,10 @@ end
|
|
7
7
|
class Bike < ActiveRecord::Base
|
8
8
|
end
|
9
9
|
|
10
|
+
class Scooter < ActiveRecord::Base
|
11
|
+
uuid_it
|
12
|
+
end
|
13
|
+
|
10
14
|
class UuidItTest < ActiveSupport::TestCase
|
11
15
|
test "should assing Uuids to new objects" do
|
12
16
|
c = Car.create
|
@@ -34,4 +38,13 @@ class UuidItTest < ActiveSupport::TestCase
|
|
34
38
|
assert b2.uuid_object
|
35
39
|
assert b2.uuid.present?
|
36
40
|
end
|
41
|
+
|
42
|
+
test "find_by_uuid" do
|
43
|
+
car = Car.create
|
44
|
+
scooter = Scooter.create
|
45
|
+
|
46
|
+
assert_nil Car.find_by_uuid("bla")
|
47
|
+
assert_equal car, Car.find_by_uuid(car.uuid)
|
48
|
+
assert_nil Car.find_by_uuid(scooter.uuid)
|
49
|
+
end
|
37
50
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "Andr\xC3\xA9 Duffeck"
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-07-04 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -32,6 +32,7 @@ files:
|
|
32
32
|
- lib/ruby-uuid/uuid.rb
|
33
33
|
- lib/generators/uuid_it_generator.rb
|
34
34
|
- lib/uuid_it.rb
|
35
|
+
- lib/tasks/uuid_it_tasks.rake
|
35
36
|
- README.md
|
36
37
|
- Rakefile
|
37
38
|
- rails/init.rb
|