Sha256: 214aa4c21ad63033f54ce0525460f0c44f867090b4f267119389e6069f81d228

Contents?: true

Size: 858 Bytes

Versions: 4

Compression:

Stored size: 858 Bytes

Contents

module Jack
  # Any class that includes this module should define @root as it is used in
  # the settings method.
  module Util
    def do_cmd(command, options={})
      UI.say "Running: #{command.colorize(:green)}"
      return command if options[:noop]
      out = `#{command}`
      UI.say out
    end

    def app_name_convention(env_name)
      pattern = settings.app_name_pattern
      env_name.match(pattern)[1]
    end

    def settings
      # do not like the instance @root variable in this module but better
      # than having to pass settings around
      @settings ||= Settings.new(@root)
    end

    def eb
      region = ENV['AWS_REGION'] || 'us-east-1'
      @@eb ||= Aws::ElasticBeanstalk::Client.new(region: region)
    end

    def ensure_folder_exist(folder)
      FileUtils.mkdir_p(folder) unless File.exist?(folder)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jack-eb-1.0.1 lib/jack/util.rb
jack-eb-1.0.0 lib/jack/util.rb
jack-eb-0.3.0 lib/jack/util.rb
jack-eb-0.2.0 lib/jack/util.rb