Class: Razor::Directory
Direct Known Subclasses
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Attributes inherited from Generable
Instance Method Summary collapse
- #generate ⇒ Object
- #http(url) ⇒ Object
-
#initialize(parent, src_name) ⇒ Directory
constructor
A new instance of Directory.
- #request ⇒ Object
Methods inherited from Generable
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
#files ⇒ Object (readonly)
Returns the value of attribute files.
58 59 60 |
# File 'lib/razor/generable.rb', line 58 def files @files end |
Instance Method Details
#generate ⇒ Object
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 |
#request ⇒ Object
89 90 91 |
# File 'lib/razor/generable.rb', line 89 def request @files.find { |f| f.dest_name == 'index.html' } end |