dry-cli 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca4829f1591a699235699ea74d43bfa27270201e9052fd72683a6c4768d6d007
4
- data.tar.gz: d4fa94fe8909cb3898cfe4b3fd2b80009deeab6078d7cb48396eb24297798057
3
+ metadata.gz: 10c2bb5f82ae29dc19f705e9caee094e6e756e6de6a110e7ad82a540a98f08fa
4
+ data.tar.gz: 9ecf08520054dae86e45f61abcaf653d0da1eb6ee3b3c1907cf2fd44706b3a4c
5
5
  SHA512:
6
- metadata.gz: 574b4f554453f8df89670bf6a1ccd3bb156fef15a3b3a53a1fec4c05dbcf8dac843fcd04194c3a63b8a77bc5708608ec3ed462f6941a36e5053fd5c0667774c8
7
- data.tar.gz: 402e1d35e7f12d93782f0ebb47762ac3a3db98bc687743e91997cf400f5fa64abd55e1e626347b9119ce27ce90a39e7eab23f14f05da6f008e0f1e0ebc717850
6
+ metadata.gz: c37d5cfb952cb82bb591ce4fd584675e117e76e73f2b5c65990b321de7b156cb56df55554caab94666c370c97d896602043edd39f5ac9e0a53cf33ada678d82e
7
+ data.tar.gz: ca346d815e518cb1306a4ddf1c9d178494bd0b1ba61024f65fe0eff282e3dac2caf57070439da99840ee719f38bcc30d6cda00158f4151001fde82c8a7ab4d40
@@ -87,3 +87,9 @@ Naming/MethodName:
87
87
 
88
88
  Style/AsciiComments:
89
89
  Enabled: false
90
+
91
+ Style/DateTime:
92
+ Enabled: false
93
+
94
+ Style/IfUnlessModifier:
95
+ Enabled: false
@@ -1,6 +1,10 @@
1
1
  # Dry::CLI
2
2
  General purpose Command Line Interface (CLI) framework for Ruby
3
3
 
4
+ ## v0.5.0 - 2019-12-21
5
+ ### Added
6
+ - [Ivan Shamatov, Piotr Solnica, Luca Guidi] [Internal] removed runtime and development dependency against `hanami-utils`
7
+
4
8
  ## v0.4.0 - 2019-12-10
5
9
  ### Added
6
10
  - [Ivan Shamatov, Piotr Solnica, Luca Guidi] `hanami-cli` => `dry-cli`
data/Gemfile CHANGED
@@ -11,8 +11,4 @@ unless ENV['CI']
11
11
  gem 'yard', require: false
12
12
  end
13
13
 
14
- gem 'hanami-utils', '~> 1.3', require: false,
15
- git: 'https://github.com/hanami/utils.git',
16
- branch: 'master'
17
-
18
14
  gem 'ossy', github: 'solnic/ossy', branch: 'master', platform: :mri
@@ -567,7 +567,7 @@ cli.call
567
567
 
568
568
  The `foo-bar` gem enhances `hello` command with callbacks:
569
569
 
570
- ```
570
+ ```ruby
571
571
  Foo::CLI::Commands.before("hello") { |args| puts "debug: #{args.inspect}" } # syntax 1
572
572
  Foo::CLI::Commands.after "hello", &->(args) { puts "bye, #{args.fetch(:name)}" } # syntax 2
573
573
  ```
@@ -27,7 +27,6 @@ Gem::Specification.new do |spec|
27
27
  end
28
28
 
29
29
  spec.add_dependency 'concurrent-ruby', '~> 1.0'
30
- spec.add_dependency 'hanami-utils', '~> 1.3'
31
30
 
32
31
  spec.add_development_dependency 'bundler', '>= 1.6', '< 3'
33
32
  spec.add_development_dependency 'rake', '~> 13.0'
@@ -15,6 +15,7 @@ module Dry
15
15
  require 'dry/cli/parser'
16
16
  require 'dry/cli/usage'
17
17
  require 'dry/cli/banner'
18
+ require 'dry/cli/inflector'
18
19
 
19
20
  # Check if command
20
21
  #
@@ -104,7 +104,7 @@ module Dry
104
104
  # rubocop:disable Metrics/AbcSize
105
105
  def self.extended_command_options(command)
106
106
  result = command.options.map do |option|
107
- name = Hanami::Utils::String.dasherize(option.name)
107
+ name = Inflector.dasherize(option.name)
108
108
  name = if option.boolean?
109
109
  "[no-]#{name}"
110
110
  else
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'concurrent/hash'
4
- require 'hanami/utils/callbacks'
5
4
 
6
5
  module Dry
7
6
  class CLI
@@ -111,8 +110,8 @@ module Dry
111
110
  @aliases = Concurrent::Hash.new
112
111
  @command = nil
113
112
 
114
- @before_callbacks = Hanami::Utils::Callbacks::Chain.new
115
- @after_callbacks = Hanami::Utils::Callbacks::Chain.new
113
+ @before_callbacks = Chain.new
114
+ @after_callbacks = Chain.new
116
115
  end
117
116
 
118
117
  # @since 0.1.0
@@ -206,6 +205,36 @@ module Dry
206
205
  @node.after_callbacks
207
206
  end
208
207
  end
208
+
209
+ # Callbacks chain
210
+ #
211
+ # @since 0.4.0
212
+ # @api private
213
+ class Chain
214
+ # @since 0.4.0
215
+ # @api private
216
+ attr_reader :chain
217
+
218
+ # @since 0.4.0
219
+ # @api private
220
+ def initialize
221
+ @chain = Set.new
222
+ end
223
+
224
+ # @since 0.4.0
225
+ # @api private
226
+ def append(&callback)
227
+ chain.add(callback)
228
+ end
229
+
230
+ # @since 0.4.0
231
+ # @api private
232
+ def run(context, *args)
233
+ chain.each do |callback|
234
+ context.instance_exec(*args, &callback)
235
+ end
236
+ end
237
+ end
209
238
  end
210
239
  end
211
240
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'hanami/utils/deprecation'
4
-
5
3
  module Dry
6
4
  # General purpose Command Line Interface (CLI) framework for Ruby
7
5
  #
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dry
4
+ class CLI
5
+ # @api private
6
+ # @since 0.5.0
7
+ module Inflector
8
+ # @api private
9
+ # @since 0.5.0
10
+ def self.dasherize(input)
11
+ return nil unless input
12
+
13
+ input.to_s.downcase.gsub(/[[[:space:]]_]/, "-")
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'hanami/utils/string'
4
-
5
3
  module Dry
6
4
  class CLI
7
5
  # Command line option
@@ -90,7 +88,7 @@ module Dry
90
88
  #
91
89
  # rubocop:disable Metrics/AbcSize
92
90
  def parser_options
93
- dasherized_name = Hanami::Utils::String.dasherize(name)
91
+ dasherized_name = Inflector.dasherize(name)
94
92
  parser_options = []
95
93
 
96
94
  if boolean?
@@ -3,6 +3,6 @@
3
3
  module Dry
4
4
  class CLI
5
5
  # @since 0.1.0
6
- VERSION = '0.4.0'
6
+ VERSION = '0.5.0'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-10 00:00:00.000000000 Z
11
+ date: 2019-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
- - !ruby/object:Gem::Dependency
28
- name: hanami-utils
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.3'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.3'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -133,6 +119,7 @@ files:
133
119
  - lib/dry/cli/command.rb
134
120
  - lib/dry/cli/command_registry.rb
135
121
  - lib/dry/cli/errors.rb
122
+ - lib/dry/cli/inflector.rb
136
123
  - lib/dry/cli/option.rb
137
124
  - lib/dry/cli/parser.rb
138
125
  - lib/dry/cli/program_name.rb