uniq_identifier 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1b83fa51ff88933f8636a88302ae1f820d434589
4
+ data.tar.gz: d9502b8b8119eadcaed4226bb6f6c114255f4b0c
5
+ SHA512:
6
+ metadata.gz: 4302b4de5568b7009943169f9c455af6e1495335ae66cc68e0182e431f0e5e4d9ddb220f2889d111ee863b1113b4afae1da513ba2f3d0c98c4221773cbe52cac
7
+ data.tar.gz: e1b71a71532dfdc247f9752e5c1411a32f1bde1ce435ed1e6964c83359b8b514790596a1359228b68cab37cab640a763b325543e907487c523625d1fca55812c
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in uniq_identifier.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ case ENV['ADAPTER']
8
+ when nil, 'active_record'
9
+ gem 'sqlite3'
10
+ gem 'activerecord'
11
+ when 'mongoid'
12
+ gem 'mongoid'
13
+ else
14
+ raise "Unknow adatper: #{ENV['ADAPTER']}"
15
+ end
16
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Joel AZEMAR
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # UniqIdentifier
2
+
3
+ This gem add uuid on your model.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'uniq_identifier'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install uniq_identifier
20
+
21
+ ## Usage
22
+
23
+ add this on your model. For example.
24
+
25
+ for ActiveRecord
26
+
27
+ ```
28
+ class Foo < ActiveRecord::Base
29
+ uniq_identifier
30
+ end
31
+ ```
32
+
33
+ for Mongoid
34
+
35
+ ```
36
+ class Foo
37
+ include Mongoid::Document
38
+ uniq_identifier
39
+ end
40
+ ```
41
+
42
+ you have this:
43
+
44
+ ```
45
+ Foo.new.uuid # => "2d931510-d99f-494a-8c67-87feb05e1594"
46
+ ```
47
+
48
+ ## Contributing
49
+
50
+ 1. Fork it ( https://github.com/[my-github-username]/uniq_identifier/fork )
51
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
52
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
53
+ 4. Push to the branch (`git push origin my-new-feature`)
54
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,10 @@
1
+ require 'securerandom'
2
+
3
+ module UniqIdentifier
4
+ module Hook
5
+
6
+ def set_uniq_identifier
7
+ self.uuid = SecureRandom.uuid
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module UniqIdentifier
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "uniq_identifier/version"
2
+ require_relative "uniq_identifier/hook"
3
+
4
+ module UniqIdentifier
5
+
6
+ def uniq_identifier
7
+ include Hook
8
+ after_initialize :set_uniq_identifier
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ require 'uniq_identifier'
2
+ require 'bundler/setup'
3
+
4
+ ENV['ADAPTER'] ||= 'active_record'
5
+ load File.dirname(__FILE__) + "/support/adapters/#{ENV['ADAPTER']}.rb"
@@ -0,0 +1,10 @@
1
+ require 'active_record'
2
+
3
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
4
+ ActiveRecord::Base.extend UniqIdentifier
5
+
6
+ load File.dirname(__FILE__) + '/../schema.rb'
7
+
8
+ class User < ActiveRecord::Base
9
+ uniq_identifier
10
+ end
@@ -0,0 +1,17 @@
1
+ require 'mongoid'
2
+
3
+ Mongoid.load!('spec/support/adapters/mongoid.yml', :test)
4
+
5
+ ::Mongoid::Document.module_eval do
6
+ def self.included(base)
7
+ base.extend UniqIdentifier
8
+ end
9
+ end
10
+
11
+ class User
12
+ include Mongoid::Document
13
+ uniq_identifier
14
+
15
+ field :name, type: String
16
+ field :uuid, type: String
17
+ end
@@ -0,0 +1,6 @@
1
+ test:
2
+ sessions:
3
+ default:
4
+ database: whatever
5
+ hosts:
6
+ - localhost:27017
@@ -0,0 +1,7 @@
1
+ ActiveRecord::Schema.define do
2
+ self.verbose = false
3
+ create_table(:users) do |t|
4
+ t.string :name
5
+ t.string :uuid
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe UniqIdentifier do
4
+ let(:user) { User.new }
5
+
6
+ specify do
7
+ expect(user.uuid).to match(/(.*)-(.*)-(.*)-(.*)-(.*)/)
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ require_relative 'lib/uniq_identifier/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "uniq_identifier"
5
+ spec.version = UniqIdentifier::VERSION
6
+ spec.authors = ["Joel AZEMAR"]
7
+ spec.email = ["joel.azemar@gmail.com"]
8
+ spec.summary = %q{This gem add uuid on your model.}
9
+ spec.description = %q{This gem add uuid on your model. for agnostic backend}
10
+ spec.homepage = "https://github.com/FinalCAD/uniq_identifier"
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files -z`.split("\x0")
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_development_dependency "bundler", "~> 1.7"
19
+ spec.add_development_dependency "rake", "~> 10.0"
20
+ spec.add_development_dependency "rspec", "~> 3.0"
21
+
22
+ spec.required_ruby_version = '~> 2.1'
23
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: uniq_identifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Joel AZEMAR
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: This gem add uuid on your model. for agnostic backend
56
+ email:
57
+ - joel.azemar@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/uniq_identifier.rb
68
+ - lib/uniq_identifier/hook.rb
69
+ - lib/uniq_identifier/version.rb
70
+ - spec/spec_helper.rb
71
+ - spec/support/adapters/active_record.rb
72
+ - spec/support/adapters/mongoid.rb
73
+ - spec/support/adapters/mongoid.yml
74
+ - spec/support/schema.rb
75
+ - spec/uniq_identifier/uniq_identifier_spec.rb
76
+ - uniq_identifier.gemspec
77
+ homepage: https://github.com/FinalCAD/uniq_identifier
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.1'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.4.2
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: This gem add uuid on your model.
101
+ test_files:
102
+ - spec/spec_helper.rb
103
+ - spec/support/adapters/active_record.rb
104
+ - spec/support/adapters/mongoid.rb
105
+ - spec/support/adapters/mongoid.yml
106
+ - spec/support/schema.rb
107
+ - spec/uniq_identifier/uniq_identifier_spec.rb