wsoc 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +4 -0
- data/COPYING.txt +339 -0
- data/History.rdoc +16 -0
- data/Manifest.txt +42 -0
- data/README.rdoc +58 -0
- data/Rakefile +27 -0
- data/bin/wsoc_server +12 -0
- data/config.ru +9 -0
- data/lib/wsoc.rb +21 -0
- data/lib/wsoc/app.rb +147 -0
- data/lib/wsoc/config.rb +46 -0
- data/lib/wsoc/course.rb +69 -0
- data/lib/wsoc/course_specs.rb +124 -0
- data/lib/wsoc/helpers.rb +34 -0
- data/lib/wsoc/helpers/course.rb +148 -0
- data/lib/wsoc/helpers/rendering.rb +111 -0
- data/lib/wsoc/runner.rb +123 -0
- data/lib/wsoc/specs.rb +62 -0
- data/lib/wsoc/version.rb +24 -0
- data/public/css/layout.css +44 -0
- data/public/css/specs.css +11 -0
- data/public/js/jquery-1.3.2.min.js +19 -0
- data/tasks/yard.rb +12 -0
- data/views/course_absolute_start.erb +19 -0
- data/views/course_cookies_get.erb +13 -0
- data/views/course_cookies_start.erb +13 -0
- data/views/course_empty_start.erb +23 -0
- data/views/course_fail.erb +11 -0
- data/views/course_frames_frame.erb +15 -0
- data/views/course_frames_iframe.erb +15 -0
- data/views/course_frames_start.erb +15 -0
- data/views/course_javascript_start.erb +19 -0
- data/views/course_loop_next.erb +13 -0
- data/views/course_loop_start.erb +19 -0
- data/views/course_pass.erb +9 -0
- data/views/course_redirects_start.erb +17 -0
- data/views/course_relative_start.erb +27 -0
- data/views/course_remote_next.erb +9 -0
- data/views/course_remote_start.erb +31 -0
- data/views/course_start.erb +22 -0
- data/views/layout.erb +24 -0
- data/views/specs.erb +48 -0
- data/views/welcome.erb +38 -0
- metadata +161 -0
- metadata.gz.sig +0 -0
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require 'hoe/signing'
|
6
|
+
require './tasks/yard.rb'
|
7
|
+
|
8
|
+
Hoe.spec('wsoc') do
|
9
|
+
self.developer('Postmodern', 'postmodern.mod3@gmail.com')
|
10
|
+
|
11
|
+
self.readme_file = 'README.rdoc'
|
12
|
+
self.history_file = 'History.rdoc'
|
13
|
+
self.remote_rdoc_dir = '/'
|
14
|
+
|
15
|
+
self.extra_deps = [
|
16
|
+
['json', '>=1.2.0'],
|
17
|
+
['sinatra', '>=0.9.4']
|
18
|
+
]
|
19
|
+
|
20
|
+
self.extra_dev_deps = [
|
21
|
+
['yard', '>=0.5.2']
|
22
|
+
]
|
23
|
+
|
24
|
+
self.spec_extras = {:has_rdoc => 'yard'}
|
25
|
+
end
|
26
|
+
|
27
|
+
# vim: syntax=ruby
|
data/bin/wsoc_server
ADDED
data/config.ru
ADDED
data/lib/wsoc.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# WSOC - The Web Spider Obstacle Course
|
3
|
+
#
|
4
|
+
# Copyright (c) 2009-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'wsoc/version'
|
data/lib/wsoc/app.rb
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
#
|
2
|
+
# WSOC - The Web Spider Obstacle Course
|
3
|
+
#
|
4
|
+
# Copyright (c) 2009-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'wsoc/course'
|
22
|
+
require 'wsoc/course_specs'
|
23
|
+
require 'wsoc/helpers'
|
24
|
+
require 'wsoc/version'
|
25
|
+
|
26
|
+
require 'rubygems'
|
27
|
+
require 'sinatra'
|
28
|
+
require 'nokogiri'
|
29
|
+
|
30
|
+
module WSOC
|
31
|
+
class App < Sinatra::Base
|
32
|
+
|
33
|
+
include Course
|
34
|
+
|
35
|
+
get '/' do
|
36
|
+
show :welcome
|
37
|
+
end
|
38
|
+
|
39
|
+
get '/specs' do
|
40
|
+
@specs = specs
|
41
|
+
|
42
|
+
show :specs
|
43
|
+
end
|
44
|
+
|
45
|
+
get Config::SPECS_PATHS[:json] do
|
46
|
+
json specs
|
47
|
+
end
|
48
|
+
|
49
|
+
get Config::SPECS_PATHS[:yaml] do
|
50
|
+
yaml specs
|
51
|
+
end
|
52
|
+
|
53
|
+
course_template '/course/start.html'
|
54
|
+
|
55
|
+
get '/course/fail' do
|
56
|
+
status 404
|
57
|
+
show :course_fail
|
58
|
+
end
|
59
|
+
|
60
|
+
course_template '/course/relative/start.html'
|
61
|
+
course_pass '/course/relative/same_directory.html'
|
62
|
+
course_pass '/course/relative/current_directory.html'
|
63
|
+
course_pass '/course/relative/normal.html'
|
64
|
+
|
65
|
+
course_template '/course/absolute/start.html'
|
66
|
+
course_pass '/course/absolute/next.html'
|
67
|
+
|
68
|
+
course_template '/course/empty/start.html'
|
69
|
+
|
70
|
+
course_template '/course/frames/start.html'
|
71
|
+
course_template '/course/frames/frame.html'
|
72
|
+
course_template '/course/frames/iframe.html'
|
73
|
+
course_pass '/course/frames/frame_contents.html'
|
74
|
+
course_pass '/course/frames/iframe_contents.html'
|
75
|
+
|
76
|
+
course_template '/course/javascript/start.html'
|
77
|
+
|
78
|
+
course_template '/course/loop/start.html'
|
79
|
+
course_template '/course/loop/next.html'
|
80
|
+
|
81
|
+
course_template '/course/remote/start.html'
|
82
|
+
course_pass '/course/remote/next.html'
|
83
|
+
|
84
|
+
course_template '/course/redirects/start.html'
|
85
|
+
|
86
|
+
get '/course/redirects/300.html' do
|
87
|
+
redirect remote_url('/course/redirects/300/pass.html')
|
88
|
+
end
|
89
|
+
|
90
|
+
course_pass '/course/redirects/300/pass.html'
|
91
|
+
|
92
|
+
get '/course/redirects/301.html' do
|
93
|
+
redirect remote_url('/course/redirects/301/pass.html')
|
94
|
+
end
|
95
|
+
|
96
|
+
course_pass '/course/redirects/301/pass.html'
|
97
|
+
|
98
|
+
get '/course/redirects/302.html' do
|
99
|
+
redirect remote_url('/course/redirects/302/pass.html')
|
100
|
+
end
|
101
|
+
|
102
|
+
course_pass '/course/redirects/302/pass.html'
|
103
|
+
|
104
|
+
get '/course/redirects/303.html' do
|
105
|
+
redirect remote_url('/course/redirects/303/pass.html')
|
106
|
+
end
|
107
|
+
|
108
|
+
course_pass '/course/redirects/303/pass.html'
|
109
|
+
|
110
|
+
get '/course/redirects/307.html' do
|
111
|
+
redirect remote_url('/course/redirects/307/pass.html')
|
112
|
+
end
|
113
|
+
|
114
|
+
course_pass '/course/redirects/307/pass.html'
|
115
|
+
|
116
|
+
get '/course/cookies/start.html' do
|
117
|
+
response.set_cookie 'auth_level', '1'
|
118
|
+
|
119
|
+
course_page :course_cookies_start
|
120
|
+
end
|
121
|
+
|
122
|
+
get '/course/cookies/get.html' do
|
123
|
+
@authed = (request.cookies['auth_level'] == '1')
|
124
|
+
|
125
|
+
course_page :course_cookies_get
|
126
|
+
end
|
127
|
+
|
128
|
+
get '/course/cookies/post.html' do
|
129
|
+
response.set_cookie 'auth_level', '2'
|
130
|
+
|
131
|
+
course_page :course_cookies_post
|
132
|
+
end
|
133
|
+
|
134
|
+
post '/course/cookies/post.html' do
|
135
|
+
@authed = (request.cookies['auth_level'] == '2')
|
136
|
+
|
137
|
+
course_page :course_cookies_post
|
138
|
+
end
|
139
|
+
|
140
|
+
course_pass '/course/cookies/protected/1.html'
|
141
|
+
|
142
|
+
get '/*' do
|
143
|
+
redirect remote_url('/course/fail')
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
end
|
data/lib/wsoc/config.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# WSOC - The Web Spider Obstacle Course
|
3
|
+
#
|
4
|
+
# Copyright (c) 2009-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'wsoc/version'
|
22
|
+
|
23
|
+
module WSOC
|
24
|
+
module Config
|
25
|
+
# Default host to run the WSOC server on
|
26
|
+
DEFAULT_HOST = 'localhost'
|
27
|
+
|
28
|
+
# Default port to run the WSOC server on
|
29
|
+
DEFAULT_PORT = 8080
|
30
|
+
|
31
|
+
# Paths to the specs files
|
32
|
+
SPECS_PATHS = {
|
33
|
+
:json => '/specs.json',
|
34
|
+
:yaml => '/specs.yaml'
|
35
|
+
}
|
36
|
+
|
37
|
+
# Course directory
|
38
|
+
COURSE_DIR = '/course'
|
39
|
+
|
40
|
+
# Path to the start of the course
|
41
|
+
COURSE_START_PATH = "#{COURSE_DIR}/start.html"
|
42
|
+
|
43
|
+
# Path to the course failure page
|
44
|
+
COURSE_FAIL_PATH = "#{COURSE_DIR}/fail"
|
45
|
+
end
|
46
|
+
end
|
data/lib/wsoc/course.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
#
|
2
|
+
# WSOC - The Web Spider Obstacle Course
|
3
|
+
#
|
4
|
+
# Copyright (c) 2009-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'wsoc/config'
|
22
|
+
|
23
|
+
module WSOC
|
24
|
+
module Course
|
25
|
+
def self.included(base)
|
26
|
+
base.module_eval do
|
27
|
+
set :host, Config::DEFAULT_HOST
|
28
|
+
set :port, Config::DEFAULT_PORT
|
29
|
+
|
30
|
+
set :root, File.expand_path(File.join(File.dirname(__FILE__),'..','..'))
|
31
|
+
set :course, File.join(self.public,'course')
|
32
|
+
enable :static, :sessions
|
33
|
+
|
34
|
+
helpers WSOC::Helpers
|
35
|
+
|
36
|
+
#
|
37
|
+
# Adds a path to the Obstacle Course, where a course template
|
38
|
+
# will be rendered.
|
39
|
+
#
|
40
|
+
# @param [String] path
|
41
|
+
# The path to add to the obstacle course.
|
42
|
+
#
|
43
|
+
# @since 0.1.0
|
44
|
+
#
|
45
|
+
def self.course_template(path)
|
46
|
+
name = path[1..-1].gsub(/\.\S*$/,'').gsub(/\/+/,'_').to_sym
|
47
|
+
|
48
|
+
get(path) do
|
49
|
+
erb name, :layout => false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# Adds a path to the Obstacle Course.
|
55
|
+
#
|
56
|
+
# @param [String] path
|
57
|
+
# The path to add to the obstacle course.
|
58
|
+
#
|
59
|
+
# @since 0.1.0
|
60
|
+
#
|
61
|
+
def self.course_pass(path)
|
62
|
+
get(path) do
|
63
|
+
erb :course_pass, :layout => false
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
#
|
2
|
+
# WSOC - The Web Spider Obstacle Course
|
3
|
+
#
|
4
|
+
# Copyright (c) 2009-2010 Hal Brodigan (postmodern.mod3 at gmail.com)
|
5
|
+
#
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program; if not, write to the Free Software
|
18
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'wsoc/specs'
|
22
|
+
|
23
|
+
module WSOC
|
24
|
+
module CourseSpecs
|
25
|
+
include Specs
|
26
|
+
|
27
|
+
should_ignore '/course/fail',
|
28
|
+
'should not visit links not part of the obstacle course'
|
29
|
+
|
30
|
+
# Absolute Links
|
31
|
+
should_visit '/course/absolute/start.html',
|
32
|
+
'should visit the absolute links start page'
|
33
|
+
should_visit '/course/absolute/next.html',
|
34
|
+
'should visit absolute links to unvisited pages'
|
35
|
+
|
36
|
+
# Empty Links
|
37
|
+
should_visit '/course/empty/start.html',
|
38
|
+
'should visit the empty links start page'
|
39
|
+
should_ignore '/course/empty/start.html%20',
|
40
|
+
'should ignore links with blank href attributes'
|
41
|
+
|
42
|
+
# Frames
|
43
|
+
should_visit '/course/frames/start.html',
|
44
|
+
'should visit the empty links start page'
|
45
|
+
should_visit '/course/frames/iframe.html',
|
46
|
+
'should visit the contents of iframes'
|
47
|
+
should_visit '/course/frames/iframe_contents.html',
|
48
|
+
'should visit links within iframes'
|
49
|
+
should_visit '/course/frames/frame.html',
|
50
|
+
'should visit the contents of frames'
|
51
|
+
should_visit '/course/frames/frame_contents.html',
|
52
|
+
'should visit links within frames'
|
53
|
+
|
54
|
+
# Javascript Links
|
55
|
+
should_visit '/course/javascript/start.html',
|
56
|
+
'should visit the javascript links start page'
|
57
|
+
should_ignore '/course/javascript/start.html#',
|
58
|
+
'should ignore target links'
|
59
|
+
should_ignore 'javascript:fail();',
|
60
|
+
'should ignore javascript: links'
|
61
|
+
|
62
|
+
# Looping Links
|
63
|
+
should_visit '/course/loop/start.html',
|
64
|
+
'should visit the looping links start page'
|
65
|
+
should_visit '/course/loop/next.html',
|
66
|
+
'should visit non-circular linking pages'
|
67
|
+
|
68
|
+
# Relative Links
|
69
|
+
should_visit '/course/relative/start.html',
|
70
|
+
'should visit the relative links start page'
|
71
|
+
should_ignore '/course/relative/start.html#',
|
72
|
+
'should ignore in-page anchor links'
|
73
|
+
should_visit '/course/relative/normal.html',
|
74
|
+
'should visit normal relative links'
|
75
|
+
should_visit '/course/relative/current_directory.html',
|
76
|
+
'should visit links relative to the current directory'
|
77
|
+
should_visit '/course/relative/same_directory.html',
|
78
|
+
'should visit relative links that traverse directories'
|
79
|
+
|
80
|
+
# Remote Links
|
81
|
+
should_visit '/course/remote/start.html',
|
82
|
+
'should visit the remote links start page'
|
83
|
+
should_ignore '/course/loop/../remote/start.html',
|
84
|
+
'should resolve the paths of remote links'
|
85
|
+
should_visit '/course/remote/next.html',
|
86
|
+
'should visit normal remote links'
|
87
|
+
should_fail 'http://spidr.rubyforge.org:1337/course/remote/fail.html',
|
88
|
+
'should safely fail on closed ports'
|
89
|
+
should_fail 'http://not.found/course/remote/fail.html',
|
90
|
+
'should safely fail on bad host-names'
|
91
|
+
|
92
|
+
# Cookies
|
93
|
+
should_visit '/course/cookies/start.html',
|
94
|
+
'should visit the cookies start page'
|
95
|
+
should_visit '/course/cookies/get.html',
|
96
|
+
'should visit the cookies GET request test page'
|
97
|
+
should_visit '/course/cookies/protected/1.html',
|
98
|
+
'should visit the first cookie protected page'
|
99
|
+
|
100
|
+
# HTTP Redirects
|
101
|
+
should_visit '/course/redirects/start.html',
|
102
|
+
'should visit the HTTP redirects start page'
|
103
|
+
should_visit '/course/redirects/300.html',
|
104
|
+
'should visit the 300 HTTP redirect test page'
|
105
|
+
should_visit '/course/redirects/300/pass.html',
|
106
|
+
'should follow HTTP 300 redirects'
|
107
|
+
should_visit '/course/redirects/301.html',
|
108
|
+
'should visit the 301 HTTP redirect test page'
|
109
|
+
should_visit '/course/redirects/301/pass.html',
|
110
|
+
'should follow HTTP 301 redirects'
|
111
|
+
should_visit '/course/redirects/302.html',
|
112
|
+
'should visit the 302 HTTP redirect test page'
|
113
|
+
should_visit '/course/redirects/302/pass.html',
|
114
|
+
'should follow HTTP 302 redirects'
|
115
|
+
should_visit '/course/redirects/303.html',
|
116
|
+
'should visit the 303 HTTP redirect test page'
|
117
|
+
should_visit '/course/redirects/303/pass.html',
|
118
|
+
'should follow HTTP 303 redirects'
|
119
|
+
should_visit '/course/redirects/307.html',
|
120
|
+
'should visit the 307 HTTP redirect test page'
|
121
|
+
should_visit '/course/redirects/307/pass.html',
|
122
|
+
'should follow HTTP 307 redirects'
|
123
|
+
end
|
124
|
+
end
|