fast_attributes-uuid 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/CHANGELOG.md +14 -0
- data/README.md +37 -9
- data/fast_attributes-uuid.gemspec +1 -1
- data/lib/fast_attributes/uuid.rb +12 -8
- data/lib/fast_attributes/uuid/version.rb +1 -1
- data/spec/fast_attributes/uuid_spec.rb +7 -0
- data/spec/fixtures/classes.rb +7 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80d79d6af52dbcb6679d6ba7e58b15fc74fc39b3
|
4
|
+
data.tar.gz: 0e6685b8b1f7682384813f5688cb733803331d30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7265afe1a556f5448a3171d707c6a1b94cb3ac971b561f936ef6e54f176aaf10270d33d46a675734d28e61aaefb723468cc0184b2551634929faa034ad782972
|
7
|
+
data.tar.gz: 8a0406a00d88c465a459a62fa8df63a72faff455b3c28c55b0f4786f9ec862100803e435b246985aaa6f2f7216aaeddb3ae53e4c6b85e50e97d9316f34b1744d
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
**0.0.5 (July 20, 2014)**
|
2
|
+
* Support `fast_attributes` 0.6.0
|
3
|
+
|
4
|
+
**0.0.4 (July 16, 2014)**
|
5
|
+
* Support `fast_attributes` 0.5.0
|
6
|
+
|
7
|
+
**0.0.3 (July 4, 2014)**
|
8
|
+
* Support `fast_attributes` 0.3.0
|
9
|
+
|
10
|
+
**0.0.2 (July 4, 2014)**
|
11
|
+
* Support `fast_attributes` 0.2.2
|
12
|
+
|
13
|
+
**0.0.1 (June 27, 2014)**
|
14
|
+
* Initial commit
|
data/README.md
CHANGED
@@ -1,28 +1,56 @@
|
|
1
1
|
# FastAttributes::UUID
|
2
|
+
[](http://rubygems.org/gems/fast_attributes-uuid)
|
3
|
+
[](https://travis-ci.org/applift/fast_attributes-uuid)
|
4
|
+
[](https://coveralls.io/r/applift/fast_attributes-uuid?branch=master)
|
5
|
+
[](https://codeclimate.com/github/applift/fast_attributes-uuid)
|
6
|
+
[](https://gemnasium.com/applift/fast_attributes-uuid)
|
2
7
|
|
3
|
-
|
8
|
+
## Overview
|
9
|
+
This gem adds support of `UUID` type to `fast_attributes` gem
|
4
10
|
|
5
11
|
## Installation
|
6
12
|
|
7
13
|
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
|
14
|
+
```ruby
|
15
|
+
gem 'fast_attributes'
|
16
|
+
gem 'fast_attributes-uuid'
|
17
|
+
```
|
10
18
|
|
11
19
|
And then execute:
|
12
|
-
|
13
|
-
|
20
|
+
```
|
21
|
+
$ bundle
|
22
|
+
```
|
14
23
|
|
15
24
|
Or install it yourself as:
|
16
|
-
|
17
|
-
|
25
|
+
```
|
26
|
+
$ gem install fast_attributes fast_attributes-uuid
|
27
|
+
```
|
18
28
|
|
19
29
|
## Usage
|
20
30
|
|
21
|
-
|
31
|
+
```ruby
|
32
|
+
require 'fast_attributes'
|
33
|
+
require 'fast_attributes/uuid'
|
34
|
+
|
35
|
+
class Request
|
36
|
+
extend FastAttributes
|
37
|
+
attribute :id, UUIDTools::UUID
|
38
|
+
end
|
39
|
+
|
40
|
+
request = Request.new
|
41
|
+
request.id = '479c4718-06d0-4712-b79d-eea7170938c8'
|
42
|
+
# => #<UUID:0x3ff8a1a0a684 UUID:479c4718-06d0-4712-b79d-eea7170938c8>
|
43
|
+
|
44
|
+
request.id = 'EFC0CCF6E72243958306D816AB82BAB7'
|
45
|
+
# => #<UUID:0x3ff8a19db924 UUID:efc0ccf6-e722-4395-8306-d816ab82bab7>
|
46
|
+
|
47
|
+
request.id = UUIDTools::UUID.parse('4e79aff3-1f04-4fea-bebf-694625551a92')
|
48
|
+
# => #<UUID:0x3ff8a19c3d24 UUID:4e79aff3-1f04-4fea-bebf-694625551a92>
|
49
|
+
```
|
22
50
|
|
23
51
|
## Contributing
|
24
52
|
|
25
|
-
1. Fork it ( https://github.com/
|
53
|
+
1. Fork it ( https://github.com/applift/fast_attributes-uuid/fork )
|
26
54
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
55
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
56
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.required_ruby_version = '>= 1.9.2'
|
22
22
|
|
23
|
-
spec.add_runtime_dependency 'fast_attributes', '~> 0.
|
23
|
+
spec.add_runtime_dependency 'fast_attributes', '~> 0.7.0'
|
24
24
|
spec.add_runtime_dependency 'uuidtools', '~> 2.1.4'
|
25
25
|
|
26
26
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
data/lib/fast_attributes/uuid.rb
CHANGED
@@ -5,14 +5,18 @@ module FastAttributes
|
|
5
5
|
module UUID
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
type_cast UUIDTools::UUID, :uuid do
|
9
|
+
from 'nil', to: 'nil'
|
10
|
+
from 'UUIDTools::UUID', to: '%s'
|
11
|
+
otherwise <<-EOS
|
12
|
+
case %s.length
|
13
|
+
when 36 then UUIDTools::UUID.parse(%s)
|
14
|
+
when 32 then UUIDTools::UUID.parse_hexdigest(%s)
|
15
|
+
when 0 then nil
|
16
|
+
else UUIDTools::UUID.parse_raw(%s)
|
17
|
+
end
|
18
|
+
EOS
|
19
|
+
end
|
16
20
|
end
|
17
21
|
|
18
22
|
require 'fast_attributes/uuid/version'
|
@@ -46,4 +46,11 @@ describe FastAttributes::UUID do
|
|
46
46
|
expect(log.request_id).to be_a(UUIDTools::UUID)
|
47
47
|
expect(log.request_id.to_s).to eq('d2b4b3e3-4f16-4aa8-bc43-cab90d008171')
|
48
48
|
end
|
49
|
+
|
50
|
+
it 'allows to define attribute using symbol notation' do
|
51
|
+
log = SymbolUUID.new
|
52
|
+
log.request_id = 'd2b4b3e3-4f16-4aa8-bc43-cab90d008171'
|
53
|
+
expect(log.request_id).to be_a(UUIDTools::UUID)
|
54
|
+
expect(log.request_id.to_s).to eq('d2b4b3e3-4f16-4aa8-bc43-cab90d008171')
|
55
|
+
end
|
49
56
|
end
|
data/spec/fixtures/classes.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_attributes-uuid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kostiantyn Stepaniuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fast_attributes
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.7.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.7.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: uuidtools
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,6 +89,8 @@ extra_rdoc_files: []
|
|
89
89
|
files:
|
90
90
|
- ".gitignore"
|
91
91
|
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- CHANGELOG.md
|
92
94
|
- Gemfile
|
93
95
|
- LICENSE.txt
|
94
96
|
- README.md
|