Class: Hash
- Includes:
- TSort
- Defined in:
- lib/ttk/loaders/YamlOld.rb,
lib/ttk/symtbl.rb,
lib/ttk/loaders/Loader.rb,
lib/ttk/logger/to_ttk_log.rb,
lib/ttk/strategies/PackageCollection.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Method Summary collapse
- #hash_to_ttk_log(log, type) ⇒ Object
- #symtbl_gsub(symtbl) ⇒ Object
- #testify(aLoader = nil, &block) ⇒ Object
- #to_ttk_log(log) ⇒ Object
- #tsort_each_child(node, &block) ⇒ Object
- #tsort_each_from(node = nil, &block) ⇒ Object
- #tsort_from(node = nil) ⇒ Object
- #yaml_load_map ⇒ Object
Instance Method Details
#hash_to_ttk_log(log, type) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ttk/logger/to_ttk_log.rb', line 32 def hash_to_ttk_log ( log, type ) each do |k,v| if v.is_a? Array and v.all? { |x| x.is_a? Hash } log.new_node(k, :seq) do v.each do |x| x.to_ttk_log(log) end end else log.new_node(k, type) do v.to_ttk_log(log) end end end end |
#symtbl_gsub(symtbl) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ttk/symtbl.rb', line 59 def symtbl_gsub ( symtbl ) changed = false res = self.class.new each do |k,v| new_k = k.symtbl_gsub(symtbl) new_v = v.symtbl_gsub(symtbl) changed = true if new_k or new_v res[new_k || k] = (new_v || v) end changed ? res : nil end |
#testify(aLoader = nil, &block) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/ttk/loaders/Loader.rb', line 103 def testify ( aLoader=nil, &block ) if size == 1 and (tab = to_a[0])[1].is_a? Hash name, doc = tab doc[:name] = name return doc.testify(aLoader, &block) end unless has_key? :strategy raise ArgumentError, "no strategy for this test (#{inspect})" end TTK::Loaders.get_class(self[:strategy]).new do |t| block[t] if block_given? t.assign(self) end end |
#to_ttk_log(log) ⇒ Object
48 49 50 |
# File 'lib/ttk/logger/to_ttk_log.rb', line 48 def to_ttk_log ( log ) hash_to_ttk_log(log, :map) end |
#tsort_each_child(node, &block) ⇒ Object
50 51 52 |
# File 'lib/ttk/strategies/PackageCollection.rb', line 50 def tsort_each_child(node, &block) fetch(node).each(&block) end |
#tsort_each_from(node = nil, &block) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ttk/strategies/PackageCollection.rb', line 54 def tsort_each_from ( node=nil, &block ) return tsort_each(&block) if node.nil? each_strongly_connected_component_from(node) do |component| if component.size == 1 block[component.first] else raise Cyclic, "topological sort failed: #{component.inspect}" end end end |
#tsort_from(node = nil) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/ttk/strategies/PackageCollection.rb', line 65 def tsort_from ( node=nil ) return tsort if node.nil? result = [] tsort_each_from(node) { |n| result << n } result end |
#yaml_load_map ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ttk/loaders/YamlOld.rb', line 22 def yaml_load_map res = {} each do |k,v| k = k.to_s.to_sym unless k.is_a? Symbol or k.is_a? Integer if k == :class or k == :strategy if k == :class k = :strategy end unless v.is_a? Strategies::Strategy v = v.to_s if v =~ /TestT/ v.gsub!(/TestTBase/, 'Strategy') v.gsub!(/TTK::Test::TestT/, 'TTK::Strategies::') v.gsub!(/Test::TestT/, 'Strategies::') v.gsub!(/TestT/, '') end end res[k] = Loaders.get_class(v) elsif k == :content res[:contents] = v.yaml_load_map else res[k] = v.yaml_load_map end end res end |