Sha256: d0102a4d7d25c0eefed4fb0c5e2eef3f905c1c57be0e895313309d153b009921

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 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/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.5 lib/load_dir.rb