module Tarpaulin

Tarpaulin is a module containing all of the great Tarpaulin classes that do such an excellent job. These are snippets of code common to my Camping apps

included into top-level TheApp module

overrides r404, defines r403 tells Tarpaulin which Controller in TheApp handles static files

don't need to require anything as these are modules that are included elsewhere and those elsewhere require stuff :)

  1. use included and then call TheApp for stuff we need (like link_controller)

  2. what is the difference between #R, #R, #D, #URL ???

  3. use decent error pages, 403, 404, and Ruby Inspect (html version) in dev mode

  4. do link_ methods need to use #R or some variant?

Constants

VERSION

Public Class Methods

included(mod) click to toggle source
# File lib/tarpaulin/camping.rb, line 16
def self.included(mod)
  $DEBUG and $stderr.puts "mod is #{@mod}"
  @mod = mod
  $DEBUG and $stderr.puts "now it is #{@mod}"
end

Public Instance Methods

r403(f=nil, &block) click to toggle source

check for Context, only show a.inspect in dev mode

# File lib/tarpaulin/camping.rb, line 23
def r403(f=nil, &block)
  #$stderr.puts "in 403"
  h = {'Content-Type' => 'text/html; charset=utf-8'}
  a = eval("Context::determine{}", block)
  if f.nil?
    f = block.call
  end
  extra = (ENV['MODE'] == 'development') ? "<br><hr>#{a.inspect}" : ''
  html_msg = "<!DOCTYPE html><html lang='en'><head>"+
             "<title>&#171; Uh oh &#187;</title><body><span class='error'>"+
             "Site error (BEEP!) 403: Invalid Path: #{f}#{extra}</span></body>"
  r(403, html_msg, h)
end
r404(f=nil, &block) click to toggle source
# File lib/tarpaulin/camping.rb, line 37
def r404(f=nil, &block) # compat with Camping
  #$stderr.puts "in 404"
  h = {'Content-Type' => 'text/html; charset=utf-8'}
  a = eval("Context::determine{}", block)
  if f.nil?
    f = block.call
  end
  extra = (ENV['MODE'] == 'development') ? "<br><hr>#{a.inspect}" : ''
  html_msg = "<!DOCTYPE html><html lang='en'><head>"+
             "<title>&#171; Uh oh &#187;</title><body><span class='error'>"+
             "Site error (BEEP!) 404: File not found: #{f}#{extra}</span></body>"
  r(404, html_msg, h)
end