coach 2.2.0 → 2.2.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
2
  SHA256:
3
- metadata.gz: c085b582900931acb9b56a21ee03e9b8b1695e8b9e36c23b5286acb8cc949868
4
- data.tar.gz: ab1dd0c12bfcbad8b93832649f96fa3699cc036d392129f4b6e1e8aca36bb72e
3
+ metadata.gz: b69c1a3041e520ebf876b90ce472ab23c579fa93fe53c69692a6d3c0e553d918
4
+ data.tar.gz: ba41cb38a04d6756e5153383010173a353211ce31bdcf19df82d62c808647db8
5
5
  SHA512:
6
- metadata.gz: 94525ce01d5c1b0dc75314c47f2901bdd33946fbe63ae847bf0ce6f1a1099e57c1db72f1c146199d0f77462eca826f47d0784aa21eeab41fb8b30aee3aa3dc0c
7
- data.tar.gz: ccd13d3dcb3623c01f6650ce6efb842c892663afaaffa30db8e8781380a8ffcdbc9be809b0d171c224d7c494448cabf7b38d9dae989af1a0c5256bee1a949758
6
+ metadata.gz: e4480d684b2ed592ebd33ee1b5463fc5a981fabd50805e3575da99be51950b962fae5265bdc4a08d1ec2837a39509c22b3e6b95198b1d3705a4fa1590b3599fe
7
+ data.tar.gz: 4f5e2c69d1b4ae613ae030f859580546bd7d364d9df421b546bce5aaeffdf899a8d48c397a8bc6b9a545d88540703752e0b475a6b3092df4e898bc53ade013c1
@@ -4,7 +4,11 @@
4
4
 
5
5
  No unreleased changes.
6
6
 
7
- # 2.2.0 / 2019-01-08
7
+ # 2.2.1 / 2020-02-06
8
+
9
+ * [#85](https://github.com/gocardless/coach/pull/85) Uses [commander](https://github.com/commander-rb/commander) for CLI option parsing
10
+
11
+ # 2.2.0 / 2020-01-08
8
12
 
9
13
  * [#68](https://github.com/gocardless/coach/pull/68) Add `coach` CLI and add
10
14
  documentation to README
@@ -135,4 +139,3 @@ consistent with other libraries. The previous names will work for now, but will
135
139
 
136
140
  Initial public release. This library is in beta until it hits 1.0, so backwards
137
141
  incompatible changes may be made in minor version releases.
138
-
data/bin/coach CHANGED
@@ -1,57 +1,95 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "slop"
4
3
  require "coach/cli/provider_finder"
4
+ require "commander"
5
5
 
6
- begin
7
- require File.join(Dir.pwd, "config/environment")
8
- rescue LoadError
9
- puts <<~EOS
10
- Could not load your Rails app
11
- =============================
6
+ module Coach
7
+ class CLI
8
+ extend Commander::Methods
12
9
 
13
- Currently the coach CLI assumes you have a config/environment.rb file that
14
- we can load. We believe this is true of Rails apps in general.
10
+ class << self
11
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
12
+ def run
13
+ program :version, Coach::VERSION
14
+ program :description,
15
+ "Coach's CLI to help understand the provide/require graph made up of " \
16
+ "all the middleware chains you've built using Coach.\n" \
17
+ " More information at: https://github.com/gocardless/coach#coach-cli."
18
+ program :help_formatter, :compact
15
19
 
16
- Please raise an issue if that's not the case!
20
+ never_trace!
17
21
 
18
- https://github.com/gocardless/coach/issues
19
- EOS
20
- exit 1
21
- end
22
+ command "find-provider" do |c|
23
+ c.syntax = "bundle exec coach find-provider"
24
+ c.description =
25
+ "Given the name of a Coach middleware and a value that it requires, it " \
26
+ "outputs the name of the middleware that provides it."
22
27
 
23
- Slop.parse do
24
- command "find-provider" do
25
- run do |_, args|
26
- middleware_name, value_name = *args
27
- raise ArgumentError, "middleware_name and value_name required" unless middleware_name && value_name
28
+ c.action do |args, _|
29
+ load_config_environment
28
30
 
29
- result = Coach::Cli::ProviderFinder.new(args[0], args[1]).find_provider
31
+ middleware_name, value_name = *args
32
+ raise ArgumentError, "middleware_name and value_name required" unless middleware_name && value_name
30
33
 
31
- puts "Value `#{value_name}` is provided to `#{middleware_name}` by:\n\n"
32
- puts result.to_a.join("\n")
33
- end
34
- end
34
+ result = Coach::Cli::ProviderFinder.new(args[0], args[1]).find_provider
35
+
36
+ puts "Value `#{value_name}` is provided to `#{middleware_name}` by:\n\n"
37
+ puts result.to_a.join("\n")
38
+ end
39
+ end
40
+
41
+ command "find-chain" do |c|
42
+ c.syntax = "bundle exec coach find-chain"
43
+ c.description =
44
+ "Given the name of a Coach middleware and a value it requires, " \
45
+ "it outputs the chains of middleware between the specified middleware " \
46
+ "and the one that provides the required value."
47
+
48
+ c.action do |args, _|
49
+ load_config_environment
50
+
51
+ middleware_name, value_name = *args
52
+ raise ArgumentError, "middleware_name and value_name required" unless middleware_name && value_name
35
53
 
36
- command "find-chain" do
37
- run do |_, args|
38
- middleware_name, value_name = *args
39
- raise ArgumentError, "middleware_name and value_name required" unless middleware_name && value_name
54
+ chains = Coach::Cli::ProviderFinder.new(middleware_name, value_name).find_chain
40
55
 
41
- chains = Coach::Cli::ProviderFinder.new(middleware_name, value_name).find_chain
56
+ if chains.size > 1
57
+ puts "Value `#{value_name}` is provided to `#{middleware_name}` " \
58
+ "by multiple middleware chains:\n\n"
59
+ else
60
+ puts "Value `#{value_name}` is provided to `#{middleware_name}` by:\n\n"
61
+ end
42
62
 
43
- if chains.size > 1
44
- puts "Value `#{value_name}` is provided to `#{middleware_name}` " \
45
- "by multiple middleware chains:\n\n"
46
- else
47
- puts "Value `#{value_name}` is provided to `#{middleware_name}` by:\n\n"
63
+ formatted_chains = chains.map do |chain|
64
+ chain.join(" -> ")
65
+ end.join("\n---\n")
66
+
67
+ puts formatted_chains
68
+ end
69
+ end
70
+
71
+ run!
48
72
  end
73
+ # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
74
+
75
+ def load_config_environment
76
+ require File.join(Dir.pwd, "config/environment")
77
+ rescue LoadError
78
+ puts <<~ERR
79
+ Could not load your Rails app
80
+ =============================
49
81
 
50
- formatted_chains = chains.map do |chain|
51
- chain.join(" -> ")
52
- end.join("\n---\n")
82
+ Currently the coach CLI assumes you have a config/environment.rb file that
83
+ we can load. We believe this is true of Rails apps in general.
53
84
 
54
- puts formatted_chains
85
+ Please raise an issue if that's not the case!
86
+
87
+ https://github.com/gocardless/coach/issues
88
+ ERR
89
+ exit 1
90
+ end
55
91
  end
56
92
  end
57
93
  end
94
+
95
+ Coach::CLI.run
@@ -21,9 +21,7 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_dependency "actionpack", ">= 4.2"
23
23
  spec.add_dependency "activesupport", ">= 4.2"
24
- # TODO: Find another CLI parser that supports subcommands
25
- # Slop v4 got rid of them :(
26
- spec.add_dependency "slop", "~> 3.6"
24
+ spec.add_dependency "commander", "~> 4.5"
27
25
 
28
26
  spec.add_development_dependency "gc_ruboconfig", "= 2.9.0"
29
27
  spec.add_development_dependency "pry", "~> 0.10"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coach
4
- VERSION = "2.2.0"
4
+ VERSION = "2.2.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coach
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-08 00:00:00.000000000 Z
11
+ date: 2020-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '4.2'
41
41
  - !ruby/object:Gem::Dependency
42
- name: slop
42
+ name: commander
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.6'
47
+ version: '4.5'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.6'
54
+ version: '4.5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: gc_ruboconfig
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -185,7 +185,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  - !ruby/object:Gem::Version
186
186
  version: '0'
187
187
  requirements: []
188
- rubygems_version: 3.0.3
188
+ rubyforge_project:
189
+ rubygems_version: 2.7.6.2
189
190
  signing_key:
190
191
  specification_version: 4
191
192
  summary: Alternative controllers built with middleware