vidibus-uuid 0.4.0 → 0.4.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/.gitignore +22 -0
- data/.travis.yml +1 -0
- data/Gemfile +3 -9
- data/README.md +50 -0
- data/Rakefile +10 -22
- data/lib/vidibus-uuid.rb +5 -2
- data/lib/vidibus/uuid.rb +0 -2
- data/lib/vidibus/uuid/validator.rb +15 -0
- data/lib/vidibus/uuid/version.rb +5 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/vidibus/uuid/mongoid_spec.rb +3 -3
- data/spec/vidibus/{validate_uuid_spec.rb → uuid/validator_spec.rb} +5 -5
- data/vidibus-uuid.gemspec +27 -72
- metadata +73 -54
- data/Gemfile.lock +0 -44
- data/README.rdoc +0 -68
- data/VERSION +0 -1
- data/lib/vidibus/validate_uuid.rb +0 -13
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
script: "bundle exec rspec spec --format progress"
|
data/Gemfile
CHANGED
@@ -1,10 +1,4 @@
|
|
1
|
-
source
|
1
|
+
source :gemcutter
|
2
2
|
|
3
|
-
gem
|
4
|
-
|
5
|
-
|
6
|
-
# Development dependencies
|
7
|
-
group :development do
|
8
|
-
gem "rspec", "~> 2.0.0"
|
9
|
-
gem "relevance-rcov"
|
10
|
-
end
|
3
|
+
# Specify your gem's dependencies in vidibus-uuid.gemspec
|
4
|
+
gemspec
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Vidibus::Uuid [](http://travis-ci.org/vidibus/vidibus-uuid) [](http://stillmaintained.com/vidibus/vidibus-uuid)
|
2
|
+
|
3
|
+
Generates and validates compact UUIDs. Basically, this is an abstraction of http://github.com/assaf/uuid
|
4
|
+
|
5
|
+
This gem is part of [Vidibus](http://vidibus.org), an open source toolset for building distributed (video) applications.
|
6
|
+
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add `gem "vidibus-uuid"` to your Gemfile. Then call `bundle install` on your console.
|
11
|
+
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
Vidibus::Uuid.generate
|
17
|
+
# => "b063263064e0012d47b658b035f038ab"
|
18
|
+
|
19
|
+
Vidibus::Uuid.validate("b063263064e0012d47b658b035f038ab")
|
20
|
+
# => true
|
21
|
+
```
|
22
|
+
|
23
|
+
### Usage in Mongoid model
|
24
|
+
|
25
|
+
Include the Vidibus::Uuid::Mongoid module in your Mongoid model:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
class MyModel
|
29
|
+
include Mongoid::Document
|
30
|
+
include Vidibus::Uuid::Mongoid
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
|
35
|
+
### Validation of custom attributes
|
36
|
+
|
37
|
+
To verfify that custom attributes are formatted as UUID, add the uuid validator to your model:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
class MyModel
|
41
|
+
include Mongoid::Document
|
42
|
+
field :product_uuid
|
43
|
+
validates :product_uuid, :uuid => {:allow_blank => true}
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
|
48
|
+
## Copyright
|
49
|
+
|
50
|
+
© 2010-2011 Andre Pankratz. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,37 +1,25 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
3
|
-
require "rake/rdoctask"
|
1
|
+
require "bundler"
|
2
|
+
require "rdoc/task"
|
4
3
|
require "rspec"
|
5
4
|
require "rspec/core/rake_task"
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
gem.summary = %Q{Provides UUID generation through UUID gem.}
|
12
|
-
gem.description = %Q{Provides UUID generation for Mongoid models. It includes a validator for UUIDs.}
|
13
|
-
gem.email = "andre@vidibus.com"
|
14
|
-
gem.homepage = "http://github.com/vidibus/vidibus-uuid"
|
15
|
-
gem.authors = ["Andre Pankratz"]
|
16
|
-
gem.add_dependency "mongoid", "~> 2.0.0.beta.20"
|
17
|
-
gem.add_dependency "uuid", "~> 2.3.1"
|
18
|
-
end
|
19
|
-
Jeweler::GemcutterTasks.new
|
20
|
-
rescue LoadError
|
21
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
22
|
-
end
|
6
|
+
Bundler::GemHelper.install_tasks
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
9
|
+
require "vidibus/uuid/version"
|
23
10
|
|
24
|
-
|
11
|
+
RSpec::Core::RakeTask.new(:rcov) do |t|
|
25
12
|
t.pattern = "spec/**/*_spec.rb"
|
26
13
|
t.rcov = true
|
27
14
|
t.rcov_opts = ["--exclude", "^spec,/gems/"]
|
28
15
|
end
|
29
16
|
|
30
17
|
Rake::RDocTask.new do |rdoc|
|
31
|
-
version = File.exist?("VERSION") ? File.read("VERSION") : ""
|
32
18
|
rdoc.rdoc_dir = "rdoc"
|
33
|
-
rdoc.title = "vidibus-
|
19
|
+
rdoc.title = "vidibus-sysinfo #{Vidibus::Uuid::VERSION}"
|
34
20
|
rdoc.rdoc_files.include("README*")
|
35
21
|
rdoc.rdoc_files.include("lib/**/*.rb")
|
36
22
|
rdoc.options << "--charset=utf-8"
|
37
23
|
end
|
24
|
+
|
25
|
+
task :default => :rcov
|
data/lib/vidibus-uuid.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
require "mongoid"
|
2
|
+
require "uuid"
|
3
|
+
|
1
4
|
require "vidibus/uuid"
|
2
|
-
require "vidibus/
|
5
|
+
require "vidibus/uuid/validator"
|
3
6
|
require "vidibus/uuid/mongoid"
|
4
7
|
|
5
8
|
if defined?(Rails)
|
@@ -8,4 +11,4 @@ if defined?(Rails)
|
|
8
11
|
end
|
9
12
|
end
|
10
13
|
|
11
|
-
ActiveModel::Validations.send(:include, Vidibus::
|
14
|
+
ActiveModel::Validations.send(:include, Vidibus::Uuid::Validator)
|
data/lib/vidibus/uuid.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Vidibus
|
2
|
+
module Uuid
|
3
|
+
module Validator
|
4
|
+
class UuidValidator < ActiveModel::EachValidator
|
5
|
+
|
6
|
+
# Ensures that every value is of a valid compact UUID format.
|
7
|
+
def validate_each(record, attribute, value)
|
8
|
+
unless Vidibus::Uuid.validate(value)
|
9
|
+
record.errors.add(attribute, :invalid_uuid)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -13,9 +13,9 @@ class Child
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "Vidibus::Uuid::Mongoid" do
|
16
|
-
let(:model) {
|
17
|
-
let(:new_model) {
|
18
|
-
let(:uuid) {
|
16
|
+
let(:model) {Model.create}
|
17
|
+
let(:new_model) {Model.new}
|
18
|
+
let(:uuid) {Vidibus::Uuid.generate}
|
19
19
|
|
20
20
|
it "should add an uuid field to model" do
|
21
21
|
model.should respond_to(:uuid)
|
@@ -4,18 +4,18 @@ class ModelWithValidations
|
|
4
4
|
include ActiveModel::Validations
|
5
5
|
attr_accessor :required_uuid, :optional_uuid
|
6
6
|
validates :required_uuid, :uuid => true
|
7
|
-
validates :optional_uuid, :uuid => {
|
7
|
+
validates :optional_uuid, :uuid => {:allow_blank => true}
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
11
|
-
let(:model) {
|
10
|
+
describe Vidibus::Uuid::Validator do
|
11
|
+
let(:model) {ModelWithValidations.new}
|
12
12
|
|
13
13
|
it "should be available as uuid validator for attribute required_uuid" do
|
14
|
-
ModelWithValidations.validators_on(:required_uuid).first.should be_a_kind_of(Vidibus::
|
14
|
+
ModelWithValidations.validators_on(:required_uuid).first.should be_a_kind_of(Vidibus::Uuid::Validator::UuidValidator)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should be available as uuid validator for attribute optional_uuid" do
|
18
|
-
ModelWithValidations.validators_on(:optional_uuid).first.should be_a_kind_of(Vidibus::
|
18
|
+
ModelWithValidations.validators_on(:optional_uuid).first.should be_a_kind_of(Vidibus::Uuid::Validator::UuidValidator)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should validate valid UUIDs" do
|
data/vidibus-uuid.gemspec
CHANGED
@@ -1,79 +1,34 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
5
2
|
|
3
|
+
lib = File.expand_path("../lib/", __FILE__)
|
4
|
+
$:.unshift lib unless $:.include?(lib)
|
5
|
+
|
6
|
+
require "vidibus/uuid/version"
|
7
|
+
|
6
8
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
+
s.name = "vidibus-uuid"
|
10
|
+
s.version = Vidibus::Uuid::VERSION
|
11
|
+
s.platform = Gem::Platform::RUBY
|
12
|
+
s.authors = "Andre Pankratz"
|
13
|
+
s.email = "andre@vidibus.com"
|
14
|
+
s.homepage = "https://github.com/vidibus/vidibus-uuid"
|
15
|
+
s.summary = "Provides UUID generation through UUID gem."
|
16
|
+
s.description = "Provides UUID generation for Mongoid models. It includes a validator for UUIDs."
|
9
17
|
|
10
|
-
s.required_rubygems_version =
|
11
|
-
s.
|
12
|
-
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".bundle/config",
|
21
|
-
".document",
|
22
|
-
".rspec",
|
23
|
-
"Gemfile",
|
24
|
-
"Gemfile.lock",
|
25
|
-
"LICENSE",
|
26
|
-
"README.rdoc",
|
27
|
-
"Rakefile",
|
28
|
-
"VERSION",
|
29
|
-
"config/locales/de.yml",
|
30
|
-
"config/locales/en.yml",
|
31
|
-
"lib/vidibus-uuid.rb",
|
32
|
-
"lib/vidibus/uuid.rb",
|
33
|
-
"lib/vidibus/uuid/mongoid.rb",
|
34
|
-
"lib/vidibus/validate_uuid.rb",
|
35
|
-
"spec/spec_helper.rb",
|
36
|
-
"spec/vidibus/uuid/mongoid_spec.rb",
|
37
|
-
"spec/vidibus/uuid_spec.rb",
|
38
|
-
"spec/vidibus/validate_uuid_spec.rb",
|
39
|
-
"vidibus-uuid.gemspec"
|
40
|
-
]
|
41
|
-
s.homepage = %q{http://github.com/vidibus/vidibus-uuid}
|
42
|
-
s.require_paths = ["lib"]
|
43
|
-
s.rubygems_version = %q{1.6.2}
|
44
|
-
s.summary = %q{Provides UUID generation through UUID gem.}
|
45
|
-
s.test_files = [
|
46
|
-
"spec/spec_helper.rb",
|
47
|
-
"spec/vidibus/uuid/mongoid_spec.rb",
|
48
|
-
"spec/vidibus/uuid_spec.rb",
|
49
|
-
"spec/vidibus/validate_uuid_spec.rb"
|
50
|
-
]
|
18
|
+
s.required_rubygems_version = ">= 1.3.6"
|
19
|
+
s.rubyforge_project = "vidibus-uuid"
|
20
|
+
|
21
|
+
s.add_dependency "mongoid", "~> 2"
|
22
|
+
s.add_dependency "uuid", "~> 2.3.1"
|
51
23
|
|
52
|
-
|
53
|
-
|
24
|
+
s.add_development_dependency "bundler", ">= 1.0.0"
|
25
|
+
s.add_development_dependency "rake"
|
26
|
+
s.add_development_dependency "rdoc"
|
27
|
+
s.add_development_dependency "rcov"
|
28
|
+
s.add_development_dependency "rspec", "~> 2"
|
29
|
+
s.add_development_dependency "rr"
|
54
30
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.0.0"])
|
59
|
-
s.add_development_dependency(%q<relevance-rcov>, [">= 0"])
|
60
|
-
s.add_runtime_dependency(%q<mongoid>, ["~> 2.0.0.beta.20"])
|
61
|
-
s.add_runtime_dependency(%q<uuid>, ["~> 2.3.1"])
|
62
|
-
else
|
63
|
-
s.add_dependency(%q<mongoid>, ["~> 2.0.0"])
|
64
|
-
s.add_dependency(%q<uuid>, ["~> 2.3.1"])
|
65
|
-
s.add_dependency(%q<rspec>, ["~> 2.0.0"])
|
66
|
-
s.add_dependency(%q<relevance-rcov>, [">= 0"])
|
67
|
-
s.add_dependency(%q<mongoid>, ["~> 2.0.0.beta.20"])
|
68
|
-
s.add_dependency(%q<uuid>, ["~> 2.3.1"])
|
69
|
-
end
|
70
|
-
else
|
71
|
-
s.add_dependency(%q<mongoid>, ["~> 2.0.0"])
|
72
|
-
s.add_dependency(%q<uuid>, ["~> 2.3.1"])
|
73
|
-
s.add_dependency(%q<rspec>, ["~> 2.0.0"])
|
74
|
-
s.add_dependency(%q<relevance-rcov>, [">= 0"])
|
75
|
-
s.add_dependency(%q<mongoid>, ["~> 2.0.0.beta.20"])
|
76
|
-
s.add_dependency(%q<uuid>, ["~> 2.3.1"])
|
77
|
-
end
|
31
|
+
s.files = `git ls-files`.split("\n")
|
32
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
33
|
+
s.require_path = 'lib'
|
78
34
|
end
|
79
|
-
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vidibus-uuid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 1
|
10
|
+
version: 0.4.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andre Pankratz
|
@@ -15,28 +15,26 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-11 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
name: mongoid
|
22
23
|
prerelease: false
|
23
|
-
type: :runtime
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 7
|
30
30
|
segments:
|
31
31
|
- 2
|
32
|
-
|
33
|
-
|
34
|
-
version: 2.0.0
|
35
|
-
name: mongoid
|
32
|
+
version: "2"
|
33
|
+
type: :runtime
|
36
34
|
version_requirements: *id001
|
37
35
|
- !ruby/object:Gem::Dependency
|
36
|
+
name: uuid
|
38
37
|
prerelease: false
|
39
|
-
type: :runtime
|
40
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
40
|
requirements:
|
@@ -48,27 +46,27 @@ dependencies:
|
|
48
46
|
- 3
|
49
47
|
- 1
|
50
48
|
version: 2.3.1
|
51
|
-
|
49
|
+
type: :runtime
|
52
50
|
version_requirements: *id002
|
53
51
|
- !ruby/object:Gem::Dependency
|
52
|
+
name: bundler
|
54
53
|
prerelease: false
|
55
|
-
type: :development
|
56
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
55
|
none: false
|
58
56
|
requirements:
|
59
|
-
- -
|
57
|
+
- - ">="
|
60
58
|
- !ruby/object:Gem::Version
|
61
|
-
hash:
|
59
|
+
hash: 23
|
62
60
|
segments:
|
63
|
-
-
|
61
|
+
- 1
|
64
62
|
- 0
|
65
63
|
- 0
|
66
|
-
version:
|
67
|
-
|
64
|
+
version: 1.0.0
|
65
|
+
type: :development
|
68
66
|
version_requirements: *id003
|
69
67
|
- !ruby/object:Gem::Dependency
|
68
|
+
name: rake
|
70
69
|
prerelease: false
|
71
|
-
type: :development
|
72
70
|
requirement: &id004 !ruby/object:Gem::Requirement
|
73
71
|
none: false
|
74
72
|
requirements:
|
@@ -78,74 +76,96 @@ dependencies:
|
|
78
76
|
segments:
|
79
77
|
- 0
|
80
78
|
version: "0"
|
81
|
-
|
79
|
+
type: :development
|
82
80
|
version_requirements: *id004
|
83
81
|
- !ruby/object:Gem::Dependency
|
82
|
+
name: rdoc
|
84
83
|
prerelease: false
|
85
|
-
type: :runtime
|
86
84
|
requirement: &id005 !ruby/object:Gem::Requirement
|
87
85
|
none: false
|
88
86
|
requirements:
|
89
|
-
- -
|
87
|
+
- - ">="
|
90
88
|
- !ruby/object:Gem::Version
|
91
|
-
hash:
|
89
|
+
hash: 3
|
92
90
|
segments:
|
93
|
-
- 2
|
94
91
|
- 0
|
95
|
-
|
96
|
-
|
97
|
-
- 20
|
98
|
-
version: 2.0.0.beta.20
|
99
|
-
name: mongoid
|
92
|
+
version: "0"
|
93
|
+
type: :development
|
100
94
|
version_requirements: *id005
|
101
95
|
- !ruby/object:Gem::Dependency
|
96
|
+
name: rcov
|
102
97
|
prerelease: false
|
103
|
-
type: :runtime
|
104
98
|
requirement: &id006 !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
version: "0"
|
107
|
+
type: :development
|
108
|
+
version_requirements: *id006
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: rspec
|
111
|
+
prerelease: false
|
112
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
105
113
|
none: false
|
106
114
|
requirements:
|
107
115
|
- - ~>
|
108
116
|
- !ruby/object:Gem::Version
|
109
|
-
hash:
|
117
|
+
hash: 7
|
110
118
|
segments:
|
111
119
|
- 2
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
120
|
+
version: "2"
|
121
|
+
type: :development
|
122
|
+
version_requirements: *id007
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: rr
|
125
|
+
prerelease: false
|
126
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
hash: 3
|
132
|
+
segments:
|
133
|
+
- 0
|
134
|
+
version: "0"
|
135
|
+
type: :development
|
136
|
+
version_requirements: *id008
|
117
137
|
description: Provides UUID generation for Mongoid models. It includes a validator for UUIDs.
|
118
138
|
email: andre@vidibus.com
|
119
139
|
executables: []
|
120
140
|
|
121
141
|
extensions: []
|
122
142
|
|
123
|
-
extra_rdoc_files:
|
124
|
-
|
125
|
-
- README.rdoc
|
143
|
+
extra_rdoc_files: []
|
144
|
+
|
126
145
|
files:
|
127
146
|
- .bundle/config
|
128
147
|
- .document
|
148
|
+
- .gitignore
|
129
149
|
- .rspec
|
150
|
+
- .travis.yml
|
130
151
|
- Gemfile
|
131
|
-
- Gemfile.lock
|
132
152
|
- LICENSE
|
133
|
-
- README.
|
153
|
+
- README.md
|
134
154
|
- Rakefile
|
135
|
-
- VERSION
|
136
155
|
- config/locales/de.yml
|
137
156
|
- config/locales/en.yml
|
138
157
|
- lib/vidibus-uuid.rb
|
139
158
|
- lib/vidibus/uuid.rb
|
140
159
|
- lib/vidibus/uuid/mongoid.rb
|
141
|
-
- lib/vidibus/
|
160
|
+
- lib/vidibus/uuid/validator.rb
|
161
|
+
- lib/vidibus/uuid/version.rb
|
142
162
|
- spec/spec_helper.rb
|
143
163
|
- spec/vidibus/uuid/mongoid_spec.rb
|
164
|
+
- spec/vidibus/uuid/validator_spec.rb
|
144
165
|
- spec/vidibus/uuid_spec.rb
|
145
|
-
- spec/vidibus/validate_uuid_spec.rb
|
146
166
|
- vidibus-uuid.gemspec
|
147
167
|
has_rdoc: true
|
148
|
-
homepage:
|
168
|
+
homepage: https://github.com/vidibus/vidibus-uuid
|
149
169
|
licenses: []
|
150
170
|
|
151
171
|
post_install_message:
|
@@ -167,19 +187,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
187
|
requirements:
|
168
188
|
- - ">="
|
169
189
|
- !ruby/object:Gem::Version
|
170
|
-
hash:
|
190
|
+
hash: 23
|
171
191
|
segments:
|
172
|
-
-
|
173
|
-
|
192
|
+
- 1
|
193
|
+
- 3
|
194
|
+
- 6
|
195
|
+
version: 1.3.6
|
174
196
|
requirements: []
|
175
197
|
|
176
|
-
rubyforge_project:
|
198
|
+
rubyforge_project: vidibus-uuid
|
177
199
|
rubygems_version: 1.6.2
|
178
200
|
signing_key:
|
179
201
|
specification_version: 3
|
180
202
|
summary: Provides UUID generation through UUID gem.
|
181
|
-
test_files:
|
182
|
-
|
183
|
-
- spec/vidibus/uuid/mongoid_spec.rb
|
184
|
-
- spec/vidibus/uuid_spec.rb
|
185
|
-
- spec/vidibus/validate_uuid_spec.rb
|
203
|
+
test_files: []
|
204
|
+
|
data/Gemfile.lock
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
activemodel (3.0.6)
|
5
|
-
activesupport (= 3.0.6)
|
6
|
-
builder (~> 2.1.2)
|
7
|
-
i18n (~> 0.5.0)
|
8
|
-
activesupport (3.0.6)
|
9
|
-
bson (1.3.0)
|
10
|
-
builder (2.1.2)
|
11
|
-
diff-lcs (1.1.2)
|
12
|
-
i18n (0.5.0)
|
13
|
-
macaddr (1.0.0)
|
14
|
-
mongo (1.3.0)
|
15
|
-
bson (>= 1.3.0)
|
16
|
-
mongoid (2.0.0)
|
17
|
-
activemodel (~> 3.0)
|
18
|
-
mongo (~> 1.2)
|
19
|
-
tzinfo (~> 0.3.22)
|
20
|
-
will_paginate (~> 3.0.pre)
|
21
|
-
relevance-rcov (0.9.2.1)
|
22
|
-
rspec (2.0.1)
|
23
|
-
rspec-core (~> 2.0.1)
|
24
|
-
rspec-expectations (~> 2.0.1)
|
25
|
-
rspec-mocks (~> 2.0.1)
|
26
|
-
rspec-core (2.0.1)
|
27
|
-
rspec-expectations (2.0.1)
|
28
|
-
diff-lcs (>= 1.1.2)
|
29
|
-
rspec-mocks (2.0.1)
|
30
|
-
rspec-core (~> 2.0.1)
|
31
|
-
rspec-expectations (~> 2.0.1)
|
32
|
-
tzinfo (0.3.26)
|
33
|
-
uuid (2.3.1)
|
34
|
-
macaddr (~> 1.0)
|
35
|
-
will_paginate (3.0.pre2)
|
36
|
-
|
37
|
-
PLATFORMS
|
38
|
-
ruby
|
39
|
-
|
40
|
-
DEPENDENCIES
|
41
|
-
mongoid (~> 2.0.0)
|
42
|
-
relevance-rcov
|
43
|
-
rspec (~> 2.0.0)
|
44
|
-
uuid (~> 2.3.1)
|
data/README.rdoc
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
= vidibus-uuid
|
2
|
-
|
3
|
-
This gem is part of the open source SOA framework Vidibus: http://www.vidibus.org
|
4
|
-
|
5
|
-
It generates and validates compact UUIDs. Basically, this is an abstraction of http://github.com/assaf/uuid
|
6
|
-
|
7
|
-
|
8
|
-
== Installation
|
9
|
-
|
10
|
-
Add the dependency to the Gemfile of your application:
|
11
|
-
|
12
|
-
gem "vidibus-uuid"
|
13
|
-
|
14
|
-
Then call bundle install on your console.
|
15
|
-
|
16
|
-
|
17
|
-
== Usage
|
18
|
-
|
19
|
-
Vidibus::Uuid.generate
|
20
|
-
# => "b063263064e0012d47b658b035f038ab"
|
21
|
-
|
22
|
-
Vidibus::Uuid.validate("b063263064e0012d47b658b035f038ab")
|
23
|
-
# => true
|
24
|
-
|
25
|
-
|
26
|
-
=== Usage in Mongoid model
|
27
|
-
|
28
|
-
Include the Vidibus::Uuid::Mongoid module in your Mongoid model:
|
29
|
-
|
30
|
-
class MyModel
|
31
|
-
include Mongoid::Document
|
32
|
-
include Vidibus::Uuid::Mongoid
|
33
|
-
end
|
34
|
-
|
35
|
-
This will extend your model as follows:
|
36
|
-
|
37
|
-
class MyModel
|
38
|
-
include Mongoid::Document
|
39
|
-
|
40
|
-
field :uuid
|
41
|
-
index :uuid, :unique => true
|
42
|
-
|
43
|
-
before_validation :generate_uuid
|
44
|
-
validates :uuid, :uniqueness => true, :uuid => true
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def generate_uuid
|
49
|
-
return unless new_record?
|
50
|
-
self.uuid ||= Vidibus::Uuid.generate
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
=== Validation of custom attributes
|
56
|
-
|
57
|
-
To verfify that custom attributes are formatted as UUID, add the uuid validator to your model:
|
58
|
-
|
59
|
-
class MyModel
|
60
|
-
include Mongoid::Document
|
61
|
-
field :product_uuid
|
62
|
-
validates :product_uuid, :uuid => { :allow_blank => true }
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
== Copyright
|
67
|
-
|
68
|
-
Copyright (c) 2010 Andre Pankratz. See LICENSE for details.
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.4.0
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Vidibus
|
2
|
-
module ValidateUuid
|
3
|
-
class UuidValidator < ActiveModel::EachValidator
|
4
|
-
|
5
|
-
# Ensures that every value is of a valid compact UUID format.
|
6
|
-
def validate_each(record, attribute, value)
|
7
|
-
unless Vidibus::Uuid.validate(value)
|
8
|
-
record.errors.add(attribute, :invalid_uuid)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|