snmp-open 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 118c73e3356d85cda27007ac7ada6ccb25e36af3
4
- data.tar.gz: a6bbbbddbb1792aa8fef75c308c988c57d74e8a6
3
+ metadata.gz: eb1bfb86bae4239a253fa4528be54e46a30e770d
4
+ data.tar.gz: 0574b00db365565c87e647314b00f34950ba8280
5
5
  SHA512:
6
- metadata.gz: c6d5f53dfcc6db0e2278926bf2cd1c86904a7575c9199f3f4a2c6e405d61c245b6d84887c0f8ca8ca7af19c4ab1639b76cc164118f6703f7fd0596749fe1e2bd
7
- data.tar.gz: 7986c9fdb242a009c384dd0be8824b73cd59f103b46502d7c142d6f863496c1983e6974f11dca2ffc2d8f3115951b624b092010b2b55196ea5a18e8765fd6858
6
+ metadata.gz: db49e2407897332554aae593b909bb74db5878a6b2f5f72779bfe6fdd1be116c2579226811bca87814c5f2ae3f55678c4a9ccbfcebd0157ccc918a4b48bea0b4
7
+ data.tar.gz: 98f0150f390faf0fe8f8cffb8e60c535aae051cda4bfa964900a4e2172449807c3e85fdcaccf9d2090c1a082084885a872d93402b423e6fa2abb94de797b086e
@@ -1,5 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.3.3
4
+ - 2.4.1
5
+ - 2.3.4
6
+ - 2.2.7
5
7
  before_install: gem install bundler -v 1.13.6
data/README.md CHANGED
@@ -36,6 +36,8 @@ end
36
36
 
37
37
  Naturally, configuration can also be supplied through `snmp.conf(5)`.
38
38
 
39
+ Environment variables can be given using the `env` keyword parameter to `SNMP::Open.new`. For example, the `SNMP_PERSISTENT_FILE` and `SNMPCONFPATH` variables are understood by Net-SNMP commands and indicate paths in which to look for configuration files.
40
+
39
41
  ## Development
40
42
 
41
43
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -30,7 +30,7 @@ module SNMP
30
30
  def get(oids)
31
31
  return enum_for(:get, oids) unless block_given?
32
32
  texts = oids.map { |oid| reader.capture(:get, oid) }
33
- Parser.new(oids).parse(texts).first.each { |arg| yield(arg) }
33
+ Parser.new(oids).parse(texts).fetch(0, []).each { |arg| yield(arg) }
34
34
  end
35
35
 
36
36
  # Perform an SNMP walk using the "snmpwalk" or "snmpbulkwalk" commands and
@@ -41,6 +41,7 @@ module SNMP
41
41
  # SNMP::Open.new(hostname => nil, '-t' => '3', '-m' => miblist)
42
42
  #
43
43
  def initialize(options)
44
+ @env = options.delete(:env)
44
45
  host = options.delete(:host) ||
45
46
  (raise ArgumentError, 'Host expected but not given')
46
47
  opts = merge_options(options).merge('-On' => nil, host => nil)
@@ -48,7 +49,11 @@ module SNMP
48
49
  end
49
50
 
50
51
  def capture(cmd, oid, options = {})
51
- out, err = Open3.capture3(cli(cmd, oid, options))
52
+ out, err = if @env
53
+ Open3.capture3(@env, cli(cmd, oid, options))
54
+ else
55
+ Open3.capture3(cli(cmd, oid, options))
56
+ end
52
57
  raise CommandError, err.chomp unless err.empty?
53
58
  out
54
59
  end
@@ -1,5 +1,5 @@
1
1
  module Snmp
2
2
  module Open
3
- VERSION = '0.1.5'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snmp-open
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Miller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-19 00:00:00.000000000 Z
11
+ date: 2017-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler