Module: WSOC::Course

Included in:
App, Helpers
Defined in:
lib/wsoc/course.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/wsoc/course.rb', line 25

def self.included(base)
  base.module_eval do
    set :host, Config::DEFAULT_HOST
    set :port, Config::DEFAULT_PORT

    set :root, File.expand_path(File.join(File.dirname(__FILE__),'..','..'))
    set :course, File.join(self.root,'course')
    enable :static, :sessions

    helpers WSOC::Helpers

    #
    # Adds a path to the Obstacle Course, where a course template
    # will be rendered.
    #
    # @param [String] path
    #   The path to add to the obstacle course.
    #
    # @since 0.1.0
    #
    def self.course_template(path)
      name = path[1..-1].gsub(/\.\S*$/,'').gsub(/\/+/,'_').to_sym

      get(path) do
        erb name, :layout => false
      end
    end

    #
    # Adds a path to the Obstacle Course.
    #
    # @param [String] path
    #   The path to add to the obstacle course.
    #
    # @since 0.1.0
    #
    def self.course_pass(path)
      get(path) do
        erb :course_pass, :layout => false
      end
    end
  end
end