eac_cli 0.35.0 → 0.36.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
  SHA256:
3
- metadata.gz: c64bf26b4c30499f44f1b0398c485b3f62e2111e1b289fe1d8b0770c58e3ed8e
4
- data.tar.gz: '088a6b2cb5046192f702e30c5dee090a2916fb1d28ec595fb2fab0caeaaa84be'
3
+ metadata.gz: fd9008aa3fd4b63d3bf1d901377a2efc3a257ccf1eba103cf74cf3f480ef9b95
4
+ data.tar.gz: ea3e787fe4c7ae277a06ab501ed74098ecad0f6beb27367400010f8696717db6
5
5
  SHA512:
6
- metadata.gz: 0b91146dc901cc943250c941eddaec66951ddbf62a0232544f34b99e483d9e4e33615e30f611c9cba7001c9a245c79b7d6a898d5c1606015ea6a217cd9eef27c
7
- data.tar.gz: 80c2f9606cad73728c47a996fa8e5a698e75c52785eff5736dc07cd5a7cf740e826737782b2884a0d8d07626dc8a2a44d37f85c614a927efa2f6a3748bf8d3fd
6
+ metadata.gz: da6e58e10afa32f283293d775814e0b4e0cd35374807f5fec4b581efc73995d8483460d79c2758aead99ac00d64069714c1c6b3c815b3f177da7991a779e1568
7
+ data.tar.gz: 27ac60328b39f15651cce3263dc3c195b69e2e9ad2a87340f0ec863fc33ee04d8aba9895c93e60360e1d011da2448e55029ba76b4d859377f4b7b4716a1dfe50
@@ -20,8 +20,8 @@ module EacCli
20
20
  end
21
21
 
22
22
  # Call a method in the runner or in one of it ancestors.
23
- def call(method_name, *args)
24
- context_call_responder(method_name).call(*args)
23
+ def call(method_name, *args, &block)
24
+ context_call_responder(method_name).call(*args, &block)
25
25
  end
26
26
 
27
27
  # @return [EacCli::Runner::ContextResponders]
@@ -46,8 +46,9 @@ module EacCli
46
46
  end
47
47
  end
48
48
 
49
- def parent_call(method_name, *args)
50
- return parent.runner_context.call(method_name, *args) if parent.respond_to?(:runner_context)
49
+ def parent_call(method_name, *args, &block)
50
+ return parent.runner_context.call(method_name, *args, &block) if
51
+ parent.respond_to?(:runner_context)
51
52
 
52
53
  raise "Parent #{parent} do not respond to .context or .runner_context (Runner: #{runner})"
53
54
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/acts_as_abstract'
5
+
6
+ module EacCli
7
+ module RunnerWith
8
+ module OutputList
9
+ class BaseFormatter
10
+ acts_as_abstract :to_output
11
+ common_constructor :columns, :rows
12
+
13
+ # @return [String]
14
+ def build_column(column)
15
+ column.to_s
16
+ end
17
+
18
+ # @return [Array<String>]
19
+ def build_columns
20
+ columns.map(&:to_s)
21
+ end
22
+
23
+ # @return [Array<Hash<String, String>>]
24
+ def build_rows
25
+ rows.map { |row| build_row(row) }
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'csv'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_cli/runner_with/output_list/base_formatter'
6
+
7
+ module EacCli
8
+ module RunnerWith
9
+ module OutputList
10
+ class CsvFormatter < ::EacCli::RunnerWith::OutputList::BaseFormatter
11
+ # @return [Array]
12
+ def build_row(row)
13
+ build_columns.map { |c| row.send(c) }
14
+ end
15
+
16
+ # @return [String]
17
+ def to_output
18
+ ::CSV.generate do |csv|
19
+ csv << build_columns
20
+ build_rows.each { |row| csv << row }
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_cli/runner_with/output_list/base_formatter'
5
+ require 'yaml'
6
+
7
+ module EacCli
8
+ module RunnerWith
9
+ module OutputList
10
+ class YamlFormatter < ::EacCli::RunnerWith::OutputList::BaseFormatter
11
+ # @return [Hash<String, String>]
12
+ def build_row(row)
13
+ build_columns.inject({}) { |a, e| a.merge(e => row.send(e).to_s) }
14
+ end
15
+
16
+ # @return [String]
17
+ def to_output
18
+ ::YAML.dump(build_rows)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner_with/output'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/acts_as_abstract'
6
+
7
+ module EacCli
8
+ module RunnerWith
9
+ module OutputList
10
+ require_sub __FILE__
11
+
12
+ FORMATS = {
13
+ 'csv' => ::EacCli::RunnerWith::OutputList::CsvFormatter,
14
+ 'yaml' => ::EacCli::RunnerWith::OutputList::YamlFormatter
15
+ }.freeze
16
+
17
+ common_concern do
18
+ acts_as_abstract :list_columns, :list_rows
19
+ include ::EacCli::RunnerWith::Output
20
+
21
+ runner_definition do
22
+ arg_opt '-f', '--format', 'Format to output list.', default: 'yaml'
23
+ end
24
+ end
25
+
26
+ # @return [String]
27
+ def output_content
28
+ formatter.to_output
29
+ end
30
+
31
+ # @return [EacCli::RunnerWith::OutputList::BaseFormatter]
32
+ def formatter
33
+ formatter_class.new(list_columns, list_rows)
34
+ end
35
+
36
+ # @return [Class]
37
+ def formatter_class
38
+ FORMATS.fetch(parsed.format)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.35.0'
4
+ VERSION = '0.36.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.35.0
4
+ version: 0.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-20 00:00:00.000000000 Z
11
+ date: 2023-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -36,28 +36,28 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.12'
39
+ version: '0.14'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.12'
46
+ version: '0.14'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: eac_ruby_utils
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '0.117'
53
+ version: '0.119'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '0.117'
60
+ version: '0.119'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: eac_ruby_gem_support
63
63
  requirement: !ruby/object:Gem::Requirement
@@ -138,6 +138,10 @@ files:
138
138
  - lib/eac_cli/runner_with/help/layout.rb
139
139
  - lib/eac_cli/runner_with/input.rb
140
140
  - lib/eac_cli/runner_with/output.rb
141
+ - lib/eac_cli/runner_with/output_list.rb
142
+ - lib/eac_cli/runner_with/output_list/base_formatter.rb
143
+ - lib/eac_cli/runner_with/output_list/csv_formatter.rb
144
+ - lib/eac_cli/runner_with/output_list/yaml_formatter.rb
141
145
  - lib/eac_cli/runner_with/subcommands.rb
142
146
  - lib/eac_cli/runner_with/subcommands/definition_concern.rb
143
147
  - lib/eac_cli/runner_with_set.rb