gabe-uuid 0.3 → 0.3.1

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.
Files changed (4) hide show
  1. data/Rakefile +1 -1
  2. data/lib/uuid.rb +2 -2
  3. data/spec/uuid_spec.rb +5 -5
  4. metadata +1 -1
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  spec = Gem::Specification.new do |s|
13
13
  s.name = 'uuid'
14
- s.version = '0.3'
14
+ s.version = '0.3.1'
15
15
  s.platform = Gem::Platform::RUBY
16
16
  s.author = 'Gabriel Boyer'
17
17
  s.email = 'gboyer@gmail.com'
data/lib/uuid.rb CHANGED
@@ -5,7 +5,7 @@ rescue LoadError
5
5
  end
6
6
 
7
7
  class UUID
8
- def initialize(value = nil)
8
+ def initialize(value)
9
9
  @value = Integer(value)
10
10
  unless (@value >= 0) && (@value < (1 << 128))
11
11
  raise RangeError, "#{value} (Integer value #{@value}) is out of range (need unsigned 128-bit value)"
@@ -70,7 +70,7 @@ class UUID
70
70
 
71
71
  def to_s
72
72
  h = hex
73
- '%s-%s-%s-%s-%s' % [h[0...8], h[8...12], h[12...16], h[16...20], h[20...32]]
73
+ '%s-%s-%s-%s-%s' % [h[0, 8], h[8, 4], h[12, 4], h[16, 4], h[20, 12]]
74
74
  end
75
75
 
76
76
  def urn
data/spec/uuid_spec.rb CHANGED
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), 'spec_helper')
3
3
  describe UUID, '.uuid4' do
4
4
  it 'generates a new UUID' do
5
5
  UUID.uuid4.should be_a_kind_of(UUID)
6
- UUID.uuid4.should_not == UUID.new
6
+ UUID.uuid4.should_not == UUID.uuid4
7
7
  end
8
8
 
9
9
  it 'generates version 4 UUIDs' do
@@ -42,7 +42,7 @@ describe UUID, '#initialize' do
42
42
  end
43
43
 
44
44
  it 'raises a RangeError when passed an Integer that is out of range for a UUID' do
45
- lambda { UUID.new -1 }.should raise_error(RangeError)
45
+ lambda { UUID.new(-1) }.should raise_error(RangeError)
46
46
  lambda { UUID.new(1 << 128) }.should raise_error(RangeError)
47
47
  end
48
48
  end
@@ -60,19 +60,19 @@ delimited_hex_format = /[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}/
60
60
 
61
61
  describe UUID, '#to_s' do
62
62
  it 'returns a UUID string in delimited hex format (i.e., xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)' do
63
- UUID.new.to_s.should =~ /^#{delimited_hex_format}$/
63
+ UUID.uuid4.to_s.should =~ /^#{delimited_hex_format}$/
64
64
  end
65
65
  end
66
66
 
67
67
  describe UUID, '#hex' do
68
68
  it 'returns a UUID string in undelimited hex format (i.e., xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)' do
69
- UUID.new.hex.should =~ /^[0-9a-fA-F]{8}([0-9a-fA-F]{4}){3}[0-9a-fA-F]{12}$/
69
+ UUID.uuid4.hex.should =~ /^[0-9a-fA-F]{8}([0-9a-fA-F]{4}){3}[0-9a-fA-F]{12}$/
70
70
  end
71
71
  end
72
72
 
73
73
  describe UUID, '#urn' do
74
74
  it 'returns a UUID string in delimited hex format with a urn prefix (i.e., urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)' do
75
- UUID.new.urn.should =~ /^urn:uuid:#{delimited_hex_format}$/
75
+ UUID.uuid4.urn.should =~ /^urn:uuid:#{delimited_hex_format}$/
76
76
  end
77
77
  end
78
78
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gabe-uuid
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.3"
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Boyer