Sha256: a349b51bc76c53e7d1711550058f4cb6ff7c3c472ad48fd769f43e07c5984dc0

Contents?: true

Size: 775 Bytes

Versions: 2

Compression:

Stored size: 775 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_DIR)
    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-2.1 lib/genit/project/pages_finder.rb
genit-2.0 lib/genit/project/pages_finder.rb