Class: Comet::DSL::Native::Source

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/comet/dsl/native/source.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#quote

Constructor Details

#initialize(**_, &block) ⇒ Source

Returns a new instance of Source.



12
13
14
15
16
# File 'lib/comet/dsl/native/source.rb', line 12

def initialize(**_, &block)
  @imports = []

  instance_exec(&block) if block_given?
end

Instance Attribute Details

#importsObject (readonly)

Returns the value of attribute imports.



22
23
24
# File 'lib/comet/dsl/native/source.rb', line 22

def imports
  @imports
end

Instance Method Details

#filesObject



32
33
34
35
36
# File 'lib/comet/dsl/native/source.rb', line 32

def files
  @imports.flat_map do |pattern|
    Dir.glob pattern
  end.uniq
end

#import(pattern) ⇒ Object



8
9
10
# File 'lib/comet/dsl/native/source.rb', line 8

def import(pattern)
  @imports.push pattern
end

#languageObject



24
25
26
# File 'lib/comet/dsl/native/source.rb', line 24

def language
  :native
end

#native?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/comet/dsl/native/source.rb', line 28

def native?
  true
end

#to_sObject



18
19
20
# File 'lib/comet/dsl/native/source.rb', line 18

def to_s
  'native source'
end

#validate!Object



38
39
40
# File 'lib/comet/dsl/native/source.rb', line 38

def validate!
  raise "#{self} references no source files" if @imports.empty?
end