mongoid_uuid_generator 0.0.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.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 SunshineLibrary
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,23 @@
1
+ mongoid_uuid_generator
2
+ ======================
3
+ 在Mongoid实例初始化后自动生成uuid字段。
4
+
5
+ Usage
6
+ ----------------------
7
+
8
+ 配置
9
+
10
+ ```ruby
11
+ class User
12
+ include Mongoid::UUIDGenerator
13
+ end
14
+
15
+ ```
16
+
17
+ 查询
18
+
19
+ ```text
20
+ irb(main):001:0> User.uuid User.last.uuid
21
+ => #<User _id: 528dba704f14f0bdea000001, created_at: 2013-11-21 07:46:56 UTC, updated_at: 2013-12-04 06:30:13 UTC, deleted_at: nil, uuid: "fc86e36c-347b-451d-a240-e0dce02f86cf", classroom_ids: ["0a8d020f-270d-4d3c-b02d-0e99c026935e", "f2c5d023-fe0a-4dae-be0e-7a387c99924f"], school_id: "815dd378-8967-11e2-bf8c-00163e011797", name: "沉沉才", user_type: "student", birthday: 1999-09-09 00:00:00 UTC, is_staff: false, cookie: nil>
22
+ irb(main):002:0>
23
+ ```
@@ -0,0 +1,28 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # 在Mongoid实例初始化后自动生成uuid字段。
4
+ #
5
+
6
+ require 'mongoid'
7
+ require 'uuidtools'
8
+
9
+ module ::Mongoid
10
+ module UUIDGenerator
11
+ extend ActiveSupport::Concern
12
+
13
+ included do
14
+ field :uuid, type: String
15
+ validates_presence_of :uuid
16
+ validates_uniqueness_of :uuid
17
+
18
+ after_initialize do
19
+ self.uuid ||= UUIDTools::UUID.random_create.to_s
20
+ end
21
+ end
22
+
23
+ module ClassMethods
24
+ def uuid uuid; self.find_by(uuid: uuid) end
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,17 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'mongoid_uuid_generator'
3
+ s.version = '0.0.1'
4
+ s.date = '2013-12-04'
5
+ s.summary = File.read("README.markdown").split(/===+/)[1].strip.split("\n")[0]
6
+ s.description = s.summary
7
+ s.authors = ["ukisami", "David Chen"]
8
+ s.email = 'mvjome@gmail.com'
9
+ s.homepage = 'https://github.com/SunshineLibrary/mongoid_uuid_generator'
10
+ s.license = 'MIT'
11
+
12
+ s.add_dependency "mongoid"
13
+ s.add_dependency "activesupport", "> 3.2"
14
+ s.add_dependency "uuidtools"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mongoid_uuid_generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - ukisami
9
+ - David Chen
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-12-04 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mongoid
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: activesupport
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>'
37
+ - !ruby/object:Gem::Version
38
+ version: '3.2'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>'
45
+ - !ruby/object:Gem::Version
46
+ version: '3.2'
47
+ - !ruby/object:Gem::Dependency
48
+ name: uuidtools
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ description: 在Mongoid实例初始化后自动生成uuid字段。
64
+ email: mvjome@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - LICENSE
71
+ - README.markdown
72
+ - lib/mongoid_uuid_generator.rb
73
+ - mongoid_uuid_generator.gemspec
74
+ homepage: https://github.com/SunshineLibrary/mongoid_uuid_generator
75
+ licenses:
76
+ - MIT
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 1.8.23
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: 在Mongoid实例初始化后自动生成uuid字段。
99
+ test_files: []