network-utility 1.1.23 → 1.1.24
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.
- checksums.yaml +4 -4
- data/network.rb +5 -1
- data/support/snmp.rb +36 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cb5f03d9092ba5cbdf265169d19f06e124b6c8ebdfcb42c03c1d04176417bbfe
|
|
4
|
+
data.tar.gz: 7ba4c50e0d0a307e490c83101fe493c69d78f8ff59b113ad1fe440fc518ecbf2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ac2a99c8f158a0aeed479261bc8fea3d150205ca36ead67bbf2d8ef9035158f9c232d769b6f28d3ddde700641e71de89f8574c5e934c4ce06fe121d7174257f2
|
|
7
|
+
data.tar.gz: 823ff7f38258b244cc590c688c93f453b722e78c01cb08c401cce296754acd0fa0d91d68da21b6fcc3ff4dfa2dffc6b5bd89aed522a44d39c49274604a6d4817
|
data/network.rb
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
'whitelist'
|
|
10
10
|
].each{|mod|require "utility/#{mod}"}
|
|
11
11
|
|
|
12
|
+
[
|
|
13
|
+
'snmp'
|
|
14
|
+
].each{|mod|require "support/#{mod}"}
|
|
15
|
+
|
|
12
16
|
[
|
|
13
17
|
'document'
|
|
14
18
|
].each{|mod|require "document/#{mod}"}
|
|
@@ -18,5 +22,5 @@
|
|
|
18
22
|
].each{|mod|require mod}
|
|
19
23
|
|
|
20
24
|
module Network
|
|
21
|
-
VERSION = '1.1.
|
|
25
|
+
VERSION = '1.1.24'
|
|
22
26
|
end
|
data/support/snmp.rb
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#coding:utf-8
|
|
2
|
+
|
|
3
|
+
module SNMP
|
|
4
|
+
module Resolve
|
|
5
|
+
module_function
|
|
6
|
+
|
|
7
|
+
def file path, rtype=:tree
|
|
8
|
+
self.parse(File.read(path).split("\n"), rtype)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def parse texts, rtype=:tree
|
|
12
|
+
list = texts.reduce([])do|list, line|
|
|
13
|
+
if line.include?('=') && line.include?(': ')
|
|
14
|
+
list << line
|
|
15
|
+
else
|
|
16
|
+
list[-1] += "\n#{line}"
|
|
17
|
+
end
|
|
18
|
+
list
|
|
19
|
+
end
|
|
20
|
+
result_list = list.map do|line|
|
|
21
|
+
head, tail = line.split('=')
|
|
22
|
+
type, val = tail.to_s.split(': ')
|
|
23
|
+
[(head[0]=='.' ? head[1..-1] : head).strip, type.to_s.strip, val.to_s.strip]
|
|
24
|
+
end
|
|
25
|
+
return result_list if rtype==:list
|
|
26
|
+
result_tree = result_list.reduce({}){|tree,term|tree[term.first]=term;tree}
|
|
27
|
+
if rtype==:tree
|
|
28
|
+
return result_tree
|
|
29
|
+
elsif rtype==:all
|
|
30
|
+
return result_list, result_tree
|
|
31
|
+
else
|
|
32
|
+
return [], {}
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: network-utility
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.24
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt
|
|
@@ -218,6 +218,7 @@ files:
|
|
|
218
218
|
- document/system-NE80E.md
|
|
219
219
|
- document/telnet.md
|
|
220
220
|
- network.rb
|
|
221
|
+
- support/snmp.rb
|
|
221
222
|
- utility/ipv4_address.rb
|
|
222
223
|
- utility/ipv6_address.rb
|
|
223
224
|
- utility/mac_address.rb
|