Module: RubyScreen::Configuration::Parser

Defined in:
lib/ruby_screen/configuration/parser.rb,
lib/ruby_screen/configuration/parser/iterator.rb,
lib/ruby_screen/configuration/parser/nesting_hash.rb,
lib/ruby_screen/configuration/parser/block_processor.rb

Defined Under Namespace

Modules: NestingHash Classes: BlockProcessor, Iterator

Class Method Summary collapse

Class Method Details

.parse(arguments, preferences_hash) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ruby_screen/configuration/parser.rb', line 8

def self.parse(arguments, preferences_hash)
  description = Description.new

  begin
    preferences_hash.extend(NestingHash)
  rescue DuplicateKeyException => e
    Kernel.abort("There are multiple configurations named '#{e.key}'.  You cannot have duplicate names!")
  end

  full_configuration_path = preferences_hash.find_nested_key(arguments.first) || []

  iterator = Iterator.new(full_configuration_path, preferences_hash)
  iterator.each_applicable_configuration_block { |block| BlockProcessor.new(block, description) }

  handle_additional_arguments_as_directories(arguments, description)

  description
end