Class: Comet::DSL::Software
- Inherits:
-
Object
- Object
- Comet::DSL::Software
- Includes:
- Helpers
- Defined in:
- lib/comet/dsl/software.rb
Instance Attribute Summary collapse
-
#depends ⇒ Object
Returns the value of attribute depends.
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
Instance Method Summary collapse
- #hardware_for(device) ⇒ Object
-
#initialize(name, depends:, &block) ⇒ Software
constructor
A new instance of Software.
- #source(language:, **kwargs, &block) ⇒ Object
- #to_s ⇒ Object
- #validate! ⇒ Object
Methods included from Helpers
Constructor Details
#initialize(name, depends:, &block) ⇒ Software
Returns a new instance of Software.
13 14 15 16 17 18 19 |
# File 'lib/comet/dsl/software.rb', line 13 def initialize(name, depends:, &block) @name = name @depends = depends @sources = [] instance_exec(&block) if block_given? end |
Instance Attribute Details
#depends ⇒ Object
Returns the value of attribute depends.
25 26 27 |
# File 'lib/comet/dsl/software.rb', line 25 def depends @depends end |
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
26 27 28 |
# File 'lib/comet/dsl/software.rb', line 26 def sources @sources end |
Instance Method Details
#hardware_for(device) ⇒ Object
28 29 30 31 32 |
# File 'lib/comet/dsl/software.rb', line 28 def hardware_for(device) @depends.flat_map do |dependent| dependent.hardware_for device end.uniq end |
#source(language:, **kwargs, &block) ⇒ Object
7 8 9 10 11 |
# File 'lib/comet/dsl/software.rb', line 7 def source(language:, **kwargs, &block) source = Source.create(language: language, **kwargs, &block) raise 'native source only allowed in hardware block' if source.native? @sources.push source end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/comet/dsl/software.rb', line 21 def to_s "software #{@name}" end |
#validate! ⇒ Object
34 35 36 37 38 39 |
# File 'lib/comet/dsl/software.rb', line 34 def validate! raise "#{@name} has no source directives" if sources.empty? depends.each(&:validate!) sources.each(&:validate!) end |