vnstat-ruby 1.0.1 → 1.0.2
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/vnstat/interface.rb +5 -1
- data/spec/lib/vnstat/interface_spec.rb +28 -0
- data/vnstat-ruby.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f4cd6bf3128b3bfd282c7245a9eed0930128a28
|
4
|
+
data.tar.gz: 000c9f5f617a544ce51b40d7d7a97621432b292b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ed11ec33f8d67565e94975c61eec4a831653510304b9808a39178ac042cc008d991fe3cfa93ee1826b9ded04e6826a86fb1e5b05a0971a04f8d85a75ff6895e
|
7
|
+
data.tar.gz: f0e5232cabc27e4d5843f38c08e7e2c354175427703668cc1e94eea222220d83d0132bed667ba2677fcc89b447e239aed03aeb779133906583538a110a19cb7b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/lib/vnstat/interface.rb
CHANGED
@@ -76,11 +76,15 @@ module Vnstat
|
|
76
76
|
#
|
77
77
|
# Sets the alias name for the interface.
|
78
78
|
#
|
79
|
+
# @raise [Error] Raised when a new nickname could not be set.
|
79
80
|
# @param [String] nick The alias name for the interface.
|
80
81
|
def nick=(nick)
|
81
|
-
Utils.call_executable_returning_status(
|
82
|
+
success = Utils.call_executable_returning_status(
|
82
83
|
'-i', id, '--nick', nick, '--update'
|
83
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
|
84
88
|
@nick = nick
|
85
89
|
end
|
86
90
|
|
@@ -141,6 +141,34 @@ describe Vnstat::Interface do
|
|
141
141
|
expect(subject.public_send(method_name)).to eq 'Ethernet'
|
142
142
|
end
|
143
143
|
end
|
144
|
+
|
145
|
+
describe "##{method_name}=" do
|
146
|
+
context 'when nickname can be set by vnstat' do
|
147
|
+
before :each do
|
148
|
+
allow(Vnstat::Utils).to receive(:call_executable_returning_status)
|
149
|
+
.and_return(true)
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'sets #nick to argument' do
|
153
|
+
expect { subject.nick = 'test' }.to change { subject.nick }.to('test')
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
context 'when nickname cannot be set by vnstat' do
|
158
|
+
before :each do
|
159
|
+
allow(Vnstat::Utils).to receive(:call_executable_returning_status)
|
160
|
+
.and_return(false)
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'raises Vnstat::Error' do
|
164
|
+
expect { subject.nick = 'test' }.to raise_error(
|
165
|
+
Vnstat::Error, 'Unable to set nickname for interface (eth0). ' \
|
166
|
+
'Please make sure the vnstat daemon is not ' \
|
167
|
+
'running while performing this operation.'
|
168
|
+
)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
144
172
|
end
|
145
173
|
|
146
174
|
describe '#created_on' do
|
data/vnstat-ruby.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
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
|
+
# stub: vnstat-ruby 1.0.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "vnstat-ruby"
|
9
|
-
s.version = "1.0.
|
9
|
+
s.version = "1.0.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|