volay 2.1.0 → 2.2.0

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
  SHA256:
3
- metadata.gz: 3e383f672606a89520f19cc97e3704539037a44b65cd8f97b4e965ba8b3bd2a0
4
- data.tar.gz: b0cfb666b0b3cdce544bb105fb58986311c72660a377df8fab2863e67e535e6b
3
+ metadata.gz: 66f48ec0ea900b7f7287f2eab6485e04bdbc06a0cc9e6a703cd49ee6a51a97ea
4
+ data.tar.gz: 32e5d402b328ccd0d504d11835c2e12951935c70127afe776ed8769e88ecccd1
5
5
  SHA512:
6
- metadata.gz: f157a6475a185d45d55b0348c8b96c0164eeab49d23f0bc8bb793e109548e729f36f95f72fdde2a8762fc2984f34e4a9c14b8a2668e7fe3718cced3623e3524b
7
- data.tar.gz: 59a3bec0c005d48f56e51eb8591e34718334a1f33fbefa62653d412a735e37a2afa1161fb5038b5ba871f8155412e8c4547d5d834e219d9c41128040af64090b
6
+ metadata.gz: a994cfad34bf6bb04ce516e571bf5e9e39a4522f96c0cf0d56bc1852b5a76aed77d3a2a3d060c2fa2eac6d051ba4d51d4e79e09c43762417440bab10b2695aaa
7
+ data.tar.gz: 923fd7c1765926770711e6f4a859467f50f0794d99b15c2db939e21f33d20abb77908a03edaa9b8e3c529256062546d267fffd3e7cc3b8a831d64edf1f0740c0
@@ -7,6 +7,8 @@ Metrics/AbcSize:
7
7
  Enabled: false
8
8
  Metrics/ClassLength:
9
9
  Enabled: false
10
+ Metrics/LineLength:
11
+ Max: 120
10
12
  Metrics/MethodLength:
11
13
  Enabled: false
12
14
  Metrics/PerceivedComplexity:
@@ -22,6 +24,3 @@ Style/FrozenStringLiteralComment:
22
24
  Exclude:
23
25
  - lib/volay/cli.rb
24
26
  - lib/volay/version.rb
25
-
26
- Performance/RegexpMatch:
27
- Enabled: false
@@ -5,9 +5,8 @@ require 'logger'
5
5
  require 'mixlib/cli'
6
6
  require 'mixlib/shellout'
7
7
 
8
- unless $LOAD_PATH.include?(File.expand_path('', __dir__))
9
- $LOAD_PATH.unshift(File.expand_path('', __dir__))
10
- end
8
+ $LOAD_PATH.unshift(File.expand_path('', __dir__)) unless
9
+ $LOAD_PATH.include?(File.expand_path('', __dir__))
11
10
 
12
11
  require 'volay/version'
13
12
  require 'volay/config'
@@ -34,6 +34,8 @@ module Volay
34
34
  end
35
35
 
36
36
  def toggle
37
+ return if current_sink.nil?
38
+
37
39
  value = if current_sink['muted'] == 'yes'
38
40
  'no'
39
41
  else
@@ -45,10 +47,10 @@ module Volay
45
47
 
46
48
  def current
47
49
  {
48
- value: current_sink['volume'],
50
+ value: current_sink.nil? ? 0 : current_sink['volume'],
49
51
  max_value: MAX_VALUE,
50
- percent: volume_percent(current_sink['volume']),
51
- muted: current_sink['muted'] == 'yes'
52
+ percent: current_sink.nil? ? 0 : volume_percent(current_sink['volume']),
53
+ muted: current_sink.nil? ? true : current_sink['muted'] == 'yes'
52
54
  }
53
55
  end
54
56
 
@@ -81,7 +83,10 @@ module Volay
81
83
  # Refresh cards data
82
84
  #
83
85
  def refresh
84
- dump = command('dump').lines
86
+ cmd = command('dump')
87
+ return unless cmd
88
+
89
+ dump = cmd.lines
85
90
  dump.each do |line|
86
91
  args = line.split
87
92
 
@@ -173,6 +178,8 @@ module Volay
173
178
  # @param [Integer] volume Volume to set up, must be a percentage
174
179
  #
175
180
  def set_volume(volume)
181
+ return if current_sink.nil?
182
+
176
183
  volume = [[0, (volume * MAX_VALUE / 100)].max, MAX_VALUE].min
177
184
  @cards[@default_sink_id]['volume'] = volume
178
185
  sink = @cards[@default_sink_id]['sink']
@@ -189,6 +196,9 @@ module Volay
189
196
  result = Mixlib::ShellOut.new(command)
190
197
  Volay::Config.logger.debug(command)
191
198
  result.run_command
199
+
200
+ return unless result.exitstatus.zero?
201
+
192
202
  Volay::Config.logger.error(result.stderr) unless result.stderr.empty?
193
203
  Volay::Config.logger.debug(result.stdout) unless result.stdout.empty?
194
204
  result.stdout
@@ -1,4 +1,4 @@
1
1
  # Volay module
2
2
  module Volay
3
- VERSION = '2.1.0'.freeze
3
+ VERSION = '2.2.0'.freeze
4
4
  end
@@ -3,9 +3,8 @@
3
3
  require 'gtk3'
4
4
  require 'mixlib-cli'
5
5
 
6
- unless $LOAD_PATH.include?(File.expand_path('', __dir__))
7
- $LOAD_PATH.unshift(File.expand_path('', __dir__))
8
- end
6
+ $LOAD_PATH.unshift(File.expand_path('', __dir__)) unless
7
+ $LOAD_PATH.include?(File.expand_path('', __dir__))
9
8
 
10
9
  require 'volay/version'
11
10
  require 'volay/app'
@@ -58,9 +58,22 @@ describe 'Volay::Config' do
58
58
  end
59
59
 
60
60
  it 'should return a mixer' do
61
+ run_command = double(
62
+ exitstatus: double(
63
+ zero?: true
64
+ )
65
+ )
66
+ shellout = double
67
+
61
68
  Volay::Config.logger.level = :info
62
- allow_any_instance_of(Mixlib::ShellOut).to receive(:new).twice
63
- allow_any_instance_of(Mixlib::ShellOut).to receive(:run_command)
69
+ allow_any_instance_of(Mixlib::ShellOut).to receive(:new)
70
+ .with('pacmd dump')
71
+ .and_return(shellout)
72
+
73
+ allow(shellout).to receive(:run_command)
74
+ .with("pacmd list-cards | grep -e device.string -e 'name:' -e 'card_name'")
75
+ .and_return(run_command)
76
+
64
77
  app_mixer('pacmd')
65
78
  expect(Volay::Config.mixer).to be_a(Volay::Mixer::Pulse)
66
79
  end
@@ -11,12 +11,17 @@ describe 'Volay::Mixer::Pulse' do
11
11
 
12
12
  def stub_shellout(cmd, stdout = '', stderr = '')
13
13
  shellout = double(
14
- run_command: nil,
15
14
  error!: nil,
16
15
  stdout: stdout,
17
- stderr: stderr
16
+ stderr: stderr,
17
+ exitstatus: double(
18
+ zero?: true
19
+ )
18
20
  )
19
21
 
22
+ allow(shellout).to receive(:run_command)
23
+ .once
24
+
20
25
  expect(Mixlib::ShellOut).to receive(:new)
21
26
  .with("pacmd #{cmd}")
22
27
  .and_return(shellout)
@@ -21,11 +21,12 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'mixlib-cli', '~>1.7'
22
22
  s.add_dependency 'mixlib-shellout', '~>2.3'
23
23
 
24
- s.add_development_dependency 'fakefs', '~>0.13'
24
+ s.add_development_dependency 'fakefs', '~>0.20'
25
25
  s.add_development_dependency 'rack', '~>2.0'
26
26
  s.add_development_dependency 'rack-test', '~>0.8'
27
- s.add_development_dependency 'rake', '~>12.0'
28
- s.add_development_dependency 'rspec', '~>3.7'
29
- s.add_development_dependency 'rubocop', '~>0.52'
30
- s.add_development_dependency 'simplecov', '~>0.15'
27
+ s.add_development_dependency 'rake', '~>12.3'
28
+ s.add_development_dependency 'rspec', '~>3.8'
29
+ s.add_development_dependency 'rubocop', '~>0.69'
30
+ s.add_development_dependency 'rubocop-performance', '~>1.3'
31
+ s.add_development_dependency 'simplecov', '~>0.16'
31
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volay
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre Rambaud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-16 00:00:00.000000000 Z
11
+ date: 2019-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glib2
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.13'
75
+ version: '0.20'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.13'
82
+ version: '0.20'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rack
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -114,56 +114,70 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '12.0'
117
+ version: '12.3'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '12.0'
124
+ version: '12.3'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rspec
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '3.7'
131
+ version: '3.8'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '3.7'
138
+ version: '3.8'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rubocop
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '0.52'
145
+ version: '0.69'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '0.52'
152
+ version: '0.69'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop-performance
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.3'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.3'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: simplecov
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
171
  - - "~>"
158
172
  - !ruby/object:Gem::Version
159
- version: '0.15'
173
+ version: '0.16'
160
174
  type: :development
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
178
  - - "~>"
165
179
  - !ruby/object:Gem::Version
166
- version: '0.15'
180
+ version: '0.16'
167
181
  description: Really simple volume system tray written in ruby.
168
182
  email: pierre.rambaud86@gmail.com
169
183
  executables:
@@ -229,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
243
  version: '0'
230
244
  requirements: []
231
245
  rubyforge_project:
232
- rubygems_version: 2.7.3
246
+ rubygems_version: 2.7.5
233
247
  signing_key:
234
248
  specification_version: 4
235
249
  summary: The Volume system tray