vnstat-ruby 3.0.5 → 3.0.6

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: a0cf928d4d16436fc18a665373fa4450ca3bfc1e
4
- data.tar.gz: b01ff0e91b89a45f2ea72520715de1da30981d67
3
+ metadata.gz: 2214aef1d2fed1c199eb30e62fd0947193fb6f18
4
+ data.tar.gz: b5115aacbd68d2199faaec3bd2d7463ac10aaf97
5
5
  SHA512:
6
- metadata.gz: 4c871bb0d162d3cd890d37da503fca411b6f3c45e1fab3eb540267fa35a4743f3dee9ba912c9d3aefb6f79f56e6ef21009aed34d17ab20b90655fc36429ad138
7
- data.tar.gz: e80dc395530309fe51602b74b4e15f4e15f6cf20a3cf99c0d28700cf19bf85d53aed11a297b59fea1698429a98e0723e309b0bb4edb5a7a93fe799cdce5e3d7b
6
+ metadata.gz: 33bc77a79debce5a520715e4676daea648f96cf5f2c8c2f977f1b2369dc2f85492bb19a7ddf6de88c00465cdc1f940fe8a082a24f5bdd756fbf8a070382a3947
7
+ data.tar.gz: 6fe044b316ac36c11654846e22c0fe94ac349f79eed7fd486461718632f00b42bdc1d1f3e292c1c024db82f246a51c6c94e1e8aeea28dbec41d01ad967d0d641
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vnstat-ruby (3.0.5)
4
+ vnstat-ruby (3.0.6)
5
5
  nokogiri (~> 1.10, >= 1.10.4)
6
6
  systemcall (~> 1.0, >= 1.0.2)
7
7
 
data/README.md CHANGED
@@ -173,4 +173,4 @@ interface.tops[1].bytes_received # => 1024000
173
173
 
174
174
  ### Copyright
175
175
 
176
- Copyright (c) 2015-2017 Tobias Casper. See LICENSE.txt for further details.
176
+ Copyright (c) 2015-2020 Tobias Casper. See LICENSE.txt for further details.
@@ -48,7 +48,10 @@ module Vnstat
48
48
  #
49
49
  # @return [String]
50
50
  def version
51
- data.xpath('vnstat').attr('version').text
51
+ attr = data.xpath('vnstat').attr('version')
52
+ raise 'Unable to determine version' if attr.nil?
53
+
54
+ attr.text
52
55
  end
53
56
 
54
57
  ##
@@ -56,7 +59,10 @@ module Vnstat
56
59
  #
57
60
  # @return [String]
58
61
  def xml_version
59
- data.xpath('vnstat').attr('xmlversion').text
62
+ attr = data.xpath('vnstat').attr('xmlversion')
63
+ raise 'Unable to determine XML version' if attr.nil?
64
+
65
+ attr.text
60
66
  end
61
67
  end
62
68
  end
@@ -98,9 +98,10 @@ module Vnstat
98
98
 
99
99
  def interfaces_hash
100
100
  @interfaces_hash ||= begin
101
+ id_attr = xml_version == '2' ? :name : :id
101
102
  elements = data.xpath('//interface')
102
103
  elements.each_with_object({}) do |node, hash|
103
- id = node[:id]
104
+ id = node[id_attr]
104
105
  hash[id] = Interface.new(id, data)
105
106
  end
106
107
  end
@@ -33,7 +33,7 @@ module Vnstat
33
33
  # Extracts the date and time from the given XML element.
34
34
  #
35
35
  # @param [Nokogiri::XML::Element] element The XML element.
36
- # @return [DateTime]
36
+ # @return [Time]
37
37
  def extract_datetime_from_xml_element(element)
38
38
  date = extract_date_from_xml_element(element)
39
39
  hour = element.xpath('time/hour').text.to_i
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vnstat
4
- VERSION = '3.0.5'
4
+ VERSION = '3.0.6'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vnstat-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.5
4
+ version: 3.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Casper
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-01 00:00:00.000000000 Z
11
+ date: 2020-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri