Class: Flatrack

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::Autoload
Defined in:
lib/flatrack.rb,
lib/flatrack/cli.rb,
lib/flatrack/site.rb,
lib/flatrack/view.rb,
lib/flatrack/request.rb,
lib/flatrack/version.rb,
lib/flatrack/response.rb,
lib/flatrack/template.rb,
lib/flatrack/template/rb.rb,
lib/flatrack/template/html.rb,
lib/flatrack/template/erubis.rb,
lib/flatrack/view/tag_helper.rb,
lib/flatrack/asset_extensions.rb,
lib/flatrack/view/link_helper.rb,
lib/flatrack/view/output_buffer.rb,
lib/flatrack/view/render_helper.rb,
lib/flatrack/view/capture_helper.rb,
lib/flatrack/view/request_helper.rb,
lib/flatrack/template/erubis/handler.rb

Defined Under Namespace

Modules: AssetExtensions, Site, Template Classes: CLI, Request, Response, View

Constant Summary collapse

TemplateNotFound =
Class.new StandardError
FileNotFound =
Class.new StandardError
FORMATS =
{}
VERSION =
'1.2.0'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.delegate_instanceObject



36
37
38
# File 'lib/flatrack.rb', line 36

def delegate_instance
  @delegate_instance ||= new
end

.gem_rootObject



27
28
29
# File 'lib/flatrack.rb', line 27

def self.gem_root
  File.expand_path File.join __FILE__, '..'
end

.reset!Object



40
41
42
# File 'lib/flatrack.rb', line 40

def reset!
  @delegate_instance = nil
end

.site_rootObject



31
32
33
# File 'lib/flatrack.rb', line 31

def self.site_root
  File.expand_path Dir.pwd
end

Instance Method Details

#assetsObject



55
56
57
58
59
60
61
62
63
64
# File 'lib/flatrack.rb', line 55

def assets
  @assets ||= begin
    Sprockets::Environment.new.tap do |environment|
      environment.append_path 'assets/images'
      environment.append_path 'assets/javascripts'
      environment.append_path 'assets/stylesheets'
      environment.context_class.class_eval { include AssetExtensions }
    end
  end
end

#config {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Flatrack)

    the object that the method was called on



51
52
53
# File 'lib/flatrack.rb', line 51

def config(&block)
  yield self
end

#middlewareObject



70
71
72
# File 'lib/flatrack.rb', line 70

def middleware
  @middleware ||= []
end

#register_format(ext, mime) ⇒ Object



66
67
68
# File 'lib/flatrack.rb', line 66

def register_format(ext, mime)
  FORMATS[ext.to_s] = mime
end

#use(*args) ⇒ Object



74
75
76
# File 'lib/flatrack.rb', line 74

def use(*args)
  middleware << args
end