Sha256: c3464c9e33e4f47780ad366b7e801b7c4ee7e47b463a6c5395ec520e13f0e516

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
humidifier-1.6.1 lib/humidifier/configuration.rb
humidifier-1.6.0 lib/humidifier/configuration.rb
humidifier-1.4.2 lib/humidifier/configuration.rb
humidifier-1.4.1 lib/humidifier/configuration.rb