Class: Texy::Configuration
- Inherits:
-
Object
- Object
- Texy::Configuration
- Includes:
- Thor::Actions, Thor::Base
- Defined in:
- lib/texy/configuration.rb,
lib/texy/configuration/client.rb,
lib/texy/configuration/person.rb,
lib/texy/configuration/company.rb
Defined Under Namespace
Classes: Client, Company, Person
Constant Summary collapse
- CONFIGURATION_FILE_NAME =
"customers.yml"
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#company ⇒ Object
readonly
Returns the value of attribute company.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Instance Method Summary collapse
-
#initialize(client_name:) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(client_name:) ⇒ Configuration
Returns a new instance of Configuration.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/texy/configuration.rb', line 14 def initialize(client_name:) configuration_file = File.read("#{TOP_LEVEL_DIRECTORY}/#{CONFIGURATION_FILE_NAME}") full_configuration = YAML.safe_load(configuration_file, aliases: true) @configuration = full_configuration.dig(client_name)&.deep_symbolize_keys unless @configuration say "No configuration in #{TOP_LEVEL_DIRECTORY}/#{CONFIGURATION_FILE_NAME} for '#{client_name}'", :red exit end @company = Configuration::Company.new(configuration.dig(:company)) @client = Configuration::Client.new(configuration.dig(:client)) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/texy/configuration.rb', line 10 def client @client end |
#company ⇒ Object (readonly)
Returns the value of attribute company.
9 10 11 |
# File 'lib/texy/configuration.rb', line 9 def company @company end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
8 9 10 |
# File 'lib/texy/configuration.rb', line 8 def configuration @configuration end |