uuidify 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.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.asc +12 -0
  3. data/LICENSE +31 -0
  4. data/README.md +25 -0
  5. data/Rakefile +44 -0
  6. data/app/models/uuidify/uuid.rb +4 -0
  7. data/db/migrate/20130612143347_create_uuidify_uuids.rb +18 -0
  8. data/lib/tasks/guidify_tasks.rake +4 -0
  9. data/lib/uuidify/engine.rb +5 -0
  10. data/lib/uuidify/uuidify_concern.rb +69 -0
  11. data/lib/uuidify/uuidify_exception.rb +2 -0
  12. data/lib/uuidify/version.rb +3 -0
  13. data/lib/uuidify.rb +22 -0
  14. data/lib/uuidify.rb~ +46 -0
  15. data/spec/dummy/README.rdoc +261 -0
  16. data/spec/dummy/Rakefile +7 -0
  17. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  18. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  19. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  20. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  21. data/spec/dummy/app/models/bar.rb +3 -0
  22. data/spec/dummy/app/models/foo.rb +3 -0
  23. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  24. data/spec/dummy/config/application.rb +69 -0
  25. data/spec/dummy/config/boot.rb +10 -0
  26. data/spec/dummy/config/database.yml +14 -0
  27. data/spec/dummy/config/database.yml.sample +14 -0
  28. data/spec/dummy/config/environment.rb +5 -0
  29. data/spec/dummy/config/environments/development.rb +37 -0
  30. data/spec/dummy/config/environments/production.rb +67 -0
  31. data/spec/dummy/config/environments/test.rb +37 -0
  32. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  33. data/spec/dummy/config/initializers/inflections.rb +15 -0
  34. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  35. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  36. data/spec/dummy/config/initializers/session_store.rb +8 -0
  37. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  38. data/spec/dummy/config/locales/en.yml +5 -0
  39. data/spec/dummy/config/routes.rb +58 -0
  40. data/spec/dummy/config.ru +4 -0
  41. data/spec/dummy/db/migrate/20130612135708_create_foos.rb +8 -0
  42. data/spec/dummy/db/migrate/20130613135222_create_bars.rb +8 -0
  43. data/spec/dummy/db/schema.rb +21 -0
  44. data/spec/dummy/db/structure.sql +35 -0
  45. data/spec/dummy/log/development.log +310 -0
  46. data/spec/dummy/log/test.log +21700 -0
  47. data/spec/dummy/public/404.html +26 -0
  48. data/spec/dummy/public/422.html +26 -0
  49. data/spec/dummy/public/500.html +25 -0
  50. data/spec/dummy/public/favicon.ico +0 -0
  51. data/spec/dummy/script/rails +6 -0
  52. data/spec/spec_helper.rb +11 -0
  53. data/spec/uuidify_spec.rb +128 -0
  54. data.tar.gz.asc +12 -0
  55. metadata +204 -0
  56. metadata.gz.asc +12 -0
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,11 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+
3
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+
7
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
8
+
9
+ RSpec.configure do |config|
10
+ config.use_transactional_fixtures = true
11
+ end
@@ -0,0 +1,128 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require 'uuidtools'
3
+
4
+ describe "uuidify" do
5
+ it "returns a uuid" do
6
+ foo = Foo.create
7
+ lambda {foo.uuid}.should_not raise_error
8
+ end
9
+
10
+ it "returns a valid uuid" do
11
+ foo = Foo.create
12
+ foo.uuid.should be_a UUIDTools::UUID
13
+ end
14
+
15
+ it "persists the uuid" do
16
+ foo = Foo.create
17
+ original_uuid = foo.uuid
18
+ foo.uuid.should == original_uuid
19
+ end
20
+
21
+ it "won't generate a uuid on an unsaved object" do
22
+ foo = Foo.new
23
+ lambda{foo.uuid}.should raise_error(Uuidify::UuidifyException)
24
+ end
25
+
26
+ it "finds model by uuid" do
27
+ foo = Foo.create
28
+ uuid = foo.uuid
29
+ new_foo = Foo.lookup_uuid(uuid)
30
+ new_foo.should == foo
31
+ end
32
+
33
+ it "doesn't find the wrong model" do
34
+ foo = Foo.create
35
+ bad_uuid = UUIDTools::UUID.timestamp_create
36
+ Uuidify::Uuid.create(:model_name => "Baz", :model_id => foo.id, :model_uuid => bad_uuid)
37
+ Foo.lookup_uuid(bad_uuid).should be_nil
38
+ end
39
+
40
+ it "destroys entry when destroying model" do
41
+ foo = Foo.create
42
+ uuid = foo.uuid
43
+ foo.destroy
44
+ Foo.lookup_uuid(uuid).should be_nil
45
+ end
46
+
47
+ it "raises error for orphan entry" do
48
+ foo = Foo.create
49
+ uuid = foo.uuid
50
+ foo.delete
51
+ lambda{Foo.lookup_uuid(uuid)}.should raise_error(ActiveRecord::RecordNotFound)
52
+ end
53
+
54
+ it "Only works when explicitly activated" do
55
+ bar = Bar.create
56
+ lambda {bar.uuid}.should raise_error
57
+ end
58
+
59
+ context "garbage collector" do
60
+ let(:foo1) { Foo.create }
61
+ let(:foo2) { Foo.create }
62
+ let(:foo3) { Foo.create }
63
+
64
+ before :each do
65
+ # force generation of uuids
66
+ foo1.uuid;foo2.uuid;foo3.uuid
67
+ end
68
+
69
+ it "should sweep up orphans" do
70
+ foo1_uuid = foo1.uuid
71
+ foo1.delete
72
+
73
+ Foo.garbage_collect_uuids
74
+ Foo.lookup_uuid(foo1_uuid).should be_nil
75
+ end
76
+
77
+ it "shouldn't sweep up non-orphans" do
78
+ foo2_uuid = foo2.uuid
79
+ foo1.delete
80
+
81
+ Foo.garbage_collect_uuids
82
+ Foo.lookup_uuid(foo2_uuid).should_not be_nil
83
+ end
84
+
85
+ it "has global gc" do
86
+ foo3_uuid = foo3.uuid
87
+ foo3.delete
88
+
89
+ Uuidify.garbage_collect_uuids
90
+
91
+ Foo.lookup_uuid(foo2.uuid).should_not be_nil
92
+ Foo.lookup_uuid(foo3_uuid).should be_nil
93
+ end
94
+
95
+ it "has global gc that handles orphaned CLASSES" do
96
+ foo1_uuid = foo1.uuid
97
+
98
+ Uuidify::Uuid.create(:model_name => "NonexistantClass", :model_id => 1, :model_uuid => UUIDTools::UUID.timestamp_create)
99
+ Uuidify.garbage_collect_uuids
100
+
101
+ Uuidify::Uuid.where(:model_name => "NonexistantClass").should be_empty
102
+ Foo.lookup_uuid(foo1_uuid).should_not be_nil
103
+ end
104
+
105
+
106
+ end
107
+
108
+ it "can force a uuid" do
109
+ new_uuid = UUIDTools::UUID.timestamp_create
110
+ foo = Foo.create
111
+ foo.uuid = new_uuid
112
+
113
+ Foo.lookup_uuid(new_uuid).should == foo
114
+ end
115
+
116
+ it "can force a new uuid over an existing one" do
117
+ foo = Foo.create
118
+ existing_uuid = foo.uuid
119
+
120
+ new_uuid = UUIDTools::UUID.timestamp_create
121
+ foo.uuid = new_uuid
122
+
123
+ Foo.lookup_uuid(new_uuid).should == foo
124
+ Foo.lookup_uuid(existing_uuid).should be_nil
125
+ end
126
+
127
+
128
+ end
data.tar.gz.asc ADDED
@@ -0,0 +1,12 @@
1
+ -----BEGIN PGP SIGNATURE-----
2
+ Version: GnuPG/MacGPG2 v2.0.19 (Darwin)
3
+ Comment: GPGTools - http://gpgtools.org
4
+
5
+ iQEcBAABCgAGBQJSYAHrAAoJEP5F5V2hilTWsNcH/jZsfLRHKJOFTffspXuh7chl
6
+ l60T4WRoDzluS+Ze/pgXSSGD7+vSfx4+oF3JLYQbaLJQkGwfpkRBHvlqPK2epjfk
7
+ nL0tb7bM43GEduJojDfEzjn0zXr2G5pyOvCnhBZbVaULncv6IGw59GSGv+5j/7qU
8
+ Gdwqa4mzOcuwc5mzfGJ6lNj2N6RveMxIy4lp0dEgp5eQejrTwvJmFubU378LwXd4
9
+ ogPbzrbmsK46kR9hY4QUEBww7sH+MCuGj3Z9GWBvvY9vAD00rRDDh7c8lOVv3/bJ
10
+ BP8MYmcd56iw4K0g81YWTm7RmAv6mj0dmUnigUPsxCRqE/4mxdJrwJqhx9LCcsQ=
11
+ =kK7N
12
+ -----END PGP SIGNATURE-----
metadata ADDED
@@ -0,0 +1,204 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: uuidify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Grant Olson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.13
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.13
27
+ - !ruby/object:Gem::Dependency
28
+ name: uuidtools
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.1.4
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 2.1.4
41
+ - !ruby/object:Gem::Dependency
42
+ name: mysql2
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.13.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.13.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: database_cleaner
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email: kgo@grant-olson.net
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files:
88
+ - README.md
89
+ files:
90
+ - app/models/uuidify/uuid.rb
91
+ - db/migrate/20130612143347_create_uuidify_uuids.rb
92
+ - lib/tasks/guidify_tasks.rake
93
+ - lib/uuidify/engine.rb
94
+ - lib/uuidify/uuidify_concern.rb
95
+ - lib/uuidify/uuidify_exception.rb
96
+ - lib/uuidify/version.rb
97
+ - lib/uuidify.rb
98
+ - lib/uuidify.rb~
99
+ - Rakefile
100
+ - LICENSE
101
+ - README.md
102
+ - spec/dummy/app/assets/javascripts/application.js
103
+ - spec/dummy/app/assets/stylesheets/application.css
104
+ - spec/dummy/app/controllers/application_controller.rb
105
+ - spec/dummy/app/helpers/application_helper.rb
106
+ - spec/dummy/app/models/bar.rb
107
+ - spec/dummy/app/models/foo.rb
108
+ - spec/dummy/app/views/layouts/application.html.erb
109
+ - spec/dummy/config/application.rb
110
+ - spec/dummy/config/boot.rb
111
+ - spec/dummy/config/database.yml
112
+ - spec/dummy/config/database.yml.sample
113
+ - spec/dummy/config/environment.rb
114
+ - spec/dummy/config/environments/development.rb
115
+ - spec/dummy/config/environments/production.rb
116
+ - spec/dummy/config/environments/test.rb
117
+ - spec/dummy/config/initializers/backtrace_silencers.rb
118
+ - spec/dummy/config/initializers/inflections.rb
119
+ - spec/dummy/config/initializers/mime_types.rb
120
+ - spec/dummy/config/initializers/secret_token.rb
121
+ - spec/dummy/config/initializers/session_store.rb
122
+ - spec/dummy/config/initializers/wrap_parameters.rb
123
+ - spec/dummy/config/locales/en.yml
124
+ - spec/dummy/config/routes.rb
125
+ - spec/dummy/config.ru
126
+ - spec/dummy/db/migrate/20130612135708_create_foos.rb
127
+ - spec/dummy/db/migrate/20130613135222_create_bars.rb
128
+ - spec/dummy/db/schema.rb
129
+ - spec/dummy/db/structure.sql
130
+ - spec/dummy/log/development.log
131
+ - spec/dummy/log/test.log
132
+ - spec/dummy/public/404.html
133
+ - spec/dummy/public/422.html
134
+ - spec/dummy/public/500.html
135
+ - spec/dummy/public/favicon.ico
136
+ - spec/dummy/Rakefile
137
+ - spec/dummy/README.rdoc
138
+ - spec/dummy/script/rails
139
+ - spec/spec_helper.rb
140
+ - spec/uuidify_spec.rb
141
+ homepage: https://github.com/grant-olson/uuidify
142
+ licenses:
143
+ - BSD 3 Clause
144
+ metadata: {}
145
+ post_install_message:
146
+ rdoc_options: []
147
+ require_paths:
148
+ - lib
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ requirements: []
160
+ rubyforge_project:
161
+ rubygems_version: 2.0.3
162
+ signing_key:
163
+ specification_version: 4
164
+ summary: Generate uuids for models
165
+ test_files:
166
+ - spec/dummy/app/assets/javascripts/application.js
167
+ - spec/dummy/app/assets/stylesheets/application.css
168
+ - spec/dummy/app/controllers/application_controller.rb
169
+ - spec/dummy/app/helpers/application_helper.rb
170
+ - spec/dummy/app/models/bar.rb
171
+ - spec/dummy/app/models/foo.rb
172
+ - spec/dummy/app/views/layouts/application.html.erb
173
+ - spec/dummy/config/application.rb
174
+ - spec/dummy/config/boot.rb
175
+ - spec/dummy/config/database.yml
176
+ - spec/dummy/config/database.yml.sample
177
+ - spec/dummy/config/environment.rb
178
+ - spec/dummy/config/environments/development.rb
179
+ - spec/dummy/config/environments/production.rb
180
+ - spec/dummy/config/environments/test.rb
181
+ - spec/dummy/config/initializers/backtrace_silencers.rb
182
+ - spec/dummy/config/initializers/inflections.rb
183
+ - spec/dummy/config/initializers/mime_types.rb
184
+ - spec/dummy/config/initializers/secret_token.rb
185
+ - spec/dummy/config/initializers/session_store.rb
186
+ - spec/dummy/config/initializers/wrap_parameters.rb
187
+ - spec/dummy/config/locales/en.yml
188
+ - spec/dummy/config/routes.rb
189
+ - spec/dummy/config.ru
190
+ - spec/dummy/db/migrate/20130612135708_create_foos.rb
191
+ - spec/dummy/db/migrate/20130613135222_create_bars.rb
192
+ - spec/dummy/db/schema.rb
193
+ - spec/dummy/db/structure.sql
194
+ - spec/dummy/log/development.log
195
+ - spec/dummy/log/test.log
196
+ - spec/dummy/public/404.html
197
+ - spec/dummy/public/422.html
198
+ - spec/dummy/public/500.html
199
+ - spec/dummy/public/favicon.ico
200
+ - spec/dummy/Rakefile
201
+ - spec/dummy/README.rdoc
202
+ - spec/dummy/script/rails
203
+ - spec/spec_helper.rb
204
+ - spec/uuidify_spec.rb
metadata.gz.asc ADDED
@@ -0,0 +1,12 @@
1
+ -----BEGIN PGP SIGNATURE-----
2
+ Version: GnuPG/MacGPG2 v2.0.19 (Darwin)
3
+ Comment: GPGTools - http://gpgtools.org
4
+
5
+ iQEcBAABCgAGBQJSYAHrAAoJEP5F5V2hilTWnukH/1eeknacJq91uaOyhvKU3HrX
6
+ D32Lf2TnkgZzxDwxYMut2Dm+arD+LeQkJl3YtN2OKWpWr/xo6Pesjw0c9lyjBtgM
7
+ CE8iFiUO9tQz3XpyIy6sZX+r2hqU78VsAHJFeDGfx6F/gmZ2bwI0l0qPfeYWEPJr
8
+ SOnJt96bC373VpOeC9CJdVTVO+K6SrPWhe+TQ0Z7VW8Vb4qR7DiHAxebfd71ys+H
9
+ IOH4D8prWysCVi2pMCZuX9XdDUaSovhBzYM05aIFQU9Ff4BwNU+kHnRzIpsJY39V
10
+ T+Faxza6nEGxHx0GEMc2RxtjPiL2hHsWJip+f0Yg+unAsTdnXbvApK8nz48xL7o=
11
+ =ZoeP
12
+ -----END PGP SIGNATURE-----