ruuid 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e771cd338893fc6ba98871678208daffbac1d5c4
4
- data.tar.gz: 8383b56ae6a40be9be60fa9655177a53ca551b8b
3
+ metadata.gz: bc063c80e473ff458f809fb2e17f92d07e1e8672
4
+ data.tar.gz: 86d3077f97bb6807045b3a7e82ac64659900043c
5
5
  SHA512:
6
- metadata.gz: 67467a1ddabc1f10de041011c4cb9529776ea312f4eda91691e55d5a7f8463197ddaa798c181828ab653f919d5268455f6c0170ff1824a63af4fa24b4791f9e6
7
- data.tar.gz: c711cb679f5e90c59c3d2ee3bcf414e00f06559e11358c6cdde09806d5a5478c32cc48a667a24ce5102e58538c9e39b7572a86150f4489f5559fa36fed183014
6
+ metadata.gz: 16490a0acab29eaf6e142243d4a2564a0164341cb23310d12e129e68b0394924fcfb6a6e7cdbee96842d5ab8a88118380f8027a188d94e222abee50b7b90752e
7
+ data.tar.gz: 40a4b538637ae730e2c3e955a6cb37a4163f892b8090dbe4f15229222176ce0055e8626161cd4852d0d87599518b77bf98143214cdcfac6263684d4588973bb1
data/lib/ruuid/parser.rb CHANGED
@@ -3,17 +3,14 @@ module RUUID
3
3
  module Parser
4
4
  extend self
5
5
 
6
- BLACKLIST = /[^a-f0-9]/i
6
+ FORMAT = /^\h{8}-?\h{4}-?\h{4}-?[89ab]\h{3}-?\h{12}$/i
7
7
 
8
8
  def parse(string)
9
- string = sanitize(string)
10
- [string].pack('H*')
11
- end
12
-
13
- private
14
-
15
- def sanitize(string)
16
- string.gsub(BLACKLIST, '')
9
+ if string[FORMAT]
10
+ [string.gsub(/\H/, '')].pack('H*')
11
+ else
12
+ string
13
+ end
17
14
  end
18
15
  end # Parser
19
16
  end # RUUID
data/lib/ruuid/uuid.rb CHANGED
@@ -65,11 +65,11 @@ module RUUID
65
65
 
66
66
  def validate
67
67
  unless data.length == 16
68
- raise InvalidUUIDError, 'Invalid UUID length'
68
+ raise InvalidUUIDError, "Invalid UUID length: #{data.inspect}"
69
69
  end
70
70
 
71
71
  unless data.bytes[8] >> 6 == 2
72
- raise InvalidUUIDError, 'Invalid UUID variant'
72
+ raise InvalidUUIDError, "Invalid UUID variant: #{data.inspect}"
73
73
  end
74
74
  end
75
75
 
data/lib/ruuid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RUUID
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruuid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabe Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-03 00:00:00.000000000 Z
11
+ date: 2015-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler