Module: BaseChip::Dsl

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#modesObject

Returns the value of attribute modes.



397
398
399
# File 'lib/base_chip/dsl.rb', line 397

def modes
  @modes
end

Class Method Details

.included(mod) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/base_chip/dsl.rb', line 25

def self.included mod
  mod.extend Dsl::ClassMethods
  mod.class_eval do
    include Reporting
    include Dsl::InstanceMethods
    attr_accessor :name
    attr_reader   :foster
    attr_reader   :parent
    attr_accessor :settings         
    attr_accessor :children
    attr_accessor :possible_settings
    attr_reader   :configured
    attr_accessor :blks
    attr_accessor :abstract

             @settings    = Hash.new
    @possible_settings    = Hash.new
             @child_types = Hash.new
    @possible_child_types = Hash.new
  end
end

Instance Method Details

#add_child_mode_as_child(child_name, mode) ⇒ Object



398
399
400
401
402
403
404
405
406
# File 'lib/base_chip/dsl.rb', line 398

def add_child_mode_as_child(child_name,mode)
  if c = @children[child_name.to_sym]
    c2       = c.clone
    c2.blks  = c.blks # copy has the same blocks
    c2.modes << mode
  else
    fault "add_child_mode_as_child could not find child '#{child_name}'"
  end
end

#inherit(name) ⇒ Object



428
429
430
431
432
433
434
435
# File 'lib/base_chip/dsl.rb', line 428

def inherit(name)
  return if @base_types.map{|t|t.name}.include? name
  things = parent.instance_eval(type_plural)
  fault "'#{full_name}' tried to inherit from #{name.inspect}, but there are no '#{type_plural}' in '#{parent.full_name}'to extend'" unless things
  thing  = things[name.to_sym]
  fault "'#{full_name}' tried to inherit from #{name.inspect}, but '#{parent.full_name}.#{type_plural}[#{name.inspect}]' is nil'" unless thing
  @base_types << thing
end

#mode(name, &blk) ⇒ Object



407
408
409
410
411
# File 'lib/base_chip/dsl.rb', line 407

def mode(name, &blk)
  if mode? name
    blk.call
  end
end

#mode?(name) ⇒ Boolean

Returns:



412
413
414
415
416
417
# File 'lib/base_chip/dsl.rb', line 412

def mode?(name)
  # fault "Attempted to use mode '#{name}', which isn't registered with the project.  Call register_mode(#{name}) in project.rb to allow." unless project.registered_modes.include? name.to_s
  if modes.include? name.to_s
    ".#{name}"
  end # else return nil
end

#type_pluralObject

else return nil



418
419
420
421
422
423
424
425
426
427
# File 'lib/base_chip/dsl.rb', line 418

def type_plural
  if    is_a? Project      ; 'project.subprojects'
  elsif is_a? Block        ; 'project.blocks'
  elsif is_a? Configuration; 'block.configurations'
  elsif is_a? Action       ; 'configuration.actions'
  elsif is_a? TestList     ; 'configuration.test_lists'
  elsif is_a? Test         ; 'test_list.test'
  else  fault "Could not determine type of '#{full_name}' in order to make 'inherit' call"
  end
end