Class: BasicConfiguration
- Inherits:
-
Object
- Object
- BasicConfiguration
- Defined in:
- lib/basic_configuration.rb
Overview
BasicConfiguration Read an ini file and create a configuration. The configuration contains the aws configuration only.
Constant Summary collapse
- DEFAULT_CONFIG_FILES =
Default list of config files to search for
['aws-config.ini', 'default-config.ini', 'config.ini']
- DEFAULT_SEARCH_PATH =
Search for config files in these directories
[ ".", ENV['AWS_HOME'], ENV['HOME'], File.dirname(__FILE__)]
- @@config_files =
DEFAULT_CONFIG_FILES- @@search_path =
DEFAULT_SEARCH_PATH
Instance Attribute Summary collapse
-
#aws ⇒ Object
readonly
Returns the value of attribute aws.
Class Method Summary collapse
-
.add_config_files(config_files) ⇒ Object
Add the given array of files to the list that we read.
-
.add_search_paths(search_paths) ⇒ Object
Add the following set of search paths to the ones that we use.
-
.setup_config_files(config_files = []) ⇒ Object
Set up the list of config files that is read when looking for configurations.
-
.setup_search_path(search_path = []) ⇒ Object
Set up the search path.
Instance Method Summary collapse
-
#initialize(config_files = [], search_paths = []) ⇒ BasicConfiguration
constructor
Create a config structure by reading the given config_filenames.
- #keys ⇒ Object
-
#refresh ⇒ Object
Read the configuration from the existing config file using the existing filenames.
Constructor Details
#initialize(config_files = [], search_paths = []) ⇒ BasicConfiguration
Create a config structure by reading the given config_filenames. If config files or search_paths are given, they apply only to this instance, but are retained for use by refresh. Create default aws config items based on environment varbiables, in case we can’t find a config file.
46 47 48 49 50 |
# File 'lib/basic_configuration.rb', line 46 def initialize(config_files = [], search_paths = []) @config_files = @@config_files | config_files @search_path = @@search_path | search_paths refresh end |
Instance Attribute Details
#aws ⇒ Object (readonly)
Returns the value of attribute aws.
9 10 11 |
# File 'lib/basic_configuration.rb', line 9 def aws @aws end |
Class Method Details
.add_config_files(config_files) ⇒ Object
Add the given array of files to the list that we read.
32 33 34 |
# File 'lib/basic_configuration.rb', line 32 def BasicConfiguration.add_config_files(config_files) @@config_files |= config_files end |
.add_search_paths(search_paths) ⇒ Object
Add the following set of search paths to the ones that we use.
37 38 39 |
# File 'lib/basic_configuration.rb', line 37 def BasicConfiguration.add_search_paths(search_paths) @@search_path |= search_paths end |
.setup_config_files(config_files = []) ⇒ Object
Set up the list of config files that is read when looking for configurations. If this is not called, a default set of files is read.
21 22 23 |
# File 'lib/basic_configuration.rb', line 21 def BasicConfiguration.setup_config_files(config_files = []) @@config_files = config_files end |
.setup_search_path(search_path = []) ⇒ Object
Set up the search path. If this is not called, a default path is used
27 28 29 |
# File 'lib/basic_configuration.rb', line 27 def BasicConfiguration.setup_search_path(search_path = []) @@search_path = search_path end |
Instance Method Details
#keys ⇒ Object
60 61 62 |
# File 'lib/basic_configuration.rb', line 60 def keys [ @aws[:aws_access_key], @aws[:aws_secret_key]] end |
#refresh ⇒ Object
Read the configuration from the existing config file using the existing filenames. This is useful for reinitiaizing on a SIGTERM
55 56 57 58 |
# File 'lib/basic_configuration.rb', line 55 def refresh @aws = get_aws_from_environment read_config end |