vnstat-ruby 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +49 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -5
- data/Gemfile +4 -10
- data/Gemfile.lock +29 -75
- data/LICENSE.txt +18 -17
- data/README.md +1 -3
- data/Rakefile +4 -25
- data/lib/vnstat-ruby.rb +2 -0
- data/lib/vnstat.rb +17 -2
- data/lib/vnstat/configuration.rb +4 -2
- data/lib/vnstat/document.rb +6 -1
- data/lib/vnstat/error.rb +2 -0
- data/lib/vnstat/errors/executable_not_found.rb +2 -0
- data/lib/vnstat/errors/unknown_interface.rb +2 -0
- data/lib/vnstat/interface.rb +4 -1
- data/lib/vnstat/interface_collection.rb +2 -0
- data/lib/vnstat/parser.rb +4 -2
- data/lib/vnstat/result.rb +8 -5
- data/lib/vnstat/result/date_delegation.rb +2 -0
- data/lib/vnstat/result/day.rb +4 -1
- data/lib/vnstat/result/hour.rb +6 -2
- data/lib/vnstat/result/minute.rb +5 -2
- data/lib/vnstat/result/month.rb +6 -2
- data/lib/vnstat/result/time_comparable.rb +2 -0
- data/lib/vnstat/system_call.rb +10 -7
- data/lib/vnstat/traffic.rb +2 -0
- data/lib/vnstat/traffic/base.rb +2 -0
- data/lib/vnstat/traffic/daily.rb +2 -0
- data/lib/vnstat/traffic/hourly.rb +2 -0
- data/lib/vnstat/traffic/monthly.rb +2 -0
- data/lib/vnstat/traffic/tops.rb +2 -0
- data/lib/vnstat/utils.rb +2 -0
- data/lib/vnstat/version.rb +5 -0
- data/vnstat-ruby.gemspec +36 -109
- metadata +27 -65
- data/.codeclimate.yml +0 -14
- data/spec/lib/vnstat/configuration_spec.rb +0 -72
- data/spec/lib/vnstat/document_spec.rb +0 -54
- data/spec/lib/vnstat/errors/executable_not_found_spec.rb +0 -5
- data/spec/lib/vnstat/errors/unknown_interface_spec.rb +0 -5
- data/spec/lib/vnstat/interface_collection_spec.rb +0 -194
- data/spec/lib/vnstat/interface_spec.rb +0 -327
- data/spec/lib/vnstat/result/day_spec.rb +0 -39
- data/spec/lib/vnstat/result/hour_spec.rb +0 -43
- data/spec/lib/vnstat/result/minute_spec.rb +0 -54
- data/spec/lib/vnstat/result/month_spec.rb +0 -39
- data/spec/lib/vnstat/result_spec.rb +0 -86
- data/spec/lib/vnstat/system_call_spec.rb +0 -209
- data/spec/lib/vnstat/traffic/daily_spec.rb +0 -109
- data/spec/lib/vnstat/traffic/hourly_spec.rb +0 -153
- data/spec/lib/vnstat/traffic/monthly_spec.rb +0 -46
- data/spec/lib/vnstat/traffic/tops_spec.rb +0 -48
- data/spec/lib/vnstat/utils_spec.rb +0 -130
- data/spec/lib/vnstat_spec.rb +0 -61
- data/spec/spec_helper.rb +0 -98
- data/spec/support/shared_examples/shared_examples_for_date_delegation.rb +0 -19
- data/spec/support/shared_examples/shared_examples_for_traffic_collection.rb +0 -19
data/spec/lib/vnstat_spec.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
describe Vnstat do
|
2
|
-
describe '.config' do
|
3
|
-
subject { described_class.config }
|
4
|
-
|
5
|
-
it { is_expected.to be_a Vnstat::Configuration }
|
6
|
-
|
7
|
-
it 'is only instantiated once' do
|
8
|
-
expect(subject).to be described_class.config
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '.configure' do
|
13
|
-
it 'returns .config' do
|
14
|
-
expect(described_class.configure { 'test' }).to eq described_class.config
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'when no block given' do
|
18
|
-
it 'raises' do
|
19
|
-
expect { described_class.configure }.to raise_error LocalJumpError
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'when block given' do
|
24
|
-
it 'yields once' do
|
25
|
-
expect { |block| described_class.configure(&block) }
|
26
|
-
.to yield_control.exactly(1).times
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'yields with configuration' do
|
30
|
-
expect { |block| described_class.configure(&block) }
|
31
|
-
.to yield_with_args(described_class.config)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '.interfaces' do
|
37
|
-
it 'calls Vnstat::InterfaceCollection.open' do
|
38
|
-
expect(Vnstat::InterfaceCollection).to receive(:open)
|
39
|
-
|
40
|
-
described_class.interfaces
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe '.[]' do
|
45
|
-
it 'delegates to #interfaces' do
|
46
|
-
allow(described_class).to receive(:interfaces) do
|
47
|
-
{ 'eth0' => 'test' }
|
48
|
-
end
|
49
|
-
|
50
|
-
expect(described_class['eth0']).to eq 'test'
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '.version' do
|
55
|
-
it 'calls Utils.call_executable with -v argument' do
|
56
|
-
expect(Vnstat::Utils).to receive(:call_executable).with('-v')
|
57
|
-
|
58
|
-
described_class.version
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
if ENV['CODECLIMATE_REPO_TOKEN']
|
2
|
-
require 'codeclimate-test-reporter'
|
3
|
-
CodeClimate::TestReporter.start
|
4
|
-
end
|
5
|
-
|
6
|
-
require 'rubygems'
|
7
|
-
require 'bundler'
|
8
|
-
begin
|
9
|
-
Bundler.setup(:default, :development)
|
10
|
-
rescue Bundler::BundlerError => e
|
11
|
-
$stderr.puts e.message
|
12
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
13
|
-
exit e.status_code
|
14
|
-
end
|
15
|
-
|
16
|
-
require 'vnstat'
|
17
|
-
|
18
|
-
Dir.glob(File.join(File.dirname(__FILE__), 'support', '**', '*.rb')).each do |file|
|
19
|
-
require file
|
20
|
-
end
|
21
|
-
|
22
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
23
|
-
RSpec.configure do |config|
|
24
|
-
# rspec-expectations config goes here. You can use an alternate
|
25
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
26
|
-
# assertions if you prefer.
|
27
|
-
config.expect_with :rspec do |expectations|
|
28
|
-
# This option will default to `true` in RSpec 4. It makes the `description`
|
29
|
-
# and `failure_message` of custom matchers include text for helper methods
|
30
|
-
# defined using `chain`, e.g.:
|
31
|
-
# be_bigger_than(2).and_smaller_than(4).description
|
32
|
-
# # => "be bigger than 2 and smaller than 4"
|
33
|
-
# ...rather than:
|
34
|
-
# # => "be bigger than 2"
|
35
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
36
|
-
end
|
37
|
-
|
38
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
39
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
40
|
-
config.mock_with :rspec do |mocks|
|
41
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
42
|
-
# a real object. This is generally recommended, and will default to
|
43
|
-
# `true` in RSpec 4.
|
44
|
-
mocks.verify_partial_doubles = true
|
45
|
-
end
|
46
|
-
|
47
|
-
# The settings below are suggested to provide a good initial experience
|
48
|
-
# with RSpec, but feel free to customize to your heart's content.
|
49
|
-
# These two settings work together to allow you to limit a spec run
|
50
|
-
# to individual examples or groups you care about by tagging them with
|
51
|
-
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
52
|
-
# get run.
|
53
|
-
config.filter_run :focus
|
54
|
-
config.run_all_when_everything_filtered = true
|
55
|
-
|
56
|
-
# Allows RSpec to persist some state between runs in order to support
|
57
|
-
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
58
|
-
# you configure your source control system to ignore this file.
|
59
|
-
# config.example_status_persistence_file_path = "spec/examples.txt"
|
60
|
-
|
61
|
-
# Limits the available syntax to the non-monkey patched syntax that is
|
62
|
-
# recommended. For more details, see:
|
63
|
-
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
64
|
-
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
65
|
-
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
66
|
-
# config.disable_monkey_patching!
|
67
|
-
|
68
|
-
# This setting enables warnings. It's recommended, but in some cases may
|
69
|
-
# be too noisy due to issues in dependencies.
|
70
|
-
# config.warnings = true
|
71
|
-
|
72
|
-
# Many RSpec users commonly either run the entire suite or an individual
|
73
|
-
# file, and it's useful to allow more verbose output when running an
|
74
|
-
# individual spec file.
|
75
|
-
# if config.files_to_run.one?
|
76
|
-
# # Use the documentation formatter for detailed output,
|
77
|
-
# # unless a formatter has already been configured
|
78
|
-
# # (e.g. via a command-line flag).
|
79
|
-
# config.default_formatter = 'doc'
|
80
|
-
# end
|
81
|
-
|
82
|
-
# Print the 10 slowest examples and example groups at the
|
83
|
-
# end of the spec run, to help surface which specs are running
|
84
|
-
# particularly slow.
|
85
|
-
# config.profile_examples = 10
|
86
|
-
|
87
|
-
# Run specs in random order to surface order dependencies. If you find an
|
88
|
-
# order dependency and want to debug it, you can fix the order by providing
|
89
|
-
# the seed, which is printed after each run.
|
90
|
-
# --seed 1234
|
91
|
-
config.order = :random
|
92
|
-
|
93
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
94
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
95
|
-
# test failures related to randomization by passing the same `--seed` value
|
96
|
-
# as the one that triggered the failure.
|
97
|
-
Kernel.srand config.seed
|
98
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
shared_examples 'date delegation' do
|
2
|
-
describe '#year' do
|
3
|
-
it 'matches the year from #date' do
|
4
|
-
expect(subject.year).to eq subject.date.year
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
describe '#month' do
|
9
|
-
it 'matches the month from #date' do
|
10
|
-
expect(subject.month).to eq subject.date.month
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#day' do
|
15
|
-
it 'matches the day from #date' do
|
16
|
-
expect(subject.day).to eq subject.date.day
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
shared_examples 'traffic collection' do
|
2
|
-
it 'includes Enumerable' do
|
3
|
-
expect(described_class).to include Enumerable
|
4
|
-
end
|
5
|
-
|
6
|
-
describe '#each' do
|
7
|
-
context 'when block given' do
|
8
|
-
it 'returns an Array' do
|
9
|
-
expect(subject.each {}).to be_an Array
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'when no block given' do
|
14
|
-
it 'returns an Enumerator' do
|
15
|
-
expect(subject.each).to be_an Enumerator
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|