sporkmonger / uuidtools Goto Github PK
View Code? Open in Web Editor NEWA simple universally unique ID generation library.
Home Page: http://uuidtools.rubyforge.org/
License: Apache License 2.0
A simple universally unique ID generation library.
Home Page: http://uuidtools.rubyforge.org/
License: Apache License 2.0
Hey,
I am receiving the following error on Jessie os using the timestamp_create method.
[1] pry(main)> UUIDTools::UUID.timestamp_create
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
ip [ -force ] -batch filename
where OBJECT := { link | addr | addrlabel | route | rule | neigh | ntable |
tunnel | tuntap | maddr | mroute | mrule | monitor | xfrm |
netns | l2tp | tcp_metrics | token | netconf }
OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |
-f[amily] { inet | inet6 | ipx | dnet | bridge | link } |
-4 | -6 | -I | -D | -B | -0 |
-l[oops] { maximum-addr-flush-attempts } |
-o[neline] | -t[imestamp] | -b[atch] [filename] |
-rc[vbuf] [size]}
NoMethodError: undefined method `split' for nil:NilClass
from /usr/local/bundle/gems/uuidtools-2.1.4/lib/uuidtools.rb:611:in `first_mac'
I have looked into it in a bit of detail, Jessie uses ip instead of ifconfig and the code for the gem does the following:
all_switch = all == nil ? "" : "-a"
The "-a" options seem to be incorrect options for ip service. Should be 'device a'
root@651fc07a3a3a:r# ip -a
Option "-a" is unknown, try "ip -help".
I used a new docker image to boot up an older Rails application that depends on the uuidtools
gem, specifically the UUIDTools::UUID.timestamp_create
method. After the image update, I was seeing a these errors in rspec tests:
Failure/Error: uuid { UUIDTools::UUID.timestamp_create.to_s }
NoMethodError:
undefined method `[]' for nil:NilClass
This comes from the assumption that /sbin/ip
will exist, at
Line 639 in e4f0e05
My solution was to add the OS package that included the ifconfig
command (which was smaller than the one that included the ip
command).
when running as a windows service i got this error:
uninitialized class variable @@mac_address in UUIDTools::UUID
C:/Ruby/lib/ruby/gems/1.9.1/gems/uuidtools-2.1.2/lib/uuidtools.rb:590:in `mac_address'
if the same code runs inside cmd.exe it works without any problem.
my code is:
uuid = UUIDTools::UUID.mac_address.to_s
thank you.
ArgumentError in 'UUIDTools::UUID when parsing should correctly parse integers'
invalid byte sequence in US-ASCII
/var/tmp/portage/dev-ruby/uuidtools-2.1.0/work/uuidtools-2.1.0/spec/uuidtools/uuid_parsing_spec.rb:115:in block (2 levels) in <top (required)>' /usr/lib64/ruby19/1.9.1/timeout.rb:44:in
timeout'
ArgumentError in 'UUIDTools::UUID when parsing should correctly parse hexdigests'
invalid byte sequence in US-ASCII
/var/tmp/portage/dev-ruby/uuidtools-2.1.0/work/uuidtools-2.1.0/spec/uuidtools/uuid_parsing_spec.rb:125:in block (2 levels) in <top (required)>' /usr/lib64/ruby19/1.9.1/timeout.rb:44:in
timeout'
Finished in 0.323076154 seconds
41 examples, 2 failures
rake aborted!
Command /usr/bin/ruby19 -I"lib" "/usr/lib64/ruby19/gems/1.9.1/gems/rspec-1.2.9/bin/spec" "spec/uuidtools/uuid_parsing_spec.rb" "spec/uuidtools/mac_address_spec.rb" "spec/uuidtools/utility_spec.rb" "spec/uuidtools/uuid_creation_spec.rb" --color --format specdoc failed
/usr/local/lib/ruby/gems/1.9.1/gems/uuidtools-2.1.2/lib/uuidtools.rb:399: warning: instance variable @string not initialized
https://rubygems.org/gems/uuidtools/versions/2.1.3
But there is no corresponding tag on github. If you use the bundler provided tasks to release to github tagging will be taken care of automatically in the future.
I installed uuidtools in Windows 7 x64 with the command:
jruby -S gem install uuidtools
have written a helper:
require 'rubygems' require 'uuidtools' module UUIDHelper def self.parse(uuidstring) self.uuid = UUID.parse(uuidstring) end def before_create() self.uuid = UUID.timestamp_create().to_s end end
but can't get the application to work.
The error message is:
no such file to load -- uuidtools
I searched web pages, tried all possible advices, restarted my Webrick 20 times - still no result.
By clicking "Go to declaration" on timestamp_create, NetBeans opens uuidtools.rb - so it CAN find uuidtools.
What could be wrong?
irb(main):001:0> require 'uuidtools' LoadError: no such file to load -- uuidtools from org/jruby/RubyKernel.java:1038:in 'require' from (irb):1:in 'evaluate' from org/jruby/RubyKernel.java:1088:in 'eval' from C:/Program Files/jruby-1.6.4/lib/ruby/1.8/irb.rb:158:in 'eval_input' from C:/Program Files/jruby-1.6.4/lib/ruby/1.8/irb.rb:271:in 'signal_status' from C:/Program Files/jruby-1.6.4/lib/ruby/1.8/irb.rb:155:in 'eval_input' from org/jruby/RubyKernel.java:1419:in 'loop' from org/jruby/RubyKernel.java:1191:in 'catch' from C:/Program Files/jruby-1.6.4/lib/ruby/1.8/irb.rb:154:in 'eval_input' from C:/Program Files/jruby-1.6.4/lib/ruby/1.8/irb.rb:71:in 'start' from org/jruby/RubyKernel.java:1191:in 'catch' from C:/Program Files/jruby-1.6.4/lib/ruby/1.8/irb.rb:70:in 'start' from C:\Program Files\jruby-1.6.4\bin\irb:13:in '(root)'
Process Monitor shows me for "require" command:
Operation: CreateFile Result: PATH NOT FOUND Path: C:\Program Files\jruby-1.6.4\lib\ruby\gems\1.8\gems\uuidtools-2.1.2\rubyjit\debug?_69049681550F92840CD2088A74CA3191A61CC9CA.class TID: 160 Desired Access: Read Attributes Disposition: Open Options: Open Reparse Point Attributes: n/a ShareMode: Read, Write, Delete AllocationSize: n/a
P.S. It seems to be a general problem with JRuby. Other modules behave in such manner too - they can't be loaded from an application, but from irb they are loaded without problems.
Here's the new fix, next time I'll just fork this and let you pull in the fix if there is anything else:
Line 415:
windoze = os_platform =~ (/win/ && !(os_platform =~ /darwin/)) ||
os_platform =~ /w32/
if windoze
script_in_path = true
.....
Line 446ish:
elsif windoze
begin
ifconfig_output = ipconfig /all
mac_addresses = ifconfig_output.scan(
Hello,
I've found in Gentoo a bug where uuidtools does not pass tests because it can't find a MAC address for the host. -The reason is relatively simple: the host has no IPv4 so the trick with ifconfig+arp will fail.- Edit: I read the logic wrong, the arp trick is for Solaris. There still is some problems as ifconfig on a hardened LXC guest does not report the ethernet address, trying to find out why right now.
I'm working on changing the code to look for the ethernet address on the ifconfig output directly โ it's going to be slightly tricky because there are two possible output styles for ifconfig, and at some point it might even disappear in favour of the ip command.
Anyway I'll submit a patch shortly.
I get the the error "Use RbConfig instead of obsolete and deprecated Config" with Ruby 1.9.3. Would it be possible to fix this in the next version of uuidtools?
Is there anyway to create unique alphanumeric length limited strings with UUIDTools?
Noticed this in the log: 'which' is not recognized as an internal or external command,
operable program or batch file.
Changed line 418 to:
if (os_platform =~ /win/ && !(os_platform =~ /darwin/)) || os_platform =~ /w32/
That fixes it.
Commit 8c0d99d fixes support for getting the mac address through the ip
command. After patching it myself, I figured out the solution was already in master. Maybe this fix deserves a new gem release, as the ip
command will be more and more common?
to_s on a uuid object seems to reference internal state, for example:
u = UUIDTools::UUID.random_create
>> #<UUID:0x1ab59b7df8 UUID:c08bf74a-98c5-4d82-bb96-e8dbaa1e1dfb>
u.to_s.gsub! '-', '/'
=> "c08bf74a/98c5/4d82/bb96/e8dbaa1e1dfb"
u
=> #<UUID:0x1ab59b7df8 UUID:c08bf74a/98c5/4d82/bb96/e8dbaa1e1dfb>
I get around the issue by using dup:
u.to_s.dup.gsub! '-', '/'
The results of to_s should be immutable with respect to the uuid object state.
UUIDTools::UUID.sha1_create(UUIDTools::UUID_DNS_NAMESPACE, "http://github.com").to_s
=> "de33c012-0cb8-5281-8f42-768c47f00bd7"
UUIDTools::UUID.sha1_create(UUIDTools::UUID_DNS_NAMESPACE, "http://github.com").to_s
=> "de33c012-0cb8-5281-8f42-768c47f00bd7"
UUIDTools::UUID.random_create
does generate valid Version 4 (Random) UUIDs, but if I parse an invalid UUID like this:
uuid = UUIDTools::UUID.parse('4e062a1e-31bd-4dc2-76b8-bf8c207c52d4')
then uuid.valid?
returns true
and it should return false
since the third group (76b8) starts with a 7, not with, a, b, 8 or 9.
http://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29
I get constant not found error
I'm had been using uuidtools gem for years, thanks for it! ๐
Because the last commit is from Aug 11, 2015, I'm thinking of using another UUID generator,
Are there better alternatives nowadays? In your opinion whats the best UUID generator in ruby (as 2017)?
Hi,
I open a new issue since the rspec output as changed (from this previous issue #12 ):
I copy paste the entire output :
Warning: cannot open /proc/net/dev (No such file or directory). Limited output.
F...............*............Warning: cannot open /proc/net/dev (No such file or directory). Limited output.
F..................F...............
Pending:
UUIDTools::UUID before obtaining a MAC address should return the output of the ifconfig program
# I'm not quite sure how to mock backticks
# ./spec/uuidtools/mac_address_spec.rb:418
Failures:
1) UUIDTools::UUID when obtaining a MAC address should obtain a MAC address
Failure/Error: @mac_address.should_not be_nil
expected: not nil
got: nil
# ./spec/uuidtools/mac_address_spec.rb:243:in `block (2 levels) in <top (required)>'
2) UUIDTools::UUID when generating should correctly generate timestamp variant UUIDs
Failure/Error: UUIDTools::UUID.timestamp_create.should_not be_random_node_id
expected random_node_id? to return false, got true
# ./spec/uuidtools/uuid_creation_spec.rb:17:in `block (2 levels) in <top (required)>'
3) UUIDTools::UUID when parsing should not treat a timestamp version UUID as a random node UUID
Failure/Error: UUIDTools::UUID.timestamp_create.should_not be_random_node_id
expected random_node_id? to return false, got true
# ./spec/uuidtools/uuid_parsing_spec.rb:27:in `block (2 levels) in <top (required)>'
Finished in 0.1865 seconds
64 examples, 3 failures, 1 pending
Failed examples:
rspec ./spec/uuidtools/mac_address_spec.rb:241 # UUIDTools::UUID when obtaining a MAC address should obtain a MAC address
rspec ./spec/uuidtools/uuid_creation_spec.rb:16 # UUIDTools::UUID when generating should correctly generate timestamp variant UUIDs
rspec ./spec/uuidtools/uuid_parsing_spec.rb:26 # UUIDTools::UUID when parsing should not treat a timestamp version UUID as a random node UUID
There have been a couple of bug fixes since the last gem version. Any chance of there being new one released?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.