Class: Frizz::Local

Inherits:
Object
  • Object
show all
Defined in:
lib/frizz/local.rb

Defined Under Namespace

Classes: File

Instance Method Summary collapse

Constructor Details

#initialize(root_path, ignorance, options = {}) ⇒ Local

Returns a new instance of Local.



3
4
5
6
7
# File 'lib/frizz/local.rb', line 3

def initialize(root_path, ignorance, options = {})
  @root_path = root_path
  @ignorance = ignorance
  @options = options
end

Instance Method Details

#file_for(local_path) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/frizz/local.rb', line 19

def file_for(local_path)
  if is_redirect?(local_path)
    Tempfile.new(local_path.gsub(/\.|\//, '-'))
  else
    ::File.read expand_path(local_path)
  end
end

#filesObject



9
10
11
12
13
14
15
16
17
# File 'lib/frizz/local.rb', line 9

def files
  @files ||= begin
    Dir.chdir(root_path) do
      Dir["**/*"].map do |local_path|
        File.new(expand_path(local_path), local_path) unless ignore?(local_path)
      end.compact
    end
  end.concat(redirect_files)
end