carps 0.2.1
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/COPYING +674 -0
- data/GEM_DESCRIPTION +10 -0
- data/History.txt +4 -0
- data/Manifest.txt +156 -0
- data/PostInstall.txt +20 -0
- data/README.rdoc +141 -0
- data/Rakefile +28 -0
- data/bin/carps +123 -0
- data/bin/carps_init +29 -0
- data/bin/carps_ipc_test +44 -0
- data/bin/carps_mod_saver_test +71 -0
- data/bin/carps_mod_test +62 -0
- data/config/website.yml +2 -0
- data/features/character_sheet.feature +40 -0
- data/features/crash.feature +15 -0
- data/features/crypt.feature +22 -0
- data/features/dice.feature +173 -0
- data/features/dm.feature +36 -0
- data/features/dmll.feature +51 -0
- data/features/edit.feature +10 -0
- data/features/email.feature +29 -0
- data/features/interface.feature +17 -0
- data/features/ipc.feature +10 -0
- data/features/mailbox.feature +33 -0
- data/features/mod.feature +31 -0
- data/features/parser.feature +9 -0
- data/features/persistent_protocol.feature +14 -0
- data/features/player.feature +22 -0
- data/features/player_turn.feature +29 -0
- data/features/random.feature +15 -0
- data/features/rule.feature +19 -0
- data/features/safety.feature +13 -0
- data/features/sessions.feature +16 -0
- data/features/start_dm.feature +18 -0
- data/features/start_player.feature +8 -0
- data/features/step_definitions/common_steps.rb +170 -0
- data/features/steps/character_sheet.rb +89 -0
- data/features/steps/crash.rb +27 -0
- data/features/steps/crypt.rb +166 -0
- data/features/steps/dice.rb +91 -0
- data/features/steps/dm.rb +147 -0
- data/features/steps/dmll.rb +47 -0
- data/features/steps/edit.rb +7 -0
- data/features/steps/email.rb +108 -0
- data/features/steps/general.rb +5 -0
- data/features/steps/interface.rb +64 -0
- data/features/steps/ipc.rb +22 -0
- data/features/steps/mailbox.rb +126 -0
- data/features/steps/mod.rb +25 -0
- data/features/steps/parser.rb +23 -0
- data/features/steps/persistent_protocol.rb +29 -0
- data/features/steps/player.rb +82 -0
- data/features/steps/player_turn.rb +56 -0
- data/features/steps/random.rb +47 -0
- data/features/steps/rule.rb +53 -0
- data/features/steps/safety.rb +17 -0
- data/features/steps/sessions.rb +37 -0
- data/features/steps/start_dm.rb +46 -0
- data/features/steps/start_player.rb +65 -0
- data/features/steps/timeout.rb +32 -0
- data/features/steps/type_verification.rb +36 -0
- data/features/steps/wizard.rb +123 -0
- data/features/support/common.rb +29 -0
- data/features/support/env.rb +14 -0
- data/features/support/matchers.rb +11 -0
- data/features/timeout.feature +11 -0
- data/features/type_verification.feature +48 -0
- data/features/wizard.feature +50 -0
- data/lib/carps/crypt/accept_handshake.rb +40 -0
- data/lib/carps/crypt/default_messages.rb +29 -0
- data/lib/carps/crypt/handshake.rb +41 -0
- data/lib/carps/crypt/mailbox.rb +265 -0
- data/lib/carps/crypt/mailer.rb +220 -0
- data/lib/carps/crypt/peer.rb +123 -0
- data/lib/carps/crypt/public_key.rb +60 -0
- data/lib/carps/crypt.rb +23 -0
- data/lib/carps/email/config.rb +122 -0
- data/lib/carps/email/imap.rb +156 -0
- data/lib/carps/email/smtp.rb +119 -0
- data/lib/carps/email/string.rb +30 -0
- data/lib/carps/email.rb +21 -0
- data/lib/carps/mod/action.rb +36 -0
- data/lib/carps/mod/answers.rb +76 -0
- data/lib/carps/mod/client_turn.rb +88 -0
- data/lib/carps/mod/dice.rb +360 -0
- data/lib/carps/mod/dm/interface.rb +160 -0
- data/lib/carps/mod/dm/mod.rb +409 -0
- data/lib/carps/mod/dm/reporter.rb +112 -0
- data/lib/carps/mod/dm/resource.rb +88 -0
- data/lib/carps/mod/dm/room.rb +33 -0
- data/lib/carps/mod/interface.rb +73 -0
- data/lib/carps/mod/launch.rb +108 -0
- data/lib/carps/mod/mod.rb +52 -0
- data/lib/carps/mod/player/interface.rb +76 -0
- data/lib/carps/mod/player/mod.rb +109 -0
- data/lib/carps/mod/question.rb +63 -0
- data/lib/carps/mod/rule.rb +112 -0
- data/lib/carps/mod/sheet/character.rb +82 -0
- data/lib/carps/mod/sheet/editor.rb +97 -0
- data/lib/carps/mod/sheet/new_sheet.rb +71 -0
- data/lib/carps/mod/sheet/schema.rb +84 -0
- data/lib/carps/mod/sheet/type.rb +161 -0
- data/lib/carps/mod/sheet/verifier.rb +41 -0
- data/lib/carps/mod/status_report.rb +51 -0
- data/lib/carps/mod.rb +40 -0
- data/lib/carps/protocol/keyword.rb +104 -0
- data/lib/carps/protocol/message.rb +138 -0
- data/lib/carps/protocol.rb +19 -0
- data/lib/carps/service/client_parser.rb +34 -0
- data/lib/carps/service/dm/config.rb +76 -0
- data/lib/carps/service/dm/mailer.rb +70 -0
- data/lib/carps/service/dm/new_game.rb +101 -0
- data/lib/carps/service/dm/start.rb +47 -0
- data/lib/carps/service/game.rb +101 -0
- data/lib/carps/service/interface.rb +174 -0
- data/lib/carps/service/invite.rb +79 -0
- data/lib/carps/service/mod.rb +43 -0
- data/lib/carps/service/player/config.rb +78 -0
- data/lib/carps/service/player/mailer.rb +49 -0
- data/lib/carps/service/player/start.rb +60 -0
- data/lib/carps/service/server_parser.rb +33 -0
- data/lib/carps/service/session.rb +96 -0
- data/lib/carps/service/start/config.rb +71 -0
- data/lib/carps/service/start/interface.rb +101 -0
- data/lib/carps/service/start/mailer.rb +46 -0
- data/lib/carps/service.rb +35 -0
- data/lib/carps/test.rb +34 -0
- data/lib/carps/ui/colour.rb +28 -0
- data/lib/carps/ui/error.rb +39 -0
- data/lib/carps/ui/highlight.rb +32 -0
- data/lib/carps/ui/question.rb +63 -0
- data/lib/carps/ui/warn.rb +37 -0
- data/lib/carps/ui.rb +21 -0
- data/lib/carps/util/config.rb +162 -0
- data/lib/carps/util/editor.rb +147 -0
- data/lib/carps/util/error.rb +75 -0
- data/lib/carps/util/files.rb +48 -0
- data/lib/carps/util/init.rb +93 -0
- data/lib/carps/util/process.rb +150 -0
- data/lib/carps/util/timeout.rb +31 -0
- data/lib/carps/util/windows.rb +29 -0
- data/lib/carps/util.rb +24 -0
- data/lib/carps/wizard/dm.rb +41 -0
- data/lib/carps/wizard/player.rb +40 -0
- data/lib/carps/wizard/steps.rb +494 -0
- data/lib/carps/wizard/wizard.rb +126 -0
- data/lib/carps/wizard.rb +21 -0
- data/lib/carps.rb +45 -0
- data/permission +16 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/tasks/readme_site.rake +28 -0
- data/test/test_carps.rb +11 -0
- data/test/test_helper.rb +3 -0
- data/website/index.html +271 -0
- metadata +304 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require "carps/ui"
|
|
2
|
+
|
|
3
|
+
Given /^\$SAFE is (\d+)$/ do |level|
|
|
4
|
+
$SAFE = level.to_i
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
Then /^allow checking a file exists in response to user input$/ do
|
|
8
|
+
File.exists?(question "Enter file name to check existense of")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
Then /^disallow eval in response to user input$/ do
|
|
12
|
+
begin
|
|
13
|
+
eval(question "Enter arbitrary ruby statement")
|
|
14
|
+
rescue InsecureOperation => e
|
|
15
|
+
puts "Recovered from Insecure Operation"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require "carps/service/session"
|
|
2
|
+
|
|
3
|
+
class ValidSessionMessage
|
|
4
|
+
|
|
5
|
+
def session
|
|
6
|
+
"killingjoke"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class InvalidSessionMessage
|
|
12
|
+
|
|
13
|
+
def session
|
|
14
|
+
"simplyred"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Given /^a session manager$/ do
|
|
20
|
+
$session = SessionManager.new
|
|
21
|
+
$session.session = "killingjoke"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
Then /^accept a message meant for this session$/ do
|
|
25
|
+
now = $session.belong? ValidSessionMessage.new
|
|
26
|
+
unless now
|
|
27
|
+
raise StandardError, "SessionManager did not accept valid message."
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
Then /^deny a message intended for another session$/ do
|
|
32
|
+
now = $session.belong? InvalidSessionMessage.new
|
|
33
|
+
if now
|
|
34
|
+
raise StandardError, "SessionManager accepted invalid message."
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require "carps/service/dm/config"
|
|
2
|
+
require "carps/service/dm/start"
|
|
3
|
+
|
|
4
|
+
require "carps/service/session"
|
|
5
|
+
|
|
6
|
+
class MockDmStartMailer
|
|
7
|
+
def address
|
|
8
|
+
"howdy"
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class MockGame
|
|
13
|
+
|
|
14
|
+
def start mailer
|
|
15
|
+
puts "Starting game..."
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def resume mailer
|
|
19
|
+
puts "Resuming game..."
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class MockConfig < DM::GameConfig
|
|
24
|
+
def spawn
|
|
25
|
+
MockGame.new
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
Then /^host a new game called (.+) with resource (.+) and mod (.+)$/ do |game_name, campaign, mod_name|
|
|
30
|
+
$game = DM::GameConfig.new game_name, mod_name, campaign, "A game about things", "session12345", "dungeon_master@email.com"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
Then /^save the game as (.+)$/ do |filename|
|
|
34
|
+
$game.save
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
Then /^the dm resumes a previous game called (.+)$/ do |filename|
|
|
38
|
+
$game = DM::GameConfig.load "games/" + filename
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
Then /^present the start game interface to the dm$/ do
|
|
42
|
+
begin
|
|
43
|
+
DM::StartInterface.start_game_interface MockDmStartMailer.new, MockConfig, $session
|
|
44
|
+
rescue SystemExit
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require "carps/service"
|
|
2
|
+
|
|
3
|
+
require "carps/protocol"
|
|
4
|
+
|
|
5
|
+
class MockPlayerGame
|
|
6
|
+
def join_game mailer
|
|
7
|
+
puts "Joining game."
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def resume mailer
|
|
11
|
+
puts "Resuming game"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class MockPlayerConfig < Player::GameConfig
|
|
17
|
+
def spawn
|
|
18
|
+
MockPlayerGame.new
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class PlayerStartMailer
|
|
23
|
+
|
|
24
|
+
def read klass, from=nil
|
|
25
|
+
msg = nil
|
|
26
|
+
until msg
|
|
27
|
+
msg = check
|
|
28
|
+
sleep 1
|
|
29
|
+
end
|
|
30
|
+
msg
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def check klass, from=nil
|
|
34
|
+
if @mail
|
|
35
|
+
mail = @mail
|
|
36
|
+
@mail = nil
|
|
37
|
+
return mail
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def send to, message
|
|
43
|
+
puts "Sending message to #{to}:"
|
|
44
|
+
puts message
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def invite
|
|
48
|
+
@mail = CARPS::Invite.new "the dm", "test", "the description", "the session"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
Given /^a mailer stub for the player start interface$/ do
|
|
53
|
+
$mailer = PlayerStartMailer.new
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
When /^an invite is sent to the player$/ do
|
|
57
|
+
$mailer.invite
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
Then /^present the start game interface to the player$/ do
|
|
61
|
+
begin
|
|
62
|
+
Player::StartInterface.start_game_interface $mailer, MockPlayerConfig, $session
|
|
63
|
+
rescue SystemExit
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require "carps/util/timeout"
|
|
2
|
+
|
|
3
|
+
Given /^a long running command$/ do
|
|
4
|
+
$command = lambda {
|
|
5
|
+
loop do
|
|
6
|
+
end
|
|
7
|
+
}
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
Then /^timeout the command after (\d+) second$/ do |t|
|
|
11
|
+
begin
|
|
12
|
+
CARPS::timeout t.to_i, "Test command 1" do
|
|
13
|
+
$command.call
|
|
14
|
+
end
|
|
15
|
+
rescue Timeout::Error => e
|
|
16
|
+
puts "The command was timed out as expected:"
|
|
17
|
+
puts e.to_s
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Then /^give the command (\d+) second to complete$/ do |t|
|
|
22
|
+
CARPS::timeout t.to_i, "test command 2" do
|
|
23
|
+
$command.call
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
Given /^a short command$/ do
|
|
28
|
+
$command = lambda {
|
|
29
|
+
puts "Hi honey!"
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require "carps/mod"
|
|
2
|
+
|
|
3
|
+
require "yaml"
|
|
4
|
+
|
|
5
|
+
Given /^an integer$/ do
|
|
6
|
+
$val = 123
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
Then /^verify: (.+) as a (.+)$/ do |opt, type_name|
|
|
10
|
+
type = Sheet::TypeParser.parse type_name
|
|
11
|
+
accepted, coerced = type.verify $val
|
|
12
|
+
pass = opt == "accept"
|
|
13
|
+
unless (pass and accepted) or (not pass and not accepted)
|
|
14
|
+
raise StandardError, "Verification mechanism fucked: should pass #{pass}, did pass #{accepted}"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
Given /^a nil value$/ do
|
|
19
|
+
$val = nil
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
Given /^a string$/ do
|
|
23
|
+
$val = "howdy!"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
Given /^'yes'$/ do
|
|
27
|
+
$val = YAML.load "yes"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
Given /^'bronze'$/ do
|
|
31
|
+
$val = "bronze"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Given /^'gold'$/ do
|
|
35
|
+
$val = "gold"
|
|
36
|
+
end
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
require "carps/wizard/wizard"
|
|
2
|
+
|
|
3
|
+
require "fileutils"
|
|
4
|
+
|
|
5
|
+
$sweet_files = ["roses", "kittens"]
|
|
6
|
+
$salty_files = ["robots", "miniguns"]
|
|
7
|
+
$salty_dirs = ["strength", "power"]
|
|
8
|
+
|
|
9
|
+
class SweetWizard < Wizard
|
|
10
|
+
|
|
11
|
+
def initialize
|
|
12
|
+
super $sweet_files, []
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class SillyStep < Setup::Interface
|
|
18
|
+
|
|
19
|
+
def initialize
|
|
20
|
+
super
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def description
|
|
24
|
+
"A pretty silly configuration step that doesn't do much."
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test
|
|
28
|
+
puts "Yup, looks good to me."
|
|
29
|
+
test_passed
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class SaltyWizard < Wizard
|
|
35
|
+
|
|
36
|
+
def initialize
|
|
37
|
+
super $salty_files, $salty_dirs
|
|
38
|
+
set_steps SillyStep.new
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
Then /^setup email$/ do
|
|
44
|
+
em = Setup::Email.new
|
|
45
|
+
em.run
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
Then /^setup processing$/ do
|
|
49
|
+
pr = Setup::Process.new
|
|
50
|
+
pr.run
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
Then /^setup editor$/ do
|
|
54
|
+
ed = Setup::Editor.new
|
|
55
|
+
ed.run
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
Given /^a player wizard$/ do
|
|
59
|
+
$wizard = Player::Wizard.new
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
Then /^clean the wizard directory$/ do
|
|
63
|
+
wiz = CARPS::root_config + "/wizard/"
|
|
64
|
+
FileUtils.rm_rf wiz
|
|
65
|
+
FileUtils.mkdir wiz
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
Then /^run the wizard$/ do
|
|
69
|
+
$wizard.run
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
Given /^a sweet wizard$/ do
|
|
73
|
+
FileUtils.touch $CONFIG + $sweet_files[0]
|
|
74
|
+
$wizard = SweetWizard.new
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
Then /^detect missing files$/ do
|
|
78
|
+
unless $wizard.first_time?
|
|
79
|
+
raise StandardError, "The wizard thought the files were present when they were not."
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
Given /^a salty wizard$/ do
|
|
84
|
+
FileUtils.touch $salty_files.map {|f| $CONFIG + "/" + f}
|
|
85
|
+
FileUtils.mkdir $salty_dirs.map {|f| $CONFIG + "/" + f}
|
|
86
|
+
$wizard = SaltyWizard.new
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
Then /^confirm files are present$/ do
|
|
90
|
+
if $wizard.first_time?
|
|
91
|
+
raise StandardError, "The wizard thought the files were not present when they were."
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
Given /^a partially populated folder$/ do
|
|
96
|
+
FileUtils.rmdir $CONFIG + $salty_dirs[0]
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
Given /^the config directory is (.+)$/ do |dir|
|
|
100
|
+
CARPS::config_dir dir
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
Then /^the salty wizard builds needed directories$/ do
|
|
104
|
+
$wizard.create_directories
|
|
105
|
+
dirs_exist = $salty_dirs.map {|f| File.exists?($CONFIG + "/" + f)}
|
|
106
|
+
unless dirs_exist.all?
|
|
107
|
+
raise StandardError, "Salty Wizard did not create needed directories."
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
When /^one of the salty wizard's files is in fact a directory$/ do
|
|
112
|
+
file = $CONFIG + "/" + $salty_files[0]
|
|
113
|
+
FileUtils.rm file
|
|
114
|
+
FileUtils.mkdir file
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
Then /^the wizard, attempting to create files, causes the program to exit$/ do
|
|
118
|
+
begin
|
|
119
|
+
$wizard.create_files
|
|
120
|
+
rescue SystemExit => e
|
|
121
|
+
puts e
|
|
122
|
+
end
|
|
123
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module CommonHelpers
|
|
2
|
+
def in_tmp_folder(&block)
|
|
3
|
+
FileUtils.chdir(@tmp_root, &block)
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def in_project_folder(&block)
|
|
7
|
+
project_folder = @active_project_folder || @tmp_root
|
|
8
|
+
FileUtils.chdir(project_folder, &block)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def in_home_folder(&block)
|
|
12
|
+
FileUtils.chdir(@home_path, &block)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def force_local_lib_override(project_name = @project_name)
|
|
16
|
+
rakefile = File.read(File.join(project_name, 'Rakefile'))
|
|
17
|
+
File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
|
|
18
|
+
f << "$:.unshift('#{@lib_path}')\n"
|
|
19
|
+
f << rakefile
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def setup_active_project_folder project_name
|
|
24
|
+
@active_project_folder = File.join(@tmp_root, project_name)
|
|
25
|
+
@project_name = project_name
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
World(CommonHelpers)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + "/../../lib/carps"
|
|
2
|
+
|
|
3
|
+
gem 'cucumber'
|
|
4
|
+
require 'cucumber'
|
|
5
|
+
|
|
6
|
+
# This is shit and means I can't test carps properly
|
|
7
|
+
# Before do
|
|
8
|
+
# @tmp_root = File.dirname(__FILE__) + "/../../tmp"
|
|
9
|
+
# @home_path = File.expand_path(File.join(@tmp_root, "home"))
|
|
10
|
+
# @lib_path = File.expand_path(File.dirname(__FILE__) + "/../../lib")
|
|
11
|
+
# FileUtils.rm_rf @tmp_root
|
|
12
|
+
# FileUtils.mkdir_p @home_path
|
|
13
|
+
# ENV['HOME'] = @home_path
|
|
14
|
+
# end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Matchers
|
|
2
|
+
def contain(expected)
|
|
3
|
+
simple_matcher("contain #{expected.inspect}") do |given, matcher|
|
|
4
|
+
matcher.failure_message = "expected #{given.inspect} to contain #{expected.inspect}"
|
|
5
|
+
matcher.negative_failure_message = "expected #{given.inspect} not to contain #{expected.inspect}"
|
|
6
|
+
given.index expected
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
World(Matchers)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Feature: timeout
|
|
2
|
+
As a programmer,
|
|
3
|
+
I find ruby's timeout lacking.
|
|
4
|
+
|
|
5
|
+
Scenario: timeout
|
|
6
|
+
Given a long running command
|
|
7
|
+
Then timeout the command after 1 second
|
|
8
|
+
|
|
9
|
+
Scenario: no timeout
|
|
10
|
+
Given a short command
|
|
11
|
+
Then give the command 1 second to complete
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
Feature: type verification
|
|
2
|
+
In order to verify character sheets correctly
|
|
3
|
+
the basic types making up those character sheets must be verified
|
|
4
|
+
|
|
5
|
+
Scenario: accept integer as integer
|
|
6
|
+
Given an integer
|
|
7
|
+
Then verify: accept as a integer
|
|
8
|
+
|
|
9
|
+
Scenario: accept integer as optional integer
|
|
10
|
+
Given an integer
|
|
11
|
+
Then verify: accept as a optional integer
|
|
12
|
+
|
|
13
|
+
Scenario: accept nil as optional integer
|
|
14
|
+
Given a nil value
|
|
15
|
+
Then verify: accept as a optional integer
|
|
16
|
+
|
|
17
|
+
Scenario: deny nil as integer
|
|
18
|
+
Given a nil value
|
|
19
|
+
Then verify: deny as a integer
|
|
20
|
+
|
|
21
|
+
Scenario: deny string as integer
|
|
22
|
+
Given a string
|
|
23
|
+
Then verify: deny as a integer
|
|
24
|
+
|
|
25
|
+
Scenario: deny string as optional integer
|
|
26
|
+
Given a string
|
|
27
|
+
Then verify: deny as a optional integer
|
|
28
|
+
|
|
29
|
+
Scenario: accept boolean as boolean
|
|
30
|
+
Given 'yes'
|
|
31
|
+
Then verify: accept as a boolean
|
|
32
|
+
|
|
33
|
+
Scenario: accept nil as optional choice gold silver
|
|
34
|
+
Given a nil value
|
|
35
|
+
Then verify: accept as a optional choice gold silver
|
|
36
|
+
|
|
37
|
+
Scenario: accept nil as optional boolean
|
|
38
|
+
Given a nil value
|
|
39
|
+
Then verify: accept as a optional boolean
|
|
40
|
+
|
|
41
|
+
Scenario: accept gold as choice gold silver
|
|
42
|
+
Given 'gold'
|
|
43
|
+
Then verify: accept as a choice gold silver
|
|
44
|
+
|
|
45
|
+
Scenario: deny bronze as choice gold silver
|
|
46
|
+
Given 'bronze'
|
|
47
|
+
Then verify: deny as a choice gold silver
|
|
48
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Feature: wizard
|
|
2
|
+
In order to play CARPS
|
|
3
|
+
we must have a valid configuration
|
|
4
|
+
|
|
5
|
+
Scenario: detect missing files
|
|
6
|
+
Given the config directory is wizard
|
|
7
|
+
Then clean the wizard directory
|
|
8
|
+
Given a sweet wizard
|
|
9
|
+
Then detect missing files
|
|
10
|
+
|
|
11
|
+
Scenario: confirm files present
|
|
12
|
+
Given the config directory is wizard
|
|
13
|
+
Then clean the wizard directory
|
|
14
|
+
Given a salty wizard
|
|
15
|
+
Then confirm files are present
|
|
16
|
+
|
|
17
|
+
Scenario: build needed directories
|
|
18
|
+
Given the config directory is wizard
|
|
19
|
+
Then clean the wizard directory
|
|
20
|
+
Given a salty wizard
|
|
21
|
+
Given a partially populated folder
|
|
22
|
+
Then the salty wizard builds needed directories
|
|
23
|
+
|
|
24
|
+
Scenario: fail on error
|
|
25
|
+
Given the config directory is wizard
|
|
26
|
+
Then clean the wizard directory
|
|
27
|
+
Given a salty wizard
|
|
28
|
+
Given one of the salty wizard's files is in fact a directory
|
|
29
|
+
Then the wizard, attempting to create files, causes the program to exit
|
|
30
|
+
|
|
31
|
+
Scenario: setup email
|
|
32
|
+
Given the config directory is wizard
|
|
33
|
+
Then clean the wizard directory
|
|
34
|
+
Then setup email
|
|
35
|
+
|
|
36
|
+
Scenario: setup processing
|
|
37
|
+
Given the config directory is wizard
|
|
38
|
+
Then clean the wizard directory
|
|
39
|
+
Then setup processing
|
|
40
|
+
|
|
41
|
+
Scenario: setup editor
|
|
42
|
+
Given the config directory is wizard
|
|
43
|
+
Then clean the wizard directory
|
|
44
|
+
Then setup editor
|
|
45
|
+
|
|
46
|
+
Scenario: configure player
|
|
47
|
+
Given the config directory is wizard
|
|
48
|
+
Then clean the wizard directory
|
|
49
|
+
Given a salty wizard
|
|
50
|
+
Then run the wizard
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Copyright 2010 John Morrice
|
|
2
|
+
|
|
3
|
+
# This file is part of CARPS.
|
|
4
|
+
|
|
5
|
+
# CARPS is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# CARPS is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with CARPS. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "carps/protocol/message"
|
|
19
|
+
|
|
20
|
+
module CARPS
|
|
21
|
+
|
|
22
|
+
class AcceptHandshake < Message
|
|
23
|
+
|
|
24
|
+
# Extend the protocol for this OKAY message
|
|
25
|
+
protoword :accept_handshake
|
|
26
|
+
|
|
27
|
+
# Parse from the void
|
|
28
|
+
def AcceptHandshake.parse blob
|
|
29
|
+
forget, blob = find K.accept_handshake, blob
|
|
30
|
+
[AcceptHandshake.new, blob]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Emit
|
|
34
|
+
def emit
|
|
35
|
+
K.accept_handshake
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Copyright 2010 John Morrice
|
|
2
|
+
|
|
3
|
+
# This file is part of CARPS.
|
|
4
|
+
|
|
5
|
+
# CARPS is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# CARPS is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with CARPS. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "carps/crypt/handshake"
|
|
19
|
+
require "carps/crypt/public_key"
|
|
20
|
+
require "carps/crypt/accept_handshake"
|
|
21
|
+
|
|
22
|
+
module CARPS
|
|
23
|
+
|
|
24
|
+
# Services will be built by extending upon these messages
|
|
25
|
+
def default_messages
|
|
26
|
+
[Handshake, AcceptHandshake, PublicKey]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Copyright 2010 John Morrice
|
|
2
|
+
|
|
3
|
+
# This file is part of CARPS.
|
|
4
|
+
|
|
5
|
+
# CARPS is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
# CARPS is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with CARPS. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
require "carps/protocol/message"
|
|
19
|
+
|
|
20
|
+
module CARPS
|
|
21
|
+
|
|
22
|
+
# A cryptographic handshake request
|
|
23
|
+
class Handshake < Message
|
|
24
|
+
|
|
25
|
+
# Extend the protocol for this request
|
|
26
|
+
protoword :handshake
|
|
27
|
+
|
|
28
|
+
# Parse from the void
|
|
29
|
+
def Handshake.parse blob
|
|
30
|
+
forget, blob = find K.handshake, blob
|
|
31
|
+
[Handshake.new, blob]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Emit
|
|
35
|
+
def emit
|
|
36
|
+
K.handshake
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|