Sha256: 9a6a425dcfa7c8af9f373fd2f33d38813dd4a6e5e80ad9a06f3a6d53b979160b

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

class LoadDir

  HTML_PATH     = Dir.pwd + '/app/views'
  CSS_PATH      = Dir.pwd + '/app/assets/stylesheets'
  CSS_MAIN_PATH = Dir.pwd + '/app/assets/stylesheets/base/styles'

  attr_accessor :directories, :files

  def initialize(*args)
    @directories = args.flatten
    @files = {}
    dir_iteration
  end

  def dir_iteration
    @directories.each do |dir|
      html_files(dir)
      layout_files(dir)
      css_files(dir)
    end
  end

  def html_files dir
    Dir.foreach(HTML_PATH + "/" + dir) do |file|
      self.files[file] = HTML_PATH + "/" + dir + "/" + file unless /^\./.match(file)
    end
  end

  def layout_files dir
    Dir.foreach(HTML_PATH + "/layouts") do |file|
      if /(#{dir}\.html|application\.html)/.match(file)
        self.files[file] = HTML_PATH + "/layouts/" + file unless /^\./.match(file)
      end
    end
  end 

  def css_files dir
    #Dir.foreach methods arg is only the base dir
    Dir.foreach(CSS_PATH) do |file|
      self.files[file] = CSS_PATH if /(#{dir}|application)/.match(file) 
    end
    Dir.foreach(CSS_MAIN_PATH) do |file|
      self.files[file] = CSS_MAIN_PATH if /(#{dir}|application)/.match(file) 
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
old_style-1.4.4 lib/load_dir.rb