snmpjr 0.3.0-java → 0.3.1-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDY3NTgwYjc3ZTBlNDViODkyNzdiY2E4NzY5NWY3NjlhMjRhYzE0ZQ==
4
+ YTFjOWFjNzJhNTEwY2I0MjE0Njg3ODMwNzk0OGY2YWUyOGFkYzJhOA==
5
5
  data.tar.gz: !binary |-
6
- NDQzMjc5ZTcwYzY5ZmRjNTU2NzlkMzBiZGZiY2Q3ZGZkNjJiZGEyZg==
6
+ MjA1NzRhZTA5MTI0MWM3NWVjZWFkZDQ0YmFlODM4NTcwOTdmZTJlNw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDc5YzIzMWJkZGRmODI1OTU4NjQwZTdmOWZmYzU5MzRjMTc2YWQxZjYwYzQ0
10
- NWNlZDhlMDQ1MWU5ZDU0NTIyOWU5ZTA0ZGViYzVmNGIzYTU5YTVhMmFiNjli
11
- NjU0MDdkNDRiMWM2NmE5YjQ1ODJiMmIzNjc5Mjc5MDg0NzhhYWQ=
9
+ Yzc3ZmJiNWM2NGViNTE1ZTgzZGMzNmFmNjA3MWNlNmZhM2Y3ZGI0YzVjNTc5
10
+ MmJlZWI3YTVkYjkwZmE1MTFhNmM3Y2UzNWJkMDEwZjRjY2M1MTU2NGQxZjFk
11
+ ZWUzMDhlNWQ1NTEzOGI0YmRmMzdmZTcxNWEzMDI0NTY2YzA1YzI=
12
12
  data.tar.gz: !binary |-
13
- OTdkZDdhZjU3NzJiNjRmNjRhYWNkYjVkMzM1Mzk2MmE3YmFiZjM2ZmRiMDNi
14
- MTQzYTI5ZmVmZTZlZjJmYjkwOWJiOGM1NjJkN2ExNzhhNWQ5OTIzNDlhYTg0
15
- NGM5ODNhY2QxMDczZDM4ZWE3MzYwMDhiMzlmMWEyODA4OGU1MTA=
13
+ M2YwNmFjMDJjMWEzZDJmNjEwMzlhMDA3YzYxNjRkYzJlZWU1NDBiYzhjZDQ5
14
+ ZWY2ZGViODdhZmFhNmJiMDMxODRkMTBkMGJhNTU3N2IyY2RlNjdkNWYxYmYy
15
+ NjQ2OTY2MjJiYWM0YzRiZmEyOTJlY2M4OTFkZTAwNDkyYTNlNmQ=
data/.semver CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 3
4
- :patch: '0'
4
+ :patch: 1
5
5
  :special: ''
6
6
  :metadata: ''
data/history.rdoc CHANGED
@@ -1,3 +1,5 @@
1
+ == v0.3.1 (02 December 2014)
2
+
1
3
  == v0.3.0 (01 December 2014)
2
4
 
3
5
  == v0.2.2 (03 November 2014)
data/lib/snmpjr/getter.rb CHANGED
@@ -9,11 +9,12 @@ class Snmpjr
9
9
  end
10
10
 
11
11
  def get oids
12
+ #TODO: Change it to be a session do end block
12
13
  @session.start
13
14
  begin
14
- results = oids.each_slice(@max_oids_per_request).map{|partial_oids|
15
+ results = oids.each_slice(@max_oids_per_request).flat_map{|partial_oids|
15
16
  get_request partial_oids
16
- }.flatten
17
+ }
17
18
  ensure
18
19
  @session.close
19
20
  end
@@ -7,18 +7,21 @@ class Snmpjr
7
7
  GET = -96
8
8
  end
9
9
 
10
- def initialize
11
- @pdu = Snmpjr::Wrappers::PDU.new
12
- end
13
-
14
10
  def create oids
11
+ pdu = create_new_pdu
15
12
  oids.map {|oid|
16
13
  oid = Snmpjr::Wrappers::SMI::OID.new oid
17
14
  variable_binding = Snmpjr::Wrappers::SMI::VariableBinding.new oid
18
- @pdu.add variable_binding
15
+ pdu.add variable_binding
19
16
  }
20
- @pdu.type = Snmpjr::PduV2C::Constants::GET
21
- @pdu
17
+ pdu.type = Snmpjr::PduV2C::Constants::GET
18
+ pdu
19
+ end
20
+
21
+ private
22
+
23
+ def create_new_pdu
24
+ Snmpjr::Wrappers::PDU.new
22
25
  end
23
26
 
24
27
  end
data/lib/snmpjr/pdu_v3.rb CHANGED
@@ -6,8 +6,15 @@ class Snmpjr
6
6
  class PduV3 < Snmpjr::PduV2C
7
7
 
8
8
  def initialize context = ''
9
- @pdu = Snmpjr::Wrappers::ScopedPDU.new
10
- @pdu.context_name = Snmpjr::Wrappers::SMI::OctetString.new(context)
9
+ @context_name = Snmpjr::Wrappers::SMI::OctetString.new(context)
10
+ end
11
+
12
+ private
13
+
14
+ def create_new_pdu
15
+ pdu = Snmpjr::Wrappers::ScopedPDU.new
16
+ pdu.context_name = @context_name
17
+ pdu
11
18
  end
12
19
 
13
20
  end
data/snmpjr.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'snmpjr/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'snmpjr'
8
- spec.version = '0.3.0'
8
+ spec.version = '0.3.1'
9
9
  spec.authors = ['Zen Kyprianou']
10
10
  spec.email = ['zen@kyprianou.eu']
11
11
  spec.summary = 'Simple SNMP interface for JRuby'
@@ -48,6 +48,21 @@ describe Snmpjr::Getter do
48
48
  end
49
49
  end
50
50
 
51
+ context 'when there is an uneven split of slices' do
52
+ before do
53
+ configuration.max_oids_per_request = 2
54
+ allow(pdu).to receive(:create).with(['1.2.3.4.5.6', '2.3.4.5.6.7']).and_return created_pdu_multiple_1
55
+ allow(pdu).to receive(:create).with(['6.5.4.3.2.1']).and_return created_pdu_multiple_2
56
+ allow(session).to receive(:send).with(created_pdu_multiple_1, target).and_return ['Foo', 'Baz']
57
+ end
58
+
59
+ it 'should not have duplicate results' do
60
+ expect(subject.get ['1.2.3.4.5.6', '2.3.4.5.6.7', '6.5.4.3.2.1']).to eq(['Foo', 'Baz', 'Bar'])
61
+ expect(session).to have_received(:send).with(created_pdu_multiple_1, target)
62
+ expect(session).to have_received(:send).with(created_pdu_multiple_2, target)
63
+ end
64
+ end
65
+
51
66
  it 'starts an snmp session' do
52
67
  subject.get ['1.2.3.4.5.6', '6.5.4.3.2.1']
53
68
  expect(session).to have_received(:start)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snmpjr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: java
6
6
  authors:
7
7
  - Zen Kyprianou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-01 00:00:00.000000000 Z
11
+ date: 2014-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-n-bake