Sha256: c285f91024fa8788c4b583a538cd0d61ca77ae97a71256101f2cf060e7474916

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 KB

Contents

module Humidifier
  # a container for user params
  class Configuration
    # The message that gets displayed when the stack body is too large to use
    # the template_body option
    UPLOAD_MESSAGE = <<-MSG.freeze
The %<identifier>s stack's body is too large to be use the template_body option, and therefore must use the
template_url option instead. You can configure Humidifier to do this automatically by setting up the s3 config
on the top-level Humidifier object like so:

    Humidifier.configure do |config|
      config.s3_bucket = 'my.s3.bucket'
      config.s3_prefix = 'my-prefix/' # optional
    end
MSG

    attr_accessor :s3_bucket, :s3_prefix, :sdk_version

    def initialize(opts = {})
      self.s3_bucket   = opts[:s3_bucket]
      self.s3_prefix   = opts[:s3_prefix]
      self.sdk_version = opts[:sdk_version]
    end

    # raise an error unless the s3_bucket field is set
    def ensure_upload_configured!(payload)
      raise UPLOAD_MESSAGE.gsub('%<identifier>s', payload.identifier) if s3_bucket.nil?
    end

    # true if the sdk_version option is set to 1 or '1'
    def sdk_version_1?
      sdk_version.to_s == '1'
    end

    # true if the sdk_version option is set to 2 or '2'
    def sdk_version_2?
      sdk_version.to_s == '2'
    end

    # true if the sdk_version option is set to 3 or '3'
    def sdk_version_3?
      sdk_version.to_s == '3'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
humidifier-1.8.0 lib/humidifier/configuration.rb
humidifier-1.7.0 lib/humidifier/configuration.rb