baf 0.14.0 → 0.14.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
- SHA1:
3
- metadata.gz: 30b9c85a7af0b78d5fde855f4df47b907ee0f3f4
4
- data.tar.gz: 5fc0895f480eb22b9589c2d7ae5cb292838db483
2
+ SHA256:
3
+ metadata.gz: 9311e4cba4d27aee336f9983d97efd78d8296b5672ec1dccc3337056b66ba620
4
+ data.tar.gz: a9ba3e9ab48e78e71173faaa63eece4addadcc9573e28ea6d3b19adbe6fc41c9
5
5
  SHA512:
6
- metadata.gz: 1048997ad551c80a4927c97966aa647eab6e3480a26f2131f2593bd0af29dfa0791ac74a401acce57972c9af5a8aa30b2c32121d1fc714c27c83a010c96a4e7b
7
- data.tar.gz: 946e877506f84efecd2f6ab63a9a8dece8665c1d6f592301424b3b58af3ac586ecc51ae08e34fe65f0d5bf966207d713bee23853951eea52be0ec74683bd309e
6
+ metadata.gz: 7aeeb1da2a0f359a5a537580ab13384b3cba5501a6c00722c0f025760eb4c31c951ddf0616410138520bd2457972386dd1bf9bd976259aa271d6365187a0d6e7
7
+ data.tar.gz: 74267eaf156de24338b988e46960565cb1eefc6dc5b241ccb1dba4db022ed6bd313f5932d944833ab010f858b314daeb3145318e01a8a6b52925e730f753f1af
data/lib/baf.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Baf
2
- Error = Class.new ::StandardError
2
+ Error = Class.new ::StandardError
3
3
  ArgumentError = Class.new Error
4
4
  end
@@ -10,7 +10,7 @@ module Baf
10
10
  class CLI
11
11
  ArgumentError = Class.new ::Baf::ArgumentError
12
12
 
13
- EX_USAGE = 64
13
+ EX_USAGE = 64
14
14
  EX_SOFTWARE = 70
15
15
 
16
16
  class << self
@@ -43,15 +43,17 @@ module Baf
43
43
  parent = Object.const_get parent_name
44
44
  parent.const_defined?(:Env) ? parent.const_get(:Env) : Env
45
45
  end
46
+
47
+ def ruby2_keywords *; end unless Module.respond_to? :ruby2_keywords, true
46
48
  end
47
49
 
48
50
  attr_reader :arguments, :env, :parser
49
51
 
50
52
  def initialize env, arguments, **opts
51
- @env = env
52
- @arguments = arguments
53
- @parser = opts[:parser] || OptionParser.new
54
- @registrant = opts[:registrant] || OptionsRegistrant.new
53
+ @env = env
54
+ @arguments = arguments
55
+ @parser = opts.fetch(:parser) { OptionParser.new }
56
+ @registrant = opts.fetch(:registrant) { OptionsRegistrant.new }
55
57
 
56
58
  registrant.register(env, parser) { setup }
57
59
  end
@@ -63,6 +65,7 @@ module Baf
63
65
  registrant.banner = arg
64
66
  end
65
67
 
68
+ ruby2_keywords \
66
69
  def flag *args
67
70
  registrant.flag *args
68
71
  end
@@ -80,15 +83,15 @@ module Baf
80
83
  tail: true
81
84
  end
82
85
 
83
- def option *args
84
- args = [*args, Proc.new] if block_given?
86
+ def option *args, &block
87
+ args = [*args, block] if block_given?
85
88
  registrant.option *args
86
89
  end
87
90
 
88
91
  def parse_arguments!
89
92
  parser.parse! arguments
90
93
  rescue OptionParser::InvalidOption
91
- raise ArgumentError, parser
94
+ fail ArgumentError, parser
92
95
  end
93
96
 
94
97
  def usage!
@@ -7,9 +7,9 @@ module Baf
7
7
  def_delegators :@output, :print, :puts
8
8
  def_delegator :@output_error, :puts, :puts_error
9
9
 
10
- def initialize input: $input, output: $stdout, output_error: $stderr
11
- @input = input
12
- @output = output
10
+ def initialize input: $stdin, output: $stdout, output_error: $stderr
11
+ @input = input
12
+ @output = output
13
13
  @output_error = output_error
14
14
  end
15
15
 
@@ -41,20 +41,20 @@ module Baf
41
41
 
42
42
  def build_attrs short, long, arg_or_desc = nil, desc_or_block = nil, block = nil
43
43
  {
44
- short: short,
45
- long: long,
46
- desc: arg_or_desc
44
+ short: short,
45
+ long: long,
46
+ desc: arg_or_desc
47
47
  }.merge case desc_or_block
48
48
  when Proc
49
49
  {
50
- desc: arg_or_desc,
51
- block: desc_or_block
50
+ desc: arg_or_desc,
51
+ block: desc_or_block
52
52
  }
53
53
  when String
54
54
  {
55
- arg: arg_or_desc,
56
- desc: desc_or_block,
57
- block: block
55
+ arg: arg_or_desc,
56
+ desc: desc_or_block,
57
+ block: block
58
58
  }
59
59
  else
60
60
  {}
@@ -40,7 +40,7 @@ def wait_until message: 'condition not met after %d seconds'
40
40
  end
41
41
  end
42
42
  rescue Timeout::Error
43
- raise Baf::Testing::WaitError.new(message % timeout, timeout)
43
+ fail Baf::Testing::WaitError.new(message % timeout, timeout)
44
44
  end
45
45
 
46
46
 
@@ -1,3 +1,3 @@
1
1
  module Baf
2
- VERSION = '0.14.0'.freeze
2
+ VERSION = '0.14.1'.freeze
3
3
  end
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.14.0
4
+ version: 0.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibault Jouan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-22 00:00:00.000000000 Z
11
+ date: 2020-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: baf-testing
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10'
40
+ version: '0'
41
41
  description: Basic Application Framework
42
42
  email: tj@a13.fr
43
43
  executables: []
@@ -60,7 +60,7 @@ homepage: https://rubygems.org/gems/baf
60
60
  licenses:
61
61
  - BSD-3-Clause
62
62
  metadata: {}
63
- post_install_message:
63
+ post_install_message:
64
64
  rdoc_options: []
65
65
  require_paths:
66
66
  - lib
@@ -75,9 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
- rubyforge_project:
79
- rubygems_version: 2.6.14
80
- signing_key:
78
+ rubygems_version: 3.1.4
79
+ signing_key:
81
80
  specification_version: 4
82
81
  summary: Basic Application Framework
83
82
  test_files: []