Sha256: 92da4cd9e15c02f2d5f3d2accbdb64d2989642283518f3eea9269cee34b08207

Contents?: true

Size: 1.19 KB

Versions: 25

Compression:

Stored size: 1.19 KB

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 initialize(hash_or_filepath = nil)
    build if respond_to?(:build)
    case hash_or_filepath
    when Hash then load(hash_or_filepath)
    when String then load_file(hash_or_filepath)
    end
  end


  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

25 entries across 25 versions & 1 rubygems

Version Path
tengine_support-1.2.2 lib/tengine/support/config/definition/suite.rb
tengine_support-1.2.1 lib/tengine/support/config/definition/suite.rb
tengine_support-1.2.0 lib/tengine/support/config/definition/suite.rb
tengine_support-1.1.0 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.27 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.26 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.25 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.24 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.22 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.21 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.20 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.19 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.18 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.17 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.16 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.15 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.14 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.13 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.12 lib/tengine/support/config/definition/suite.rb
tengine_support-0.3.11 lib/tengine/support/config/definition/suite.rb