baf 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/baf.rb +2 -2
- data/lib/baf/cli.rb +14 -5
- data/lib/baf/env.rb +5 -3
- data/lib/baf/testing/cucumber/steps/output_wait.rb +2 -2
- data/lib/baf/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b953e86f4f36c48b3401c8415ebad766276a775
|
4
|
+
data.tar.gz: b25cb6a092dc3d54fae9696a8104fde2ff25b7c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 357dde19820d28cbffabe4f9edc9ba71992af6c341214c74c815db8978e989415f56f6ef8ddc6fee6a8a33c1ba4a5a09e409e82fb9800ce9203e03f26790919e
|
7
|
+
data.tar.gz: 0a1bc15eab8fb67eab0b0baa1a3bdd9e4c13a93ff364fcc9e16dedc2ca36ef2d698b2678d44e5208f85fd929dc8388f088ffd2c6fda3ebdc1512c1d423fd6720
|
data/lib/baf.rb
CHANGED
data/lib/baf/cli.rb
CHANGED
@@ -8,30 +8,39 @@ require 'baf/options_registrant'
|
|
8
8
|
|
9
9
|
module Baf
|
10
10
|
class CLI
|
11
|
-
ArgumentError = Class.new
|
11
|
+
ArgumentError = Class.new ::Baf::ArgumentError
|
12
12
|
|
13
13
|
EX_USAGE = 64
|
14
14
|
EX_SOFTWARE = 70
|
15
15
|
|
16
16
|
class << self
|
17
17
|
def run arguments, stdin: $stdin, stdout: $stdout, stderr: $stderr
|
18
|
-
cli = new
|
18
|
+
cli = new env = build_env(stdin, stdout, stderr), arguments
|
19
19
|
cli.parse_arguments!
|
20
20
|
cli.run
|
21
21
|
rescue ArgumentError => e
|
22
22
|
stderr.puts e
|
23
23
|
exit EX_USAGE
|
24
24
|
rescue StandardError => e
|
25
|
-
|
26
|
-
|
25
|
+
if respond_to? :handle_error
|
26
|
+
status = handle_error cli.env, e
|
27
|
+
exit status if status.respond_to? :to_int
|
28
|
+
else
|
29
|
+
stderr.puts "#{e.class.name}: #{e}"
|
30
|
+
stderr.puts e.backtrace.map { |l| ' %s' % l }
|
31
|
+
end
|
27
32
|
exit EX_SOFTWARE
|
28
33
|
end
|
29
34
|
|
30
35
|
private
|
31
36
|
|
37
|
+
def build_env stdin, stdout, stderr
|
38
|
+
env_class.new input: stdin, output: stdout, output_error: stderr
|
39
|
+
end
|
40
|
+
|
32
41
|
def env_class
|
33
42
|
return Env unless parent_name = name =~ /::[^:]+\Z/ ? $` : nil
|
34
|
-
parent = Object.const_get
|
43
|
+
parent = Object.const_get parent_name
|
35
44
|
parent.const_defined?(:Env) ? parent.const_get(:Env) : Env
|
36
45
|
end
|
37
46
|
end
|
data/lib/baf/env.rb
CHANGED
@@ -5,10 +5,12 @@ module Baf
|
|
5
5
|
extend Forwardable
|
6
6
|
def_delegators :@input, :gets
|
7
7
|
def_delegators :@output, :print, :puts
|
8
|
+
def_delegator :@output_error, :puts, :puts_error
|
8
9
|
|
9
|
-
def initialize input: $input, output: $stdout
|
10
|
-
@input
|
11
|
-
@output
|
10
|
+
def initialize input: $input, output: $stdout, output_error: $stderr
|
11
|
+
@input = input
|
12
|
+
@output = output
|
13
|
+
@output_error = output_error
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
@@ -33,7 +33,7 @@ def wait_until message: 'condition not met after %d seconds'
|
|
33
33
|
timeout = ENV.key?('BAF_TEST_TIMEOUT') ?
|
34
34
|
ENV['BAF_TEST_TIMEOUT'].to_i :
|
35
35
|
2
|
36
|
-
Timeout.timeout
|
36
|
+
Timeout.timeout timeout do
|
37
37
|
loop do
|
38
38
|
break if yield
|
39
39
|
sleep 0.05
|
@@ -45,7 +45,7 @@ end
|
|
45
45
|
|
46
46
|
|
47
47
|
Then /^the output will match \/([^\/]+)\/([a-z]*)$/ do |pattern, options|
|
48
|
-
wait_output! build_regexp
|
48
|
+
wait_output! build_regexp pattern, options
|
49
49
|
end
|
50
50
|
|
51
51
|
Then /^the output will contain:$/ do |content|
|
data/lib/baf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thibault Jouan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: baf-testing
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
78
|
rubyforge_project:
|
79
|
-
rubygems_version: 2.6.
|
79
|
+
rubygems_version: 2.6.14
|
80
80
|
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: Basic Application Framework
|