Class: Nesta::Static::HtmlFile
- Inherits:
-
Object
- Object
- Nesta::Static::HtmlFile
- Defined in:
- lib/nesta/static/html_file.rb
Instance Method Summary collapse
- #filename ⇒ Object
-
#initialize(build_dir, page) ⇒ HtmlFile
constructor
A new instance of HtmlFile.
- #page_shares_path_with_directory?(dir, base_without_ext) ⇒ Boolean
Constructor Details
#initialize(build_dir, page) ⇒ HtmlFile
Returns a new instance of HtmlFile.
4 5 6 7 |
# File 'lib/nesta/static/html_file.rb', line 4 def initialize(build_dir, page) @build_dir = build_dir @content_path = page.filename end |
Instance Method Details
#filename ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/nesta/static/html_file.rb', line 13 def filename dir, base = File.split(@content_path) base_without_ext = File.basename(base, File.extname(base)) subdir = dir.sub(/^#{Nesta::Config.page_path}/, '') path = File.join(@build_dir, subdir, base_without_ext) if page_shares_path_with_directory?(dir, base_without_ext) File.join(path, 'index.html') else path + '.html' end end |
#page_shares_path_with_directory?(dir, base_without_ext) ⇒ Boolean
9 10 11 |
# File 'lib/nesta/static/html_file.rb', line 9 def page_shares_path_with_directory?(dir, base_without_ext) Dir.exist?(File.join(dir, base_without_ext)) end |