woyo-server 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/lib/woyo/runner.rb +12 -4
- data/lib/woyo/server/server.rb +23 -10
- data/lib/woyo/server/version.rb +1 -1
- data/public/server/css/server.css +10 -0
- data/public/server/default.html +4 -4
- data/public/server/js/server.js +23 -0
- data/spec/spec_helper.rb +3 -2
- data/spec/woyo/server/1_server_spec.rb +252 -81
- data/spec/woyo/server/runner_spec.rb +9 -4
- data/tmux +1 -2
- data/todo.txt +11 -0
- data/views/server/layout.haml +15 -7
- data/views/server/location.haml +4 -11
- data/views/server/way.haml +7 -0
- data/views/server/world.haml +15 -0
- data/woyo-server.gemspec +2 -0
- metadata +37 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87c8e693d26deb5a3998f39f7c2e6d3e69df026a
|
4
|
+
data.tar.gz: 4198785cc371867a214a09b4e87d8ae72c2dbfe0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a7e1b47a7bed1ff4a43b06d2eef01c55f240e4f433d50f9eacfbca4b5c88427357e3e4d48f94b3dda0ffa900c12126dddcaa8377dfa862f17abbeff43ceebe6
|
7
|
+
data.tar.gz: 05d70ebabd602d740197446c06534c3b728be0e629757a342ec1f65013348fb0b877cedf8cc1a369ad5e69878129f73674bf5d43cb2322e259dd0eab121547a7
|
data/.gitignore
CHANGED
data/lib/woyo/runner.rb
CHANGED
@@ -58,8 +58,8 @@ class Runner
|
|
58
58
|
[ 'public', 'views', 'world' ].each do |subdir|
|
59
59
|
FileUtils.cp_r File.join( __dir__, '../../', subdir ), dir, preserve: true
|
60
60
|
end
|
61
|
-
FileUtils.ln_s 'foundation-5.2.2', File.join(dir,'public/server/foundation')
|
62
|
-
FileUtils.ln_s 'jquery-2.1.1', File.join(dir,'public/server/jquery')
|
61
|
+
# FileUtils.ln_s 'foundation-5.2.2', File.join(dir,'public/server/foundation')
|
62
|
+
# FileUtils.ln_s 'jquery-2.1.1', File.join(dir,'public/server/jquery')
|
63
63
|
return 0
|
64
64
|
end
|
65
65
|
|
@@ -77,8 +77,8 @@ class Runner
|
|
77
77
|
[ 'public', 'views', 'world' ].each do |subdir|
|
78
78
|
FileUtils.cp_r File.join( __dir__, '../../', subdir ), '.', preserve: true
|
79
79
|
end
|
80
|
-
FileUtils.ln_s 'foundation-5.2.2', 'public/server/foundation' unless File.exists? 'public/server/foundation'
|
81
|
-
FileUtils.ln_s 'jquery-2.1.1', 'public/server/jquery' unless File.exists? 'public/server/jquery'
|
80
|
+
# FileUtils.ln_s 'foundation-5.2.2', 'public/server/foundation' unless File.exists? 'public/server/foundation'
|
81
|
+
# FileUtils.ln_s 'jquery-2.1.1', 'public/server/jquery' unless File.exists? 'public/server/jquery'
|
82
82
|
return 0
|
83
83
|
end
|
84
84
|
|
@@ -91,7 +91,15 @@ class Runner
|
|
91
91
|
print_error 'This is not a Woyo::Server directory'
|
92
92
|
return -4
|
93
93
|
end
|
94
|
+
# if @args.include?('-d') || @args.include?('--dev')
|
95
|
+
# FileUtils.ln_s 'foundation-5.2.2', 'public/server/foundation'
|
96
|
+
# FileUtils.ln_s 'jquery-2.1.1', 'public/server/jquery'
|
97
|
+
# end
|
94
98
|
Woyo::Server.run!
|
99
|
+
# if @args.include?('-d') || @args.include?('--dev')
|
100
|
+
# FileUtils.rm 'public/server/foundation'
|
101
|
+
# FileUtils.rm 'public/server/jquery'
|
102
|
+
# end
|
95
103
|
return 0
|
96
104
|
end
|
97
105
|
|
data/lib/woyo/server/server.rb
CHANGED
@@ -1,19 +1,26 @@
|
|
1
1
|
require 'sinatra/base'
|
2
|
+
require 'sinatra/partial'
|
2
3
|
require 'haml'
|
4
|
+
require 'json'
|
3
5
|
require 'woyo/world'
|
4
6
|
|
5
7
|
module Woyo
|
6
8
|
|
7
9
|
class Server < Sinatra::Application
|
8
10
|
|
9
|
-
def self.load_world
|
11
|
+
def self.load_world glob = 'world/*.rb'
|
10
12
|
world = Woyo::World.new
|
11
|
-
Dir[
|
12
|
-
|
13
|
+
Dir[glob].each do |filename|
|
14
|
+
eval_world File.read( filename ), filename, world
|
13
15
|
end
|
14
16
|
world
|
15
17
|
end
|
16
18
|
|
19
|
+
def self.eval_world text, filename, world = nil
|
20
|
+
world ||= Woyo::World.new
|
21
|
+
world.instance_eval text, filename
|
22
|
+
end
|
23
|
+
|
17
24
|
configure do
|
18
25
|
enable :sessions
|
19
26
|
set root: '.'
|
@@ -27,18 +34,24 @@ class Server < Sinatra::Application
|
|
27
34
|
end
|
28
35
|
|
29
36
|
get '/' do
|
30
|
-
redirect to 'default.html' if world.
|
31
|
-
@
|
32
|
-
session[:
|
33
|
-
haml :
|
37
|
+
redirect to 'default.html' if world.name.nil? && world.description.nil? && world.start.nil?
|
38
|
+
@world = world
|
39
|
+
session[:location_id] = world.start
|
40
|
+
haml :world
|
34
41
|
end
|
35
42
|
|
36
|
-
get '/
|
37
|
-
@location = session[:
|
38
|
-
session[:location] = @location
|
43
|
+
get '/location' do
|
44
|
+
@location = world.locations[session[:location_id]]
|
39
45
|
haml :location
|
40
46
|
end
|
41
47
|
|
48
|
+
get '/go/*' do |way_id|
|
49
|
+
way = world.locations[session[:location_id]].ways[way_id.to_sym]
|
50
|
+
session[:location_id] = way.to.id if way.open?
|
51
|
+
content_type :json
|
52
|
+
way.go.to_json
|
53
|
+
end
|
54
|
+
|
42
55
|
get '/do/*/*?/*?' do |item,action,tool|
|
43
56
|
# do default or optional action on required item with optional tool
|
44
57
|
end
|
data/lib/woyo/server/version.rb
CHANGED
data/public/server/default.html
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
<meta charset="utf-8" />
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6
6
|
<title>WOYO - World Of Your Own</title>
|
7
|
-
<link rel="stylesheet" href="foundation/css/foundation.css" />
|
8
|
-
<script src="foundation/js/vendor/modernizr.js"></script>
|
7
|
+
<link rel="stylesheet" href="foundation-5.2.2/css/foundation.css" />
|
8
|
+
<script src="foundation-5.2.2/js/vendor/modernizr.js"></script>
|
9
9
|
</head>
|
10
10
|
<body>
|
11
11
|
|
@@ -32,8 +32,8 @@
|
|
32
32
|
</div>
|
33
33
|
</div>
|
34
34
|
|
35
|
-
<script src="foundation/js/vendor/jquery.js"></script>
|
36
|
-
<script src="foundation/js/foundation.min.js"></script>
|
35
|
+
<script src="foundation-5.2.2/js/vendor/jquery.js"></script>
|
36
|
+
<script src="foundation-5.2.2/js/foundation.min.js"></script>
|
37
37
|
<script>
|
38
38
|
$(document).foundation();
|
39
39
|
</script>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
$(document).foundation();
|
3
|
+
|
4
|
+
$(document).ready( function() {
|
5
|
+
$("body").fadeIn('slow');
|
6
|
+
$(".way .go").click( function() {
|
7
|
+
$go_link = $(this);
|
8
|
+
go_url = $go_link.attr("href");
|
9
|
+
$.get( go_url, function(json) {
|
10
|
+
if ( json.go == true ) {
|
11
|
+
$go_link.siblings(".going").text(json.going).fadeIn('slow', function() {
|
12
|
+
$("body").fadeOut('slow', function() {
|
13
|
+
window.location.reload(true);
|
14
|
+
});
|
15
|
+
});
|
16
|
+
} else {
|
17
|
+
$go_link.siblings(".going").text(json.going).fadeIn('slow');
|
18
|
+
};
|
19
|
+
});
|
20
|
+
return false;
|
21
|
+
});
|
22
|
+
});
|
23
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'rack/test'
|
2
|
+
ENV['RACK_ENV'] = 'test'
|
3
|
+
|
2
4
|
require 'capybara/rspec'
|
3
5
|
Capybara.app = Woyo::Server
|
4
6
|
Capybara.ignore_hidden_elements = false
|
5
|
-
|
6
|
-
ENV['RACK_ENV'] = 'test'
|
7
|
+
#Capybara.default_driver = :selenium #:rack_test
|
7
8
|
|
8
9
|
module RSpecMixin
|
9
10
|
include Rack::Test::Methods
|
@@ -1,10 +1,18 @@
|
|
1
1
|
require_relative '../../../lib/woyo/server'
|
2
2
|
require 'spec_helper.rb'
|
3
|
+
require 'fileutils'
|
3
4
|
|
4
|
-
describe Woyo::Server, :type => :feature
|
5
|
+
describe Woyo::Server, :type => :feature do
|
5
6
|
|
6
7
|
before :all do
|
8
|
+
# directories
|
9
|
+
@original_path = Dir.pwd
|
10
|
+
File.basename(@original_path).should eq 'woyo-server'
|
11
|
+
@test_dir = 'tmp/test'
|
12
|
+
# worlds
|
7
13
|
@small_world = Woyo::World.new do
|
14
|
+
name "Small World"
|
15
|
+
description "It's a small world after all"
|
8
16
|
location :small
|
9
17
|
end
|
10
18
|
@home_world = Woyo::World.new do
|
@@ -55,98 +63,261 @@ describe Woyo::Server, :type => :feature do
|
|
55
63
|
end
|
56
64
|
|
57
65
|
# these must be the first tests so that Woyo::Server.setting.world is not set
|
58
|
-
# that is why this file is
|
66
|
+
# that is why this file is named 1_server_spec.rb
|
59
67
|
|
60
|
-
|
61
|
-
visit '/'
|
62
|
-
status_code.should eq 200
|
63
|
-
page.should have_content 'Woyo'
|
64
|
-
end
|
68
|
+
context 'with no world' do
|
65
69
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
70
|
+
it 'welcome page is displayed if there is no world' do
|
71
|
+
visit '/'
|
72
|
+
status_code.should eq 200
|
73
|
+
page.should have_content 'Woyo'
|
74
|
+
end
|
72
75
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
it 'welcome page links to github docs' do
|
77
|
+
visit '/'
|
78
|
+
status_code.should eq 200
|
79
|
+
page.should have_link '', href: 'https://github.com/iqeo/woyo-world/wiki'
|
80
|
+
page.should have_link '', href: 'https://github.com/iqeo/woyo-server/wiki'
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'uses foundation framework' do
|
84
|
+
visit '/'
|
85
|
+
status_code.should eq 200
|
86
|
+
page.should have_css 'head link[href="foundation-5.2.2/css/foundation.css"]'
|
87
|
+
page.should have_css 'head script[src="foundation-5.2.2/js/vendor/modernizr.js"]'
|
88
|
+
end
|
79
89
|
|
80
|
-
it 'accepts a world (without start - display welcome)' do
|
81
|
-
Woyo::Server.set :world, @small_world
|
82
|
-
visit '/'
|
83
|
-
status_code.should eq 200
|
84
|
-
page.should have_content 'Woyo'
|
85
90
|
end
|
86
91
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
+
context 'loads the world' do
|
93
|
+
|
94
|
+
it 'from files in directory' do
|
95
|
+
content1 = "
|
96
|
+
name 'Simple'
|
97
|
+
start :one
|
98
|
+
location :one do
|
99
|
+
description 'First'
|
100
|
+
end
|
101
|
+
"
|
102
|
+
content2 = "
|
103
|
+
location :two do
|
104
|
+
description 'Second'
|
105
|
+
end
|
106
|
+
"
|
107
|
+
FileUtils.mkdir_p @test_dir
|
108
|
+
File.write File.join( @test_dir, 'file1.rb' ), content1
|
109
|
+
File.write File.join( @test_dir, 'file2.rb' ), content2
|
110
|
+
world = nil
|
111
|
+
expect { world = Woyo::Server.load_world File.join( @test_dir, '*.rb' ) }.to_not raise_error
|
112
|
+
Woyo::Server.set :world, world
|
113
|
+
visit '/'
|
114
|
+
status_code.should eq 200
|
115
|
+
page.should have_title /^Simple$/
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'shows filename and lineno in backtrace upon error' do
|
119
|
+
bad_world = "
|
120
|
+
location :bad do
|
121
|
+
raise 'boom'
|
122
|
+
end
|
123
|
+
"
|
124
|
+
expect { Woyo::Server.eval_world bad_world, 'bad_world' }.to raise_error { |e|
|
125
|
+
e.message.should eq 'boom'
|
126
|
+
e.backtrace.first.should =~ /^bad_world.3/
|
127
|
+
}
|
128
|
+
end
|
129
|
+
|
92
130
|
end
|
93
131
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
132
|
+
context 'describes the world' do
|
133
|
+
|
134
|
+
it 'title is world name' do
|
135
|
+
Woyo::Server.set :world, @small_world
|
136
|
+
visit '/'
|
137
|
+
status_code.should eq 200
|
138
|
+
page.should have_title /^Small World$/
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'without start location' do
|
142
|
+
Woyo::Server.set :world, @small_world
|
143
|
+
visit '/'
|
144
|
+
status_code.should eq 200
|
145
|
+
page.should have_selector '.world .name', text: "Small World"
|
146
|
+
page.should have_selector '.world .description', text: "It's a small world after all"
|
147
|
+
page.should have_selector '.world .no-start'
|
148
|
+
page.should_not have_selector '.world .start'
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'with start location' do
|
152
|
+
@small_world.start = :small
|
153
|
+
Woyo::Server.set :world, @small_world
|
154
|
+
visit '/'
|
155
|
+
status_code.should eq 200
|
156
|
+
page.should have_selector '.world .name', text: "Small World"
|
157
|
+
page.should have_selector '.world .description', text: "It's a small world after all"
|
158
|
+
page.should have_selector '.world .start a[href="/location"]', text: "Start"
|
159
|
+
page.should_not have_selector '.world .no-start'
|
160
|
+
end
|
161
|
+
|
114
162
|
end
|
115
163
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
164
|
+
context 'describes locations' do
|
165
|
+
|
166
|
+
it 'title is location name' do
|
167
|
+
Woyo::Server.set :world, @small_world
|
168
|
+
visit '/'
|
169
|
+
click_on 'start'
|
170
|
+
status_code.should eq 200
|
171
|
+
page.should have_title /^Small$/
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'start location' do
|
175
|
+
Woyo::Server.set :world, @home_world
|
176
|
+
visit '/'
|
177
|
+
click_on 'start'
|
178
|
+
status_code.should eq 200
|
179
|
+
page.should have_selector '.location#location_home'
|
180
|
+
page.should have_selector '.location#location_home .name', text: 'Home'
|
181
|
+
page.should have_selector '.location#location_home .description', text: 'Where the heart is.'
|
182
|
+
page.should have_selector '.way#way_out'
|
183
|
+
page.should have_selector '.way#way_out .name', text: 'Door'
|
184
|
+
page.should have_selector '.way#way_out .description', text: 'A sturdy wooden door'
|
185
|
+
page.should have_selector '.way#way_down'
|
186
|
+
page.should have_selector '.way#way_down .name', text: 'Stairs'
|
187
|
+
page.should have_selector '.way#way_down .description', text: 'Rickety stairs lead down'
|
188
|
+
end
|
189
|
+
|
126
190
|
end
|
127
191
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
192
|
+
context 'ways' do
|
193
|
+
|
194
|
+
before :all do
|
195
|
+
@ways_world = Woyo::World.new do
|
196
|
+
start :home
|
197
|
+
location :home do
|
198
|
+
way :door do
|
199
|
+
description open: 'A sturdy wooden door', closed: 'Never closed'
|
200
|
+
going open: 'The door opens, leading to a sunlit garden', closed: 'Never closed'
|
201
|
+
to :garden
|
202
|
+
end
|
203
|
+
way :stairs do
|
204
|
+
description closed: 'Broken stairs lead down into darkness.', open: 'Never open'
|
205
|
+
going closed: 'The broken stairs are impassable.', open: 'Never open'
|
206
|
+
end
|
207
|
+
way :window do
|
208
|
+
description 'A nice view.'
|
209
|
+
going 'Makes no difference.'
|
210
|
+
to :yard
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
Woyo::Server.set :world, @ways_world
|
215
|
+
end
|
216
|
+
|
217
|
+
context 'are described' do
|
218
|
+
|
219
|
+
before :each do
|
220
|
+
visit '/'
|
221
|
+
click_on 'start'
|
222
|
+
status_code.should eq 200
|
223
|
+
end
|
224
|
+
|
225
|
+
it 'open' do
|
226
|
+
page.should have_selector '.way#way_door a#go_door'
|
227
|
+
page.should have_selector '.way#way_door .name', text: 'Door'
|
228
|
+
page.should have_selector '.way#way_door .description', text: 'A sturdy wooden door'
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'closed' do
|
232
|
+
page.should have_selector '.way#way_stairs a#go_stairs'
|
233
|
+
page.should have_selector '.way#way_stairs .name', text: 'Stairs'
|
234
|
+
page.should have_selector '.way#way_stairs .description', text: 'Broken stairs lead down into darkness.'
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
238
|
+
|
239
|
+
context 'are described with default' do
|
240
|
+
|
241
|
+
it 'open' do
|
242
|
+
window = @ways_world.locations[:home].ways[:window]
|
243
|
+
window.open!
|
244
|
+
window.should be_open
|
245
|
+
visit '/'
|
246
|
+
click_on 'start'
|
247
|
+
status_code.should eq 200
|
248
|
+
page.should have_selector '.way#way_window a#go_window'
|
249
|
+
page.should have_selector '.way#way_window .name', text: 'Window'
|
250
|
+
page.should have_selector '.way#way_window .description', text: 'A nice view.'
|
251
|
+
end
|
252
|
+
|
253
|
+
it 'closed' do
|
254
|
+
window = @ways_world.locations[:home].ways[:window]
|
255
|
+
window.close!
|
256
|
+
window.should be_closed
|
257
|
+
visit '/'
|
258
|
+
click_on 'start'
|
259
|
+
status_code.should eq 200
|
260
|
+
page.should have_selector '.way#way_window a#go_window'
|
261
|
+
page.should have_selector '.way#way_window .name', text: 'Window'
|
262
|
+
page.should have_selector '.way#way_window .description', text: 'A nice view.'
|
263
|
+
end
|
264
|
+
|
265
|
+
end
|
266
|
+
|
267
|
+
context 'are described going', :js => true do
|
268
|
+
|
269
|
+
before :each do
|
270
|
+
visit '/'
|
271
|
+
page.find('body', visible: true)
|
272
|
+
click_on 'start'
|
273
|
+
end
|
274
|
+
|
275
|
+
it 'open' do
|
276
|
+
page.should have_selector '.way#way_door a#go_door'
|
277
|
+
click_link 'go_door'
|
278
|
+
page.should have_selector '.way#way_door .going', text: 'The door opens, leading to a sunlit garden'
|
279
|
+
sleep 3
|
280
|
+
page.should have_selector '.location#location_garden .name', text: 'Garden'
|
281
|
+
end
|
282
|
+
|
283
|
+
it 'closed' do
|
284
|
+
page.should have_selector '.way#way_stairs a#go_stairs'
|
285
|
+
click_link 'go_stairs'
|
286
|
+
page.should have_selector '.way#way_stairs .going', text: 'The broken stairs are impassable.'
|
287
|
+
page.should have_selector '.location#location_home .name', text: 'Home'
|
288
|
+
end
|
289
|
+
|
290
|
+
end
|
291
|
+
|
292
|
+
context 'are described going with default', :js => true do
|
293
|
+
|
294
|
+
it 'open' do
|
295
|
+
window = @ways_world.locations[:home].ways[:window]
|
296
|
+
window.open!
|
297
|
+
window.should be_open
|
298
|
+
visit '/'
|
299
|
+
click_on 'start'
|
300
|
+
page.should have_selector '.way#way_window a#go_window'
|
301
|
+
click_link 'go_window'
|
302
|
+
page.should have_selector '.way#way_window .going', text: 'Makes no difference.'
|
303
|
+
sleep 3
|
304
|
+
page.should have_selector '.location#location_yard .name', text: 'Yard'
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'closed' do
|
308
|
+
window = @ways_world.locations[:home].ways[:window]
|
309
|
+
window.close!
|
310
|
+
window.should be_closed
|
311
|
+
visit '/'
|
312
|
+
click_on 'start'
|
313
|
+
page.should have_selector '.way#way_window a#go_window'
|
314
|
+
click_link 'go_window'
|
315
|
+
page.should have_selector '.way#way_window .going', text: 'Makes no difference.'
|
316
|
+
page.should have_selector '.location#location_home .name', text: 'Home'
|
317
|
+
end
|
318
|
+
|
319
|
+
end
|
320
|
+
|
150
321
|
end
|
151
322
|
|
152
323
|
end
|
@@ -3,7 +3,7 @@ require 'fileutils'
|
|
3
3
|
require 'stringio'
|
4
4
|
require 'open-uri'
|
5
5
|
|
6
|
-
|
6
|
+
STDOUT.sync = true
|
7
7
|
STDERR.sync = true
|
8
8
|
|
9
9
|
describe Woyo::Runner do
|
@@ -20,10 +20,10 @@ describe Woyo::Runner do
|
|
20
20
|
'world' => %w( . .. .gitkeep ),
|
21
21
|
'views' => %w( . .. app server ),
|
22
22
|
'views/app' => %w( . .. .gitkeep ),
|
23
|
-
'views/server' => %w( . .. layout.haml location.haml ),
|
23
|
+
'views/server' => %w( . .. layout.haml location.haml way.haml world.haml ),
|
24
24
|
'public' => %w( . .. app server ),
|
25
25
|
'public/app' => %w( . .. html images js css ),
|
26
|
-
'public/server' => %w( . .. default.html foundation
|
26
|
+
'public/server' => %w( . .. css default.html foundation-5.2.2 jquery-2.1.1 js ),
|
27
27
|
}
|
28
28
|
@original_path = Dir.pwd
|
29
29
|
File.basename(@original_path).should eq 'woyo-server'
|
@@ -31,6 +31,7 @@ describe Woyo::Runner do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'prints a helpful message to stderr for help (-h/--help) switch' do
|
34
|
+
pending
|
34
35
|
[['-h'],['--help']].each do |args|
|
35
36
|
Woyo::Runner.run( args, out: @output, err: @error ).should eq 0
|
36
37
|
@error.string.should include 'woyo'
|
@@ -108,6 +109,7 @@ describe Woyo::Runner do
|
|
108
109
|
end
|
109
110
|
|
110
111
|
it 'help (-h/--help) explains new command' do
|
112
|
+
pending
|
111
113
|
[['-h'],['--help']].each do |help|
|
112
114
|
Woyo::Runner.run( ['new'] + help, out: @output, err: @error ).should eq 0
|
113
115
|
@error.string.should include 'woyo new'
|
@@ -153,12 +155,13 @@ describe Woyo::Runner do
|
|
153
155
|
Woyo::Server.set :world, Woyo::World.new { start :home ; location(:home) { name 'Home' } }
|
154
156
|
page = ''
|
155
157
|
expect { page = open("http://127.0.0.1:4567/").read }.to_not raise_error
|
156
|
-
page.should include '
|
158
|
+
page.should include 'Start'
|
157
159
|
Woyo::Server.stop!
|
158
160
|
thread.join
|
159
161
|
end
|
160
162
|
|
161
163
|
it 'help (-h/--help) explains server command' do
|
164
|
+
pending
|
162
165
|
[['-h'],['--help']].each do |help|
|
163
166
|
Woyo::Runner.run( ['server'] + help, out: @output, err: @error ).should eq 0
|
164
167
|
@error.string.should include 'woyo server'
|
@@ -193,6 +196,7 @@ describe Woyo::Runner do
|
|
193
196
|
# it 'starts a world application console'
|
194
197
|
|
195
198
|
# it 'help (-h/--help) explains console command' do
|
199
|
+
# pending
|
196
200
|
# [['-h'],['--help']].each do |help|
|
197
201
|
# Woyo::Runner.run( ['console'] + help, out: @output, err: @error ).should eq 0
|
198
202
|
# @error.string.should include 'woyo console'
|
@@ -275,6 +279,7 @@ describe Woyo::Runner do
|
|
275
279
|
end
|
276
280
|
|
277
281
|
it 'help (-h/--help) explains update command' do
|
282
|
+
pending
|
278
283
|
[['-h'],['--help']].each do |help|
|
279
284
|
Woyo::Runner.run( ['update'] + help, out: @output, err: @error ).should eq 0
|
280
285
|
@error.string.should include 'woyo update'
|
data/tmux
CHANGED
data/todo.txt
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
|
2
|
+
Debugger
|
3
|
+
Use haml tenplate for default page including layout.haml
|
4
|
+
Test location description states
|
5
|
+
Document DSL attributes and groups usage
|
6
|
+
-> way descriptions
|
7
|
+
-> way going
|
8
|
+
-> location descriptions
|
9
|
+
Auto generate DSL docs from tests ?
|
10
|
+
Test worlds in separate files - useful for manual testing
|
11
|
+
|
data/views/server/layout.haml
CHANGED
@@ -3,15 +3,23 @@
|
|
3
3
|
%head
|
4
4
|
%meta{ :charset => "utf-8" }
|
5
5
|
%meta{ :name => "viewport", :content => "width=device-width, initial-scale=1.0" }
|
6
|
-
%link{ :rel => "stylesheet", :href => "/foundation/css/foundation.css" }
|
7
|
-
%
|
8
|
-
%
|
6
|
+
%link{ :rel => "stylesheet", :href => "/foundation-5.2.2/css/foundation.css" }
|
7
|
+
%link{ :rel => "stylesheet", :href => "/css/server.css" }
|
8
|
+
%script{ :src => "/foundation-5.2.2/js/vendor/modernizr.js" }
|
9
|
+
|
10
|
+
%title<
|
11
|
+
- case
|
12
|
+
- when @world
|
13
|
+
= @world.name
|
14
|
+
- when @location
|
15
|
+
= @location.name
|
9
16
|
|
10
17
|
%body
|
11
18
|
|
12
19
|
= yield
|
13
20
|
|
14
|
-
%script{ :src => "/foundation/js/vendor/jquery.js" }
|
15
|
-
%script{ :src => "/foundation/js/foundation.min.js" }
|
16
|
-
%script
|
17
|
-
|
21
|
+
%script{ :src => "/foundation-5.2.2/js/vendor/jquery.js" }
|
22
|
+
%script{ :src => "/foundation-5.2.2/js/foundation.min.js" }
|
23
|
+
%script{ :src => "/js/server.js" }
|
24
|
+
|
25
|
+
|
data/views/server/location.haml
CHANGED
@@ -1,14 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
.row
|
2
|
+
.large-12.columns
|
3
|
+
.location{ :id => "location_#{@location.id}" }
|
4
4
|
%h1.name= @location.name
|
5
5
|
%p.description= @location.description
|
6
|
-
|
7
|
-
- @location.ways.each do |id,way|
|
8
|
-
%div.row
|
9
|
-
%div.large-12.columns
|
10
|
-
%div.way{ :id => "way_#{id}" }
|
11
|
-
%a{ :id => "go_#{id}", :href => "/go/#{id}" }
|
12
|
-
%h3.name= way.name
|
13
|
-
%p.description= way.description
|
6
|
+
= partial :way, collection: @location.ways.values
|
14
7
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
.row
|
2
|
+
.large-12.columns
|
3
|
+
.world
|
4
|
+
%h1.name= @world.name
|
5
|
+
%p.description= @world.description
|
6
|
+
|
7
|
+
.row
|
8
|
+
.large-12.columns
|
9
|
+
- if @world.start
|
10
|
+
.start
|
11
|
+
%a#start{ :href => "/location" } Start
|
12
|
+
- else
|
13
|
+
.no-start
|
14
|
+
%p No start location defined
|
15
|
+
|
data/woyo-server.gemspec
CHANGED
@@ -23,10 +23,12 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "rack-test", "~> 0.6.2"
|
24
24
|
spec.add_development_dependency "rspec"
|
25
25
|
spec.add_development_dependency "capybara"
|
26
|
+
spec.add_development_dependency "selenium-webdriver"
|
26
27
|
|
27
28
|
spec.add_runtime_dependency "woyo-world", Woyo::SERVER_VERSION
|
28
29
|
spec.add_runtime_dependency "sinatra", "~> 1.4.5"
|
29
30
|
spec.add_runtime_dependency "sinatra-contrib", "~> 1.4.2"
|
31
|
+
spec.add_runtime_dependency "sinatra-partial"
|
30
32
|
spec.add_runtime_dependency "haml"
|
31
33
|
|
32
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: woyo-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerard Fowley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,20 +80,34 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: selenium-webdriver
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: woyo-world
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - '='
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.0.
|
103
|
+
version: 0.0.6
|
90
104
|
type: :runtime
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - '='
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.0.
|
110
|
+
version: 0.0.6
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: sinatra
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +136,20 @@ dependencies:
|
|
122
136
|
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: 1.4.2
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: sinatra-partial
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
125
153
|
- !ruby/object:Gem::Dependency
|
126
154
|
name: haml
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,6 +188,7 @@ files:
|
|
160
188
|
- public/app/html/.gitkeep
|
161
189
|
- public/app/images/.gitkeep
|
162
190
|
- public/app/js/.gitkeep
|
191
|
+
- public/server/css/server.css
|
163
192
|
- public/server/default.html
|
164
193
|
- public/server/foundation-5.2.2/css/foundation.css
|
165
194
|
- public/server/foundation-5.2.2/css/foundation.min.css
|
@@ -194,13 +223,17 @@ files:
|
|
194
223
|
- public/server/jquery-2.1.1/jquery.js
|
195
224
|
- public/server/jquery-2.1.1/jquery.min.js
|
196
225
|
- public/server/jquery-2.1.1/jquery.min.map
|
226
|
+
- public/server/js/server.js
|
197
227
|
- spec/spec_helper.rb
|
198
228
|
- spec/woyo/server/1_server_spec.rb
|
199
229
|
- spec/woyo/server/runner_spec.rb
|
200
230
|
- tmux
|
231
|
+
- todo.txt
|
201
232
|
- views/app/.gitkeep
|
202
233
|
- views/server/layout.haml
|
203
234
|
- views/server/location.haml
|
235
|
+
- views/server/way.haml
|
236
|
+
- views/server/world.haml
|
204
237
|
- world/.gitkeep
|
205
238
|
- woyo-server.gemspec
|
206
239
|
homepage: ''
|