Class: Lifer::URIStrategy::Simple

Inherits:
Lifer::URIStrategy show all
Defined in:
lib/lifer/uri_strategy/simple.rb

Overview

The default URI strategy. It simply takes an input filename (i.e. “entry.md”) and outputs a mirrorring output filename with the correct output format (i.e. “entry.html”).

Instance Attribute Summary

Attributes inherited from Lifer::URIStrategy

#root

Instance Method Summary collapse

Methods inherited from Lifer::URIStrategy

#initialize

Constructor Details

This class inherits a constructor from Lifer::URIStrategy

Instance Method Details

#output_file(entry) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/lifer/uri_strategy/simple.rb', line 9

def output_file(entry)
  basename = File.basename entry.file,
    Lifer::Utilities.file_extension(entry.file)

  Pathname entry.file.to_s
    .gsub(/#{root}[\/]{0,1}/, "")
    .gsub(/#{basename}(\..+)/, "#{basename}.#{file_extension(entry)}")
end