Class: Texy::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#clientObject (readonly)

Returns the value of attribute client.



10
11
12
# File 'lib/texy/configuration.rb', line 10

def client
  @client
end

#companyObject (readonly)

Returns the value of attribute company.



9
10
11
# File 'lib/texy/configuration.rb', line 9

def company
  @company
end

#configurationObject (readonly)

Returns the value of attribute configuration.



8
9
10
# File 'lib/texy/configuration.rb', line 8

def configuration
  @configuration
end