Sha256: 45b67bbabadfa7044c2dab144d6e86169f87b80869fa10615216a9e29d8c5e8c

Contents?: true

Size: 1003 Bytes

Versions: 1

Compression:

Stored size: 1003 Bytes

Contents

module SectionsRails
  module ViewFinder

    # Returns an array with the file name of all views in the given directory.
    # Views are all files that end in .html.erb
    def self.find_all_views root
      result = []
      Dir.entries(root).each do |view_file|
        next if ['.', '..', '.gitkeep'].include? view_file
        next if view_file[-4..-1] == '.swp'
        full_path = "#{root}/#{view_file}"
        if File.directory? full_path
          result.concat find_all_views(full_path)
        else
          next unless view_file['.html.'] || view_file[-3..-1] == '.rb'
          result << full_path
        end
      end
      result
    end

    # Used for :prepare_pages. Not used right now.
    # def self.parse_views views
    #   result = {}
    #   views_to_parse.each do |view_to_parse|
    #     puts root

    #     view_text = IO.read(File.join root, view_to_parse)
    #     result[view_to_parse] = find_sections_in_text view_text
    #   end
    #   result
    # end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sections_rails-0.11.0 lib/sections_rails/view_finder.rb