Class: Genit::PagesFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/genit/project/pages_finder.rb

Overview

I can find the list of all page names, named from the site root.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(working_dir) ⇒ PagesFinder

Public: Constructor.

working_dir - The String working directory, where live the project.



12
13
14
15
# File 'lib/genit/project/pages_finder.rb', line 12

def initialize working_dir
  @working_dir = working_dir
  @pages_folder = File.join(@working_dir, PAGES_DIR)
end

Class Method Details

.pagenames2urls(array, url_string) ⇒ Object



26
27
28
# File 'lib/genit/project/pages_finder.rb', line 26

def self.pagenames2urls array, url_string
  array.map { |name| File.join(url_string, name) }
end

Instance Method Details

#findObject

Public: Retrieve the list of all page names.

Returns an Array of String.



20
21
22
23
24
# File 'lib/genit/project/pages_finder.rb', line 20

def find
  list = Dir.glob(File.join(@pages_folder, '**/*'))
  list.map! { |name| name.gsub(@pages_folder + '/', '')}
  list.map { |name| name.force_html_extension }
end