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 2013.09 running PHP 5.4", "php55" => "64bit Amazon Linux 2013.09 running PHP 5.5", "nodejs" => "64bit Amazon Linux 2013.09 running Node.js", "java7" => "64bit Amazon Linux 2013.09 running Tomcat 7 Java 7", "java6" => "64bit Amazon Linux 2013.09 running Tomcat 7 Java 6", "python27" => "64bit Amazon Linux 2013.09 running Python 2.7", "ruby18" => "64bit Amazon Linux 2013.09 running Ruby 1.8.7", "ruby19" => "64bit Amazon Linux 2013.09 running Ruby 1.9.3", }
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
48 49 50 |
# File 'lib/ebfly/ebfly.rb', line 48 def debug(obj) pp obj if ENV["DEBUG"] end |
#eb ⇒ Object
20 21 22 23 |
# File 'lib/ebfly/ebfly.rb', line 20 def eb @eb ||= AWS::ElasticBeanstalk.new @eb.client end |
#env_name(app, env) ⇒ Object
56 57 58 |
# File 'lib/ebfly/ebfly.rb', line 56 def env_name(app, env) "#{app}-#{env}" end |
#exist_command?(cmd) ⇒ Boolean
52 53 54 |
# File 'lib/ebfly/ebfly.rb', line 52 def exist_command?(cmd) Open3.capture3("type", cmd)[2].exitstatus == 0 rescue nil end |
#run(&block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ebfly/ebfly.rb', line 29 def run(&block) begin res = yield raise res.error unless res.successful? res rescue => err style_err(err) exit 1 end end |
#s3 ⇒ Object
25 26 27 |
# File 'lib/ebfly/ebfly.rb', line 25 def s3 @s3 ||= AWS::S3.new end |
#s3_bucket ⇒ Object
40 41 42 |
# File 'lib/ebfly/ebfly.rb', line 40 def s3_bucket @s3_bucket ||= (run { eb.create_storage_location }[:s3_bucket]) end |
#solution_stack(name) ⇒ Object
70 71 72 73 |
# File 'lib/ebfly/ebfly.rb', line 70 def solution_stack(name) return PREDEFINED_SOLUTION_STACKS[name] if PREDEFINED_SOLUTION_STACKS.key?(name) return name end |
#style_err(err) ⇒ Object
44 45 46 |
# File 'lib/ebfly/ebfly.rb', line 44 def style_err(err) puts "ERR! #{err.message}" end |
#tier(type) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/ebfly/ebfly.rb', line 60 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 |