Class: BaseChip::Block
- Inherits:
-
Object
- Object
- BaseChip::Block
- Defined in:
- lib/base_chip/block.rb
Instance Attribute Summary
Attributes included from Dsl
Instance Method Summary collapse
- #configuration_dereference(name, names, passive) ⇒ Object
- #dereference_workload(names = nil, passive = false) ⇒ Object
- #discover_configurations ⇒ Object
- #shortcut(name, array) ⇒ Object
Methods included from Hierarchy
Methods included from Base
Methods included from Dsl
#add_child_mode_as_child, included, #inherit, #mode, #mode?, #type_plural
Instance Method Details
#configuration_dereference(name, names, passive) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/base_chip/block.rb', line 26 def configuration_dereference(name,names,passive) if configuration = @configurations[name] configuration.configure configuration.dereference_workload(names,passive) elsif configuration = @configurations[:default] configuration.configure configuration.dereference_workload(names.map{|n|"#{name}:#{n}"},passive) elsif passive [] else fault "Could not find configuration #{name} in block #{@name}" # FIXME say who wanted it, and if shortcut occurred end end |
#dereference_workload(names = nil, passive = false) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/base_chip/block.rb', line 39 def dereference_workload(names = nil,passive=false) configure fault "No configurations specified for block #{@name}" unless @configurations # || passive || names.nil? names ||= ['all'] out = Array.new names.each do |n| n = n.to_s case n when 'all', 'gate', 'upgate', 'downgate', 'diffgate' # FIXME , 'alltests', 'allactions' next unless @configurations @configurations.keys.each { |k| out += configuration_dereference(k,[n],true) } when /^all:(.*)$/ next unless @configurations tmp = $1 @configurations.keys.each { |k| out += configuration_dereference(k,[tmp],true) } when /^([^:]*?):(.*)$/ out += configuration_dereference($1.to_sym,[$2],passive) else fault "No configurations specified for block #{@name}" unless @configurations || passive if @configurations[:default] out += configuration_dereference(:default,[n],passive) elsif @configurations.size == 1 out += configuration_dereference(@configurations.keys[0],[n],passive) end end end out.uniq! out end |
#discover_configurations ⇒ Object
74 75 |
# File 'lib/base_chip/block.rb', line 74 def discover_configurations ; file_glob("#{@directory}/*/base_chip/configuration.rb" , /(\w+)\/base_chip\/configuration\.rb$/ , :configuration) file_glob("#{@directory}/base_chip/configurations/*.rb", /base_chip\/configurations\/(\w+)\.rb$/, :configuration) end |
#shortcut(name, array) ⇒ Object
69 70 71 72 |
# File 'lib/base_chip/block.rb', line 69 def shortcut(name, array) @shortcuts ||= {} @shortcuts[name] = array end |