avm-tools 0.68.0 → 0.70.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/data/instance/files_unit.rb +1 -1
- data/lib/avm/eac_rails_base0/apache_host.rb +17 -0
- data/lib/avm/eac_rails_base0/apache_path.rb +50 -0
- data/lib/avm/eac_rails_base0/deploy.rb +51 -0
- data/lib/avm/eac_rails_base0/instance.rb +14 -0
- data/lib/avm/eac_redmine_base0/deploy.rb +4 -4
- data/lib/avm/eac_redmine_base0/instance.rb +6 -5
- data/lib/avm/eac_ubuntu_base0/apache.rb +26 -0
- data/lib/avm/eac_ubuntu_base0/apache/resource.rb +59 -0
- data/lib/avm/eac_ubuntu_base0/docker_image.rb +14 -0
- data/lib/avm/eac_webapp_base0/apache_host.rb +103 -0
- data/lib/avm/eac_webapp_base0/deploy.rb +102 -0
- data/lib/avm/eac_webapp_base0/deploy/appended_directories.rb +25 -0
- data/lib/avm/eac_webapp_base0/deploy/file_unit.rb +42 -0
- data/lib/avm/eac_webapp_base0/deploy/git_info.rb +49 -0
- data/lib/avm/eac_webapp_base0/deploy/version.rb +20 -0
- data/lib/avm/eac_webapp_base0/instance.rb +50 -0
- data/lib/avm/eac_webapp_base0/runner/apache_host.rb +39 -0
- data/lib/avm/eac_webapp_base0/runner/data.rb +25 -0
- data/lib/avm/eac_webapp_base0/runner/data/dump.rb +69 -0
- data/lib/avm/eac_webapp_base0/runner/data/load.rb +66 -0
- data/lib/avm/eac_webapp_base0/runner/deploy.rb +59 -0
- data/lib/avm/git/issue/complete/_git_subrepos.rb +1 -0
- data/lib/avm/instances/base/auto_values/filesystem.rb +3 -1
- data/lib/avm/instances/entries.rb +5 -8
- data/lib/avm/instances/entry.rb +47 -0
- data/lib/avm/instances/entry_keys.rb +2 -0
- data/lib/avm/self/instance.rb +1 -1
- data/lib/avm/stereotypes/eac_wordpress_base0/apache_host.rb +3 -3
- data/lib/avm/stereotypes/eac_wordpress_base0/deploy.rb +2 -2
- data/lib/avm/stereotypes/eac_wordpress_base0/instance.rb +2 -2
- data/lib/avm/tools/runner/eac_rails_base0.rb +9 -14
- data/lib/avm/tools/runner/eac_rails_base0/apache_host.rb +3 -26
- data/lib/avm/tools/runner/eac_rails_base0/apache_path.rb +38 -0
- data/lib/avm/tools/runner/eac_rails_base0/data.rb +2 -2
- data/lib/avm/tools/runner/eac_rails_base0/deploy.rb +3 -3
- data/lib/avm/tools/runner/eac_redmine_base0/data.rb +1 -1
- data/lib/avm/tools/runner/eac_redmine_base0/data/dump.rb +2 -2
- data/lib/avm/tools/runner/eac_redmine_base0/deploy.rb +2 -2
- data/lib/avm/tools/runner/eac_redmine_base0/project_rename.rb +1 -0
- data/lib/avm/tools/runner/eac_wordpress_base0/apache_host.rb +3 -25
- data/lib/avm/tools/runner/eac_wordpress_base0/data.rb +2 -2
- data/lib/avm/tools/runner/eac_wordpress_base0/deploy.rb +2 -2
- data/lib/avm/tools/runner/git/deploy.rb +3 -1
- data/lib/avm/tools/version.rb +1 -1
- data/template/avm/eac_rails_base0/apache_path/default.conf +13 -0
- data/template/avm/{stereotypes/eac_rails_base0 → eac_rails_base0}/deploy/config/database.yml.template +0 -0
- data/template/avm/{stereotypes/eac_webapp_base0 → eac_webapp_base0}/apache_host/no_ssl.conf +0 -0
- data/template/avm/self/docker_image/Dockerfile +1 -1
- data/vendor/eac_cli/Gemfile +5 -0
- data/vendor/eac_cli/eac_cli.gemspec +18 -0
- data/vendor/eac_cli/lib/eac_cli.rb +7 -0
- data/vendor/eac_cli/lib/eac_cli/core_ext.rb +4 -0
- data/vendor/eac_cli/lib/eac_cli/default_runner.rb +14 -0
- data/vendor/eac_cli/lib/eac_cli/definition.rb +72 -0
- data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +13 -0
- data/vendor/eac_cli/lib/eac_cli/definition/base_option.rb +26 -0
- data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +13 -0
- data/vendor/eac_cli/lib/eac_cli/definition/positional_argument.rb +27 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/doc_builder.rb +77 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +45 -0
- data/vendor/eac_cli/lib/eac_cli/parser.rb +14 -0
- data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +56 -0
- data/vendor/eac_cli/lib/eac_cli/parser/error.rb +15 -0
- data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +105 -0
- data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +21 -0
- data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +49 -0
- data/vendor/eac_cli/lib/eac_cli/patches.rb +4 -0
- data/vendor/eac_cli/lib/eac_cli/patches/object.rb +5 -0
- data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +24 -0
- data/vendor/eac_cli/lib/eac_cli/runner.rb +87 -0
- data/vendor/eac_cli/lib/eac_cli/runner/context.rb +18 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with.rb +9 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +19 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +26 -0
- data/vendor/eac_cli/lib/eac_cli/version.rb +5 -0
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +70 -0
- data/vendor/eac_cli/spec/rubocop_spec.rb +7 -0
- data/vendor/eac_cli/spec/spec_helper.rb +100 -0
- data/vendor/eac_git/lib/eac_git/version.rb +1 -1
- data/vendor/eac_git/vendor/git-subrepo/lib/git-subrepo +9 -7
- data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +3 -3
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +5 -1
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +1 -1
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb +10 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/version_file.rb +6 -5
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple.rb +5 -34
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/decorated_gem.rb +42 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/result.rb +25 -0
- data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
- data/vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec.rb +14 -0
- data/vendor/eac_ruby_gems_utils/spec/lib/eac_ruby_gems_utils/gem/version_file_spec_files/a_version_file.rb +7 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +4 -4
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner.rb +6 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +8 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +18 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb +3 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +9 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +6 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +53 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +15 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +46 -0
- metadata +66 -22
- data/lib/avm/instances/entries/entry_reader.rb +0 -45
- data/lib/avm/stereotypes/eac_rails_base0/apache_host.rb +0 -19
- data/lib/avm/stereotypes/eac_rails_base0/deploy.rb +0 -52
- data/lib/avm/stereotypes/eac_rails_base0/instance.rb +0 -16
- data/lib/avm/stereotypes/eac_ubuntu_base0/apache.rb +0 -27
- data/lib/avm/stereotypes/eac_ubuntu_base0/apache/site.rb +0 -61
- data/lib/avm/stereotypes/eac_ubuntu_base0/docker_image.rb +0 -16
- data/lib/avm/stereotypes/eac_webapp_base0/apache_host.rb +0 -97
- data/lib/avm/stereotypes/eac_webapp_base0/deploy.rb +0 -104
- data/lib/avm/stereotypes/eac_webapp_base0/deploy/appended_directories.rb +0 -27
- data/lib/avm/stereotypes/eac_webapp_base0/deploy/file_unit.rb +0 -43
- data/lib/avm/stereotypes/eac_webapp_base0/deploy/git_info.rb +0 -51
- data/lib/avm/stereotypes/eac_webapp_base0/deploy/version.rb +0 -22
- data/lib/avm/stereotypes/eac_webapp_base0/instance.rb +0 -52
- data/lib/avm/stereotypes/eac_webapp_base0/runner/data.rb +0 -27
- data/lib/avm/stereotypes/eac_webapp_base0/runner/data/dump.rb +0 -71
- data/lib/avm/stereotypes/eac_webapp_base0/runner/data/load.rb +0 -68
- data/lib/avm/stereotypes/eac_webapp_base0/runner/deploy.rb +0 -61
data/lib/avm/tools/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
<IfModule mod_passenger.c>
|
2
|
+
Alias "%%WEB.PATH%%" "%%FS_PATH%%/public"
|
3
|
+
<Location "%%WEB.PATH%%">
|
4
|
+
PassengerBaseURI "%%WEB.PATH%%"
|
5
|
+
PassengerAppRoot "%%FS_PATH%%"
|
6
|
+
PassengerAppEnv production
|
7
|
+
</Location>
|
8
|
+
<Directory "%%FS_PATH%%/public">
|
9
|
+
Allow from all
|
10
|
+
Options -MultiViews
|
11
|
+
Require all granted
|
12
|
+
</Directory>
|
13
|
+
</IfModule>
|
File without changes
|
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
4
|
+
|
5
|
+
require 'eac_cli/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = 'eac_cli'
|
9
|
+
s.version = ::EacCli::VERSION
|
10
|
+
s.authors = ['Esquilo Azul Company']
|
11
|
+
s.summary = 'Utilities to build CLI applications with Ruby.'
|
12
|
+
|
13
|
+
s.files = Dir['{lib}/**/*', 'Gemfile']
|
14
|
+
|
15
|
+
s.add_dependency 'eac_ruby_utils', '~> 0.45'
|
16
|
+
|
17
|
+
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.1', '>= 0.1.2'
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/runner_with/help'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
|
6
|
+
module EacCli
|
7
|
+
module DefaultRunner
|
8
|
+
common_concern do
|
9
|
+
include ::EacCli::RunnerWith::Help
|
10
|
+
enable_console_speaker
|
11
|
+
enable_simple_cache
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/definition/argument_option'
|
4
|
+
require 'eac_cli/definition/boolean_option'
|
5
|
+
require 'eac_cli/definition/positional_argument'
|
6
|
+
require 'eac_ruby_utils/core_ext'
|
7
|
+
|
8
|
+
module EacCli
|
9
|
+
class Definition
|
10
|
+
require_sub __FILE__
|
11
|
+
attr_accessor :description
|
12
|
+
attr_accessor :options_argument
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
self.description = '-- NO DESCRIPTION SET --'
|
16
|
+
self.options_argument = true
|
17
|
+
end
|
18
|
+
|
19
|
+
def alt(&block)
|
20
|
+
r = ::EacCli::Definition.new
|
21
|
+
r.instance_eval(&block)
|
22
|
+
alternatives << r
|
23
|
+
r
|
24
|
+
end
|
25
|
+
|
26
|
+
def alternatives
|
27
|
+
@alternatives ||= []
|
28
|
+
end
|
29
|
+
|
30
|
+
def arg_opt(short, long, description, option_options = {})
|
31
|
+
options << ::EacCli::Definition::ArgumentOption.new(
|
32
|
+
short, long, description, option_options
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
def bool_opt(short, long, description, option_options = {})
|
37
|
+
options << ::EacCli::Definition::BooleanOption.new(short, long, description, option_options)
|
38
|
+
end
|
39
|
+
|
40
|
+
def desc(description)
|
41
|
+
self.description = description
|
42
|
+
end
|
43
|
+
|
44
|
+
def options_arg(options_argument)
|
45
|
+
self.options_argument = options_argument
|
46
|
+
end
|
47
|
+
|
48
|
+
def options
|
49
|
+
@options ||= []
|
50
|
+
end
|
51
|
+
|
52
|
+
def pos_arg(name, arg_options = {})
|
53
|
+
positional << ::EacCli::Definition::PositionalArgument.new(name, arg_options)
|
54
|
+
end
|
55
|
+
|
56
|
+
def positional
|
57
|
+
@positional ||= []
|
58
|
+
end
|
59
|
+
|
60
|
+
def subcommands
|
61
|
+
positional << ::EacCli::Definition::PositionalArgument.new('subcommand', subcommand: true)
|
62
|
+
end
|
63
|
+
|
64
|
+
def options_first(enable = true)
|
65
|
+
@options_first = enable
|
66
|
+
end
|
67
|
+
|
68
|
+
def options_first?
|
69
|
+
@options_first ? true : false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacCli
|
6
|
+
class Definition
|
7
|
+
class BaseOption
|
8
|
+
attr_reader :short, :long, :description, :options
|
9
|
+
|
10
|
+
def initialize(short, long, description, options = {})
|
11
|
+
@short = short
|
12
|
+
@long = long
|
13
|
+
@description = description
|
14
|
+
@options = options.with_indifferent_access
|
15
|
+
end
|
16
|
+
|
17
|
+
def identifier
|
18
|
+
long.to_s.variableize.to_sym
|
19
|
+
end
|
20
|
+
|
21
|
+
def show_on_usage?
|
22
|
+
options[:usage]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacCli
|
6
|
+
class Definition
|
7
|
+
class PositionalArgument
|
8
|
+
common_constructor :name, :options, default: [{}]
|
9
|
+
|
10
|
+
def identifier
|
11
|
+
name.to_s.variableize.to_sym
|
12
|
+
end
|
13
|
+
|
14
|
+
def optional?
|
15
|
+
options[:optional]
|
16
|
+
end
|
17
|
+
|
18
|
+
def repeat?
|
19
|
+
options[:repeat]
|
20
|
+
end
|
21
|
+
|
22
|
+
def subcommand?
|
23
|
+
options[:subcommand]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
5
|
+
|
6
|
+
module EacCli
|
7
|
+
module Docopt
|
8
|
+
class DocBuilder
|
9
|
+
common_constructor :definition
|
10
|
+
|
11
|
+
SEP = ' '
|
12
|
+
IDENT = SEP * 2
|
13
|
+
OPTION_DESC_SEP = IDENT * 2
|
14
|
+
|
15
|
+
def positional_argument(positional)
|
16
|
+
if positional.subcommand?
|
17
|
+
::EacRubyUtils::Console::DocoptRunner::SUBCOMMANDS_MACRO
|
18
|
+
else
|
19
|
+
r = "<#{positional.name}>"
|
20
|
+
r += '...' if positional.repeat?
|
21
|
+
r = "[#{r}]" if positional.optional?
|
22
|
+
r
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def option_argument(option)
|
27
|
+
option_long(option)
|
28
|
+
end
|
29
|
+
|
30
|
+
def option_definition(option)
|
31
|
+
option.short + SEP + option_long(option) + OPTION_DESC_SEP + option.description
|
32
|
+
end
|
33
|
+
|
34
|
+
def option_long(option)
|
35
|
+
b = option.long
|
36
|
+
b += '=<value>' if option.argument?
|
37
|
+
b
|
38
|
+
end
|
39
|
+
|
40
|
+
def section(header, include_header = true)
|
41
|
+
b = include_header ? "#{header.humanize}:\n" : ''
|
42
|
+
b += send("self_#{header}") + "\n"
|
43
|
+
definition.alternatives.each do |alternative|
|
44
|
+
b += self.class.new(alternative).section(header, false)
|
45
|
+
end
|
46
|
+
b
|
47
|
+
end
|
48
|
+
|
49
|
+
def self_options
|
50
|
+
definition.options.map { |option| IDENT + option_definition(option) }.join("\n")
|
51
|
+
end
|
52
|
+
|
53
|
+
def self_usage
|
54
|
+
IDENT + self_usage_arguments.join(SEP)
|
55
|
+
end
|
56
|
+
|
57
|
+
def self_usage_arguments
|
58
|
+
[::EacRubyUtils::Console::DocoptRunner::PROGRAM_MACRO] +
|
59
|
+
definition.options_argument.if_present([]) { |_v| ['[options]'] } +
|
60
|
+
self_usage_arguments_options +
|
61
|
+
self_usage_arguments_positional
|
62
|
+
end
|
63
|
+
|
64
|
+
def self_usage_arguments_options
|
65
|
+
definition.options.select(&:show_on_usage?).map { |option| option_argument(option) }
|
66
|
+
end
|
67
|
+
|
68
|
+
def self_usage_arguments_positional
|
69
|
+
definition.positional.map { |p| positional_argument(p) }
|
70
|
+
end
|
71
|
+
|
72
|
+
def to_s
|
73
|
+
"#{definition.description}\n\n#{section('usage')}\n#{section('options')}\n"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/docopt/doc_builder'
|
4
|
+
require 'eac_ruby_utils/console/docopt_runner'
|
5
|
+
|
6
|
+
module EacCli
|
7
|
+
module Docopt
|
8
|
+
module RunnerExtension
|
9
|
+
extend ::ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
prepend InstanceMethods
|
13
|
+
end
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def check(klass)
|
17
|
+
return unless klass < ::EacRubyUtils::Console::DocoptRunner
|
18
|
+
|
19
|
+
::EacCli::Runner.alias_runner_class_methods(klass, '', 'eac_cli')
|
20
|
+
::EacCli::Runner.alias_runner_class_methods(klass, 'original', '')
|
21
|
+
|
22
|
+
klass.include(self)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module InstanceMethods
|
27
|
+
def doc
|
28
|
+
::EacCli::Docopt::DocBuilder.new(self.class.runner_definition).to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
def docopt_options
|
32
|
+
super.merge(options_first: self.class.runner_definition.options_first?)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def extra_available_subcommands
|
37
|
+
self.class.constants
|
38
|
+
.map { |name| self.class.const_get(name) }
|
39
|
+
.select { |c| c.instance_of? Class }
|
40
|
+
.select { |c| c.included_modules.include?(::EacCli::Runner) }
|
41
|
+
.map { |c| c.name.demodulize.underscore.dasherize }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module EacCli
|
6
|
+
class Parser
|
7
|
+
require_sub __FILE__
|
8
|
+
common_constructor :definition
|
9
|
+
|
10
|
+
def parse(argv)
|
11
|
+
::EacCli::Parser::ParseResult.new(definition, argv).result
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'eac_ruby_utils/struct'
|
5
|
+
|
6
|
+
module EacCli
|
7
|
+
class Parser
|
8
|
+
class Collector
|
9
|
+
class << self
|
10
|
+
def to_data(definition)
|
11
|
+
collector = new(definition)
|
12
|
+
yield(collector)
|
13
|
+
collector.to_data
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
common_constructor :definition do
|
18
|
+
default_values
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [OpenStruct]
|
22
|
+
def to_data
|
23
|
+
::EacRubyUtils::Struct.new(data.transform_keys(&:identifier))
|
24
|
+
end
|
25
|
+
|
26
|
+
def collect(option, value)
|
27
|
+
if data[option].is_a?(::Array)
|
28
|
+
data[option] << value
|
29
|
+
else
|
30
|
+
data[option] = value
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def data
|
37
|
+
@data ||= {}
|
38
|
+
end
|
39
|
+
|
40
|
+
def default_values
|
41
|
+
definition.options.each { |option| data[option] = option_default_value(option) }
|
42
|
+
definition.positional.each do |positional|
|
43
|
+
data[positional] = positional_default_value(positional)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def option_default_value(option)
|
48
|
+
option.argument? ? nil : false
|
49
|
+
end
|
50
|
+
|
51
|
+
def positional_default_value(positional)
|
52
|
+
positional.repeat? ? [] : nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|