class Opsicle::Update
Attributes
client[R]
type[R]
Public Class Methods
new(environment, type)
click to toggle source
# File lib/opsicle/commands/update.rb, line 8 def initialize(environment, type) @client = Client.new(environment) @type = type end
Public Instance Methods
describe()
click to toggle source
# File lib/opsicle/commands/update.rb, line 20 def describe api_method = "describe_#{@type}s" api_opts = { :"#{@type}_ids" => [client.config.opsworks_config[:"#{@type}_id"]] } client.api_call(api_method, api_opts)[:"#{@type}s"][0] end
execute(values, options)
click to toggle source
# File lib/opsicle/commands/update.rb, line 13 def execute(values, options) before = describe update(values) after = describe print(before, after) end
format_diff(diff)
click to toggle source
# File lib/opsicle/commands/update.rb, line 40 def format_diff(diff) diff.map { |change| case change[0] when '-' change.insert(3, nil) change.map! { |i| Output.format(i, :removal) } when '+' change.insert(2, nil) change.map! { |i| Output.format(i, :addition) } when '~' change.map! { |i| Output.format(i, :modification) } end change } end
print(before, after)
click to toggle source
# File lib/opsicle/commands/update.rb, line 34 def print(before, after) diff = Hashdiff.diff(before, after) Output.say("Changes: #{diff.size}") Output.terminal.say(Terminal::Table.new headings: %w[Change Key Before After], rows: format_diff(diff)) if diff.size > 0 end
update(values)
click to toggle source
# File lib/opsicle/commands/update.rb, line 28 def update(values) api_method = "update_#{@type}" api_opts = values.merge(:"#{@type}_id" => client.config.opsworks_config[:"#{@type}_id"]) client.api_call(api_method, api_opts) end