Class: PBSimply::Hooks

Inherits:
Object
  • Object
show all
Defined in:
lib/pbsimply/hooks.rb

Overview

Hooks is new in PureBuilder Simply 2.2. Hooks object has instance variables for each timing.

Defined Under Namespace

Classes: HooksHolder, HooksHolderPre

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pbsimply, config) ⇒ Hooks

Returns a new instance of Hooks.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/pbsimply/hooks.rb', line 62

def initialize(pbsimply, config)
  @pbsimply = pbsimply
  @config = config
  @hooks_loaded = false

  # Called first phase before generate. This hooks called before blessing.
  #
  # Argument: frontmatter, procdoc.
  # procdoc is processing source document path.
  @pre = HooksHolderPre.new "pre"

  # Called after document was generated.
  # 
  # Argument: outpath, frontmatter, procdoc.
  # outpath is generated final document path. You can read output result.
  # procdoc is source document path before generate.
  @process = HooksHolder.new "process"

  # Called each deleted document on ACCS final phase, before deletion.
  #
  # Argument: target_file_path, source_file_path.
  # target_file_path is output file path (existing or non-existing.)
  @delete = HooksHolder.new "delete"

  # Called after all document were generated.
  #
  # Argument: this_time_processed([{source, dest, frontmatter}...])
  # this_time_processed has actually processed documents.
  # source is source file path, dest is generated file path.
  @post = HooksHolder.new "post"

  # Called before generating ACCS index.
  #
  # Argument: index, indexes.
  #
  # index is @index (frontmatter for ACCS index),
  # indexes is @indexes.
  @accs = HooksHolder.new "accs"
end

Instance Attribute Details

#accsObject (readonly)

Returns the value of attribute accs.



114
115
116
# File 'lib/pbsimply/hooks.rb', line 114

def accs
  @accs
end

#configObject (readonly)

Returns the value of attribute config.



116
117
118
# File 'lib/pbsimply/hooks.rb', line 116

def config
  @config
end

#deleteObject (readonly)

Returns the value of attribute delete.



112
113
114
# File 'lib/pbsimply/hooks.rb', line 112

def delete
  @delete
end

#postObject (readonly)

Returns the value of attribute post.



113
114
115
# File 'lib/pbsimply/hooks.rb', line 113

def post
  @post
end

#preObject (readonly)

Returns the value of attribute pre.



110
111
112
# File 'lib/pbsimply/hooks.rb', line 110

def pre
  @pre
end

#processObject (readonly)

Returns the value of attribute process.



111
112
113
# File 'lib/pbsimply/hooks.rb', line 111

def process
  @process
end

Instance Method Details

#loadObject



102
103
104
105
106
107
108
# File 'lib/pbsimply/hooks.rb', line 102

def load
  if File.file?("./.pbsimply-hooks.rb")
    require './.pbsimply-hooks.rb'
    PBSimply::Hooks.load_hooks(self) unless @hooks_loaded
    @hooks_loaded = true
  end
end