Sha256: 842c07019fbb426ca8f09467303d845def90ed122ffbc9c4406869438bc02c92
Contents?: true
Size: 730 Bytes
Versions: 26
Compression:
Stored size: 730 Bytes
Contents
require 'yaml' module AwsEc2 class Hook def initialize(options={}) @options = options end def run(name) return if @options[:noop] return unless hooks[name] command = hooks[name] puts "Running hook #{name}: #{command}" sh(command) end def hooks hooks_path = "#{AwsEc2.root}/config/hooks.yml" data = File.exist?(hooks_path) ? YAML.load_file(hooks_path) : {} data ? data : {} # in case the file is empty end def sh(command) puts "=> #{command}".colorize(:cyan) success = system(command) abort("Command failed") unless success end def self.run(name, options={}) Hook.new(options).run(name.to_s) end end end
Version data entries
26 entries across 26 versions & 1 rubygems