Class: Yuzu::Generators::IndexGenerator

Inherits:
Generator show all
Defined in:
lib/yuzu/generators/index.rb

Constant Summary collapse

@@indexed_folders =
[]

Instance Attribute Summary

Attributes inherited from Generator

#directive, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Generator

generators, registry

Constructor Details

#initializeIndexGenerator

Returns a new instance of IndexGenerator.



19
20
21
22
# File 'lib/yuzu/generators/index.rb', line 19

def initialize
  @name = "index"
  @directive = "INDEX"
end

Class Method Details

.add_indexed_folder(folder) ⇒ Object



11
12
13
# File 'lib/yuzu/generators/index.rb', line 11

def self.add_indexed_folder(folder)
  @@indexed_folders.push(folder)
end

.get_indexedObject



7
8
9
# File 'lib/yuzu/generators/index.rb', line 7

def self.get_indexed
  @@index_folders
end

.is_indexed?(folder) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/yuzu/generators/index.rb', line 15

def self.is_indexed?(folder)
  @@indexed_folders.include?(folder)
end

Instance Method Details

#generate!(website_folder) ⇒ Object



33
34
35
36
37
# File 'lib/yuzu/generators/index.rb', line 33

def generate!(website_folder)
  return if IndexGenerator.is_indexed?(website_folder)

  generate_index_at_path!(website_folder)
end

#generate_index_at_path!(website_folder) ⇒ Object



39
40
41
42
43
44
# File 'lib/yuzu/generators/index.rb', line 39

def generate_index_at_path!(website_folder)
  new_index = GeneratedIndex.new(website_folder)

  website_folder.append_child(new_index)
  IndexGenerator.add_indexed_folder(website_folder)
end

#should_generate?(website_folder) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
# File 'lib/yuzu/generators/index.rb', line 24

def should_generate?(website_folder)
  not IndexGenerator.is_indexed?(website_folder) and \
    not website_folder.has_index?
end

#visitor_filterObject



29
30
31
# File 'lib/yuzu/generators/index.rb', line 29

def visitor_filter
  proc {|c| c.folder? and c.config.can_index_folder?(c.path)}
end