Class: Automan::Base
- Inherits:
-
Object
- Object
- Automan::Base
- Includes:
- Mixins::AwsCaller
- Defined in:
- lib/automan/base.rb
Direct Known Subclasses
Automan::Beanstalk::Application, Automan::Beanstalk::Configuration, Automan::Beanstalk::Deployer, Automan::Beanstalk::Package, Automan::Beanstalk::Router, Automan::Beanstalk::Terminator, Automan::Beanstalk::Uploader, Automan::Beanstalk::Version, Chef::Uploader, Cloudformation::Launcher, Cloudformation::Replacer, Cloudformation::Terminator, Cloudformation::Uploader, Ec2::Image, Ec2::Instance, ElastiCache::Router, RDS::Snapshot, S3::Downloader, S3::Uploader
Constant Summary
Constants included from Mixins::AwsCaller
Class Attribute Summary collapse
-
.option_names ⇒ Object
Returns the value of attribute option_names.
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#wait ⇒ Object
Returns the value of attribute wait.
Attributes included from Mixins::AwsCaller
#as, #cfn, #eb, #ec, #ec2, #elb, #r53, #rds, #s3
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #log_options ⇒ Object
- #wait_until(raise_on_fail = nil, &block) ⇒ Object
Methods included from Mixins::AwsCaller
#account, #configure_aws, #looks_like_s3_path?, #parse_s3_path, #s3_object_exists?, #s3_read
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/automan/base.rb', line 15 def initialize(={}) $stdout.sync = true @logger = Logger.new(STDOUT) if !.nil? .each_pair do |k,v| accessor = (k.to_s + '=').to_sym send(accessor, v) if respond_to? accessor end end = {} if [:log_aws] [:logger] = @logger end configure_aws() end |
Class Attribute Details
.option_names ⇒ Object
Returns the value of attribute option_names.
8 9 10 |
# File 'lib/automan/base.rb', line 8 def option_names @option_names end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
11 12 13 |
# File 'lib/automan/base.rb', line 11 def logger @logger end |
#wait ⇒ Object
Returns the value of attribute wait.
11 12 13 |
# File 'lib/automan/base.rb', line 11 def wait @wait end |
Class Method Details
.add_option(*args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/automan/base.rb', line 33 def self.add_option(*args) args.each do |arg| self.class_eval("def #{arg};@#{arg};end") self.class_eval("def #{arg}=(val);@#{arg}=val;end") if self.option_names.nil? self.option_names = [] end self.option_names << arg end end |
Instance Method Details
#log_options ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/automan/base.rb', line 44 def biggest_opt_name_length = self.class.option_names.max_by(&:length).length = "called with:\n" self.class.option_names.each do |opt| opt_name = opt.to_s.concat(':').ljust(biggest_opt_name_length) += "#{opt_name} #{send(opt)}\n" end logger.info end |
#wait_until(raise_on_fail = nil, &block) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/automan/base.rb', line 54 def wait_until(raise_on_fail=nil, &block) begin wait.until do yield end rescue Wait::ResultInvalid => e if raise_on_fail.nil? raise e else raise raise_on_fail end end end |