Class: Prick::Build::BuildBatch

Inherits:
Object
  • Object
show all
Includes:
Timer
Defined in:
lib/prick/builder/batch.rb

Direct Known Subclasses

FoxBatch, ModuleBatch, SqlBatch

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Timer

file, file=, new, off!, off?, on!, on?, scale, scale=, #time, time, unit, unit=

Constructor Details

#initialize(builder) ⇒ BuildBatch

Returns a new instance of BuildBatch.



12
13
14
15
# File 'lib/prick/builder/batch.rb', line 12

def initialize(builder)
  @builder = builder
  @nodes = []
end

Instance Attribute Details

#builderObject (readonly)

Returns the value of attribute builder.



6
7
8
# File 'lib/prick/builder/batch.rb', line 6

def builder
  @builder
end

#nodesObject (readonly)

Returns the value of attribute nodes.



10
11
12
# File 'lib/prick/builder/batch.rb', line 10

def nodes
  @nodes
end

Instance Method Details

#dumpObject



28
29
30
31
# File 'lib/prick/builder/batch.rb', line 28

def dump
  puts kind.upcase
  indent { nodes.each(&:dump) }
end

#execute(**opts, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/prick/builder/batch.rb', line 17

def execute(**opts, &block)
  name = self.class.to_s.sub(/.*::/, "").split(/(?=[A-Z])/).map(&:downcase).join(" ")
  node_paths = nodes.map(&:relpath)
  time "Execute #{name} (nodes: #{nodes.size})" do
    yield(**opts)
  end
  if Timer.on?
    ::Timer.file.indent { |f| f.puts node_paths }
  end
end

#kindObject



9
# File 'lib/prick/builder/batch.rb', line 9

def kind() @nodes.first&.kind end