ahoward / macaddr Goto Github PK
View Code? Open in Web Editor NEWcross platform mac address determination for ruby
License: Other
cross platform mac address determination for ruby
License: Other
NAME macaddr DESCRIPTION cross platform mac address determination for ruby URI http://github.com/ahoward/macaddr http://rubyforg.org/projects/codeforpeople INSTALL gem install macaddr HISTORY New: - added a Gemfile for easier testing/dev with Bundler - added an example .rvmrc file that will setup for ruby 1.9.3 - updated systemu gem to ~>2.4.0 to work with ruby 1.9.3 1.1.0: - added dependancy on systemu to work around butt-licky windoze io capture: http://redmine.ruby-lang.org/issues/show/3215 1.0.0: - rdoc added - eric hodel kicks ass. to find why, see http://drawohara.com/post/44678286/eric-hodel-kicks-ass SYNOPSIS require 'macaddr' Mac.addr #=> first mac addr on your system Mac.addr.list #=> all mac addrs on your system
Forgot to thank you for this gem ;)
Mac.addr returns a string. "mac", and the singlemethod #list is not applied to it.
So I need: Mac.addr.respond_to?(:list) . Can't get any uglier.
Also, a better approach here: https://github.com/tsilen/macaddr
The singleton method #list really doesn't make sense.
Looks like you need to declare a runtime dependency on the systemu gem.
/Users/mperham/.rvm/gems/jruby-1.5.6@banyan/gems/macaddr-1.2.0/lib/macaddr.rb:23:in `require': no such file to load -- systemu (LoadError)
irb(main):001:0> require 'macaddr'
=> true
irb(main):002:0> Mac.from_getifaddrs
NameError: uninitialized constant Socket::PF_LINK
from /home/stevecrozz/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/macaddr-1.7.0/lib/macaddr.rb:83:in `block in from_getifaddrs'
from /home/stevecrozz/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/macaddr-1.7.0/lib/macaddr.rb:82:in `select'
from /home/stevecrozz/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/macaddr-1.7.0/lib/macaddr.rb:82:in `from_getifaddrs'
from (irb):2
from /home/stevecrozz/.rbenv/versions/2.1.1/bin/irb:11:in `<main>'
system: Windows7
ruby-version: ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]
irb(main):004:0> Mac.addr
NoMethodError: undefined method pfamily' for nil:N from C:/Ruby23/lib/ruby/gems/2.3.0/gems/mac from C:/Ruby23/lib/ruby/gems/2.3.0/gems/mac from C:/Ruby23/lib/ruby/gems/2.3.0/gems/mac from C:/Ruby23/lib/ruby/gems/2.3.0/gems/mac from (irb):4 from C:/Ruby23/bin/irb.cmd:19:in
vendor/bundle/ruby/1.9.1/gems/systemu-2.2.0/lib/systemu.rb:29: Use RbConfig instead of obsolete and deprecated Config.
I am running a windows 7 virtual machine and both Socket::PF_PACKET and Socket::PF_LINK are undefined. I can confirm this in the constants list for Socket in irb.
irb(main):001:0> require 'socket'
=> true
irb(main):002:0> Socket.const_defined? :PF_LINK
=> false
irb(main):003:0> Socket.const_defined? :PF_PACKET
=> false
Is there another constant that will work instead or is there a reason why these constants may not be defined that is explainable that can lead to a solution?
Fetching: macaddr-1.3.0.gem (100%)
ERROR: While executing gem ... (Errno::EINVAL)
Invalid argument - C:/Ruby192/lib/ruby/gems/1.9.1/gems/macaddr-1.3.0/test/data/c8:bc:c8:9b:28:b1
I'm packaging macaddr gem for Fedora, and there are some information due to license text:
https://fedoraproject.org/wiki/Packaging:LicensingGuidelines?rd=Packaging/LicensingGuidelines#License_Text
Ruby is using these license files:
https://raw.githubusercontent.com/ruby/ruby/trunk/COPYING
https://raw.githubusercontent.com/ruby/ruby/trunk/BSDL
Can you confirm the files are OK for macaddr? (for example is macaddr dual-licensed the same way as ruby?) Could you provide the full license texts in the sources?
Thanks.
I'm not sure if this is a systemu or macaddr issue. Ran into this trouble on a simple Ruby/Sinatra stack app.
rerun -p '**/*.{rb,js,css,scss,sass,erb,html,haml,ru,slim}' --dir routes,views,public,models,models/general,models/session,helpers,lib,config -- 'rackup config/config.ru'
13:18:10 [rerun] Src launched
/home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/backports-3.6.0/lib/backports/tools.rb:343:in `require': cannot load such file -- systemu (LoadError)
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/backports-3.6.0/lib/backports/tools.rb:343:in `require_with_backports'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/macaddr-1.6.2/lib/macaddr.rb:23:in `<top (required)>'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/backports-3.6.0/lib/backports/tools.rb:343:in `require'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/backports-3.6.0/lib/backports/tools.rb:343:in `require_with_backports'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/uuid-2.3.7/lib/uuid.rb:14:in `<top (required)>'
from /home/br/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
from /home/br/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
from /home/br/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
from /home/br/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
from /home/br/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
from /home/br/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
from /home/br/.rvm/gems/ruby-2.1.0@global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
from /home/br/companies/clothesnetwork/companies/clients/external.dev.clothesnetwork.com/ascots_website/src/config/config.ru:6:in `block in <main>'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from /home/br/companies/clothesnetwork/companies/clients/external.dev.clothesnetwork.com/ascots_website/src/config/config.ru:in `new'
from /home/br/companies/clothesnetwork/companies/clients/external.dev.clothesnetwork.com/ascots_website/src/config/config.ru:in `<main>'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/server.rb:250:in `start'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/lib/rack/server.rb:141:in `start'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rack-1.5.2/bin/rackup:4:in `<top (required)>'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/rackup:23:in `load'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/rackup:23:in `<main>'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/ruby_executable_hooks:15:in `eval'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/ruby_executable_hooks:15:in `<main>'
NoMethodError: undefined method `stop' for nil:NilClass stopping listener
/home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rerun-0.8.2/lib/rerun/watcher.rb:74:in `sleep': execution expired (Timeout::Error)
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rerun-0.8.2/lib/rerun/watcher.rb:74:in `block in adapter'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rerun-0.8.2/lib/rerun/watcher.rb:73:in `adapter'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rerun-0.8.2/lib/rerun/runner.rb:162:in `start'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rerun-0.8.2/lib/rerun/runner.rb:9:in `keep_running'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/gems/rerun-0.8.2/bin/rerun:12:in `<top (required)>'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/rerun:23:in `load'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/rerun:23:in `<main>'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/ruby_executable_hooks:15:in `eval'
from /home/br/.rvm/gems/ruby-2.1.0@easydc_project/bin/ruby_executable_hooks:15:in `<main>'
Current workarouind for me is to pin the macaddr gem to 1.6.1 by adding
gem 'macaddr', '=1.6.1'
to gemfile. With 1.6.1 it works like a charm.
ruby 2.1.0p0 (2013-12-25 revision 44422) [i686-linux]
When I use macaddr on a w2k8r2 system it does not find the mac address
irb(main):026:0> Mac.addr
RuntimeError: all of /sbin/ifconfig /bin/ifconfig ifconfig ipconfig /all failed
from C:/Program Files (x86)/Shoreline Communications/ShoreWare Director/Ruby/mingw32/lib/ruby/gems/1.9.1
caddr-1.4.0/lib/macaddr.rb:67:in address' from (irb):26 from C:/Program Files (x86)/Shoreline Communications/ShoreWare Director/Ruby/mingw32/lib/ruby/gems/1.9.1 ilties-3.1.1/lib/rails/commands/console.rb:45:in
start'
from C:/Program Files (x86)/Shoreline Communications/ShoreWare Director/Ruby/mingw32/lib/ruby/gems/1.9.1
ilties-3.1.1/lib/rails/commands/console.rb:8:in start' from C:/Program Files (x86)/Shoreline Communications/ShoreWare Director/Ruby/mingw32/lib/ruby/gems/1.9.1 ilties-3.1.1/lib/rails/commands.rb:40:in
<top (required)>'
from script/rails:6:in require' from script/rails:6:in
If i run
systemu('ipconfig /all')
from rails console i do get output
using ruby 1.9.2.p136
Having some issues with unlicensed gems here. Can you please pick a license for this project and commit a LICENSE and specify it in gemspec. Thanks.
using the Mac.addr.list method, it would be useful to get more info regarding each mac address. I imagine something like this:
{ 'eth0' => '00:ff:23:45:67:89', 'wlan0' => '00:ff:12:34:56:78' }
Hi, in your gemspec you missed systemu
gem dependency. And now it's looks like this:
$ bundle exec rspec
/home/travis/.rvm/gems/ruby-1.9.3-p484/gems/macaddr-1.6.2/lib/macaddr.rb:23:in `require': cannot load such file -- systemu (LoadError)
from /home/travis/.rvm/gems/ruby-1.9.3-p484/gems/macaddr-1.6.2/lib/macaddr.rb:23:in `<top (required)>'
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.