Sha256: 549340c69344a8872d7149c94ef1bb1073542e520f4377cad76caa8ca3c77105

Contents?: true

Size: 787 Bytes

Versions: 2

Compression:

Stored size: 787 Bytes

Contents

# -*- encoding: utf-8 -*-

module Genit

  # I can find the list of all page names, named from
  # the site root.
  class PagesFinder
  
    # Public: Constructor.
    #
    # working_dir - The String working directory, where live the project.
    def initialize working_dir
      @working_dir = working_dir
      @pages_folder = File.join(@working_dir, 'pages')
    end
  
    # Public: Retrieve the list of all page names.
    #
    # Returns an Array of String.
    def find
      list = Dir.glob(File.join(@pages_folder, '**/*'))
      list.map! { |name| name.gsub(@pages_folder + '/', '')}
      list.map { |name| name.force_html_extension }
    end
    
    def self.pagenames2urls array, url_string
      array.map { |name| File.join(url_string, name) }
    end
    
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
genit-1.0.1 lib/genit/project/pages_finder.rb
genit-1.0 lib/genit/project/pages_finder.rb