class Prez::Build

Private Class Methods

source_root() click to toggle source
# File lib/prez/build.rb, line 59
def source_root
  File.absolute_path File.expand_path("../../../templates", __FILE__)
end

Public Instance Methods

check_file!() click to toggle source
# File lib/prez/build.rb, line 10
def check_file!
  if File.exists? prez_name
    @filename = prez_name
  elsif File.exists? "#{prez_name}.prez"
    @filename = "#{prez_name}.prez"
  else
    raise Prez::Error.new("Missing prez file '#{prez_name}'")
  end

  if filename =~ /\.html$/
    raise Prez::Error.new("Prez file cannot be an html file: '#{prez_name}'")
  end
end
generate_html() click to toggle source
# File lib/prez/build.rb, line 24
def generate_html
  create_file html_filename, build_html(filename)
end

Private Instance Methods

base_name() click to toggle source
# File lib/prez/build.rb, line 46
def base_name
  filename.sub /\.prez$/, ""
end
filename() click to toggle source
# File lib/prez/build.rb, line 50
def filename
  @filename
end
html_filename() click to toggle source
# File lib/prez/build.rb, line 54
def html_filename
  "#{base_name}.html"
end
only_existing_prez() click to toggle source
# File lib/prez/build.rb, line 34
def only_existing_prez
  results = Dir.glob "*.prez"

  if results.empty?
    raise Prez::Error.new("No .prez files found!")
  elsif results.size > 1
    raise Prez::Error.new("More than one .prez file found!\nPlease specify which one you want to build.")
  end

  results.first
end
prez_name() click to toggle source
# File lib/prez/build.rb, line 30
def prez_name
  @prez_name = name || only_existing_prez
end