fast_attributes-uuid 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/fast_attributes-uuid.gemspec +29 -0
- data/lib/fast_attributes/uuid/version.rb +5 -0
- data/lib/fast_attributes/uuid.rb +19 -0
- data/spec/fast_attributes/uuid_spec.rb +46 -0
- data/spec/fixtures/classes.rb +6 -0
- data/spec/spec_helper.rb +2 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 52ef359e8d52780ab0a5f1563286fdb831d0765d
|
4
|
+
data.tar.gz: 9eaf0c45397a125712300ddc374e41031a0f352f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b0239946fd85ae7bf28b0e18c8fa3a24429dafe746326caffeb10187255705131e9bafe46839072906b26d9de97c00a8de468f24cba52eadc97beeb9f394663f
|
7
|
+
data.tar.gz: 77477b53778c5b2e368a638e67309a5a8cad0ad744ec41affb27dc23642fefc2eae0904b97539ad56b6be9862304e8643f65bf25eb9f5932d74bbfc94d37ab4e
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Kostyantyn
|
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,29 @@
|
|
1
|
+
# FastAttributes::UUID
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'fast_attributes-uuid'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install fast_attributes-uuid
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/fast_attributes-uuid/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fast_attributes/uuid/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'fast_attributes-uuid'
|
8
|
+
spec.version = FastAttributes::UUID::VERSION
|
9
|
+
spec.authors = ['Kostiantyn Stepaniuk']
|
10
|
+
spec.email = ['ks@applift.com']
|
11
|
+
spec.summary = 'Add UUID type to fast_attributes'
|
12
|
+
spec.description = 'Add UUID type to fast_attributes'
|
13
|
+
spec.homepage = 'https://github.com/applift/fast_attributes-uuid'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.required_ruby_version = '>= 1.9.2'
|
22
|
+
|
23
|
+
spec.add_runtime_dependency 'fast_attributes', '~> 0.2.1'
|
24
|
+
spec.add_runtime_dependency 'uuidtools', '~> 2.1.4'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
27
|
+
spec.add_development_dependency 'rake'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0.0'
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'fast_attributes'
|
2
|
+
require 'uuidtools'
|
3
|
+
|
4
|
+
module FastAttributes
|
5
|
+
module UUID
|
6
|
+
end
|
7
|
+
|
8
|
+
set_type_casting UUIDTools::UUID, <<-EOS.gsub(/^\s*/, '')
|
9
|
+
_value = %s
|
10
|
+
case value.length
|
11
|
+
when 36 then UUIDTools::UUID.parse(_value)
|
12
|
+
when 32 then UUIDTools::UUID.parse_hexdigest(_value)
|
13
|
+
when 0 then nil
|
14
|
+
else UUIDTools::UUID.parse_raw(_value)
|
15
|
+
end
|
16
|
+
EOS
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'fast_attributes/uuid/version'
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FastAttributes::UUID do
|
4
|
+
it 'adds UUID type to supported list' do
|
5
|
+
expect(FastAttributes.type_casting).to eq({
|
6
|
+
String => 'String(%s)',
|
7
|
+
Integer => 'Integer(%s)',
|
8
|
+
Array => 'Array(%s)',
|
9
|
+
Date => 'Date.parse(%s)',
|
10
|
+
Time => 'Time.parse(%s)',
|
11
|
+
DateTime => 'DateTime.parse(%s)',
|
12
|
+
UUIDTools::UUID => <<-EOS.gsub(/^\s*/, '')
|
13
|
+
_value = %s
|
14
|
+
case value.length
|
15
|
+
when 36 then UUIDTools::UUID.parse(_value)
|
16
|
+
when 32 then UUIDTools::UUID.parse_hexdigest(_value)
|
17
|
+
when 0 then nil
|
18
|
+
else UUIDTools::UUID.parse_raw(_value)
|
19
|
+
end
|
20
|
+
EOS
|
21
|
+
})
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'attribute parses UUID value' do
|
25
|
+
log = Log.new
|
26
|
+
log.request_id = 'd2b4b3e3-4f16-4aa8-bc43-cab90d008171'
|
27
|
+
expect(log.request_id).to be_a(UUIDTools::UUID)
|
28
|
+
expect(log.request_id.to_s).to eq('d2b4b3e3-4f16-4aa8-bc43-cab90d008171')
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'attribute parses serialized UUID value' do
|
32
|
+
log = Log.new
|
33
|
+
log.request_id = 'D2B4B3E34F164AA8BC43CAB90D008171'
|
34
|
+
expect(log.request_id).to be_a(UUIDTools::UUID)
|
35
|
+
expect(log.request_id.to_s).to eq('d2b4b3e3-4f16-4aa8-bc43-cab90d008171')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'attribute parses raw UUID value' do
|
39
|
+
uuid = UUIDTools::UUID.parse('d2b4b3e3-4f16-4aa8-bc43-cab90d008171')
|
40
|
+
|
41
|
+
log = Log.new
|
42
|
+
log.request_id = uuid.raw
|
43
|
+
expect(log.request_id).to be_a(UUIDTools::UUID)
|
44
|
+
expect(log.request_id.to_s).to eq('d2b4b3e3-4f16-4aa8-bc43-cab90d008171')
|
45
|
+
end
|
46
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fast_attributes-uuid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kostiantyn Stepaniuk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fast_attributes
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.1
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.0.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.0.0
|
83
|
+
description: Add UUID type to fast_attributes
|
84
|
+
email:
|
85
|
+
- ks@applift.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- fast_attributes-uuid.gemspec
|
97
|
+
- lib/fast_attributes/uuid.rb
|
98
|
+
- lib/fast_attributes/uuid/version.rb
|
99
|
+
- spec/fast_attributes/uuid_spec.rb
|
100
|
+
- spec/fixtures/classes.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
homepage: https://github.com/applift/fast_attributes-uuid
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 1.9.2
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.2.2
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: Add UUID type to fast_attributes
|
126
|
+
test_files:
|
127
|
+
- spec/fast_attributes/uuid_spec.rb
|
128
|
+
- spec/fixtures/classes.rb
|
129
|
+
- spec/spec_helper.rb
|