class RidgepoleRake::Command
Attributes
action[R]
config[R]
options[R]
stash[R]
Public Class Methods
new(action, config, options = {})
click to toggle source
# File lib/ridgepole_rake/command.rb, line 4 def initialize(action, config, options = {}) @stash = [] @action = action @config = config @options = options build end
Public Instance Methods
execute()
click to toggle source
# File lib/ridgepole_rake/command.rb, line 13 def execute Kernel.system(*stash) end
inspect()
click to toggle source
# File lib/ridgepole_rake/command.rb, line 17 def inspect stash.join(' ').strip end
Private Instance Methods
add_action()
click to toggle source
# File lib/ridgepole_rake/command.rb, line 34 def add_action case action when :apply, :merge, :export, :diff __send__("add_#{action}_action") else raise UndefinedActionError, "Undefined action: '#{action}'" end end
add_apply_action()
click to toggle source
# File lib/ridgepole_rake/command.rb, line 43 def add_apply_action stash.push('--apply') stash.push('--file', config.ridgepole.fetch(:file)) end
add_config()
click to toggle source
# File lib/ridgepole_rake/command.rb, line 72 def add_config stash.push('--config', config.ridgepole.fetch(:config)) end
add_diff_action()
click to toggle source
# File lib/ridgepole_rake/command.rb, line 60 def add_diff_action stash.push('--diff', config.ridgepole.fetch(:config), config.ridgepole.fetch(:file)) end
add_dry_run()
click to toggle source
# File lib/ridgepole_rake/command.rb, line 64 def add_dry_run stash.push('--dry-run') if options[:dry_run] end
add_env()
click to toggle source
# File lib/ridgepole_rake/command.rb, line 68 def add_env stash.push('--env', config.ridgepole.fetch(:env)) end
add_export_action()
click to toggle source
# File lib/ridgepole_rake/command.rb, line 53 def add_export_action stash.push('--export') stash.push('--output', config.ridgepole.fetch(:output)) stash.push('--split') if config.ridgepole.has_key?(:split) stash.push('--split-with-dir') if config.ridgepole.has_key?('split-with-dir') end
add_extras()
click to toggle source
# File lib/ridgepole_rake/command.rb, line 76 def add_extras stash.concat(extra_options) end
add_merge_action()
click to toggle source
# File lib/ridgepole_rake/command.rb, line 48 def add_merge_action stash.push('--merge') stash.push('--file', options[:merge_file]) end
add_ridgepole()
click to toggle source
# File lib/ridgepole_rake/command.rb, line 92 def add_ridgepole stash.unshift('ridgepole') end
build()
click to toggle source
# File lib/ridgepole_rake/command.rb, line 25 def build add_action add_dry_run add_env add_config add_extras add_ridgepole end
configurable_options()
click to toggle source
# File lib/ridgepole_rake/command.rb, line 88 def configurable_options config.ridgepole.except(*Option.ignored_keys).slice(*Option.recognized_keys) end
extra_options()
click to toggle source
# File lib/ridgepole_rake/command.rb, line 80 def extra_options configurable_options.each_with_object([]) do |(k, v), arr| v = nil if Option.non_value_key?(k) k = Option.add_hyphens_if_needed(k) arr.push(k, v) end.compact end