uh-wm 0.0.2.pre → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +15 -0
  5. data/Gemfile +5 -0
  6. data/Guardfile +12 -0
  7. data/LICENSE +30 -0
  8. data/README.md +68 -0
  9. data/Rakefile +40 -0
  10. data/bin/uhwm +5 -0
  11. data/config/cucumber.yaml +1 -0
  12. data/features/actions/execute.feature +9 -0
  13. data/features/actions/layout_delegation.feature +31 -0
  14. data/features/actions/quit.feature +9 -0
  15. data/features/cli/debug.feature +5 -0
  16. data/features/cli/layout.feature +15 -0
  17. data/features/cli/require.feature +5 -0
  18. data/features/cli/run_control.feature +9 -0
  19. data/features/cli/usage.feature +11 -0
  20. data/features/cli/verbose.feature +5 -0
  21. data/features/cli/version.feature +6 -0
  22. data/features/cli/worker.feature +9 -0
  23. data/features/layout/manage.feature +12 -0
  24. data/features/layout/protocol.feature +24 -0
  25. data/features/layout/unmanage.feature +10 -0
  26. data/features/manager/check_other_wm.feature +8 -0
  27. data/features/manager/input_events.feature +8 -0
  28. data/features/manager/manage.feature +14 -0
  29. data/features/manager/unmanage.feature +13 -0
  30. data/features/manager/x_errors.feature +17 -0
  31. data/features/run_control/evaluation.feature +18 -0
  32. data/features/run_control/key.feature +33 -0
  33. data/features/run_control/modifier.feature +10 -0
  34. data/features/run_control/worker.feature +9 -0
  35. data/features/session/connection.feature +5 -0
  36. data/features/session/termination.feature +13 -0
  37. data/features/steps/filesystem_steps.rb +3 -0
  38. data/features/steps/output_steps.rb +44 -0
  39. data/features/steps/run_control_steps.rb +3 -0
  40. data/features/steps/run_steps.rb +41 -0
  41. data/features/steps/x_steps.rb +53 -0
  42. data/features/support/env.rb +33 -0
  43. data/lib/uh/wm.rb +8 -0
  44. data/lib/uh/wm/actions_handler.rb +46 -0
  45. data/lib/uh/wm/cli.rb +20 -13
  46. data/lib/uh/wm/client.rb +64 -0
  47. data/lib/uh/wm/dispatcher.rb +3 -1
  48. data/lib/uh/wm/env.rb +15 -9
  49. data/lib/uh/wm/env_logging.rb +8 -0
  50. data/lib/uh/wm/logger_formatter.rb +16 -0
  51. data/lib/uh/wm/manager.rb +96 -14
  52. data/lib/uh/wm/run_control.rb +8 -3
  53. data/lib/uh/wm/runner.rb +82 -14
  54. data/lib/uh/wm/testing/acceptance_helpers.rb +140 -18
  55. data/lib/uh/wm/version.rb +1 -1
  56. data/lib/uh/wm/workers.rb +21 -0
  57. data/lib/uh/wm/workers/base.rb +27 -0
  58. data/lib/uh/wm/workers/blocking.rb +11 -0
  59. data/lib/uh/wm/workers/mux.rb +18 -0
  60. data/spec/spec_helper.rb +26 -0
  61. data/spec/support/exit_helpers.rb +6 -0
  62. data/spec/support/filesystem_helpers.rb +11 -0
  63. data/spec/uh/wm/actions_handler_spec.rb +30 -0
  64. data/spec/uh/wm/cli_spec.rb +214 -0
  65. data/spec/uh/wm/client_spec.rb +133 -0
  66. data/spec/uh/wm/dispatcher_spec.rb +76 -0
  67. data/spec/uh/wm/env_spec.rb +145 -0
  68. data/spec/uh/wm/manager_spec.rb +355 -0
  69. data/spec/uh/wm/run_control_spec.rb +102 -0
  70. data/spec/uh/wm/runner_spec.rb +186 -0
  71. data/uh-wm.gemspec +25 -0
  72. metadata +112 -9
@@ -0,0 +1,102 @@
1
+ require 'support/filesystem_helpers'
2
+
3
+ module Uh
4
+ module WM
5
+ RSpec.describe RunControl do
6
+ include FileSystemHelpers
7
+
8
+ let(:code) { :run_control_code }
9
+ let(:env) { Env.new(StringIO.new) }
10
+ subject(:rc) { described_class.new env }
11
+
12
+ describe '.evaluate' do
13
+ around do |example|
14
+ with_file ':run_control_code' do |f|
15
+ env.rc_path = f.path
16
+ example.run
17
+ end
18
+ end
19
+
20
+ it 'builds a new instance with given env' do
21
+ expect(described_class).to receive(:new).with(env).and_call_original
22
+ described_class.evaluate env
23
+ end
24
+
25
+ it 'tells the new instance to evaluate run control file content' do
26
+ expect(rc)
27
+ .to receive(:evaluate).with(':run_control_code', env.rc_path)
28
+ allow(described_class).to receive(:new) { rc }
29
+ described_class.evaluate env
30
+ end
31
+
32
+ context 'when run control file is not present' do
33
+ before { env.rc_path = 'non_existent_rc_file.rb' }
34
+
35
+ it 'does not raise any error' do
36
+ expect { described_class.evaluate env }.not_to raise_error
37
+ end
38
+ end
39
+ end
40
+
41
+ describe '#evaluate' do
42
+ it 'evaluates given code' do
43
+ expect { rc.evaluate 'throw :run_control_code', 'some_path' }
44
+ .to throw_symbol :run_control_code
45
+ end
46
+
47
+ it 'provides access to assigned env' do
48
+ expect { rc.evaluate 'fail @env.object_id.to_s', 'some_path' }
49
+ .to raise_error env.object_id.to_s
50
+ end
51
+ end
52
+
53
+ describe '#modifier' do
54
+ it 'updates env modifier' do
55
+ rc.modifier :ctrl
56
+ expect(env.modifier).to eq :ctrl
57
+ end
58
+ end
59
+
60
+ describe '#key' do
61
+ let(:code) { -> { :keybind_code } }
62
+
63
+ it 'registers a key binding in the env' do
64
+ rc.key :f, &code
65
+ expect(env.keybinds.keys).to include :f
66
+ end
67
+
68
+ it 'registers a combined keys binding in the env' do
69
+ rc.key :f, :shift, &code
70
+ expect(env.keybinds.keys).to include %i[f shift]
71
+ end
72
+
73
+ it 'registers given block with the key binding' do
74
+ rc.key :f, &code
75
+ expect(env.keybinds[:f].call).to eq :keybind_code
76
+ end
77
+
78
+ it 'translates common key names to equivalent X keysym' do
79
+ rc.key :enter, &code
80
+ expect(env.keybinds.keys).to include :Return
81
+ end
82
+
83
+ it 'translates upcased key name to a combination with shift' do
84
+ rc.key :F, &code
85
+ expect(env.keybinds.keys).to include %i[f shift]
86
+ end
87
+ end
88
+
89
+ describe '#worker' do
90
+ it 'sets the worker type in the env' do
91
+ rc.worker :some_worker
92
+ expect(env.worker[0]).to eq :some_worker
93
+ end
94
+
95
+ it 'sets the worker options in the env' do
96
+ rc.worker :some_worker, some: :option
97
+ expect(env.worker[1]).to eq({ some: :option })
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,186 @@
1
+ SomeLayout = Class.new do
2
+ define_method(:register) { |*args| }
3
+ define_method(:suggest_geo) { Uh::Geo.new(0, 0, 42, 42) }
4
+ define_method(:<<) { |*args| }
5
+ define_method(:remove) { |*args| }
6
+ end
7
+
8
+ module Uh
9
+ module WM
10
+ RSpec.describe Runner do
11
+ let(:env) { Env.new(StringIO.new) }
12
+ subject(:runner) { described_class.new env }
13
+
14
+ before do
15
+ env.layout_class = SomeLayout
16
+ env.rc_path = 'non_existent_run_control.rb'
17
+ end
18
+
19
+ it 'has the env' do
20
+ expect(runner.env).to be env
21
+ end
22
+
23
+ it 'has a dispatcher' do
24
+ expect(runner.events).to be_a Dispatcher
25
+ end
26
+
27
+ it 'is not stopped' do
28
+ expect(runner).not_to be_stopped
29
+ end
30
+
31
+ describe '#stopped?' do
32
+ context 'when not stopped' do
33
+ it 'returns false' do
34
+ expect(runner.stopped?).to be false
35
+ end
36
+ end
37
+
38
+ context 'when stopped' do
39
+ before { runner.stop! }
40
+
41
+ it 'returns true' do
42
+ expect(runner.stopped?).to be true
43
+ end
44
+ end
45
+ end
46
+
47
+ describe '#stop!' do
48
+ it 'sets the runner as stopped' do
49
+ expect { runner.stop! }
50
+ .to change { runner.stopped? }
51
+ .from(false).to(true)
52
+ end
53
+ end
54
+
55
+ describe '#manager' do
56
+ it 'returns the manager' do
57
+ expect(runner.manager).to be_a Manager
58
+ end
59
+
60
+ it 'sets the manager modifier as env modifier' do
61
+ expect(runner.manager.modifier).to eq env.modifier
62
+ end
63
+ end
64
+
65
+ describe '#evaluate_run_control' do
66
+ it 'evaluates the run control file with RunControl and current env' do
67
+ expect(RunControl).to receive(:evaluate).with env
68
+ runner.evaluate_run_control
69
+ end
70
+ end
71
+
72
+ describe '#register_event_hooks' do
73
+ it 'registers quit event hook' do
74
+ runner.register_event_hooks
75
+ expect(runner).to receive(:stop!)
76
+ runner.events.emit :quit
77
+ end
78
+
79
+ context 'layout hooks' do
80
+ it 'registers for :connected event' do
81
+ runner.register_event_hooks
82
+ expect(env.layout).to receive(:register).with :display
83
+ runner.events.emit :connected, args: :display
84
+ end
85
+
86
+ it 'registers for :configure event' do
87
+ runner.register_event_hooks
88
+ expect(runner.events.emit :configure, args: :window)
89
+ .to eq Geo.new(0, 0, 42, 42)
90
+ end
91
+
92
+ it 'registers for :manage event' do
93
+ runner.register_event_hooks
94
+ expect(env.layout).to receive(:<<).with :client
95
+ runner.events.emit :manage, args: :client
96
+ end
97
+
98
+ it 'registers for :unmanage event' do
99
+ runner.register_event_hooks
100
+ expect(env.layout).to receive(:remove).with :client
101
+ runner.events.emit :unmanage, args: :client
102
+ end
103
+ end
104
+
105
+ context 'keys hooks' do
106
+ it 'registers for :key' do
107
+ env.keybinds[:f] = -> { }
108
+ runner.register_event_hooks
109
+ expect(runner.events[:key, :f]).not_to be_empty
110
+ end
111
+
112
+ it 'registers for :key with combined key bindings' do
113
+ env.keybinds[[:f, :shift]] = -> { }
114
+ runner.register_event_hooks
115
+ expect(runner.events[:key, :f, :shift]).not_to be_empty
116
+ end
117
+
118
+ it 'registers code evaluation with the actions handler' do
119
+ env.keybinds[:f] = code = proc { }
120
+ runner.register_event_hooks
121
+ expect(runner.actions).to receive(:evaluate).with code
122
+ runner.events.emit :key, :f
123
+ end
124
+ end
125
+ end
126
+
127
+ describe '#connect_manager' do
128
+ let(:manager) { instance_spy Manager }
129
+ subject(:runner) { described_class.new env, manager: manager }
130
+
131
+ it 'connects the manager' do
132
+ expect(runner.manager).to receive :connect
133
+ runner.connect_manager
134
+ end
135
+
136
+ it 'tells the manager to grab keys for env key bindings' do
137
+ env.keybinds[:f] = -> { }
138
+ expect(runner.manager).to receive(:grab_key).with :f
139
+ runner.connect_manager
140
+ end
141
+ end
142
+
143
+ describe '#worker' do
144
+ it 'returns a worker' do
145
+ expect(runner.worker).to respond_to :work_events
146
+ end
147
+
148
+ it 'setups the read callback to tell manager to handle pending events' do
149
+ expect(runner.manager).to receive :handle_pending_events
150
+ runner.worker.on_read.call
151
+ end
152
+
153
+ it 'setups the read_next callback to tell manager to handle next event' do
154
+ expect(runner.manager).to receive :handle_next_event
155
+ runner.worker.on_read_next.call
156
+ end
157
+
158
+ it 'setups the timeout callback to tell manager to flush the output' do
159
+ expect(runner.manager).to receive :flush
160
+ runner.worker.on_timeout.call
161
+ end
162
+ end
163
+
164
+ describe '#run_until' do
165
+ it 'tells the worker to watch the manager' do
166
+ expect(runner.worker).to receive(:watch).with runner.manager
167
+ runner.run_until { true }
168
+ end
169
+
170
+ it 'tells the worker to work events until given block is true' do
171
+ block = proc { }
172
+ allow(block).to receive(:call).and_return(false, false, false, true)
173
+ expect(runner.worker).to receive(:work_events).exactly(3).times
174
+ runner.run_until &block
175
+ end
176
+ end
177
+
178
+ describe '#terminate' do
179
+ it 'tells the manager to disconnect' do
180
+ expect(runner.manager).to receive :disconnect
181
+ runner.terminate
182
+ end
183
+ end
184
+ end
185
+ end
186
+ end
data/uh-wm.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ require File.expand_path('../lib/uh/wm/version', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'uh-wm'
5
+ s.version = Uh::WM::VERSION.dup
6
+ s.summary = 'minimalistic tiling and stacking window manager for X'
7
+ s.description = s.name
8
+ s.homepage = 'https://rubygems.org/gems/uh-wm'
9
+
10
+ s.authors = 'Thibault Jouan'
11
+ s.email = 'tj@a13.fr'
12
+
13
+ s.files = `git ls-files`.split $/
14
+ s.test_files = s.files.grep /\A(spec|features)\//
15
+ s.executables = s.files.grep(/\Abin\//) { |f| File.basename(f) }
16
+
17
+ s.add_dependency 'uh', '2.0.0.pre2'
18
+ s.add_dependency 'uh-layout', '0.2.0.pre'
19
+
20
+ s.add_development_dependency 'aruba', '~> 0.6'
21
+ s.add_development_dependency 'cucumber', '~> 2.0'
22
+ s.add_development_dependency 'headless', '~> 1.0'
23
+ s.add_development_dependency 'rake', '~> 10.4'
24
+ s.add_development_dependency 'rspec', '~> 3.2'
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uh-wm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.pre
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibault Jouan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-15 00:00:00.000000000 Z
11
+ date: 2015-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uh
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0.pre
19
+ version: 2.0.0.pre2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0.pre
26
+ version: 2.0.0.pre2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: uh-layout
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -110,20 +110,81 @@ dependencies:
110
110
  version: '3.2'
111
111
  description: uh-wm
112
112
  email: tj@a13.fr
113
- executables: []
113
+ executables:
114
+ - uhwm
114
115
  extensions: []
115
116
  extra_rdoc_files: []
116
117
  files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - Gemfile
122
+ - Guardfile
123
+ - LICENSE
124
+ - README.md
125
+ - Rakefile
126
+ - bin/uhwm
127
+ - config/cucumber.yaml
128
+ - features/actions/execute.feature
129
+ - features/actions/layout_delegation.feature
130
+ - features/actions/quit.feature
131
+ - features/cli/debug.feature
132
+ - features/cli/layout.feature
133
+ - features/cli/require.feature
134
+ - features/cli/run_control.feature
135
+ - features/cli/usage.feature
136
+ - features/cli/verbose.feature
137
+ - features/cli/version.feature
138
+ - features/cli/worker.feature
139
+ - features/layout/manage.feature
140
+ - features/layout/protocol.feature
141
+ - features/layout/unmanage.feature
142
+ - features/manager/check_other_wm.feature
143
+ - features/manager/input_events.feature
144
+ - features/manager/manage.feature
145
+ - features/manager/unmanage.feature
146
+ - features/manager/x_errors.feature
147
+ - features/run_control/evaluation.feature
148
+ - features/run_control/key.feature
149
+ - features/run_control/modifier.feature
150
+ - features/run_control/worker.feature
151
+ - features/session/connection.feature
152
+ - features/session/termination.feature
153
+ - features/steps/filesystem_steps.rb
154
+ - features/steps/output_steps.rb
155
+ - features/steps/run_control_steps.rb
156
+ - features/steps/run_steps.rb
157
+ - features/steps/x_steps.rb
158
+ - features/support/env.rb
117
159
  - lib/uh/wm.rb
118
160
  - lib/uh/wm/actions_handler.rb
119
161
  - lib/uh/wm/cli.rb
162
+ - lib/uh/wm/client.rb
120
163
  - lib/uh/wm/dispatcher.rb
121
164
  - lib/uh/wm/env.rb
165
+ - lib/uh/wm/env_logging.rb
166
+ - lib/uh/wm/logger_formatter.rb
122
167
  - lib/uh/wm/manager.rb
123
168
  - lib/uh/wm/run_control.rb
124
169
  - lib/uh/wm/runner.rb
125
170
  - lib/uh/wm/testing/acceptance_helpers.rb
126
171
  - lib/uh/wm/version.rb
172
+ - lib/uh/wm/workers.rb
173
+ - lib/uh/wm/workers/base.rb
174
+ - lib/uh/wm/workers/blocking.rb
175
+ - lib/uh/wm/workers/mux.rb
176
+ - spec/spec_helper.rb
177
+ - spec/support/exit_helpers.rb
178
+ - spec/support/filesystem_helpers.rb
179
+ - spec/uh/wm/actions_handler_spec.rb
180
+ - spec/uh/wm/cli_spec.rb
181
+ - spec/uh/wm/client_spec.rb
182
+ - spec/uh/wm/dispatcher_spec.rb
183
+ - spec/uh/wm/env_spec.rb
184
+ - spec/uh/wm/manager_spec.rb
185
+ - spec/uh/wm/run_control_spec.rb
186
+ - spec/uh/wm/runner_spec.rb
187
+ - uh-wm.gemspec
127
188
  homepage: https://rubygems.org/gems/uh-wm
128
189
  licenses: []
129
190
  metadata: {}
@@ -138,13 +199,55 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
199
  version: '0'
139
200
  required_rubygems_version: !ruby/object:Gem::Requirement
140
201
  requirements:
141
- - - ">"
202
+ - - ">="
142
203
  - !ruby/object:Gem::Version
143
- version: 1.3.1
204
+ version: '0'
144
205
  requirements: []
145
206
  rubyforge_project:
146
207
  rubygems_version: 2.4.5
147
208
  signing_key:
148
209
  specification_version: 4
149
- summary: uh window manager
150
- test_files: []
210
+ summary: minimalistic tiling and stacking window manager for X
211
+ test_files:
212
+ - features/actions/execute.feature
213
+ - features/actions/layout_delegation.feature
214
+ - features/actions/quit.feature
215
+ - features/cli/debug.feature
216
+ - features/cli/layout.feature
217
+ - features/cli/require.feature
218
+ - features/cli/run_control.feature
219
+ - features/cli/usage.feature
220
+ - features/cli/verbose.feature
221
+ - features/cli/version.feature
222
+ - features/cli/worker.feature
223
+ - features/layout/manage.feature
224
+ - features/layout/protocol.feature
225
+ - features/layout/unmanage.feature
226
+ - features/manager/check_other_wm.feature
227
+ - features/manager/input_events.feature
228
+ - features/manager/manage.feature
229
+ - features/manager/unmanage.feature
230
+ - features/manager/x_errors.feature
231
+ - features/run_control/evaluation.feature
232
+ - features/run_control/key.feature
233
+ - features/run_control/modifier.feature
234
+ - features/run_control/worker.feature
235
+ - features/session/connection.feature
236
+ - features/session/termination.feature
237
+ - features/steps/filesystem_steps.rb
238
+ - features/steps/output_steps.rb
239
+ - features/steps/run_control_steps.rb
240
+ - features/steps/run_steps.rb
241
+ - features/steps/x_steps.rb
242
+ - features/support/env.rb
243
+ - spec/spec_helper.rb
244
+ - spec/support/exit_helpers.rb
245
+ - spec/support/filesystem_helpers.rb
246
+ - spec/uh/wm/actions_handler_spec.rb
247
+ - spec/uh/wm/cli_spec.rb
248
+ - spec/uh/wm/client_spec.rb
249
+ - spec/uh/wm/dispatcher_spec.rb
250
+ - spec/uh/wm/env_spec.rb
251
+ - spec/uh/wm/manager_spec.rb
252
+ - spec/uh/wm/run_control_spec.rb
253
+ - spec/uh/wm/runner_spec.rb