Class: Bookbinder::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/bookbinder/configuration.rb

Defined Under Namespace

Classes: AwsCredentials, CfCredentials, ConfigSchemaUnsupportedError, CredentialKeyError

Constant Summary collapse

CURRENT_SCHEMA_VERSION =
'1.0.0'
STARTING_SCHEMA_VERSION =
'1.0.0'
CONFIG_REQUIRED_KEYS =
%w(book_repo layout_repo cred_repo sections public_host pdf pdf_index versions)
CONFIG_OPTIONAL_KEYS =
%w(archive_menu)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger, config_hash) ⇒ Configuration

Returns a new instance of Configuration.



103
104
105
106
# File 'lib/bookbinder/configuration.rb', line 103

def initialize(logger, config_hash)
  @logger = logger
  @config = config_hash
end

Instance Attribute Details

#schema_major_versionObject (readonly)

Returns the value of attribute schema_major_version.



101
102
103
# File 'lib/bookbinder/configuration.rb', line 101

def schema_major_version
  @schema_major_version
end

#schema_minor_versionObject (readonly)

Returns the value of attribute schema_minor_version.



101
102
103
# File 'lib/bookbinder/configuration.rb', line 101

def schema_minor_version
  @schema_minor_version
end

#schema_patch_versionObject (readonly)

Returns the value of attribute schema_patch_version.



101
102
103
# File 'lib/bookbinder/configuration.rb', line 101

def schema_patch_version
  @schema_patch_version
end

#schema_versionObject (readonly)

Returns the value of attribute schema_version.



101
102
103
# File 'lib/bookbinder/configuration.rb', line 101

def schema_version
  @schema_version
end

Instance Method Details

#==(o) ⇒ Object Also known as: eql?



143
144
145
# File 'lib/bookbinder/configuration.rb', line 143

def ==(o)
  (o.class == self.class) && (o.config == self.config)
end

#aws_credentialsObject



131
132
133
# File 'lib/bookbinder/configuration.rb', line 131

def aws_credentials
  @aws_creds ||= AwsCredentials.new(credentials.fetch('aws'))
end

#cf_production_credentialsObject



139
140
141
# File 'lib/bookbinder/configuration.rb', line 139

def cf_production_credentials
  @cf_prod_creds ||= CfCredentials.new(credentials.fetch('cloud_foundry'), true)
end

#cf_staging_credentialsObject



135
136
137
# File 'lib/bookbinder/configuration.rb', line 135

def cf_staging_credentials
  @cf_staging_creds ||= CfCredentials.new(credentials.fetch('cloud_foundry'), false)
end

#has_option?(key) ⇒ Boolean

Returns:

  • (Boolean)


123
124
125
# File 'lib/bookbinder/configuration.rb', line 123

def has_option?(key)
  @config.has_key?(key)
end

#template_variablesObject



127
128
129
# File 'lib/bookbinder/configuration.rb', line 127

def template_variables
  config.fetch('template_variables', {})
end