Sha256: b28923278f1d2ebf131ac10975b4761b418f6128a183e1e0f9d1a4a7bbc12ce1

Contents?: true

Size: 1014 Bytes

Versions: 3

Compression:

Stored size: 1014 Bytes

Contents

# -*- coding: utf-8 -*-
require 'tengine/support/config/definition'

require 'tengine/support/yaml_with_erb'

class Tengine::Support::Config::Definition::Suite
  include Tengine::Support::Config::Definition::HasManyChildren

  def mapping(mapping = nil)
    @mapping = mapping if mapping
    @mapping
  end

  def parent; nil; end
  def root; self; end

  def load_file(filepath)
    load(YAML.load_file(filepath))
  end

  def banner(banner = nil)
    @banner = banner if banner
    @banner
  end

  def parse!(argv)
    v = Tengine::Support::Config::Definition::OptparseVisitor.new(self)
    self.accept_visitor(v)
    if load_config = children.detect{|child| child.type == :load_config}
      opts = v.option_parser.getopts(argv.dup) # このdup重要。もう一度parseに使用する場合に中身が空にならないように。
      if filepath = opts[load_config.__name__.to_s]
        load_file(filepath)
      end
    end
    v.option_parser.parse(argv.dup)
  end

  def name_array
    []
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tengine_support-0.3.5 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.4 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.3 lib/tengine/support/config/definition/suite.rb