vnstat-ruby 1.0.5 → 1.1.0

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.
@@ -1,12 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - '1.9.3'
4
3
  - '2.0.0'
5
4
  - '2.1.7'
6
5
  - '2.2.3'
7
- - jruby
8
- - jruby-head
9
- - rbx-2
6
+ - '2.3.1'
7
+ - '2.4.1'
10
8
  script: bundle exec rspec
11
9
  addons:
12
10
  code_climate:
data/Gemfile CHANGED
@@ -3,9 +3,10 @@ source 'http://rubygems.org'
3
3
  gem 'nokogiri', '~> 1.6'
4
4
 
5
5
  group :development do
6
- gem 'rspec', '~> 3.0'
7
- gem 'yard', '~> 0'
8
6
  gem 'bundler', '~> 1.0'
7
+ gem 'codeclimate-test-reporter', '0.6.0', require: false
9
8
  gem 'jeweler', '~> 2.0', '>= 2.0.1'
10
- gem 'codeclimate-test-reporter', '~> 0', require: false
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'rubocop', '~> 0'
11
+ gem 'yard', '~> 0'
11
12
  end
@@ -1,9 +1,11 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- addressable (2.3.8)
5
- builder (3.2.2)
6
- codeclimate-test-reporter (0.4.8)
4
+ addressable (2.5.1)
5
+ public_suffix (~> 2.0, >= 2.0.2)
6
+ ast (2.3.0)
7
+ builder (3.2.3)
8
+ codeclimate-test-reporter (0.6.0)
7
9
  simplecov (>= 0.7.1, < 1.0.0)
8
10
  descendants_tracker (0.0.4)
9
11
  thread_safe (~> 0.3, >= 0.3.1)
@@ -11,43 +13,50 @@ GEM
11
13
  docile (1.1.5)
12
14
  faraday (0.9.2)
13
15
  multipart-post (>= 1.2, < 3)
14
- git (1.2.9.1)
15
- github_api (0.12.4)
16
+ git (1.3.0)
17
+ github_api (0.11.3)
16
18
  addressable (~> 2.3)
17
- descendants_tracker (~> 0.0.4)
19
+ descendants_tracker (~> 0.0.1)
18
20
  faraday (~> 0.8, < 0.10)
19
- hashie (>= 3.4)
21
+ hashie (>= 1.2)
20
22
  multi_json (>= 1.7.5, < 2.0)
21
- nokogiri (~> 1.6.6)
23
+ nokogiri (~> 1.6.0)
22
24
  oauth2
23
- hashie (3.4.2)
25
+ hashie (3.5.5)
24
26
  highline (1.7.8)
25
- jeweler (2.0.1)
27
+ jeweler (2.1.2)
26
28
  builder
27
29
  bundler (>= 1.0)
28
30
  git (>= 1.2.5)
29
- github_api
31
+ github_api (~> 0.11.0)
30
32
  highline (>= 1.6.15)
31
33
  nokogiri (>= 1.5.10)
32
34
  rake
33
35
  rdoc
34
- json (1.8.3)
35
- jwt (1.5.1)
36
- mini_portile (0.6.2)
37
- multi_json (1.11.2)
38
- multi_xml (0.5.5)
36
+ semver
37
+ json (2.1.0)
38
+ jwt (1.5.6)
39
+ mini_portile2 (2.1.0)
40
+ multi_json (1.12.1)
41
+ multi_xml (0.6.0)
39
42
  multipart-post (2.0.0)
40
- nokogiri (1.6.6.2)
41
- mini_portile (~> 0.6.0)
42
- oauth2 (1.0.0)
43
- faraday (>= 0.8, < 0.10)
43
+ nokogiri (1.6.8.1)
44
+ mini_portile2 (~> 2.1.0)
45
+ oauth2 (1.3.1)
46
+ faraday (>= 0.8, < 0.12)
44
47
  jwt (~> 1.0)
45
48
  multi_json (~> 1.3)
46
49
  multi_xml (~> 0.5)
47
- rack (~> 1.2)
48
- rack (1.6.4)
49
- rake (10.4.2)
50
- rdoc (4.2.0)
50
+ rack (>= 1.2, < 3)
51
+ parser (2.4.0.0)
52
+ ast (~> 2.2)
53
+ powerpack (0.1.1)
54
+ public_suffix (2.0.5)
55
+ rack (1.6.5)
56
+ rainbow (2.2.2)
57
+ rake
58
+ rake (12.0.0)
59
+ rdoc (5.1.0)
51
60
  rspec (3.3.0)
52
61
  rspec-core (~> 3.3.0)
53
62
  rspec-expectations (~> 3.3.0)
@@ -61,24 +70,34 @@ GEM
61
70
  diff-lcs (>= 1.2.0, < 2.0)
62
71
  rspec-support (~> 3.3.0)
63
72
  rspec-support (3.3.0)
64
- simplecov (0.10.0)
73
+ rubocop (0.48.1)
74
+ parser (>= 2.3.3.1, < 3.0)
75
+ powerpack (~> 0.1)
76
+ rainbow (>= 1.99.1, < 3.0)
77
+ ruby-progressbar (~> 1.7)
78
+ unicode-display_width (~> 1.0, >= 1.0.1)
79
+ ruby-progressbar (1.8.1)
80
+ semver (1.0.1)
81
+ simplecov (0.14.1)
65
82
  docile (~> 1.1.0)
66
- json (~> 1.8)
83
+ json (>= 1.8, < 3)
67
84
  simplecov-html (~> 0.10.0)
68
85
  simplecov-html (0.10.0)
69
- thread_safe (0.3.5)
70
- yard (0.8.7.6)
86
+ thread_safe (0.3.6)
87
+ unicode-display_width (1.2.1)
88
+ yard (0.9.9)
71
89
 
72
90
  PLATFORMS
73
91
  ruby
74
92
 
75
93
  DEPENDENCIES
76
94
  bundler (~> 1.0)
77
- codeclimate-test-reporter (~> 0)
95
+ codeclimate-test-reporter (= 0.6.0)
78
96
  jeweler (~> 2.0, >= 2.0.1)
79
97
  nokogiri (~> 1.6)
80
98
  rspec (~> 3.0)
99
+ rubocop (~> 0)
81
100
  yard (~> 0)
82
101
 
83
102
  BUNDLED WITH
84
- 1.10.6
103
+ 1.14.6
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # vnstat-ruby
2
2
 
3
- [![Code Climate](https://codeclimate.com/github/tlux/vnstat-ruby/badges/gpa.svg)](https://codeclimate.com/github/tlux/vnstat-ruby) [![Test Coverage](https://codeclimate.com/github/tlux/vnstat-ruby/badges/coverage.svg)](https://codeclimate.com/github/tlux/vnstat-ruby/coverage) [![Build Status](https://travis-ci.org/tlux/vnstat-ruby.svg?branch=master)](https://travis-ci.org/tlux/vnstat-ruby)
3
+ [![Code Climate](https://codeclimate.com/github/tlux/vnstat-ruby/badges/gpa.svg)](https://codeclimate.com/github/tlux/vnstat-ruby)
4
+ [![Test Coverage](https://codeclimate.com/github/tlux/vnstat-ruby/badges/coverage.svg)](https://codeclimate.com/github/tlux/vnstat-ruby/coverage)
5
+ [![Build Status](https://travis-ci.org/tlux/vnstat-ruby.svg?branch=master)](https://travis-ci.org/tlux/vnstat-ruby)
6
+ [![Gem Version](https://badge.fury.io/rb/vnstat-ruby.svg)](https://badge.fury.io/rb/vnstat-ruby)
4
7
 
5
8
  Vnstat is a tool that tracks the traffic on your network interfaces.
6
9
  This tiny library is intended to provide network traffic information
@@ -10,24 +13,12 @@ It depends on the
10
13
  [vnstat command line utility](http://humdi.net/vnstat/) which is
11
14
  maintained by Teemu Toivola.
12
15
 
13
-
14
16
  ### Prerequisites
15
17
 
16
- You need one of the following Ruby versions installed to run the gem:
17
-
18
- * Ruby >= 1.9.3
19
- * JRuby
20
- * Rubinius >= 2
21
-
22
- Also make sure you have the vnstat CLI installed by running `which vnstat`.
23
-
24
- If the executable was not found, you are able to obtain the vnstat package
25
- via aptitude (or a similar package manager):
26
-
27
- ```bash
28
- apt-get install vnstat
29
- ```
18
+ * Ruby 2.0.0 or greater
19
+ * Make sure you have `vnstat` CLI installed by running `which vnstat`.
30
20
 
21
+ On Ubuntu you can get the vnstat package via `apt-get install vnstat`.
31
22
 
32
23
  ### Getting Started
33
24
 
@@ -183,5 +174,4 @@ interface.tops[1].bytes_received # => 1024000
183
174
 
184
175
  ### Copyright
185
176
 
186
- Copyright (c) 2015 Tobias Casper. See LICENSE.txt for
187
- further details.
177
+ Copyright (c) 2015-2017 Tobias Casper. See LICENSE.txt for further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.5
1
+ 1.1.0
@@ -26,7 +26,7 @@ module Vnstat
26
26
  # @return [String]
27
27
  def executable_path
28
28
  @executable_path ||= Utils.system_call('which', 'vnstat') do
29
- fail ExecutableNotFound, 'Unable to locate vnstat executable'
29
+ raise ExecutableNotFound, 'Unable to locate vnstat executable'
30
30
  end
31
31
  end
32
32
 
@@ -21,8 +21,8 @@ module Vnstat
21
21
  # A hook used by {.open} that is intended to be overridden by subclasses.
22
22
  #
23
23
  # @raise [NotImplementedError]
24
- def self.load_data(*args)
25
- fail NotImplementedError, "Please override #{name}.#{__method__}"
24
+ def self.load_data(*_args)
25
+ raise NotImplementedError, "Please override #{name}.#{__method__}"
26
26
  end
27
27
 
28
28
  attr_reader :data
@@ -33,7 +33,7 @@ module Vnstat
33
33
  # @param [String] data A string representing the document.
34
34
  # @raise [ArgumentError] Raised if the specified data was nil.
35
35
  def data=(data)
36
- fail ArgumentError, 'No document data specified' if data.nil?
36
+ raise ArgumentError, 'No document data specified' if data.nil?
37
37
  @data = Nokogiri::XML.parse(data.to_s)
38
38
  end
39
39
 
@@ -82,14 +82,16 @@ module Vnstat
82
82
  success = Utils.call_executable_returning_status(
83
83
  '-i', id, '--nick', nick, '--update'
84
84
  )
85
- fail Error, "Unable to set nickname for interface (#{id}). " \
86
- 'Please make sure the vnstat daemon is not running while ' \
87
- 'performing this operation.' unless success
85
+ unless success
86
+ raise Error, "Unable to set nickname for interface (#{id}). " \
87
+ 'Please make sure the vnstat daemon is not running while ' \
88
+ 'performing this operation.'
89
+ end
88
90
  @nick = nick
89
91
  end
90
92
 
91
- alias_method :name, :nick
92
- alias_method :name=, :nick=
93
+ alias name nick
94
+ alias name= nick=
93
95
 
94
96
  ##
95
97
  # The date on which tracking of the interface began.
@@ -47,8 +47,8 @@ module Vnstat
47
47
  # @return [Interface]
48
48
  def [](id)
49
49
  interfaces_hash.fetch(id.to_s) do
50
- fail UnknownInterface.new(id.to_s),
51
- "Unknown interface: #{id}"
50
+ raise UnknownInterface.new(id.to_s),
51
+ "Unknown interface: #{id}"
52
52
  end
53
53
  end
54
54
 
@@ -33,7 +33,11 @@ module Vnstat
33
33
  def self.extract_from_xml_element(element)
34
34
  date = Parser.extract_date_from_xml_element(element)
35
35
  hour = Integer(element.attr('id').to_s)
36
- new(date, hour, *Parser.extract_transmitted_bytes_from_xml_element(element))
36
+ new(
37
+ date,
38
+ hour,
39
+ *Parser.extract_transmitted_bytes_from_xml_element(element)
40
+ )
37
41
  end
38
42
 
39
43
  ##
@@ -68,7 +68,7 @@ module Vnstat
68
68
  # @raise [RuntimeError] Raises when the command has not yet been called.
69
69
  # @return [true, false]
70
70
  def success?
71
- fail 'Command not invoked' unless called?
71
+ raise 'Command not invoked' unless called?
72
72
  exit_status.success?
73
73
  end
74
74
 
@@ -20,7 +20,7 @@ module Vnstat
20
20
  when 1 then args.first
21
21
  when 3 then Date.new(*args)
22
22
  else
23
- fail ArgumentError, 'wrong number of arguments ' \
23
+ raise ArgumentError, 'wrong number of arguments ' \
24
24
  "(#{args.count} for 1 or 3)"
25
25
  end
26
26
  entries_hash[date]
@@ -24,7 +24,7 @@ module Vnstat
24
24
  when 2 then args.first
25
25
  when 4 then Date.new(*args)
26
26
  else
27
- fail ArgumentError, 'wrong number of arguments ' \
27
+ raise ArgumentError, 'wrong number of arguments ' \
28
28
  "(#{args_count} for 2 or 4)"
29
29
  end
30
30
  entries_hash[[date, hour]]
@@ -29,7 +29,7 @@ describe Vnstat::Document do
29
29
  end
30
30
 
31
31
  it 'changes #data' do
32
- expect { subject.data = '<vnstat />' }.to change { subject.data }
32
+ expect { subject.data = '<vnstat />' }.to(change { subject.data })
33
33
  end
34
34
 
35
35
  it 'stores the XML fragment in #data' do
@@ -45,7 +45,7 @@ describe Vnstat::InterfaceCollection do
45
45
 
46
46
  describe '#ids' do
47
47
  it 'returns interface names from the data' do
48
- expect(subject.ids).to eq %w(eth0 wlan0)
48
+ expect(subject.ids).to eq %w[eth0 wlan0]
49
49
  end
50
50
  end
51
51
 
@@ -153,7 +153,8 @@ describe Vnstat::InterfaceCollection do
153
153
  allow(described_class).to receive(:load_data).and_return('<test />')
154
154
  end
155
155
 
156
- context 'when Vnstat::Utils.call_executable_returning_status returns true' do
156
+ context 'when Vnstat::Utils.call_executable_returning_status ' \
157
+ 'returns true' do
157
158
  before :each do
158
159
  allow(Vnstat::Utils)
159
160
  .to receive(:call_executable_returning_status)
@@ -171,7 +172,8 @@ describe Vnstat::InterfaceCollection do
171
172
  end
172
173
  end
173
174
 
174
- context 'when Vnstat::Utils.call_executable_returning_status returns false' do
175
+ context 'when Vnstat::Utils.call_executable_returning_status ' \
176
+ 'returns false' do
175
177
  before :each do
176
178
  allow(Vnstat::Utils)
177
179
  .to receive(:call_executable_returning_status)
@@ -106,7 +106,7 @@ describe Vnstat::Interface do
106
106
  end
107
107
  end
108
108
 
109
- %w(nick name).each do |method_name|
109
+ %w[nick name].each do |method_name|
110
110
  describe "##{method_name}" do
111
111
  it 'returns value from the nick node' do
112
112
  expect(subject.public_send(method_name)).to eq 'Ethernet'
@@ -151,7 +151,7 @@ describe Vnstat::Interface do
151
151
 
152
152
  describe '#updated_at' do
153
153
  it 'returns the DateTime from the updated node in the correct time zone' do
154
- time = DateTime.new(2015, 10, 21, 22, 58, 00, DateTime.now.offset)
154
+ time = DateTime.new(2015, 10, 21, 22, 58, 0o0, DateTime.now.offset)
155
155
 
156
156
  expect(subject.updated_at).to eq time
157
157
  end
@@ -264,7 +264,7 @@ describe Vnstat::Interface do
264
264
  end
265
265
 
266
266
  [true, false].each do |expected|
267
- context "when Vnstat::Utils.call_executable_returning_status " \
267
+ context 'when Vnstat::Utils.call_executable_returning_status ' \
268
268
  "returns #{expected}" do
269
269
  before :each do
270
270
  allow(Vnstat::Utils).to receive(:call_executable_returning_status)
@@ -22,7 +22,7 @@ describe Vnstat::Result::Minute do
22
22
  it { is_expected.to be_a described_class }
23
23
 
24
24
  it 'initializes with the correct #time with the system time zone' do
25
- time = DateTime.new(2015, 2, 3, 12, 34, 00, DateTime.now.offset)
25
+ time = DateTime.new(2015, 2, 3, 12, 34, 0o0, DateTime.now.offset)
26
26
 
27
27
  expect(subject.time).to eq time
28
28
  end
@@ -62,7 +62,7 @@ describe Vnstat::Result do
62
62
  let(:other) { double(bytes_transmitted: 4000) }
63
63
 
64
64
  it 'returns -1' do
65
- expect(subject <=> other).to eq -1
65
+ expect(subject <=> other).to eq(-1)
66
66
  end
67
67
  end
68
68
 
@@ -1,5 +1,5 @@
1
1
  describe Vnstat::SystemCall do
2
- let(:args) { ['test', 'test2', 'test3'] }
2
+ let(:args) { %w[test test2 test3] }
3
3
 
4
4
  describe '#initialize' do
5
5
  context 'when arguments are anything' do
@@ -32,7 +32,7 @@ describe Vnstat::SystemCall do
32
32
  described_class.call('test')
33
33
  end
34
34
 
35
- it "returns result of #call" do
35
+ it 'returns result of #call' do
36
36
  allow_any_instance_of(described_class)
37
37
  .to receive(:call).and_return('test')
38
38
 
@@ -2,7 +2,9 @@ describe Vnstat::Utils do
2
2
  let(:executable_path) { '/any/path' }
3
3
 
4
4
  before :each do
5
- allow(Vnstat.config).to receive(:executable_path).and_return(executable_path)
5
+ allow(Vnstat.config)
6
+ .to receive(:executable_path)
7
+ .and_return(executable_path)
6
8
  end
7
9
 
8
10
  describe '.system_call' do
@@ -93,7 +95,7 @@ describe Vnstat::Utils do
93
95
  end
94
96
 
95
97
  describe '.call_executable' do
96
- let(:block) { Proc.new {} }
98
+ let(:block) { proc {} }
97
99
 
98
100
  it 'calls .system_call using vnstat executable' do
99
101
  expect(described_class).to receive(:system_call)
@@ -2,18 +2,18 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: vnstat-ruby 1.0.5 ruby lib
5
+ # stub: vnstat-ruby 1.1.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
- s.name = "vnstat-ruby"
9
- s.version = "1.0.5"
8
+ s.name = "vnstat-ruby".freeze
9
+ s.version = "1.1.0"
10
10
 
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
- s.authors = ["Tobias Casper"]
14
- s.date = "2015-11-28"
15
- s.description = "Uses the the vnstat CLI to track your network traffic."
16
- s.email = "tobias.casper@gmail.com"
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Tobias Casper".freeze]
14
+ s.date = "2017-04-27"
15
+ s.description = "Uses the the vnstat CLI to track your network traffic.".freeze
16
+ s.email = "tobias.casper@gmail.com".freeze
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE.txt",
19
19
  "README.md"
@@ -78,36 +78,39 @@ Gem::Specification.new do |s|
78
78
  "spec/support/shared_examples/shared_examples_for_traffic_collection.rb",
79
79
  "vnstat-ruby.gemspec"
80
80
  ]
81
- s.homepage = "http://github.com/tlux/vnstat-ruby"
82
- s.licenses = ["MIT"]
83
- s.rubygems_version = "2.4.5.1"
84
- s.summary = "A Ruby wrapper for vnstat."
81
+ s.homepage = "http://github.com/tlux/vnstat-ruby".freeze
82
+ s.licenses = ["MIT".freeze]
83
+ s.rubygems_version = "2.6.11".freeze
84
+ s.summary = "A Ruby wrapper for vnstat.".freeze
85
85
 
86
86
  if s.respond_to? :specification_version then
87
87
  s.specification_version = 4
88
88
 
89
89
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
90
- s.add_runtime_dependency(%q<nokogiri>, ["~> 1.6"])
91
- s.add_development_dependency(%q<rspec>, ["~> 3.0"])
92
- s.add_development_dependency(%q<yard>, ["~> 0"])
93
- s.add_development_dependency(%q<bundler>, ["~> 1.0"])
94
- s.add_development_dependency(%q<jeweler>, [">= 2.0.1", "~> 2.0"])
95
- s.add_development_dependency(%q<codeclimate-test-reporter>, ["~> 0"])
90
+ s.add_runtime_dependency(%q<nokogiri>.freeze, ["~> 1.6"])
91
+ s.add_development_dependency(%q<bundler>.freeze, ["~> 1.0"])
92
+ s.add_development_dependency(%q<codeclimate-test-reporter>.freeze, ["= 0.6.0"])
93
+ s.add_development_dependency(%q<jeweler>.freeze, [">= 2.0.1", "~> 2.0"])
94
+ s.add_development_dependency(%q<rspec>.freeze, ["~> 3.0"])
95
+ s.add_development_dependency(%q<rubocop>.freeze, ["~> 0"])
96
+ s.add_development_dependency(%q<yard>.freeze, ["~> 0"])
96
97
  else
97
- s.add_dependency(%q<nokogiri>, ["~> 1.6"])
98
- s.add_dependency(%q<rspec>, ["~> 3.0"])
99
- s.add_dependency(%q<yard>, ["~> 0"])
100
- s.add_dependency(%q<bundler>, ["~> 1.0"])
101
- s.add_dependency(%q<jeweler>, [">= 2.0.1", "~> 2.0"])
102
- s.add_dependency(%q<codeclimate-test-reporter>, ["~> 0"])
98
+ s.add_dependency(%q<nokogiri>.freeze, ["~> 1.6"])
99
+ s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
100
+ s.add_dependency(%q<codeclimate-test-reporter>.freeze, ["= 0.6.0"])
101
+ s.add_dependency(%q<jeweler>.freeze, [">= 2.0.1", "~> 2.0"])
102
+ s.add_dependency(%q<rspec>.freeze, ["~> 3.0"])
103
+ s.add_dependency(%q<rubocop>.freeze, ["~> 0"])
104
+ s.add_dependency(%q<yard>.freeze, ["~> 0"])
103
105
  end
104
106
  else
105
- s.add_dependency(%q<nokogiri>, ["~> 1.6"])
106
- s.add_dependency(%q<rspec>, ["~> 3.0"])
107
- s.add_dependency(%q<yard>, ["~> 0"])
108
- s.add_dependency(%q<bundler>, ["~> 1.0"])
109
- s.add_dependency(%q<jeweler>, [">= 2.0.1", "~> 2.0"])
110
- s.add_dependency(%q<codeclimate-test-reporter>, ["~> 0"])
107
+ s.add_dependency(%q<nokogiri>.freeze, ["~> 1.6"])
108
+ s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
109
+ s.add_dependency(%q<codeclimate-test-reporter>.freeze, ["= 0.6.0"])
110
+ s.add_dependency(%q<jeweler>.freeze, [">= 2.0.1", "~> 2.0"])
111
+ s.add_dependency(%q<rspec>.freeze, ["~> 3.0"])
112
+ s.add_dependency(%q<rubocop>.freeze, ["~> 0"])
113
+ s.add_dependency(%q<yard>.freeze, ["~> 0"])
111
114
  end
112
115
  end
113
116