Module: Ebfly::Command
- Included in:
- App, Config, Environment
- Defined in:
- lib/ebfly/ebfly.rb
Constant Summary collapse
- PREDEFINED_SOLUTION_STACKS =
{ "php53" => "64bit Amazon Linux running PHP 5.3", "php54" => "64bit Amazon Linux 2014.02 v1.0.1 running PHP 5.4", "php55" => "64bit Amazon Linux 2014.02 v1.0.1 running PHP 5.5", "nodejs" => "64bit Amazon Linux 2014.02 v1.0.1 running Node.js", "python26" => "64bit Amazon Linux 2013.09 v1.0.1 running Python", "python27" => "64bit Amazon Linux 2013.09 v1.0.1 running Python 2.7", "ruby18" => "64bit Amazon Linux 2014.02 v1.0.1 running Ruby 1.8.7", "ruby19" => "64bit Amazon Linux 2014.02 v1.0.1 running Ruby 1.9.3", "ruby20" => "64bit Amazon Linux 2014.03 v1.0.1 running Ruby 2.0 (Passenger Standalone)", "ruby20-puma" => "64bit Amazon Linux 2014.03 v1.0.1 running Ruby 2.0 (Puma)" }
Instance Method Summary collapse
- #debug(obj) ⇒ Object
- #eb ⇒ Object
- #env_name(app, env) ⇒ Object
- #exist_command?(cmd) ⇒ Boolean
- #run(&block) ⇒ Object
- #s3 ⇒ Object
- #s3_bucket ⇒ Object
- #solution_stack(name) ⇒ Object
- #style_err(err) ⇒ Object
- #tier(type) ⇒ Object
Instance Method Details
#debug(obj) ⇒ Object
49 50 51 |
# File 'lib/ebfly/ebfly.rb', line 49 def debug(obj) pp obj if ENV["DEBUG"] end |
#eb ⇒ Object
21 22 23 24 |
# File 'lib/ebfly/ebfly.rb', line 21 def eb @eb ||= AWS::ElasticBeanstalk.new @eb.client end |
#env_name(app, env) ⇒ Object
64 65 66 |
# File 'lib/ebfly/ebfly.rb', line 64 def env_name(app, env) "#{app}-#{env}" end |
#exist_command?(cmd) ⇒ Boolean
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ebfly/ebfly.rb', line 53 def exist_command?(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each { |ext| exe = File.join(path, "#{cmd}#{ext}") return exe if File.executable? exe } end return nil end |
#run(&block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ebfly/ebfly.rb', line 30 def run(&block) begin res = yield raise res.error unless res.successful? res rescue => err style_err(err) exit 1 end end |
#s3 ⇒ Object
26 27 28 |
# File 'lib/ebfly/ebfly.rb', line 26 def s3 @s3 ||= AWS::S3.new end |
#s3_bucket ⇒ Object
41 42 43 |
# File 'lib/ebfly/ebfly.rb', line 41 def s3_bucket @s3_bucket ||= (run { eb.create_storage_location }[:s3_bucket]) end |
#solution_stack(name) ⇒ Object
78 79 80 81 |
# File 'lib/ebfly/ebfly.rb', line 78 def solution_stack(name) return PREDEFINED_SOLUTION_STACKS[name] if PREDEFINED_SOLUTION_STACKS.key?(name) return name end |
#style_err(err) ⇒ Object
45 46 47 |
# File 'lib/ebfly/ebfly.rb', line 45 def style_err(err) puts "ERR! #{err.}" end |
#tier(type) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/ebfly/ebfly.rb', line 68 def tier(type) if type == "web" return { name: "WebServer", type: "Standard", version: "1.0" } elsif type == "worker" return { name: "Worker", type: "SQS/HTTP", version: "1.0" } else raise "Environment tier definition not found" end end |