Sha256: f0bcc7282b3ad82c101123c030d4a325e45962e74a78e9674d0d46ecc8865480

Contents?: true

Size: 1.11 KB

Versions: 11

Compression:

Stored size: 1.11 KB

Contents

module Jack
  module EbConfig
    # Abstract Class
    # Concrete classes should implement methods: platform and app_name
    class Base
      include Util

      attr_reader :eb_config_path
      def initialize(options={})
        @options = options
        @root = options[:root] || '.'
        @env_name = options[:env_name]
        @eb_config_path = "#{@root}/.elasticbeanstalk/config.yml"
        ensure_folder_exist(File.dirname(@eb_config_path))
      end

      def sync
        ensure_eb_init
        write_eb_config_yml
      end

      def ensure_eb_init
        unless File.exist?(eb_config_path)
          sh(%Q|#{eb_bin} init#{eb_base_flags} -p "#{platform}" "#{app_name}"|, @options)
        end
      end

      def write_eb_config_yml
        data = YAML.load_file(eb_config_path)
        data['global']['application_name'] = app_name # from subclass
        data['global']['default_platform'] = platform # from subclass
        dump = YAML.dump(data).gsub("!ruby/object:Hash", '')
        dump = dump.split("\n")[1..-1].join("\n") # strip first line
        File.write(eb_config_path, dump)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
jack-eb-1.4.4 lib/jack/eb_config/base.rb
jack-eb-1.4.3 lib/jack/eb_config/base.rb
jack-eb-1.4.2 lib/jack/eb_config/base.rb
jack-eb-1.4.1 lib/jack/eb_config/base.rb
jack-eb-1.4.0 lib/jack/eb_config/base.rb
jack-eb-1.3.0 lib/jack/eb_config/base.rb
jack-eb-1.2.1 lib/jack/eb_config/base.rb
jack-eb-1.2.0 lib/jack/eb_config/base.rb
jack-eb-1.1.2 lib/jack/eb_config/base.rb
jack-eb-1.1.1 lib/jack/eb_config/base.rb
jack-eb-1.1.0 lib/jack/eb_config/base.rb