fusuma-plugin-wmctrl 1.3.0 → 1.3.1

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: d7d5c06318f60d7af1b280b92ffa40c5731ce8bc015896fe0c799c7d1b3fad80
4
- data.tar.gz: c1d75d389a37332b94ea5878e3df4c157642027beb396a677e60606f762dbba8
3
+ metadata.gz: d929c23fcedce401d4fa3c9ac1f5a39e2aba97eb7fdce00864a385da0b391723
4
+ data.tar.gz: 6ad065e14cb5f184ce47e8ae8925f93bc14fb54c0740822937d45137571ac179
5
5
  SHA512:
6
- metadata.gz: a4f702853056e8c0f145fb303ae56114a2a80fcd8972f1122036318b871d53cc2aafd3edc83b97a51ce19ec30ce2c59561023fb41c00b1082c7df115cde8107b
7
- data.tar.gz: 3b9af4c2bac33dbc05d5530c1bd804bd15c08279bc070ede6ff03b20e5df31b692092f0214d22ffc095162d4698a5fa2df316146e1ced4223438720b6002fc20
6
+ metadata.gz: a35a9f5ca6338b8c62a58905c7d03f7f4738eb104cd792e03b23cba48faf3a5dec8b957a3cfcc294f78d7c20120537d687b52d9541b965f5c485fb1e0ceff63a
7
+ data.tar.gz: 5ad6fd27a381ce6698e974dbcddd04369c5f9741859866cfcf0bf5a311c3478565e809b3150c2cc43507ebc9379a14e29753de3cd5280d7557721bb1b0fd2d31
@@ -1,28 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'fusuma/plugin/wmctrl/version'
5
+ require "fusuma/plugin/wmctrl/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'fusuma-plugin-wmctrl'
9
- spec.version = Fusuma::Plugin::Wmctrl::VERSION
10
- spec.authors = ['iberianpig']
11
- spec.email = ['yhkyky@gmail.com']
8
+ spec.name = "fusuma-plugin-wmctrl"
9
+ spec.version = Fusuma::Plugin::Wmctrl::VERSION
10
+ spec.authors = ["iberianpig"]
11
+ spec.email = ["yhkyky@gmail.com"]
12
12
 
13
- spec.summary = 'Wmctrl plugin for Fusuma '
14
- spec.description = 'fusuma-plugin-wmctrl is Fusuma plugin for window manager.'
15
- spec.homepage = 'https://github.com/iberianpig/fusuma-plugin-wmctrl'
16
- spec.license = 'MIT'
13
+ spec.summary = "Wmctrl plugin for Fusuma "
14
+ spec.description = "fusuma-plugin-wmctrl is Fusuma plugin for window manager."
15
+ spec.homepage = "https://github.com/iberianpig/fusuma-plugin-wmctrl"
16
+ spec.license = "MIT"
17
17
 
18
18
  # Specify which files should be added to the gem when it is released.
19
- spec.files = Dir['{bin,lib,exe}/**/*', 'LICENSE*', 'README*', '*.gemspec']
20
- spec.test_files = Dir['{test,spec,features}/**/*']
21
- spec.bindir = 'exe'
22
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
- spec.require_paths = ['lib']
19
+ spec.files = Dir["{bin,lib,exe}/**/*", "LICENSE*", "README*", "*.gemspec"]
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
24
23
 
25
- spec.required_ruby_version = '>= 2.5.1' # https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all&section=main
24
+ spec.required_ruby_version = ">= 2.5.1" # https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all&section=main
26
25
  # support bionic (18.04LTS) 2.5.1
27
- spec.add_dependency 'fusuma', '>= 3.1'
26
+ spec.add_dependency "fusuma", ">= 3.1"
28
27
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../wmctrl/window'
4
- require_relative '../wmctrl/workspace'
3
+ require_relative "../wmctrl/window"
4
+ require_relative "../wmctrl/workspace"
5
5
 
6
6
  module Fusuma
7
7
  module Plugin
@@ -16,16 +16,16 @@ module Fusuma
16
16
 
17
17
  def config_param_types
18
18
  {
19
- 'wrap-navigation': [TrueClass, FalseClass],
20
- 'matrix-col-size': [Integer]
19
+ "wrap-navigation": [TrueClass, FalseClass],
20
+ "matrix-col-size": [Integer]
21
21
  }
22
22
  end
23
23
 
24
24
  def initialize
25
25
  super()
26
26
  @workspace = Wmctrl::Workspace.new(
27
- wrap_navigation: config_params(:'wrap-navigation'),
28
- matrix_col_size: config_params(:'matrix-col-size')
27
+ wrap_navigation: config_params(:"wrap-navigation"),
28
+ matrix_col_size: config_params(:"matrix-col-size")
29
29
  )
30
30
  @window = Wmctrl::Window.new
31
31
  end
@@ -45,7 +45,7 @@ module Fusuma
45
45
  # @param event [Event]
46
46
  # @return [TrueClass, FalseClass]
47
47
  def executable?(event)
48
- event.tag.end_with?('_detector') &&
48
+ event.tag.end_with?("_detector") &&
49
49
  event.record.type == :index &&
50
50
  search_command(event)
51
51
  end
@@ -69,9 +69,9 @@ module Fusuma
69
69
  index = Config::Index.new([*event.record.index.keys, :workspace])
70
70
 
71
71
  case property = Config.search(index)
72
- when 'prev', 'next'
72
+ when "prev", "next"
73
73
  @workspace.move_command(direction: property)
74
- when 'left', 'right', 'up', 'down'
74
+ when "left", "right", "up", "down"
75
75
  @workspace.move_command_for_matrix(direction: property)
76
76
  when nil
77
77
  nil
@@ -87,15 +87,15 @@ module Fusuma
87
87
  index = Config::Index.new([*event.record.index.keys, :window])
88
88
 
89
89
  case property = Config.search(index)
90
- when 'prev', 'next'
90
+ when "prev", "next"
91
91
  @workspace.move_window_command(direction: property)
92
- when 'left', 'right', 'up', 'down'
92
+ when "left", "right", "up", "down"
93
93
  @workspace.move_window_command_for_matrix(direction: property)
94
- when 'fullscreen'
95
- @window.fullscreen(method: 'toggle')
96
- when 'maximized'
97
- @window.maximized(method: 'toggle')
98
- when 'close'
94
+ when "fullscreen"
95
+ @window.fullscreen(method: "toggle")
96
+ when "maximized"
97
+ @window.maximized(method: "toggle")
98
+ when "close"
99
99
  @window.close
100
100
  when Hash
101
101
  if property[:fullscreen]
@@ -3,7 +3,7 @@
3
3
  module Fusuma
4
4
  module Plugin
5
5
  module Wmctrl
6
- VERSION = '1.3.0'
6
+ VERSION = "1.3.1"
7
7
  end
8
8
  end
9
9
  end
@@ -11,7 +11,7 @@ module Fusuma
11
11
  end
12
12
 
13
13
  def close
14
- 'wmctrl -c :ACTIVE:'
14
+ "wmctrl -c :ACTIVE:"
15
15
  end
16
16
 
17
17
  # @param method [String] "toggle" or "add" or "remove"
@@ -53,7 +53,7 @@ module Fusuma
53
53
  matrix-col-size: 2
54
54
  ```
55
55
  ERRRORMESSAGE
56
- raise MissingMatrixOption, 'You need to set matrix option to config.yml'
56
+ raise MissingMatrixOption, "You need to set matrix option to config.yml"
57
57
  end
58
58
 
59
59
  # @return [Integer]
@@ -65,7 +65,7 @@ module Fusuma
65
65
  x = current_workspace_num % col_size
66
66
  y = current_workspace_num / col_size
67
67
  case direction
68
- when 'right'
68
+ when "right"
69
69
  if x < col_size - 1
70
70
  current_workspace_num + 1
71
71
  elsif @wrap_navigation
@@ -73,7 +73,7 @@ module Fusuma
73
73
  else
74
74
  current_workspace_num
75
75
  end
76
- when 'left'
76
+ when "left"
77
77
  if x.positive?
78
78
  current_workspace_num - 1
79
79
  elsif @wrap_navigation
@@ -81,7 +81,7 @@ module Fusuma
81
81
  else
82
82
  current_workspace_num
83
83
  end
84
- when 'down'
84
+ when "down"
85
85
  if y < row_size - 1
86
86
  current_workspace_num + col_size
87
87
  elsif @wrap_navigation
@@ -89,7 +89,7 @@ module Fusuma
89
89
  else
90
90
  current_workspace_num
91
91
  end
92
- when 'up'
92
+ when "up"
93
93
  if y.positive?
94
94
  current_workspace_num - col_size
95
95
  elsif @wrap_navigation
@@ -104,13 +104,13 @@ module Fusuma
104
104
 
105
105
  def move_command(direction:)
106
106
  workspace_num = case direction
107
- when 'next'
108
- next_workspace_num(step: 1)
109
- when 'prev'
110
- next_workspace_num(step: -1)
111
- else
112
- raise "#{direction} is invalid key"
113
- end
107
+ when "next"
108
+ next_workspace_num(step: 1)
109
+ when "prev"
110
+ next_workspace_num(step: -1)
111
+ else
112
+ raise "#{direction} is invalid key"
113
+ end
114
114
  "wmctrl -s #{workspace_num}"
115
115
  end
116
116
 
@@ -121,13 +121,13 @@ module Fusuma
121
121
 
122
122
  def move_window_command(direction:)
123
123
  workspace_num = case direction
124
- when 'next'
125
- next_workspace_num(step: 1)
126
- when 'prev'
127
- next_workspace_num(step: -1)
128
- else
129
- raise "#{direction} is invalid key"
130
- end
124
+ when "next"
125
+ next_workspace_num(step: 1)
126
+ when "prev"
127
+ next_workspace_num(step: -1)
128
+ else
129
+ raise "#{direction} is invalid key"
130
+ end
131
131
  "wmctrl -r :ACTIVE: -t #{workspace_num} ; wmctrl -s #{workspace_num}"
132
132
  end
133
133
 
@@ -149,7 +149,7 @@ module Fusuma
149
149
  # (_NET_CURRENT_DESKTOP or _WIN_WORKSPACE property)`
150
150
  return [0, 1] if current_line.nil?
151
151
 
152
- current_workspace_num = current_line.chars.first.to_i
152
+ current_workspace_num = current_line[0].to_i
153
153
  total_workspace_num = wmctrl_output.length
154
154
 
155
155
  [current_workspace_num, total_workspace_num]
@@ -2,5 +2,5 @@
2
2
 
3
3
  # fusuma will `require fusuma-plugin-xxxx/plugin/xxxx.rb`
4
4
 
5
- require_relative './wmctrl/version'
6
- require_relative './executors/wmctrl_executor'
5
+ require_relative "wmctrl/version"
6
+ require_relative "executors/wmctrl_executor"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fusuma-plugin-wmctrl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - iberianpig
@@ -44,11 +44,6 @@ files:
44
44
  - lib/fusuma/plugin/wmctrl/version.rb
45
45
  - lib/fusuma/plugin/wmctrl/window.rb
46
46
  - lib/fusuma/plugin/wmctrl/workspace.rb
47
- - spec/fusuma/plugin/plugin/executors/wmctrl_executor_spec.rb
48
- - spec/fusuma/plugin/plugin/wmctrl/workspace_spec.rb
49
- - spec/fusuma/plugin/wmctrl_spec.rb
50
- - spec/helpers/config_helper.rb
51
- - spec/spec_helper.rb
52
47
  homepage: https://github.com/iberianpig/fusuma-plugin-wmctrl
53
48
  licenses:
54
49
  - MIT
@@ -72,9 +67,4 @@ rubygems_version: 3.3.26
72
67
  signing_key:
73
68
  specification_version: 4
74
69
  summary: Wmctrl plugin for Fusuma
75
- test_files:
76
- - spec/fusuma/plugin/plugin/executors/wmctrl_executor_spec.rb
77
- - spec/fusuma/plugin/plugin/wmctrl/workspace_spec.rb
78
- - spec/fusuma/plugin/wmctrl_spec.rb
79
- - spec/helpers/config_helper.rb
80
- - spec/spec_helper.rb
70
+ test_files: []
@@ -1,358 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- require 'fusuma/plugin/executors/executor'
6
- require 'fusuma/plugin/events/event'
7
- require 'fusuma/plugin/events/records/index_record'
8
-
9
- require './lib/fusuma/plugin/executors/wmctrl_executor'
10
-
11
- module Fusuma
12
- module Plugin
13
- module Executors
14
- RSpec.describe WmctrlExecutor do
15
- before do
16
- @workspace = double(Wmctrl::Workspace)
17
- allow(Wmctrl::Workspace)
18
- .to receive(:new)
19
- .and_return(@workspace)
20
-
21
- index = Config::Index.new([:dummy, 1, :direction])
22
- record = Events::Records::IndexRecord.new(index: index)
23
- @event = Events::Event.new(tag: 'dummy_detector', record: record)
24
- @executor = WmctrlExecutor.new
25
- allow(@executor).to receive(:search_command).and_return 'dummy command'
26
- end
27
-
28
- around do |example|
29
- ConfigHelper.load_config_yml = <<~CONFIG
30
- dummy:
31
- 1:
32
- direction:
33
- workspace: 'prev'
34
- CONFIG
35
-
36
- example.run
37
-
38
- Config.custom_path = nil
39
- end
40
-
41
- describe '#execute' do
42
- it 'detach' do
43
- pid = rand(20)
44
- allow(Process).to receive(:spawn).with(@executor.search_command(@event))
45
- .and_return pid
46
-
47
- expect(Process).to receive(:detach).with(pid)
48
-
49
- @executor.execute(@event)
50
- end
51
- end
52
-
53
- describe '#executable?' do
54
- context 'when given valid event tagged as xxxx_detector' do
55
- it { expect(@executor.executable?(@event)).to be_truthy }
56
- end
57
-
58
- context 'when given INVALID event tagged as invalid_tag' do
59
- before do
60
- @event.tag = 'invalid_tag'
61
- end
62
- it { expect(@executor.executable?(@event)).to be_falsey }
63
- end
64
- end
65
-
66
- describe '#search_command' do
67
- before do
68
- allow(@executor).to receive(:search_command).and_call_original
69
-
70
- @current_workspace = 1
71
- @total_workspaces = 3
72
- allow(@workspace)
73
- .to receive(:workspace_values)
74
- .and_return([@current_workspace, @total_workspaces])
75
- end
76
- context "when workspace: 'prev'" do
77
- around do |example|
78
- ConfigHelper.load_config_yml = <<~CONFIG
79
- dummy:
80
- 1:
81
- direction:
82
- workspace: 'prev'
83
- CONFIG
84
-
85
- example.run
86
-
87
- Config.custom_path = nil
88
- end
89
-
90
- it 'should return wmctrl command' do
91
- expect(@workspace).to receive(:move_command).with(direction: 'prev')
92
- @executor.search_command(@event)
93
- end
94
- end
95
-
96
- context "when window: 'prev'" do
97
- around do |example|
98
- ConfigHelper.load_config_yml = <<~CONFIG
99
- dummy:
100
- 1:
101
- direction:
102
- window: 'prev'
103
- CONFIG
104
-
105
- example.run
106
-
107
- Config.custom_path = nil
108
- end
109
-
110
- it 'should return wmctrl command' do
111
- expect(@workspace).to receive(:move_window_command).with(direction: 'prev')
112
- @executor.search_command(@event)
113
- end
114
- end
115
-
116
- context "when window: 'fullscreen'" do
117
- around do |example|
118
- ConfigHelper.load_config_yml = <<~CONFIG
119
- dummy:
120
- 1:
121
- direction:
122
- window: 'fullscreen'
123
- CONFIG
124
-
125
- example.run
126
-
127
- Config.custom_path = nil
128
- end
129
-
130
- it 'should return wmctrl command' do
131
- expect(@executor.search_command(@event))
132
- .to match(/wmctrl -r :ACTIVE: -b toggle,fullscreen/)
133
- end
134
- end
135
-
136
- context 'when window: [fullscreen: something]' do
137
- context "when fullscreen: 'toggle'" do
138
- around do |example|
139
- ConfigHelper.load_config_yml = <<~CONFIG
140
- dummy:
141
- 1:
142
- direction:
143
- window:
144
- fullscreen: 'toggle'
145
- CONFIG
146
-
147
- example.run
148
-
149
- Config.custom_path = nil
150
- end
151
-
152
- it 'should return wmctrl command' do
153
- expect(@executor.search_command(@event))
154
- .to match(/wmctrl -r :ACTIVE: -b toggle,fullscreen/)
155
- end
156
- end
157
-
158
- context "when fullscreen: 'add'" do
159
- around do |example|
160
- ConfigHelper.load_config_yml = <<~CONFIG
161
- dummy:
162
- 1:
163
- direction:
164
- window:
165
- fullscreen: 'add'
166
- CONFIG
167
-
168
- example.run
169
-
170
- Config.custom_path = nil
171
- end
172
-
173
- it 'should return wmctrl command' do
174
- expect(@executor.search_command(@event))
175
- .to match(/wmctrl -r :ACTIVE: -b add,fullscreen/)
176
- end
177
- end
178
-
179
- context "when fullscreen: 'remove'" do
180
- around do |example|
181
- ConfigHelper.load_config_yml = <<~CONFIG
182
- dummy:
183
- 1:
184
- direction:
185
- window:
186
- fullscreen: 'remove'
187
- CONFIG
188
-
189
- example.run
190
-
191
- Config.custom_path = nil
192
- end
193
-
194
- it 'should return wmctrl command' do
195
- expect(@executor.search_command(@event))
196
- .to match(/wmctrl -r :ACTIVE: -b remove,fullscreen/)
197
- end
198
- end
199
- end
200
-
201
- context "when window: 'maximized'" do
202
- around do |example|
203
- ConfigHelper.load_config_yml = <<~CONFIG
204
- dummy:
205
- 1:
206
- direction:
207
- window: 'maximized'
208
- CONFIG
209
-
210
- example.run
211
-
212
- Config.custom_path = nil
213
- end
214
-
215
- it 'should return wmctrl command' do
216
- expect(@executor.search_command(@event))
217
- .to match(/wmctrl -r :ACTIVE: -b toggle,maximized/)
218
- end
219
- end
220
-
221
- context 'when window: [maximized: something]' do
222
- context "when maximized: 'toggle'" do
223
- around do |example|
224
- ConfigHelper.load_config_yml = <<~CONFIG
225
- dummy:
226
- 1:
227
- direction:
228
- window:
229
- maximized: 'toggle'
230
- CONFIG
231
-
232
- example.run
233
-
234
- Config.custom_path = nil
235
- end
236
-
237
- it 'should return wmctrl command' do
238
- expect(@executor.search_command(@event))
239
- .to match(/wmctrl -r :ACTIVE: -b toggle,maximized/)
240
- end
241
- end
242
-
243
- context "when maximized: 'add'" do
244
- around do |example|
245
- ConfigHelper.load_config_yml = <<~CONFIG
246
- dummy:
247
- 1:
248
- direction:
249
- window:
250
- maximized: 'add'
251
- CONFIG
252
-
253
- example.run
254
-
255
- Config.custom_path = nil
256
- end
257
-
258
- it 'should return wmctrl command' do
259
- expect(@executor.search_command(@event))
260
- .to match(/wmctrl -r :ACTIVE: -b add,maximized/)
261
- end
262
- end
263
-
264
- context "when maximized: 'remove'" do
265
- around do |example|
266
- ConfigHelper.load_config_yml = <<~CONFIG
267
- dummy:
268
- 1:
269
- direction:
270
- window:
271
- maximized: 'remove'
272
- CONFIG
273
-
274
- example.run
275
-
276
- Config.custom_path = nil
277
- end
278
-
279
- it 'should return wmctrl command' do
280
- expect(@executor.search_command(@event))
281
- .to match(/wmctrl -r :ACTIVE: -b remove,maximized/)
282
- end
283
- end
284
- end
285
- context "when window: 'close'" do
286
- around do |example|
287
- ConfigHelper.load_config_yml = <<~CONFIG
288
- dummy:
289
- 1:
290
- direction:
291
- window: 'close'
292
- CONFIG
293
-
294
- example.run
295
-
296
- Config.custom_path = nil
297
- end
298
-
299
- it 'should return wmctrl command' do
300
- expect(@executor.search_command(@event))
301
- .to match(/wmctrl -c :ACTIVE:/)
302
- end
303
- end
304
-
305
- describe 'wrap_navigation: true' do
306
- around do |example|
307
- ConfigHelper.load_config_yml = <<~CONFIG
308
- plugin:
309
- executors:
310
- wmctrl_executor:
311
- wrap-navigation: true
312
- CONFIG
313
-
314
- example.run
315
-
316
- Config.custom_path = nil
317
- end
318
-
319
- it 'should wrap-navigation mode' do
320
- expect(Wmctrl::Workspace).to receive(:new).with(
321
- wrap_navigation: true,
322
- matrix_col_size: nil
323
- )
324
- WmctrlExecutor.new
325
- end
326
- end
327
-
328
- describe 'matrix-col-size' do
329
- context "with matrix-col-size: '3', right" do
330
- around do |example|
331
- ConfigHelper.load_config_yml = <<~CONFIG
332
- dummy:
333
- 1:
334
- direction:
335
- window: 'right'
336
- plugin:
337
- executors:
338
- wmctrl_executor:
339
- matrix-col-size: 3
340
- CONFIG
341
-
342
- example.run
343
-
344
- Config.custom_path = nil
345
- end
346
-
347
- it 'should return wmctrl command with index of right(next) workspace' do
348
- expect(@workspace).to receive(:move_window_command_for_matrix)
349
- .with(direction: 'right')
350
- @executor.search_command(@event)
351
- end
352
- end
353
- end
354
- end
355
- end
356
- end
357
- end
358
- end
@@ -1,236 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require './lib/fusuma/plugin/wmctrl/workspace'
5
-
6
- module Fusuma
7
- module Plugin
8
- module Wmctrl
9
- RSpec.describe Workspace do
10
- def stub_workspace_values(current:, total:)
11
- allow(@workspace).to receive(:workspace_values).and_return([current, total])
12
- end
13
-
14
- before { @workspace = Workspace.new }
15
-
16
- describe '#move_command' do
17
- before { stub_workspace_values(current: 1, total: 3) }
18
-
19
- context "with 'direction: next'" do
20
- before { @direction = 'next' }
21
- it 'returns wmctrl command to move NEXT workspace' do
22
- expect(@workspace.move_command(direction: @direction))
23
- .to match(/wmctrl -s 2/)
24
- end
25
- it 'calls next_workspace_num' do
26
- expect(@workspace).to receive(:next_workspace_num).with(step: 1)
27
- @workspace.move_command(direction: @direction)
28
- end
29
- end
30
- end
31
-
32
- describe '#move_command_for_matrix' do
33
- before do
34
- @workspace = Workspace.new(matrix_col_size: 3)
35
- stub_workspace_values(current: 0, total: 9)
36
- end
37
-
38
- context "with direction: 'right'" do
39
- before { @direction = 'right' }
40
-
41
- it 'returns wmctrl command to move RIGHT workspace' do
42
- expect(@workspace.move_command_for_matrix(direction: @direction))
43
- .to match(/wmctrl -s 1/)
44
- end
45
- it 'calls next_workspace_num_for_matrix' do
46
- expect(@workspace).to receive(:next_workspace_num_for_matrix)
47
- .with(direction: @direction)
48
- @workspace.move_command_for_matrix(direction: @direction)
49
- end
50
- end
51
- context "with direction: 'down'" do
52
- before { @direction = 'down' }
53
-
54
- it 'returns wmctrl command to move workspace to DOWN' do
55
- expect(@workspace.move_command_for_matrix(direction: @direction))
56
- .to match(/wmctrl -s 3/)
57
- end
58
- end
59
- end
60
-
61
- describe '#move_window_command' do
62
- before { stub_workspace_values(current: 1, total: 3) }
63
-
64
- context "with direction: 'next'" do
65
- before { @direction = 'next' }
66
-
67
- it 'returns wmctrl command to move NEXT workspace' do
68
- wmctrl_move_window = /wmctrl -r :ACTIVE: -t 2/
69
- wmctrl_move_workspace = /wmctrl -s 2/
70
- expect(@workspace.move_window_command(direction: @direction))
71
- .to match(wmctrl_move_window)
72
- expect(@workspace.move_window_command(direction: @direction))
73
- .to match(wmctrl_move_workspace)
74
- end
75
- end
76
-
77
- context "with direction: 'prev'" do
78
- before { @direction = 'prev' }
79
-
80
- it 'returns wmctrl command to move NEXT workspace' do
81
- wmctrl_move_window = /wmctrl -r :ACTIVE: -t 0/
82
- wmctrl_move_workspace = /wmctrl -s 0/
83
- expect(@workspace.move_window_command(direction: @direction))
84
- .to match(wmctrl_move_window)
85
- expect(@workspace.move_window_command(direction: @direction))
86
- .to match(wmctrl_move_workspace)
87
- end
88
- end
89
- end
90
-
91
- describe '#move_window_command_for_matrix' do
92
- before do
93
- @workspace = Workspace.new(matrix_col_size: 3)
94
- stub_workspace_values(current: 0, total: 9)
95
- end
96
-
97
- context "with direction: 'right'" do
98
- before { @direction = 'right' }
99
-
100
- it 'returns wmctrl command to move NEXT workspace' do
101
- wmctrl_move_window = /wmctrl -r :ACTIVE: -t 1/
102
- wmctrl_move_workspace = /wmctrl -s 1/
103
- expect(@workspace.move_window_command_for_matrix(direction: @direction))
104
- .to match(wmctrl_move_window)
105
- expect(@workspace.move_window_command_for_matrix(direction: @direction))
106
- .to match(wmctrl_move_workspace)
107
- end
108
- end
109
- context "with direction: 'down'" do
110
- before { @direction = 'down' }
111
-
112
- it 'returns wmctrl command to move NEXT workspace' do
113
- wmctrl_move_window = /wmctrl -r :ACTIVE: -t 3/
114
- wmctrl_move_workspace = /wmctrl -s 3/
115
- expect(@workspace.move_window_command_for_matrix(direction: @direction))
116
- .to match(wmctrl_move_window)
117
- expect(@workspace.move_window_command_for_matrix(direction: @direction))
118
- .to match(wmctrl_move_workspace)
119
- end
120
- end
121
- end
122
-
123
- describe '#next_workspace_num' do
124
- before { stub_workspace_values(current: 1, total: 3) }
125
- context 'with step: 1' do
126
- before { @step = 1 }
127
- it { expect(@workspace.next_workspace_num(step: @step)).to eq 1 + @step }
128
- end
129
- end
130
-
131
- describe '#next_workspace_num_for_matrix' do
132
- context 'without matrix option' do
133
- before { @workspace = Workspace.new(matrix_col_size: nil) }
134
-
135
- it 'raises InvalidOption' do
136
- expect do
137
- @workspace.next_workspace_num_for_matrix(direction: 'prev')
138
- end.to raise_error(Wmctrl::Workspace::MissingMatrixOption)
139
- end
140
- end
141
-
142
- context 'with matrix_col_size: 3' do
143
- # +---+---+---+
144
- # | 0 | 1 | 2 |
145
- # +---+---+---+
146
- # | 3 | 4 | 5 |
147
- # +---+---+---+
148
- # | 6 | 7 | 8 |
149
- # +---+---+---+
150
- before do
151
- @workspace = Workspace.new(matrix_col_size: 3)
152
- stub_workspace_values(current: 1, total: 9)
153
- end
154
-
155
- context 'with invalid direction' do
156
- before { @direction = 'foo' }
157
- it 'raises InvalidOption' do
158
- expect do
159
- @workspace.next_workspace_num_for_matrix(direction: @direction)
160
- end.to raise_error(RuntimeError, "#{@direction} is invalid key")
161
- end
162
- end
163
-
164
- context 'with direction: right' do
165
- before { @direction = 'right' }
166
- it 'next workspace' do
167
- expect(
168
- @workspace.next_workspace_num_for_matrix(direction: @direction)
169
- ).to eq 2
170
- end
171
- context 'when current_workspace is right edge' do
172
- before { stub_workspace_values(current: 2, total: 9) }
173
- it 'same workspace' do
174
- expect(
175
- @workspace.next_workspace_num_for_matrix(direction: @direction)
176
- ).to eq 2
177
- end
178
-
179
- context 'with wrap_navigation: true' do
180
- before { @workspace.instance_variable_set(:@wrap_navigation, true) }
181
- it 'same workspace' do
182
- expect(
183
- @workspace.next_workspace_num_for_matrix(direction: @direction)
184
- ).to eq 0
185
- end
186
- end
187
- end
188
- end
189
- context 'with direction: down' do
190
- before { @direction = 'down' }
191
- it 'next workspace' do
192
- expect(
193
- @workspace.next_workspace_num_for_matrix(direction: @direction)
194
- ).to eq 4
195
- end
196
- context 'when current_workspace is bottom' do
197
- before { stub_workspace_values(current: 7, total: 9) }
198
- it 'same workspace' do
199
- expect(
200
- @workspace.next_workspace_num_for_matrix(direction: @direction)
201
- ).to eq 7
202
- end
203
-
204
- context 'with wrap_navigation: true' do
205
- before { @workspace.instance_variable_set(:@wrap_navigation, true) }
206
- it 'same workspace' do
207
- expect(
208
- @workspace.next_workspace_num_for_matrix(direction: @direction)
209
- ).to eq 1
210
- end
211
- end
212
- end
213
- end
214
- end
215
- end
216
-
217
- describe '#matrix_size' do
218
- context 'with matrix_col_size' do
219
- before do
220
- @workspace = Workspace.new(matrix_col_size: 3)
221
- stub_workspace_values(current: 1, total: 3)
222
- end
223
- it { expect(@workspace.matrix_size(3)).to eq [1, 3] }
224
- end
225
- context 'with matrix_col_size' do
226
- before do
227
- @workspace = Workspace.new(matrix_col_size: nil)
228
- stub_workspace_values(current: 1, total: 3)
229
- end
230
- it { expect { @workspace.matrix_size(3) }.to raise_error Workspace::MissingMatrixOption }
231
- end
232
- end
233
- end
234
- end
235
- end
236
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe Fusuma::Plugin::Wmctrl do
6
- it 'has a version number' do
7
- expect(Fusuma::Plugin::Wmctrl::VERSION).not_to be nil
8
- end
9
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'tempfile'
4
- require 'fusuma/config'
5
-
6
- module Fusuma
7
- module ConfigHelper
8
- module_function
9
-
10
- def load_config_yml=(string)
11
- Config.custom_path = Tempfile.open do |temp_file|
12
- temp_file.tap { |f| f.write(string) }
13
- end
14
- end
15
- end
16
- end
data/spec/spec_helper.rb DELETED
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/setup'
4
- require 'helpers/config_helper'
5
-
6
- RSpec.configure do |config|
7
- # Enable flags like --only-failures and --next-failure
8
- config.example_status_persistence_file_path = '.rspec_status'
9
-
10
- # Disable RSpec exposing methods globally on `Module` and `main`
11
- config.disable_monkey_patching!
12
-
13
- config.expect_with :rspec do |c|
14
- c.syntax = :expect
15
- end
16
-
17
- config.include(Fusuma::ConfigHelper)
18
- end