aaalex-ruby-ifconfig 1.2.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.
- data/COPYING +340 -0
- data/Changelog +20 -0
- data/INSTALL +239 -0
- data/README +37 -0
- data/Rakefile +14 -0
- data/TODO +8 -0
- data/ifconfig_examples/darwin.txt +17 -0
- data/ifconfig_examples/dragonflybsd.txt +10 -0
- data/ifconfig_examples/dragonflybsd_netstat.txt +14 -0
- data/ifconfig_examples/freebsd.txt +17 -0
- data/ifconfig_examples/freebsd_netstat.txt +24 -0
- data/ifconfig_examples/linux.txt +60 -0
- data/ifconfig_examples/linux_ethernet.txt +20 -0
- data/ifconfig_examples/netbsd.txt +10 -0
- data/ifconfig_examples/openbsd.txt +36 -0
- data/ifconfig_examples/sunos.txt +10 -0
- data/lib/ifconfig.rb +71 -0
- data/lib/ifconfig/bsd/ifconfig.rb +72 -0
- data/lib/ifconfig/bsd/interface_types.rb +69 -0
- data/lib/ifconfig/bsd/network_types.rb +3 -0
- data/lib/ifconfig/common/ifconfig.rb +84 -0
- data/lib/ifconfig/common/interface_types.rb +130 -0
- data/lib/ifconfig/common/network_types.rb +49 -0
- data/lib/ifconfig/linux/ifconfig.rb +41 -0
- data/lib/ifconfig/linux/interface_types.rb +112 -0
- data/lib/ifconfig/linux/network_types.rb +55 -0
- data/lib/ifconfig/sunos/ifconfig.rb +38 -0
- data/lib/ifconfig/sunos/interface_types.rb +77 -0
- data/lib/ifconfig/sunos/network_types.rb +4 -0
- data/test/test_bsd.rb +35 -0
- data/test/test_darwin.rb +33 -0
- data/test/test_dragonflybsd.rb +35 -0
- data/test/test_helper.rb +4 -0
- data/test/test_linux.rb +31 -0
- data/test/test_netbsd.rb +33 -0
- data/test/test_openbsd.rb +33 -0
- data/test/test_sunos.rb +35 -0
- data/test/unit/tc_darwin.rb +40 -0
- data/test/unit/tc_dragonflybsd.rb +39 -0
- data/test/unit/tc_freebsd.rb +40 -0
- data/test/unit/tc_linux.rb +49 -0
- data/test/unit/tc_netbsd.rb +39 -0
- data/test/unit/tc_openbsd.rb +39 -0
- data/test/unit/tc_sunos.rb +44 -0
- metadata +101 -0
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class TC_DragonFlyBSDTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
sample = IO.readlines("#{File.dirname(__FILE__)}"+
|
6
|
+
"/../../ifconfig_examples/dragonflybsd.txt").join
|
7
|
+
@cfg = IfconfigWrapper.new('BSD',sample).parse
|
8
|
+
end
|
9
|
+
def test_interface_list
|
10
|
+
assert(@cfg.interfaces == ["rl0", "lo0"],
|
11
|
+
"Fauled to parse all interfaces")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_mac_parse
|
15
|
+
assert(@cfg['rl0'].mac == "00:02:44:8f:bb:15",
|
16
|
+
"Failed to parse MAC address: "+@cfg['rl0'].mac)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_flags
|
20
|
+
assert(@cfg['rl0'].flags.include?('BROADCAST') &&
|
21
|
+
@cfg['rl0'].flags.include?('RUNNING') &&
|
22
|
+
@cfg['rl0'].flags.include?('MULTICAST') &&
|
23
|
+
@cfg['rl0'].up?,
|
24
|
+
"FLAG Parsing failed: #{@cfg['rl0'].flags}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_addr_types
|
28
|
+
assert(@cfg['rl0'].addr_types.include?('inet') &&
|
29
|
+
@cfg['rl0'].addr_types.include?('inet6'),
|
30
|
+
"Failed to parse all address types")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_attribs
|
34
|
+
assert(@cfg['rl0'].rx['bytes'].class == Fixnum || NilClass &&
|
35
|
+
@cfg['rl0'].tx['bytes'].class == Fixnum || NilClass, "Wrong class")
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class TC_FreeBSDTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
sample = IO.readlines("#{File.dirname(__FILE__)}"+
|
6
|
+
"/../../ifconfig_examples/freebsd.txt").join
|
7
|
+
@cfg = IfconfigWrapper.new('BSD',sample).parse
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_interface_list
|
11
|
+
assert(@cfg.interfaces == ["rl0", "lo0", "xl0"],
|
12
|
+
"Failed to parse all interfaces")
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_mac_parse
|
16
|
+
assert(@cfg['rl0'].mac == "00:00:21:03:08:e1",
|
17
|
+
"Failed to parse MAC address: "+@cfg['rl0'].mac)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_flags
|
21
|
+
assert(@cfg['rl0'].flags.include?('BROADCAST') &&
|
22
|
+
@cfg['rl0'].flags.include?('RUNNING') &&
|
23
|
+
@cfg['rl0'].flags.include?('MULTICAST') &&
|
24
|
+
@cfg['rl0'].up?,
|
25
|
+
"FLAG Parsing failed: #{@cfg['rl0'].flags}")
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_addr_types
|
29
|
+
assert(@cfg['rl0'].addr_types.include?('inet') &&
|
30
|
+
@cfg['rl0'].addr_types.include?('inet6'),
|
31
|
+
"Failed to parse all address types")
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_attribs
|
35
|
+
assert(@cfg['rl0'].rx['bytes'].class == Fixnum || NilClass &&
|
36
|
+
@cfg['rl0'].tx['bytes'].class == Fixnum || NilClass, "Wrong class")
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class TC_Linux < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
sample = IO.readlines("#{File.dirname(__FILE__)}"+
|
6
|
+
'/../../ifconfig_examples/linux.txt').join
|
7
|
+
@cfg = IfconfigWrapper.new('Linux',sample).parse
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_intefaces
|
11
|
+
assert(@cfg.interfaces == ["sl0", "lo", "ppp0", "eth0",
|
12
|
+
"eth0:0", "sit0", "sit1"],
|
13
|
+
"Not all interfaces parsed")
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_mtu
|
17
|
+
assert(@cfg['eth0'].mtu == 1500, "Failed to parse eth0 mtu")
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_mac_parse
|
21
|
+
assert(@cfg['eth0'].mac == "00:50:DA:C1:C3:45",
|
22
|
+
"Failed to parse MAC address: "+@cfg['eth0'].mac)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_flags
|
26
|
+
types = ['BROADCAST', 'RUNNING', 'MULTICAST']
|
27
|
+
types.each do |t|
|
28
|
+
assert(@cfg['eth0'].flags.include?(t),
|
29
|
+
"FLAG Parsing failed: #{@cfg['eth0'].flags}")
|
30
|
+
end
|
31
|
+
assert(@cfg['eth0'].up?,
|
32
|
+
"FLAG Parsing failed: #{@cfg['eth0'].flags}")
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_networks
|
36
|
+
types = ['EtherTalk Phase 2', 'IPX/Ethernet 802.2', 'IPX/Ethernet 802.3',
|
37
|
+
'IPX/Ethernet II','IPX/Ethernet SNAP','inet', 'inet6']
|
38
|
+
types.each do |t|
|
39
|
+
assert(@cfg['eth0'].addr_types.include?(t),
|
40
|
+
"Missing Address Types: #{@cfg['eth0'].addr_types}")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_attribs
|
45
|
+
assert(@cfg['eth0'].rx['bytes'] == 1037052545)
|
46
|
+
assert(@cfg['eth0'].tx['bytes'] == 32859376)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class TC_NetBSDTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
sample = IO.readlines("#{File.dirname(__FILE__)}"+
|
6
|
+
'/../../ifconfig_examples/netbsd.txt').join
|
7
|
+
@cfg = IfconfigWrapper.new('BSD',sample).parse
|
8
|
+
end
|
9
|
+
def test_interface_list
|
10
|
+
assert(@cfg.interfaces == ["cs0", "lo0"],
|
11
|
+
"Failed to parse all interfaces")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_mac_parse
|
15
|
+
assert(@cfg['cs0'].mac == "08:00:2b:81:62:ca",
|
16
|
+
"Failed to parse MAC address: "+@cfg['cs0'].mac)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_flags
|
20
|
+
assert(@cfg['cs0'].flags.include?('BROADCAST') &&
|
21
|
+
@cfg['cs0'].flags.include?('RUNNING') &&
|
22
|
+
@cfg['cs0'].flags.include?('MULTICAST') &&
|
23
|
+
@cfg['cs0'].up?,
|
24
|
+
"FLAG Parsing failed: #{@cfg['cs0'].flags}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_addr_types
|
28
|
+
assert(@cfg['cs0'].addr_types.include?('inet') &&
|
29
|
+
@cfg['cs0'].addr_types.include?('inet6'),
|
30
|
+
"Failed to parse all address types")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_attribs
|
34
|
+
assert(@cfg['cs0'].rx['bytes'].class == Fixnum || NilClass &&
|
35
|
+
@cfg['cs0'].tx['bytes'].class == Fixnum || NilClass, "Wrong class")
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class TC_OpenBSDTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
sample = IO.readlines("#{File.dirname(__FILE__)}"+
|
6
|
+
'/../../ifconfig_examples/openbsd.txt').join
|
7
|
+
@cfg = IfconfigWrapper.new('BSD',sample).parse
|
8
|
+
end
|
9
|
+
def test_interface_list
|
10
|
+
assert(@cfg.interfaces == ["lo0", "lo1", "ep0", "xl0"],
|
11
|
+
"Failed to parse all interfaces")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_mac_parse
|
15
|
+
assert(@cfg['xl0'].mac == "00:01:02:c6:4b:3d",
|
16
|
+
"Failed to parse MAC address: "+@cfg['xl0'].mac)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_flags
|
20
|
+
assert(@cfg['xl0'].flags.include?('BROADCAST') &&
|
21
|
+
@cfg['xl0'].flags.include?('RUNNING') &&
|
22
|
+
@cfg['xl0'].flags.include?('MULTICAST') &&
|
23
|
+
@cfg['xl0'].up?,
|
24
|
+
"FLAG Parsing failed: #{@cfg['xl0'].flags}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_addr_types
|
28
|
+
assert(@cfg['xl0'].addr_types.include?('inet') &&
|
29
|
+
@cfg['xl0'].addr_types.include?('inet6'),
|
30
|
+
"Failed to parse all address types")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_attribs
|
34
|
+
assert(@cfg['xl0'].rx['bytes'].class == Fixnum || NilClass &&
|
35
|
+
@cfg['xl0'].tx['bytes'].class == Fixnum || NilClass, "Wrong class")
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class TC_SunOSTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
sample = IO.readlines("#{File.dirname(__FILE__)}"+
|
6
|
+
'/../../ifconfig_examples/sunos.txt').join
|
7
|
+
@@cfg = IfconfigWrapper.new('SunOS',sample).parse
|
8
|
+
end
|
9
|
+
def test_interface_list
|
10
|
+
assert(@@cfg.interfaces == ["le1", "lo0", "bge0"],
|
11
|
+
"Fauled to parse all interfaces")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_mac_parse
|
15
|
+
assert(@@cfg['bge0'].mac == "0:3:ba:42:9d:ef",
|
16
|
+
"Failed to parse MAC address: "+@@cfg['bge0'].mac)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_flags
|
20
|
+
assert(@@cfg['bge0'].flags.include?('BROADCAST') &&
|
21
|
+
@@cfg['bge0'].flags.include?('RUNNING') &&
|
22
|
+
@@cfg['bge0'].flags.include?('MULTICAST') &&
|
23
|
+
@@cfg['bge0'].up?,
|
24
|
+
"FLAG Parsing failed: #{@@cfg['bge0'].flags}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_addr_types
|
28
|
+
assert(@@cfg['bge0'].addr_types.include?('inet') &&
|
29
|
+
@@cfg['bge0'].addr_types.include?('inet6'),
|
30
|
+
"Failed to parse all address types")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_networks
|
34
|
+
assert(@@cfg['bge0'].addr_types.include?('inet') &&
|
35
|
+
@@cfg['bge0'].addr_types.include?('inet6'),
|
36
|
+
"Missing Address Types: #{@@cfg['bge0'].addr_types}")
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_attribs
|
40
|
+
assert(@@cfg['bge0'].rx['bytes'].class == Fixnum || NilClass&&
|
41
|
+
@@cfg['bge0'].tx['bytes'].class == Fixnum || NilClass, "Wrong class")
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aaalex-ruby-ifconfig
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Hobe
|
8
|
+
- Alex Peuchert
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2008-12-09 00:00:00 -08:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description: Ruby wrapper around the ifconfig command.
|
18
|
+
email: daniel@nightrunner.com
|
19
|
+
executables: []
|
20
|
+
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files:
|
24
|
+
- INSTALL
|
25
|
+
- README
|
26
|
+
- Changelog
|
27
|
+
- TODO
|
28
|
+
- COPYING
|
29
|
+
files:
|
30
|
+
- lib/ifconfig/sunos/interface_types.rb
|
31
|
+
- lib/ifconfig/sunos/ifconfig.rb
|
32
|
+
- lib/ifconfig/sunos/network_types.rb
|
33
|
+
- lib/ifconfig/bsd/interface_types.rb
|
34
|
+
- lib/ifconfig/bsd/ifconfig.rb
|
35
|
+
- lib/ifconfig/bsd/network_types.rb
|
36
|
+
- lib/ifconfig/linux/interface_types.rb
|
37
|
+
- lib/ifconfig/linux/ifconfig.rb
|
38
|
+
- lib/ifconfig/linux/network_types.rb
|
39
|
+
- lib/ifconfig/common/interface_types.rb
|
40
|
+
- lib/ifconfig/common/ifconfig.rb
|
41
|
+
- lib/ifconfig/common/network_types.rb
|
42
|
+
- lib/ifconfig.rb
|
43
|
+
- Rakefile
|
44
|
+
- INSTALL
|
45
|
+
- README
|
46
|
+
- Changelog
|
47
|
+
- TODO
|
48
|
+
- COPYING
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: http://github.com/aaalex/ruby-ifconfig
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options:
|
53
|
+
- --main
|
54
|
+
- README
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project: ruby-ifconfig
|
72
|
+
rubygems_version: 1.2.0
|
73
|
+
signing_key:
|
74
|
+
specification_version: 2
|
75
|
+
summary: This is a Ruby wrapper around the ifconfig command. The goal is to make getting any information that ifconfig provides easy to access.
|
76
|
+
test_files:
|
77
|
+
- test/test_dragonflybsd.rb
|
78
|
+
- test/test_openbsd.rb
|
79
|
+
- test/test_darwin.rb
|
80
|
+
- test/test_bsd.rb
|
81
|
+
- test/test_sunos.rb
|
82
|
+
- test/unit/tc_openbsd.rb
|
83
|
+
- test/unit/tc_dragonflybsd.rb
|
84
|
+
- test/unit/tc_linux.rb
|
85
|
+
- test/unit/tc_freebsd.rb
|
86
|
+
- test/unit/tc_netbsd.rb
|
87
|
+
- test/unit/tc_darwin.rb
|
88
|
+
- test/unit/tc_sunos.rb
|
89
|
+
- test/test_helper.rb
|
90
|
+
- test/test_netbsd.rb
|
91
|
+
- test/test_linux.rb
|
92
|
+
- ifconfig_examples/darwin.txt
|
93
|
+
- ifconfig_examples/dragonflybsd.txt
|
94
|
+
- ifconfig_examples/dragonflybsd_netstat.txt
|
95
|
+
- ifconfig_examples/netbsd.txt
|
96
|
+
- ifconfig_examples/freebsd_netstat.txt
|
97
|
+
- ifconfig_examples/linux.txt
|
98
|
+
- ifconfig_examples/linux_ethernet.txt
|
99
|
+
- ifconfig_examples/freebsd.txt
|
100
|
+
- ifconfig_examples/openbsd.txt
|
101
|
+
- ifconfig_examples/sunos.txt
|