Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

changed bitwise operator to .match function #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
PATH
remote: .
specs:
uuid (2.3.7)
uuid (2.3.9)
macaddr (~> 1.0)

GEM
remote: https://rubygems.org/
specs:
macaddr (1.6.7)
systemu (~> 2.6.2)
macaddr (1.7.2)
systemu (~> 2.6.5)
mocha (0.9.12)
rake (0.8.7)
systemu (2.6.4)
systemu (2.6.5)
yard (0.6.7)

PLATFORMS
Expand All @@ -22,3 +22,6 @@ DEPENDENCIES
rake
uuid!
yard

BUNDLED WITH
2.2.32
9 changes: 4 additions & 5 deletions lib/uuid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ def self.state_file=(path)
# Returns true if +uuid+ is in compact, default or urn formats. Does not
# validate the layout (RFC 4122 section 4) of the UUID.
def self.validate(uuid)
return true if uuid =~ /\A[\da-f]{32}\z/i
return true if
uuid =~ /\A(urn:uuid:)?[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}\z/i
return true if /\A[\da-f]{32}\z/i.match(uuid)
return true if /\A(urn:uuid:)?[\da-f]{8}-([\da-f]{4}-){3}[\da-f]{12}\z/i.match(uuid)
end

##
Expand Down Expand Up @@ -437,7 +436,7 @@ def bind(address)
end
sock = UNIXServer.new(address)
File.chmod 0666, address
elsif address =~ /^(\d+\.\d+\.\d+\.\d+):(\d+)$/
elsif /^(\d+\.\d+\.\d+\.\d+):(\d+)$/.match(address)
sock = TCPServer.new($1, $2.to_i)
else
raise ArgumentError, "Don't know how to bind #{address}"
Expand Down Expand Up @@ -476,7 +475,7 @@ def connect(address)
return address unless String === address
if address[0] == ?/
sock = UNIXSocket.new(address)
elsif address =~ /^(\d+\.\d+\.\d+\.\d+):(\d+)$/
elsif /^(\d+\.\d+\.\d+\.\d+):(\d+)$/.match(address)
sock = TCPSocket.new($1, $2.to_i)
else
raise ArgumentError, "Don't know how to connect to #{address}"
Expand Down