Class: Bake::Project
Constant Summary collapse
- SCHEME =
nil
Instance Attribute Summary collapse
-
#loader ⇒ Object
Returns the value of attribute loader.
Attributes inherited from Target
#children, #deps, #name, #parent
Instance Method Summary collapse
- #find(name) ⇒ Object
-
#initialize(parent) ⇒ Project
constructor
A new instance of Project.
- #map(mappings) ⇒ Object
- #mapping(name) ⇒ Object
Methods inherited from Target
Methods included from Configuration
#[], #default, #get, #has_prop?, #is?, #opt, #req
Constructor Details
#initialize(parent) ⇒ Project
Returns a new instance of Project.
71 72 73 74 |
# File 'lib/bake/target.rb', line 71 def initialize(parent) super(parent) @mappings = {} end |
Instance Attribute Details
#loader ⇒ Object
Returns the value of attribute loader.
69 70 71 |
# File 'lib/bake/target.rb', line 69 def loader @loader end |
Instance Method Details
#find(name) ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'lib/bake/target.rb', line 105 def find(name) target = mapping(name) target ||= children.find do |child| !child.is_a?(Project) && child.name == name end target ||= parent.find(name) if parent return target end |
#map(mappings) ⇒ Object
76 77 78 79 80 81 |
# File 'lib/bake/target.rb', line 76 def map(mappings) mappings.each do |name, loc| raise "target '#{name}' already mapped" if @mappings[name] @mappings[name] = loc end end |
#mapping(name) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/bake/target.rb', line 83 def mapping(name) target = nil mapping = @mappings[name] if mapping if mapping.instance_of?(String) path = @mappings[name].split('/') proj = self path.each do |dir| proj = loader.load_project(dir, proj) end target = proj.child(name) @mappings[name] = target raise "invalid mapping #{@mappings[name]}" if !target elsif mapping.is_a?(Target) target = mapping else raise "mapping has invalid class '#{mapping.class.name}'" end end return target end |