uh-wm 0.1.0 → 0.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
  SHA1:
3
- metadata.gz: 959239c4e633cdfa25d86371729560ddf40afa4a
4
- data.tar.gz: 704626fb3cfe89b8ea8d84fe5f6e1200d9000ffa
3
+ metadata.gz: 27b71703a3d4d2c882d1b7eb6a972959dae65c49
4
+ data.tar.gz: ead216935237c4e923b9e9469ce86681555daaba
5
5
  SHA512:
6
- metadata.gz: e2a06d4832cfff8ffdb1ed5bf6c59f999b51c8d6e3f055f449e5414be799fd0c88beaf0b054a0c9054d0930d0bfb5a170fc1b5090966c3f60f90b1a9778de3ff
7
- data.tar.gz: 5f96afa7bc57f3ea5e48dc7a8ba8544b9472b29957c06ef0a760a3ba8423c6d0ce26614e2cee2f9e1f70e57aa3253ff724962f2c9b4bfcd8043bda5953442cb7
6
+ metadata.gz: e62db9a4023fe8ca1f9237135c5bb4349ea74842614808bd64c72d41a1b1dcab8094cf1419faba6de0ee5068e1e0f30be683684604a105dd78720a19579da731
7
+ data.tar.gz: 5d5d760b11fc9c6c21365ae3c9a06a5a25dc3ba49508588c6dbdd196c2aa34e9d8f07bac4186bff6c53342584f8274729f4a4fbf326279a819e909777724b96a
@@ -1,3 +1,4 @@
1
+ require 'baf/cli'
1
2
  require 'forwardable'
2
3
  require 'logger'
3
4
  require 'optparse'
@@ -1,90 +1,39 @@
1
1
  module Uh
2
2
  module WM
3
- class CLI
4
- ArgumentError = Class.new(ArgumentError)
5
-
6
- include EnvLogging
7
-
8
- USAGE = "Usage: #{File.basename $0} [options]".freeze
9
-
10
- EX_USAGE = 64
11
- EX_SOFTWARE = 70
12
-
3
+ class CLI < Baf::CLI
13
4
  class << self
14
- def run arguments, stdout: $stdout, stderr: $stderr
15
- cli = new arguments, stdout: stdout
16
- cli.parse_arguments!
17
- cli.run
18
- rescue ArgumentError => e
19
- stderr.puts e
20
- exit EX_USAGE
21
- rescue RuntimeError => e
22
- stderr.puts "#{e.class.name}: #{e.message}"
23
- stderr.puts e.backtrace.map { |l| ' %s' % l } if cli.env.debug?
24
- exit EX_SOFTWARE
5
+ def handle_error env, ex
6
+ env.puts_error "#{ex.class.name}: #{ex.message}"
7
+ env.puts_error ex.backtrace.map { |l| ' %s' % l } if env.debug?
25
8
  end
26
9
  end
27
10
 
28
- attr_reader :env
11
+ def setup
12
+ flag_verbose
13
+ flag_debug
14
+ flag_version WM::VERSION
29
15
 
30
- def initialize args, stdout: $stdout
31
- @arguments = args
32
- @env = Env.new(stdout.tap { |o| o.sync = true })
33
- end
16
+ option :f, :run_control, 'PATH', 'specify alternate run control file' do |path|
17
+ @env.rc_path = path
18
+ end
19
+ option :r, :require, 'PATH', 'require ruby feature' do |feature|
20
+ require feature
21
+ env.log "Loaded `#{feature}' ruby feature"
22
+ end
23
+ option :l, :layout, 'LAYOUT', 'specify layout' do |layout|
24
+ env.layout_class = Object.const_get layout.to_sym
25
+ end
26
+ option :w, :worker, 'WORKER', 'specify worker' do |worker|
27
+ env.worker = worker.to_sym
28
+ end
34
29
 
35
- def parse_arguments!
36
- option_parser.parse! @arguments
37
- rescue OptionParser::InvalidOption
38
- raise ArgumentError, option_parser
30
+ env.sync_output
39
31
  end
40
32
 
41
33
  def run
34
+ env.log_logger_level
42
35
  Runner.run env
43
36
  end
44
-
45
- private
46
-
47
- def option_parser
48
- OptionParser.new do |opts|
49
- opts.banner = USAGE
50
- opts.separator ''
51
- opts.separator 'options:'
52
-
53
- opts.on '-v', '--verbose', 'enable verbose mode' do
54
- @env.verbose = true
55
- @env.log_logger_level
56
- end
57
- opts.on '-d', '--debug', 'enable debug mode' do
58
- @env.debug = true
59
- @env.log_logger_level
60
- end
61
- opts.on '-f', '--run-control PATH',
62
- 'specify alternate run control file' do |e|
63
- @env.rc_path = e
64
- end
65
- opts.on '-r', '--require PATH', 'require ruby feature' do |feature|
66
- require feature
67
- log "Loaded `#{feature}' ruby feature"
68
- end
69
- opts.on '-l', '--layout LAYOUT', 'specify layout' do |layout|
70
- @env.layout_class = Object.const_get layout.to_sym
71
- end
72
- opts.on '-w', Workers.types, '--worker WORKER',
73
- 'specify worker' do |worker|
74
- @env.worker = worker.to_sym
75
- end
76
-
77
- opts.separator ''
78
- opts.on_tail '-h', '--help', 'print this message' do
79
- @env.print opts
80
- exit
81
- end
82
- opts.on_tail '-V', '--version', 'print version' do
83
- @env.puts WM::VERSION
84
- exit
85
- end
86
- end
87
- end
88
37
  end
89
38
  end
90
39
  end
@@ -1,6 +1,6 @@
1
1
  module Uh
2
2
  module WM
3
- class Env
3
+ class Env < Baf::Env
4
4
  RC_PATH = '~/.uhwmrc.rb'.freeze
5
5
 
6
6
  MODIFIER = :mod1
@@ -15,19 +15,17 @@ module Uh
15
15
  LOGGER_LEVEL_STRINGS = %w[DEBUG INFO WARN ERROR FATAL UNKNOWN].freeze
16
16
 
17
17
  extend Forwardable
18
- def_delegator :logger, :info, :log
19
- def_delegator :logger, :fatal, :log_fatal
20
- def_delegator :logger, :error, :log_error
21
- def_delegator :logger, :debug, :log_debug
22
- def_delegators :@output, :print, :puts
18
+ def_delegator :logger, :info, :log
19
+ def_delegator :logger, :fatal, :log_fatal
20
+ def_delegator :logger, :error, :log_error
21
+ def_delegator :logger, :debug, :log_debug
23
22
 
24
- attr_reader :output, :keybinds
25
- attr_accessor :verbose, :debug, :rc_path, :modifier, :modifier_ignore,
26
- :worker, :layout, :layout_class, :layout_options, :rules,
27
- :launch
23
+ attr_reader :keybinds
24
+ attr_accessor :rc_path, :modifier, :modifier_ignore, :worker, :layout,
25
+ :layout_class, :layout_options, :rules, :launch
28
26
 
29
- def initialize output
30
- @output = output
27
+ def initialize output: $stdout, **_
28
+ super
31
29
  @rc_path = RC_PATH
32
30
  @modifier = MODIFIER
33
31
  @modifier_ignore = []
@@ -37,14 +35,6 @@ module Uh
37
35
  @rules = {}
38
36
  end
39
37
 
40
- def verbose?
41
- !!@verbose
42
- end
43
-
44
- def debug?
45
- !!@debug
46
- end
47
-
48
38
  def layout
49
39
  @layout ||= if layout_class
50
40
  layout_class.new @layout_options
@@ -1,3 +1,5 @@
1
+ require 'baf/testing/cucumber/steps/output_wait'
2
+
1
3
  require 'uh'
2
4
  require 'uh/wm/testing/x_client'
3
5
 
@@ -5,22 +7,11 @@ module Uh
5
7
  module WM
6
8
  module Testing
7
9
  module AcceptanceHelpers
8
- TIMEOUT_DEFAULT = 2
9
10
  QUIT_KEYBINDING = 'alt+shift+q'.freeze
10
11
  LOG_READY = 'Working events'.freeze
11
12
 
12
13
  attr_reader :other_wm
13
14
 
14
- def build_regexp pattern, options
15
- Regexp.new(pattern, options.each_char.inject(0) do |m, e|
16
- m | case e
17
- when ?i then Regexp::IGNORECASE
18
- when ?m then Regexp::MULTILINE
19
- when ?x then Regexp::EXTENDED
20
- end
21
- end)
22
- end
23
-
24
15
  def icccm_window_start
25
16
  @icccm_window = ChildProcess.build(*%w[xmessage window])
26
17
  @icccm_window.start
@@ -34,49 +25,20 @@ module Uh
34
25
  'xmessage'
35
26
  end
36
27
 
37
- def uhwm_run options = '-v'
38
- command = %w[uhwm]
39
- command << options if options
40
- @interactive = @process = run command.join ' '
41
- end
42
-
43
- def uhwm
44
- @process
45
- end
46
-
47
28
  def uhwm_request_quit
48
29
  x_key QUIT_KEYBINDING
49
30
  end
50
31
 
51
32
  def uhwm_ensure_stop
52
- if @process
53
- x_key 'alt+shift+q'
54
- @process.terminate
55
- end
56
- end
57
-
58
- def uhwm_wait_output message, times = 1, value = nil
59
- output = -> { @process.stdout + @process.stderr }
60
- timeout_until do
61
- case message
62
- when Regexp then (value = output.call.scan(message)).size >= times
63
- when String then output.call.include? message
64
- end
65
- end
66
- value
67
- rescue TimeoutError => e
68
- raise <<-eoh
69
- expected `#{message}' (#{times}) not seen after #{e.timeout} seconds in:
70
- ```\n#{output.call.lines.map { |l| " #{l}" }.join} ```
71
- eoh
33
+ uhwm_request_quit
72
34
  end
73
35
 
74
36
  def uhwm_wait_ready
75
- uhwm_wait_output LOG_READY
37
+ wait_output! LOG_READY
76
38
  end
77
39
 
78
- def uhwm_run_wait_ready options = nil
79
- if options then uhwm_run options else uhwm_run end
40
+ def uhwm_run_wait_ready options = '-v'
41
+ program_run wait: false, opts: options
80
42
  uhwm_wait_ready
81
43
  end
82
44
 
@@ -116,31 +78,6 @@ expected `#{message}' (#{times}) not seen after #{e.timeout} seconds in:
116
78
  end
117
79
  `xwininfo #{select_args} 2> /dev/null`[/Map State: (\w+)/, 1]
118
80
  end
119
-
120
- private
121
-
122
- def timeout_until message = 'condition not met after %d seconds'
123
- timeout = ENV.key?('UHWMTEST_TIMEOUT') ?
124
- ENV['UHWMTEST_TIMEOUT'].to_i :
125
- TIMEOUT_DEFAULT
126
- Timeout.timeout(timeout) do
127
- loop do
128
- break if yield
129
- sleep 0.1
130
- end
131
- end
132
- rescue Timeout::Error
133
- raise TimeoutError.new(message % timeout, timeout)
134
- end
135
-
136
- class TimeoutError < ::StandardError
137
- attr_reader :timeout
138
-
139
- def initialize message, timeout
140
- super message
141
- @timeout = timeout
142
- end
143
- end
144
81
  end
145
82
  end
146
83
  end
@@ -1,5 +1,5 @@
1
1
  module Uh
2
2
  module WM
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uh-wm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibault Jouan
@@ -10,10 +10,27 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2017-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: baf
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.9'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rb-kqueue
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.2'
17
34
  - - ">="
18
35
  - !ruby/object:Gem::Version
19
36
  version: 0.2.4
@@ -21,6 +38,9 @@ dependencies:
21
38
  prerelease: false
22
39
  version_requirements: !ruby/object:Gem::Requirement
23
40
  requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.2'
24
44
  - - ">="
25
45
  - !ruby/object:Gem::Version
26
46
  version: 0.2.4
@@ -42,6 +62,9 @@ dependencies:
42
62
  name: uh-layout
43
63
  requirement: !ruby/object:Gem::Requirement
44
64
  requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.4'
45
68
  - - ">="
46
69
  - !ruby/object:Gem::Version
47
70
  version: 0.4.2
@@ -49,65 +72,40 @@ dependencies:
49
72
  prerelease: false
50
73
  version_requirements: !ruby/object:Gem::Requirement
51
74
  requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '0.4'
52
78
  - - ">="
53
79
  - !ruby/object:Gem::Version
54
80
  version: 0.4.2
55
81
  - !ruby/object:Gem::Dependency
56
- name: aruba
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '='
60
- - !ruby/object:Gem::Version
61
- version: 0.7.4
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '='
67
- - !ruby/object:Gem::Version
68
- version: 0.7.4
69
- - !ruby/object:Gem::Dependency
70
- name: cucumber
82
+ name: rake
71
83
  requirement: !ruby/object:Gem::Requirement
72
84
  requirements:
73
85
  - - "~>"
74
86
  - !ruby/object:Gem::Version
75
- version: '2.0'
87
+ version: '10'
76
88
  type: :development
77
89
  prerelease: false
78
90
  version_requirements: !ruby/object:Gem::Requirement
79
91
  requirements:
80
92
  - - "~>"
81
93
  - !ruby/object:Gem::Version
82
- version: '2.0'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
94
+ version: '10'
97
95
  - !ruby/object:Gem::Dependency
98
- name: rspec
96
+ name: baf-testing
99
97
  requirement: !ruby/object:Gem::Requirement
100
98
  requirements:
101
99
  - - "~>"
102
100
  - !ruby/object:Gem::Version
103
- version: '3.2'
101
+ version: '0.0'
104
102
  type: :development
105
103
  prerelease: false
106
104
  version_requirements: !ruby/object:Gem::Requirement
107
105
  requirements:
108
106
  - - "~>"
109
107
  - !ruby/object:Gem::Version
110
- version: '3.2'
108
+ version: '0.0'
111
109
  description: |2
112
110
  uhwm is a minimalistic tiling and stacking window manager for X. It
113
111
  shares some similarities with dwm and wmii, but is written in ruby so