class Kleiber::Settings

Provides access to settings of library @author Кирилл Бобыкин <qelphybox@gmail.com>

Constants

REQUIRED_KEYS

backporting for old ruby versions

Attributes

path[RW]

Public Class Methods

new(path) click to toggle source
# File lib/kleiber/settings.rb, line 15
def initialize(path)
  @path = path
end

Public Instance Methods

projects() click to toggle source

Returns projects settings hash @return [Array] projects hash

# File lib/kleiber/settings.rb, line 21
def projects
  config[:projects]
end
symphonies() click to toggle source

Returns symphonies settings @return [Hash]

# File lib/kleiber/settings.rb, line 39
def symphonies
  config[:symphonies]
end
tasks() click to toggle source

Returns tasks settings hash @return [Hash] tasks hash

# File lib/kleiber/settings.rb, line 27
def tasks
  config[:tasks]
end
terminal() click to toggle source

Returns terminal settings @return [Hash]

# File lib/kleiber/settings.rb, line 33
def terminal
  config[:terminal]
end
valid?() click to toggle source

Validates settings @return [Boolean] validation result

# File lib/kleiber/settings.rb, line 45
def valid?
  private_methods.map do |m|
    send(m) if m.to_s.start_with?('validate_')
  end.compact.all?
end

Private Instance Methods

config() click to toggle source
# File lib/kleiber/settings.rb, line 66
def config
  YAML.load_file(@path)
end
validate_projects() click to toggle source
# File lib/kleiber/settings.rb, line 61
def validate_projects
  projects && projects.is_a?(Array) &&
    projects.all? { |p| (REQUIRED_KEYS - p.keys).empty? }
end
validate_symphonies() click to toggle source
# File lib/kleiber/settings.rb, line 53
def validate_symphonies
  symphonies && symphonies.is_a?(Hash) &&
    symphonies.values.all? do |symp|
      symp.key?(:projects) && symp[:projects].is_a?(Array) &&
        symp[:projects].all? { |p| projects.map { |e| e[:name] }.include?(p) }
    end
end