Module: WSOC::Helpers::Course

Defined in:
lib/wsoc/helpers/course.rb

Instance Method Summary collapse

Instance Method Details

#course_dirString

The course directory.

Examples:

course_dir
# => "/course/"

Returns:

  • (String)

    The course directory.

Since:

  • 0.1.0



99
100
101
# File 'lib/wsoc/helpers/course.rb', line 99

def course_dir
  "#{Config::COURSE_DIR}/"
end

#course_failString

The full course failure URL.

Examples:

course_fail
# => "http://localhost:8080/course/fail"

Returns:

  • (String)

    The remote course failure URL.

Since:

  • 0.1.0



131
132
133
# File 'lib/wsoc/helpers/course.rb', line 131

def course_fail
  remote_url Config::COURSE_FAIL_PATH
end

#course_page(name) ⇒ String

Renders a course page.

Examples:

course_page :course_start

Parameters:

  • name (Symbol)

    The name of the course page.

Returns:

  • (String)

    The rendered page.

Since:

  • 0.1.0



41
42
43
# File 'lib/wsoc/helpers/course.rb', line 41

def course_page(name)
  erb name, :layout => false
end

#course_startString

The full course starting URL.

Examples:

course_start
# => "http://localhost:8080/course/start.html"

Returns:

  • (String)

    The remote course starting URL.

Since:

  • 0.1.0



115
116
117
# File 'lib/wsoc/helpers/course.rb', line 115

def course_start
  remote_url Config::COURSE_START_PATH
end

#remote_url(path) ⇒ String

Generates a remote URL containing a given path.

Examples:

remote_url '/course/redirects/start.html'
# => "http://localhost:8080/course/redirects/start.html"

Parameters:

  • path (String)

    The path to include within the URL.

Returns:

  • (String)

    The remote URL.

Since:

  • 0.1.0



79
80
81
82
83
84
85
# File 'lib/wsoc/helpers/course.rb', line 79

def remote_url(path)
  s = "#{request.scheme}://#{request.host}"
  s << ":#{request.port}" if request.port != 80
  s << path

  return s
end

#specsArray<Hash>

The specs for the course.

Returns:

  • (Array<Hash>)

    The Array of specs for each URL within the course.

Since:

  • 0.1.0



143
144
145
# File 'lib/wsoc/helpers/course.rb', line 143

def specs
  CourseSpecs.map(request.host,request.port)
end

#title_for(*names) ⇒ String

Renders a title string.

Examples:

title_for 'HTTP Redirects'
# => "Web Spider Obstacle Course :: HTTP Redirects"

Parameters:

  • names (Array)

    The names to put into the title.

Returns:

  • (String)

    The title.

Since:

  • 0.1.0



60
61
62
# File 'lib/wsoc/helpers/course.rb', line 60

def title_for(*names)
  (['Web Spider Obstacle Course'] + names).join(' :: ')
end