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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1715a5093d7a2a70bf97ff7fdba6841947b757fc
4
- data.tar.gz: 36bb4148f065f37f5fddcc86cc030ca17cdb6540
3
+ metadata.gz: 9f4cd6bf3128b3bfd282c7245a9eed0930128a28
4
+ data.tar.gz: 000c9f5f617a544ce51b40d7d7a97621432b292b
5
5
  SHA512:
6
- metadata.gz: 1d4f1d8b0748d356bd2571c61ef35df7993b6ee02d1a5b2dbd755abd8b8b581fca6a700eedd3f856fb38c1fee21f39ce9dc2f7ad10ae488d5fbb31b08ca55f5e
7
- data.tar.gz: be614eabb9d0398b3d6725225296dba0416214ba0ac823b79f8c403045efdb818bc7576b959bfd9b48e5cf9b629bd22fa801d11d3a98867a14b5656ba0bc4c1c
6
+ metadata.gz: 6ed11ec33f8d67565e94975c61eec4a831653510304b9808a39178ac042cc008d991fe3cfa93ee1826b9ded04e6826a86fb1e5b05a0971a04f8d85a75ff6895e
7
+ data.tar.gz: f0e5232cabc27e4d5843f38c08e7e2c354175427703668cc1e94eea222220d83d0132bed667ba2677fcc89b447e239aed03aeb779133906583538a110a19cb7b
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -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.1 ruby lib
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.1"
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"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vnstat-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Casper