Class: Hash
- Includes:
- TSort
- Defined in:
- lib/uttk/loaders/Loader.rb,
lib/uttk/logger/to_uttk_log.rb,
lib/uttk/strategies/Iterate.rb,
lib/uttk/strategies/PackageCollection.rb
Instance Method Summary collapse
- #testify(symtbl, &block) ⇒ Object
- #to_uttk_log(log) ⇒ Object
- #to_uttk_log_with_key(key, log, opts = nil) ⇒ Object
- #tsort_each_child(node, &block) ⇒ Object
- #tsort_each_from(node = nil, &block) ⇒ Object
- #tsort_from(node = nil) ⇒ Object
- #uttk_each(*a, &b) ⇒ Object
Instance Method Details
#testify(symtbl, &block) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/uttk/loaders/Loader.rb', line 138 def testify ( symtbl, &block ) if size == 1 and (tab = to_a[0])[1].is_a? Hash name, doc = tab doc[:name] = name return doc.testify(symtbl, &block) end raise ArgumentError, "nil symtbl" if symtbl.nil? strategy = self[:strategy] || symtbl[:strategy] if strategy.nil? raise ArgumentError, "no strategy for this test (#{inspect})" end Uttk::Loaders.get_class(strategy).new do |t| t.symtbl ||= symtbl block[t] if block t.assign(self) end end |
#to_uttk_log(log) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/uttk/logger/to_uttk_log.rb', line 38 def to_uttk_log ( log ) each do |k, v| next if k == :strategy log[k] = v end end |
#to_uttk_log_with_key(key, log, opts = nil) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/uttk/logger/to_uttk_log.rb', line 45 def to_uttk_log_with_key ( key, log, opts=nil ) if has_key? :strategy opts = (opts || {}).merge(:type => self[:strategy]) end log.new_node key, opts do log << self end end |
#tsort_each_child(node, &block) ⇒ Object
56 57 58 |
# File 'lib/uttk/strategies/PackageCollection.rb', line 56 def tsort_each_child(node, &block) fetch(node).each(&block) end |
#tsort_each_from(node = nil, &block) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/uttk/strategies/PackageCollection.rb', line 60 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
71 72 73 74 75 76 |
# File 'lib/uttk/strategies/PackageCollection.rb', line 71 def tsort_from ( node=nil ) return tsort if node.nil? result = [] tsort_each_from(node) { |n| result << n } result end |
#uttk_each(*a, &b) ⇒ Object
135 136 137 |
# File 'lib/uttk/strategies/Iterate.rb', line 135 def uttk_each ( *a, &b ) each(*a) { |k, v| b[k, v] } end |