activerecord_uuid 0.0.1 → 0.0.2

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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 72a751aad79e2de683a3a8e18b330924f5807de2
4
+ data.tar.gz: 8eca9caa91f757de64e2ce93a20e6a6fd7263cd5
5
+ SHA512:
6
+ metadata.gz: 7dddcee48c2abdbaadeba0a35a15681eceb7f5bf646fb74757a4535bac9a3262ba7f6984688fcd38521d32015bd516f0f0e81f1591e75bb96c9ac6613fcd5252
7
+ data.tar.gz: 59a0f3d13ab874d7e3591254ee98ac346556ddcb07b3be5dcac262b3304ea10aabd65013361a87b79f249f4468409b30651cc560cb57e52cd42a7bef09965d58
data/.gitignore CHANGED
@@ -1,5 +1,5 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
5
- .idea
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .idea
@@ -0,0 +1 @@
1
+ activerecord_uuid
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0
5
+ - 2.1
6
+ - jruby
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in activerecord_uuid.gemspec
4
- gemspec
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in activerecord_uuid.gemspec
4
+ gemspec
data/README.md CHANGED
@@ -1,67 +1,70 @@
1
- # ActiveRecordUUID
2
-
3
- UUID extension for ActiveRecord
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'activerecord_uuid'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install activerecord_uuid
18
-
19
- ## Usage
20
-
21
- ### Migrations
22
-
23
- Define attribute as UUID
24
-
25
- class CreateCountries < ActiveRecord::Migration
26
- def change
27
- create_table :countries do |t|
28
- t.uuid :key
29
- end
30
- end
31
- end
32
-
33
- Define primary key as UUID
34
-
35
- class CreateLanguages < ActiveRecord::Migration
36
- def change
37
- create_table :languages do |t|
38
- t.uuid :id, primary_key: true
39
- end
40
- end
41
- end
42
-
43
- ### Models
44
-
45
- For automatic generation of UUID before creation
46
-
47
- class Country < ActiveRecord::Base
48
- attr_uuid :key
49
- end
50
-
51
- For change primary key to UUID
52
-
53
- class Language < ActiveRecord::Base
54
- pk_uuid
55
- end
56
-
57
- ### Manually creation of UUIDs
58
-
59
- ActiveRecordUUID.random
60
-
61
- ## Contributing
62
-
63
- 1. Fork it
64
- 2. Create your feature branch (`git checkout -b my-new-feature`)
65
- 3. Commit your changes (`git commit -am 'Added some feature'`)
66
- 4. Push to the branch (`git push origin my-new-feature`)
67
- 5. Create new Pull Request
1
+ # ActiveRecordUUID
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/activerecord_uuid.png)](https://rubygems.org/gems/activerecord_uuid)
4
+ [![Build Status](https://travis-ci.org/gabynaiman/activerecord_uuid.png?branch=master)](https://travis-ci.org/gabynaiman/activerecord_uuid)
5
+
6
+ UUID extension for ActiveRecord
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'activerecord_uuid'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install activerecord_uuid
21
+
22
+ ## Usage
23
+
24
+ ### Migrations
25
+
26
+ Define attribute as UUID
27
+
28
+ class CreateCountries < ActiveRecord::Migration
29
+ def change
30
+ create_table :countries do |t|
31
+ t.uuid :key
32
+ end
33
+ end
34
+ end
35
+
36
+ Define primary key as UUID
37
+
38
+ class CreateLanguages < ActiveRecord::Migration
39
+ def change
40
+ create_table :languages do |t|
41
+ t.uuid :id, primary_key: true
42
+ end
43
+ end
44
+ end
45
+
46
+ ### Models
47
+
48
+ For automatic generation of UUID before creation
49
+
50
+ class Country < ActiveRecord::Base
51
+ attr_uuid :key
52
+ end
53
+
54
+ For change primary key to UUID
55
+
56
+ class Language < ActiveRecord::Base
57
+ pk_uuid
58
+ end
59
+
60
+ ### Manually creation of UUIDs
61
+
62
+ ActiveRecordUUID.random
63
+
64
+ ## Contributing
65
+
66
+ 1. Fork it
67
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
68
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
69
+ 4. Push to the branch (`git push origin my-new-feature`)
70
+ 5. Create new Pull Request
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
- require "bundler/gem_tasks"
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec) do |task|
5
+ task.rspec_opts = '--tty --color -f documentation'
6
+ task.verbose = false
7
+ end
8
+
9
+ task default: :spec
@@ -1,24 +1,29 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "activerecord_uuid/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'activerecord_uuid'
7
- s.version = ActiveRecordUUID::VERSION
8
- s.authors = ['Gabriel Naiman']
9
- s.email = ['gabynaiman@gmail.com']
10
- s.homepage = 'https://github.com/gabynaiman/activerecord_uuid'
11
- s.summary = 'UUID extension for ActiveRecord'
12
- s.description = 'UUID extension for ActiveRecord'
13
-
14
- s.files = `git ls-files`.split("\n")
15
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
- s.require_paths = ["lib"]
18
-
19
- s.add_dependency 'rails', '>= 3.2.0'
20
- s.add_dependency 'uuidtools'
21
-
22
- s.add_development_dependency 'sqlite3'
23
- s.add_development_dependency 'rspec'
24
- end
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "activerecord_uuid/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'activerecord_uuid'
7
+ s.version = ActiveRecordUUID::VERSION
8
+ s.authors = ['Gabriel Naiman']
9
+ s.email = ['gabynaiman@gmail.com']
10
+ s.homepage = 'https://github.com/gabynaiman/activerecord_uuid'
11
+ s.summary = 'UUID extension for ActiveRecord'
12
+ s.description = 'UUID extension for ActiveRecord'
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_dependency 'activerecord', '~> 3'
20
+ s.add_dependency 'uuidtools'
21
+
22
+ if RUBY_ENGINE == 'jruby'
23
+ s.add_development_dependency 'activerecord-jdbcsqlite3-adapter'
24
+ else
25
+ s.add_development_dependency 'sqlite3'
26
+ end
27
+ s.add_development_dependency 'rspec', '~> 2.14.0'
28
+ s.add_development_dependency 'rake'
29
+ end
@@ -1,17 +1,17 @@
1
- require 'active_record'
2
- require 'uuidtools'
3
- require 'logger'
4
-
5
- require 'activerecord_uuid/version'
6
- require 'activerecord_uuid/active_record_extension'
7
-
8
- ActiveRecord::Base.send :extend, ActiveRecordUUID::ActiveRecord
9
- ActiveRecord::ConnectionAdapters::TableDefinition.send :include, ActiveRecordUUID::TableDefinition
10
-
11
- module ActiveRecordUUID
12
-
13
- def self.random
14
- UUIDTools::UUID.random_create.to_s
15
- end
16
-
17
- end
1
+ require 'active_record'
2
+ require 'uuidtools'
3
+ require 'logger'
4
+
5
+ require 'activerecord_uuid/version'
6
+ require 'activerecord_uuid/active_record_extension'
7
+
8
+ ActiveRecord::Base.send :extend, ActiveRecordUUID::ActiveRecord
9
+ ActiveRecord::ConnectionAdapters::TableDefinition.send :include, ActiveRecordUUID::TableDefinition
10
+
11
+ module ActiveRecordUUID
12
+
13
+ def self.random
14
+ UUIDTools::UUID.random_create.to_s
15
+ end
16
+
17
+ end
@@ -1,26 +1,26 @@
1
- module ActiveRecordUUID
2
-
3
- module ActiveRecord
4
- def pk_uuid
5
- self.primary_key = :id
6
- self.sequence_name = nil
7
- before_create do
8
- self.id = ActiveRecordUUID.random unless self.id
9
- end
10
- end
11
-
12
- def attr_uuid(name)
13
- before_create do
14
- self.send("#{name}=", ActiveRecordUUID.random) unless self.send("#{name}")
15
- end
16
- end
17
- end
18
-
19
- module TableDefinition
20
- def uuid(name, options={})
21
- @columns.delete @columns_hash.delete('id') if options[:primary_key]
22
- column(name, :string, limit: 36, null: options[:null] || !options[:primary_key], primary: options[:primary_key])
23
- end
24
- end
25
-
1
+ module ActiveRecordUUID
2
+
3
+ module ActiveRecord
4
+ def pk_uuid
5
+ self.primary_key = :id
6
+ self.sequence_name = nil
7
+ before_create do
8
+ self.id = ActiveRecordUUID.random unless self.id
9
+ end
10
+ end
11
+
12
+ def attr_uuid(name)
13
+ before_create do
14
+ self.send("#{name}=", ActiveRecordUUID.random) unless self.send("#{name}")
15
+ end
16
+ end
17
+ end
18
+
19
+ module TableDefinition
20
+ def uuid(name, options={})
21
+ @columns.delete @columns_hash.delete('id') if options[:primary_key]
22
+ column(name, :string, limit: 36, null: options[:null] || !options[:primary_key], primary: options[:primary_key])
23
+ end
24
+ end
25
+
26
26
  end
@@ -1,3 +1,3 @@
1
- module ActiveRecordUUID
2
- VERSION = '0.0.1'
3
- end
1
+ module ActiveRecordUUID
2
+ VERSION = '0.0.2'
3
+ end
@@ -1,48 +1,48 @@
1
- require 'spec_helper'
2
-
3
- describe 'ActiveRecord extension' do
4
-
5
- before :all do
6
- ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ":memory:"
7
- ActiveRecord::Base.connection
8
- ActiveRecord::Migrator.migrate ActiveRecord::Migrator.migrations_path
9
- end
10
-
11
- context 'Attribute uuid' do
12
-
13
- it 'Migration type' do
14
- Country.primary_key.should eq 'id'
15
- uuid_column = Country.columns_hash['key']
16
- uuid_column.type.should eq :string
17
- uuid_column.limit.should eq 36
18
- uuid_column.null.should be_true
19
- end
20
-
21
- it 'ActiveRecord generation' do
22
- model = Country.create!
23
- model.key.should be_a String
24
- model.key.size.should eq 36
25
- end
26
-
27
- end
28
-
29
- context 'Primary key uuid' do
30
-
31
- it 'Migration type' do
32
- Language.primary_key.should eq 'id'
33
- uuid_column = Language.columns_hash['id']
34
- uuid_column.type.should eq :string
35
- uuid_column.limit.should eq 36
36
- uuid_column.primary.should be_true
37
- uuid_column.null.should be_false
38
- end
39
-
40
- it 'ActiveRecord generation' do
41
- model = Language.create!
42
- model.id.should be_a String
43
- model.id.size.should eq 36
44
- end
45
-
46
- end
47
-
1
+ require 'spec_helper'
2
+
3
+ describe 'ActiveRecord extension' do
4
+
5
+ before :all do
6
+ ActiveRecord::Base.establish_connection adapter: SQLITE_ADAPTER, database: ":memory:"
7
+ ActiveRecord::Base.connection
8
+ ActiveRecord::Migrator.migrate ActiveRecord::Migrator.migrations_path
9
+ end
10
+
11
+ context 'Attribute uuid' do
12
+
13
+ it 'Migration type' do
14
+ Country.primary_key.should eq 'id'
15
+ uuid_column = Country.columns_hash['key']
16
+ uuid_column.type.should eq :string
17
+ uuid_column.limit.should eq 36
18
+ uuid_column.null.should be true
19
+ end
20
+
21
+ it 'ActiveRecord generation' do
22
+ model = Country.create!
23
+ model.key.should be_a String
24
+ model.key.size.should eq 36
25
+ end
26
+
27
+ end
28
+
29
+ context 'Primary key uuid' do
30
+
31
+ it 'Migration type' do
32
+ Language.primary_key.should eq 'id'
33
+ uuid_column = Language.columns_hash['id']
34
+ uuid_column.type.should eq :string
35
+ uuid_column.limit.should eq 36
36
+ uuid_column.primary.should be true
37
+ uuid_column.null.should be false
38
+ end
39
+
40
+ it 'ActiveRecord generation' do
41
+ model = Language.create!
42
+ model.id.should be_a String
43
+ model.id.size.should eq 36
44
+ end
45
+
46
+ end
47
+
48
48
  end
@@ -1,7 +1,7 @@
1
- class CreateCountries < ActiveRecord::Migration
2
- def change
3
- create_table :countries do |t|
4
- t.uuid :key
5
- end
6
- end
7
- end
1
+ class CreateCountries < ActiveRecord::Migration
2
+ def change
3
+ create_table :countries do |t|
4
+ t.uuid :key
5
+ end
6
+ end
7
+ end
@@ -1,7 +1,7 @@
1
- class CreateLanguages < ActiveRecord::Migration
2
- def change
3
- create_table :languages do |t|
4
- t.uuid :id, primary_key: true
5
- end
6
- end
7
- end
1
+ class CreateLanguages < ActiveRecord::Migration
2
+ def change
3
+ create_table :languages do |t|
4
+ t.uuid :id, primary_key: true
5
+ end
6
+ end
7
+ end
@@ -1,11 +1,8 @@
1
- require 'activerecord_uuid'
2
-
3
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
4
-
5
- TEMP_PATH = ENV['TMP'].gsub("\\", '/')
6
-
7
- ActiveRecord::Base.logger = Logger.new($stdout)
8
- ActiveRecord::Migrator.migrations_path = "#{File.dirname(__FILE__)}/migrations"
9
-
10
- RSpec.configure do |config|
11
- end
1
+ require 'activerecord_uuid'
2
+
3
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
4
+
5
+ ActiveRecord::Base.logger = Logger.new($stdout)
6
+ ActiveRecord::Migrator.migrations_path = "#{File.dirname(__FILE__)}/migrations"
7
+
8
+ SQLITE_ADAPTER = RUBY_ENGINE == 'jruby' ? 'jdbcsqlite3' : 'sqlite3'
@@ -1,3 +1,3 @@
1
- class Country < ActiveRecord::Base
2
- attr_uuid :key
1
+ class Country < ActiveRecord::Base
2
+ attr_uuid :key
3
3
  end
@@ -1,3 +1,3 @@
1
- class Language < ActiveRecord::Base
2
- pk_uuid
1
+ class Language < ActiveRecord::Base
2
+ pk_uuid
3
3
  end
metadata CHANGED
@@ -1,60 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord_uuid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Gabriel Naiman
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-10-10 00:00:00.000000000 Z
11
+ date: 2014-09-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: rails
16
- requirement: &2175168 !ruby/object:Gem::Requirement
17
- none: false
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 3.2.0
19
+ version: '3'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *2175168
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: uuidtools
27
- requirement: &2174436 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *2174436
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: sqlite3
38
- requirement: &2173824 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ! '>='
45
+ - - ">="
42
46
  - !ruby/object:Gem::Version
43
47
  version: '0'
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *2173824
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: rspec
49
- requirement: &2173296 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.14.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ! '>='
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.14.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
53
74
  - !ruby/object:Gem::Version
54
75
  version: '0'
55
76
  type: :development
56
77
  prerelease: false
57
- version_requirements: *2173296
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
58
83
  description: UUID extension for ActiveRecord
59
84
  email:
60
85
  - gabynaiman@gmail.com
@@ -62,7 +87,9 @@ executables: []
62
87
  extensions: []
63
88
  extra_rdoc_files: []
64
89
  files:
65
- - .gitignore
90
+ - ".gitignore"
91
+ - ".ruby-gemset"
92
+ - ".travis.yml"
66
93
  - Gemfile
67
94
  - README.md
68
95
  - Rakefile
@@ -78,26 +105,25 @@ files:
78
105
  - spec/support/models/language.rb
79
106
  homepage: https://github.com/gabynaiman/activerecord_uuid
80
107
  licenses: []
108
+ metadata: {}
81
109
  post_install_message:
82
110
  rdoc_options: []
83
111
  require_paths:
84
112
  - lib
85
113
  required_ruby_version: !ruby/object:Gem::Requirement
86
- none: false
87
114
  requirements:
88
- - - ! '>='
115
+ - - ">="
89
116
  - !ruby/object:Gem::Version
90
117
  version: '0'
91
118
  required_rubygems_version: !ruby/object:Gem::Requirement
92
- none: false
93
119
  requirements:
94
- - - ! '>='
120
+ - - ">="
95
121
  - !ruby/object:Gem::Version
96
122
  version: '0'
97
123
  requirements: []
98
124
  rubyforge_project:
99
- rubygems_version: 1.8.16
125
+ rubygems_version: 2.2.2
100
126
  signing_key:
101
- specification_version: 3
127
+ specification_version: 4
102
128
  summary: UUID extension for ActiveRecord
103
129
  test_files: []