Class: Razor::Directory

Inherits:
Generable show all
Defined in:
lib/razor/generable.rb

Direct Known Subclasses

Site

Instance Attribute Summary collapse

Attributes inherited from Generable

#parent, #src_name

Instance Method Summary collapse

Methods inherited from Generable

#dest, #src, #url

Constructor Details

#initialize(parent, src_name) ⇒ Directory

Returns a new instance of Directory.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/razor/generable.rb', line 60

def initialize(parent, src_name)
	super(parent, src_name)
	@files = Dir.entries(src).reject { |filename|
		filename =~ /^[\._].*/ or filename=='Rakefile'
	}.map { |filename|
		if File.directory? File.join(src,filename)
			Directory.new(self, filename)
		elsif filename =~ /^[^~].*\.rb$/
			ViewFile.new(self, filename)
		else
			RegularFile.new(self, filename)
		end
	}
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



58
59
60
# File 'lib/razor/generable.rb', line 58

def files
  @files
end

Instance Method Details

#generateObject



75
76
77
78
# File 'lib/razor/generable.rb', line 75

def generate
	Dir.mkdir(dest) rescue nil
	@files.each(&:generate)
end

#http(url) ⇒ Object



80
81
82
83
84
85
86
87
# File 'lib/razor/generable.rb', line 80

def http(url)
	s = super(url)
	s and return s
	name, *rest = url.split('/')
	file = @files.find { |f| f.dest_name == name }
	file or return nil
	file.http(rest*'/')
end

#requestObject



89
90
91
# File 'lib/razor/generable.rb', line 89

def request
	@files.find { |f| f.dest_name == 'index.html' }
end