Class: Awestruct::Extensions::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/awestruct/extensions/pipeline.rb

Overview

Public. Extension declaration class, initialized by the end user to declare their extensions, helpers, transformers, etc.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Pipeline

Returns a new instance of Pipeline



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/awestruct/extensions/pipeline.rb', line 25

def initialize(&block)
  @before_all_extensions       = []
  @extensions                  = []
  @helpers                     = []
  @transformers                = []
  @after_all_extensions        = []
  @after_generation_extensions = []
  begin
    instance_eval(&block) if block
  rescue Exception => e
    abort("Failed to initialize pipeline: #{e}")
  end
end

Instance Attribute Details

#after_all_extensionsObject (readonly)

Returns the value of attribute after_all_extensions



20
21
22
# File 'lib/awestruct/extensions/pipeline.rb', line 20

def after_all_extensions
  @after_all_extensions
end

#after_generation_extensionsObject (readonly)

Returns the value of attribute after_generation_extensions



23
24
25
# File 'lib/awestruct/extensions/pipeline.rb', line 23

def after_generation_extensions
  @after_generation_extensions
end

#before_all_extensionsObject (readonly)

Returns the value of attribute before_all_extensions



18
19
20
# File 'lib/awestruct/extensions/pipeline.rb', line 18

def before_all_extensions
  @before_all_extensions
end

#extensionsObject (readonly)

Returns the value of attribute extensions



19
20
21
# File 'lib/awestruct/extensions/pipeline.rb', line 19

def extensions
  @extensions
end

#helpersObject (readonly)

Returns the value of attribute helpers



21
22
23
# File 'lib/awestruct/extensions/pipeline.rb', line 21

def helpers
  @helpers
end

#transformersObject (readonly)

Returns the value of attribute transformers



22
23
24
# File 'lib/awestruct/extensions/pipeline.rb', line 22

def transformers
  @transformers
end

Instance Method Details

#after_extensions(ext) ⇒ Object



51
52
53
# File 'lib/awestruct/extensions/pipeline.rb', line 51

def after_extensions(ext)
  @after_all_extensions << ext
end

#after_generation(ext) ⇒ Object



63
64
65
# File 'lib/awestruct/extensions/pipeline.rb', line 63

def after_generation(ext)
  @after_generation_extensions << ext
end

#before_extensions(ext) ⇒ Object



39
40
41
# File 'lib/awestruct/extensions/pipeline.rb', line 39

def before_extensions(ext)
  @before_all_extensions << ext
end

#execute(site) ⇒ Object



67
68
69
70
71
# File 'lib/awestruct/extensions/pipeline.rb', line 67

def execute(site)
  extensions.each do |ext|
    ext.execute( site )
  end
end

#extension(ext) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/awestruct/extensions/pipeline.rb', line 43

def extension(ext)
  @extensions << ext if ext.respond_to?(:execute)

  @before_all_extensions << ext if ext.respond_to?(:before_extensions)
  @after_all_extensions << ext if ext.respond_to?(:after_extensions)
  @after_generation_extensions << ext if ext.respond_to?(:after_generation)
end

#helper(helper) ⇒ Object



55
56
57
# File 'lib/awestruct/extensions/pipeline.rb', line 55

def helper(helper)
  @helpers << helper
end

#transformer(transformer) ⇒ Object



59
60
61
# File 'lib/awestruct/extensions/pipeline.rb', line 59

def transformer(transformer)
  @transformers << transformer
end

#watch(watched_dirs) ⇒ Object



73
74
75
76
77
# File 'lib/awestruct/extensions/pipeline.rb', line 73

def watch(watched_dirs)
  extensions.each do |ext|
    ext.watch( watched_dirs ) if ext.respond_to?('watch')
  end
end