Module: Ebfly::Command
- Included in:
- App, Config, ElasticBeanstalk, Environment
- Defined in:
- lib/ebfly/ebfly.rb
Constant Summary collapse
- PREDEFINED_SOLUTION_STACKS =
{ "docker16" => "64bit Amazon Linux 2015.03 v1.4.3 running Docker 1.6.2", "nodejs" => "64bit Amazon Linux 2015.03 v1.4.3 running Node.js", "php55" => "64bit Amazon Linux 2015.03 v1.4.3 running PHP 5.5", "php56" => "64bit Amazon Linux 2015.03 v1.4.3 running PHP 5.6", "python27" => "64bit Amazon Linux 2015.03 v1.4.3 running Python 2.7", "python34" => "64bit Amazon Linux 2015.03 v1.4.3 running Python 2.7", "ruby19" => "64bit Amazon Linux 2015.03 v1.4.3 running Ruby 1.9.3", "ruby20" => "64bit Amazon Linux 2015.03 v1.4.3 running Ruby 2.0 (Passenger Standalone)", "ruby20-puma" => "64bit Amazon Linux 2015.03 v1.4.3 running Ruby 2.0 (Puma)", "ruby21" => "64bit Amazon Linux 2015.03 v1.4.3 running Ruby 2.1 (Passenger Standalone)", "ruby21-puma" => "64bit Amazon Linux 2015.03 v1.4.3 running Ruby 2.1 (Puma)", "ruby22" => "64bit Amazon Linux 2015.03 v1.4.3 running Ruby 2.2 (Passenger Standalone)", "ruby22-puma" => "64bit Amazon Linux 2015.03 v1.4.3 running Ruby 2.2 (Puma)", }
- SUPPORTED_SOLUTION_STACKS =
['Docker', 'Node.js', 'PHP', 'Python', 'Ruby']
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
54 55 56 |
# File 'lib/ebfly/ebfly.rb', line 54 def debug(obj) pp obj if ENV["DEBUG"] end |
#eb ⇒ Object
26 27 28 29 |
# File 'lib/ebfly/ebfly.rb', line 26 def eb @eb ||= AWS::ElasticBeanstalk.new @eb.client end |
#env_name(app, env) ⇒ Object
69 70 71 |
# File 'lib/ebfly/ebfly.rb', line 69 def env_name(app, env) "#{app}-#{env}" end |
#exist_command?(cmd) ⇒ Boolean
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ebfly/ebfly.rb', line 58 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
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ebfly/ebfly.rb', line 35 def run(&block) begin res = yield raise res.error unless res.successful? res rescue => err style_err(err) exit 1 end end |
#s3 ⇒ Object
31 32 33 |
# File 'lib/ebfly/ebfly.rb', line 31 def s3 @s3 ||= AWS::S3.new end |
#s3_bucket ⇒ Object
46 47 48 |
# File 'lib/ebfly/ebfly.rb', line 46 def s3_bucket @s3_bucket ||= (run { eb.create_storage_location }[:s3_bucket]) end |
#solution_stack(name) ⇒ Object
85 86 87 88 |
# File 'lib/ebfly/ebfly.rb', line 85 def solution_stack(name) return PREDEFINED_SOLUTION_STACKS[name] if PREDEFINED_SOLUTION_STACKS.key?(name) return name end |
#style_err(err) ⇒ Object
50 51 52 |
# File 'lib/ebfly/ebfly.rb', line 50 def style_err(err) puts "ERR! #{err.}" end |
#tier(type) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ebfly/ebfly.rb', line 73 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.1" } elsif type == "worker1.0" return { name: "Worker", type: "SQS/HTTP", version: "1.0" } else raise "Environment tier definition not found" end end |