pairzone 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +26 -0
- data/.rspec +1 -0
- data/.rvmrc +7 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +76 -0
- data/README.md +44 -0
- data/Rakefile +14 -0
- data/bin/pairzone +83 -0
- data/config/cucumber.yml +4 -0
- data/features/collaborator_joins_pairzone.feature +20 -0
- data/features/developer_signs_in.feature +11 -0
- data/features/developer_starts_pairzone.feature +35 -0
- data/features/keys/bob.key +12 -0
- data/features/keys/bob.key.pub +1 -0
- data/features/keys/derek.key +27 -0
- data/features/keys/derek.key.pub +1 -0
- data/features/server/stub-pairzone-server.rb +76 -0
- data/features/step_definitions/authorisation_steps.rb +8 -0
- data/features/step_definitions/info_steps.rb +5 -0
- data/features/step_definitions/repository_steps.rb +6 -0
- data/features/step_definitions/running_steps.rb +32 -0
- data/features/step_definitions/starting_steps.rb +47 -0
- data/features/support/aruba.rb +1 -0
- data/features/support/env.rb +5 -0
- data/features/support/helpers/server_helper.rb +40 -0
- data/features/support/hooks.rb +24 -0
- data/features/support/pairzone-config.rb +13 -0
- data/lib/pairzone.rb +14 -0
- data/lib/pairzone/api/base.rb +27 -0
- data/lib/pairzone/api/pairzone.rb +25 -0
- data/lib/pairzone/api/pairzone_connection.rb +32 -0
- data/lib/pairzone/api/pairzone_lifecycle.rb +34 -0
- data/lib/pairzone/api/user.rb +16 -0
- data/lib/pairzone/authenticate.rb +51 -0
- data/lib/pairzone/commands/info.rb +25 -0
- data/lib/pairzone/commands/join.rb +21 -0
- data/lib/pairzone/commands/start.rb +29 -0
- data/lib/pairzone/logger.rb +33 -0
- data/lib/pairzone/shell.rb +38 -0
- data/lib/pairzone/version.rb +3 -0
- data/pairzone.gemspec +35 -0
- data/spec/pairzone/api/pairzone_lifecycle_spec.rb +26 -0
- data/spec/pairzone/authentication_spec.rb +44 -0
- data/spec/pairzone/logger_spec.rb +41 -0
- data/spec/spec_helper.rb +7 -0
- metadata +292 -0
data/.gitignore
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## PROJECT::GENERAL
|
17
|
+
coverage
|
18
|
+
rdoc
|
19
|
+
doc
|
20
|
+
.yardoc
|
21
|
+
pkg
|
22
|
+
.bundle
|
23
|
+
|
24
|
+
## PROJECT::SPECIFIC
|
25
|
+
tmp/aruba*
|
26
|
+
tmp/foo*
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
-fs -c
|
data/.rvmrc
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pairzone (0.0.1)
|
5
|
+
gli
|
6
|
+
highline
|
7
|
+
net-ssh
|
8
|
+
party_resource
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
activesupport (3.2.6)
|
14
|
+
i18n (~> 0.6)
|
15
|
+
multi_json (~> 1.0)
|
16
|
+
aruba (0.4.11)
|
17
|
+
childprocess (>= 0.2.3)
|
18
|
+
cucumber (>= 1.1.1)
|
19
|
+
ffi (>= 1.0.11)
|
20
|
+
rspec (>= 2.7.0)
|
21
|
+
background_process (1.2)
|
22
|
+
builder (3.0.0)
|
23
|
+
childprocess (0.3.3)
|
24
|
+
ffi (~> 1.0.6)
|
25
|
+
cucumber (1.2.1)
|
26
|
+
builder (>= 2.1.2)
|
27
|
+
diff-lcs (>= 1.1.3)
|
28
|
+
gherkin (~> 2.11.0)
|
29
|
+
json (>= 1.4.6)
|
30
|
+
diff-lcs (1.1.3)
|
31
|
+
ffi (1.0.11)
|
32
|
+
gherkin (2.11.1)
|
33
|
+
json (>= 1.4.6)
|
34
|
+
gli (1.6.0)
|
35
|
+
highline (1.6.13)
|
36
|
+
httparty (0.8.3)
|
37
|
+
multi_json (~> 1.0)
|
38
|
+
multi_xml
|
39
|
+
i18n (0.6.0)
|
40
|
+
json (1.4.6)
|
41
|
+
multi_json (1.3.6)
|
42
|
+
multi_xml (0.5.1)
|
43
|
+
net-ssh (2.5.2)
|
44
|
+
party_resource (0.0.3)
|
45
|
+
activesupport (>= 2.3.5)
|
46
|
+
httparty (>= 0.5.2)
|
47
|
+
rack (1.2.1)
|
48
|
+
rack-contrib (1.1.0)
|
49
|
+
rack (>= 0.9.1)
|
50
|
+
rake (0.9.2.2)
|
51
|
+
rspec (2.10.0)
|
52
|
+
rspec-core (~> 2.10.0)
|
53
|
+
rspec-expectations (~> 2.10.0)
|
54
|
+
rspec-mocks (~> 2.10.0)
|
55
|
+
rspec-core (2.10.1)
|
56
|
+
rspec-expectations (2.10.0)
|
57
|
+
diff-lcs (~> 1.1.3)
|
58
|
+
rspec-mocks (2.10.1)
|
59
|
+
sinatra (1.1.0)
|
60
|
+
rack (~> 1.1)
|
61
|
+
tilt (~> 1.1)
|
62
|
+
tilt (1.1)
|
63
|
+
|
64
|
+
PLATFORMS
|
65
|
+
ruby
|
66
|
+
|
67
|
+
DEPENDENCIES
|
68
|
+
aruba (~> 0.4)
|
69
|
+
background_process
|
70
|
+
cucumber (~> 1.2)
|
71
|
+
json
|
72
|
+
pairzone!
|
73
|
+
rack-contrib
|
74
|
+
rake (~> 0.9.2.2)
|
75
|
+
rspec (~> 2.10.0)
|
76
|
+
sinatra
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Pairzone
|
2
|
+
|
3
|
+
This is the gem code for pairzone.
|
4
|
+
|
5
|
+
*THIS IS A WORK IN PROGRESS AND WILL NOT WORK AND IS NOT FINISHED!*
|
6
|
+
|
7
|
+
There's lots to do:
|
8
|
+
|
9
|
+
* Transfer the gem from using a server to using local ec2 keys (via fog?)
|
10
|
+
* Convert the cucumber tests to do everything locally
|
11
|
+
* Get the chef code into this repo and convert to chef-solo
|
12
|
+
* Make the pairzone gem:
|
13
|
+
|
14
|
+
** Request ec2 credentials
|
15
|
+
** Boot up an ec2 instance
|
16
|
+
** Use chef to configure it
|
17
|
+
** Upload your git repo (DONE)
|
18
|
+
|
19
|
+
** Sign in
|
20
|
+
|
21
|
+
## Working on the code
|
22
|
+
|
23
|
+
We're using github issues and pull requests. Usual score.
|
24
|
+
|
25
|
+
We hang out in #pairzone on Freenode.
|
26
|
+
|
27
|
+
### Getting set up
|
28
|
+
|
29
|
+
In order to run the features you need a user account on your machine called pairzone-auth with the following in _~/.ssh/authorized_keys:_
|
30
|
+
|
31
|
+
<pre>
|
32
|
+
command="echo bob.key" ssh-dss AAAAB3NzaC1kc3MAAACBAPD5ncLLo+X1GIkOXY9VQ8fWeFqtd7xSQvLOfANYh3u55mrL4xVrBaU8wku3WBOF8hWqmXThNspWJ9J95lKT89lpmAD2cGqWul619VR97Q31ar/xy4C6FI3RCUe8QIRffbGG8fWPHkAHmMPNnM9i7fBt4O0uqbgQ2K0WiE5EFkO/AAAAFQDmMkzSFVsYIpaIyFdYGGsB4qxiuwAAAIBQ+uMl6dePFYKazCdqNbP4uRq8IO4dcAC7dfM1cE0KQFK/OLfM2mcI2OBZksL2BT30NOPlvxoFekTsXw0O3NU0ejA0Xfbg4/mH6klpN9+X8TkO5A9EGSyZ+8n9N0hSTtW7YxK/ADDudnn3fZnp2+qrEmXvkfOZFY7RFYzQn6P6dgAAAIEAvXmzl+P4SEcWH48BEsFWkAlb2iz7xYLYa1MVN/pwxyA5DMZ8VXkRk1z2QBU4TMkCOc/e8XAt0aBPlp/L00bQPC2xVwxic6cdEg50LYS+UQQnirlOs9+lref48ksIdSThuvnkIs+T9L7SAuj/zon4xuroLQWsKtgRRS6SN0Q62t0= bob.key.pub
|
33
|
+
command="echo derek.key" ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvoEkswUJgBnwv0fH1LO4BXnN1zwC6ARLWvWmH7rhmRz0Y9YodEu7Kz7xYQUB5eWm1eOVTu+Bq6c29MzynTvRJi1WCumILDUQ29LciC9Y6A9VmVrHFoehtzqIpfsXpn1pTP+8RZCfS4Pt+yVyWzJKx1AkbT+cgi0wjAhQxnpdqMmp3kBfb1XZgi3qBz2Cm+Q8GRI3b0Xj7ahhYmMzJWS5qHn57jXsjxxYQuFMIScm2L6x+RhP1aE5Y/RBWW2xLQ3WCN252wWHFvWfKKCAMOXaSJKImdGwDnr0cIUbDyJhzbjPSPOjP1P0t05YK/cqK6t7BQBvcFPvXJCLBD7ZAO5t7w== derek.key.pub
|
34
|
+
</pre>
|
35
|
+
|
36
|
+
You will also need a 'pairzone' account to pretend to be the actual pairzone instance. This should have a similar file set up in _~/.ssh/authorized_keys:_
|
37
|
+
|
38
|
+
<pre>
|
39
|
+
ssh-dss AAAAB3NzaC1kc3MAAACBAPD5ncLLo+X1GIkOXY9VQ8fWeFqtd7xSQvLOfANYh3u55mrL4xVrBaU8wku3WBOF8hWqmXThNspWJ9J95lKT89lpmAD2cGqWul619VR97Q31ar/xy4C6FI3RCUe8QIRffbGG8fWPHkAHmMPNnM9i7fBt4O0uqbgQ2K0WiE5EFkO/AAAAFQDmMkzSFVsYIpaIyFdYGGsB4qxiuwAAAIBQ+uMl6dePFYKazCdqNbP4uRq8IO4dcAC7dfM1cE0KQFK/OLfM2mcI2OBZksL2BT30NOPlvxoFekTsXw0O3NU0ejA0Xfbg4/mH6klpN9+X8TkO5A9EGSyZ+8n9N0hSTtW7YxK/ADDudnn3fZnp2+qrEmXvkfOZFY7RFYzQn6P6dgAAAIEAvXmzl+P4SEcWH48BEsFWkAlb2iz7xYLYa1MVN/pwxyA5DMZ8VXkRk1z2QBU4TMkCOc/e8XAt0aBPlp/L00bQPC2xVwxic6cdEg50LYS+UQQnirlOs9+lref48ksIdSThuvnkIs+T9L7SAuj/zon4xuroLQWsKtgRRS6SN0Q62t0= bob.key.pub
|
40
|
+
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvoEkswUJgBnwv0fH1LO4BXnN1zwC6ARLWvWmH7rhmRz0Y9YodEu7Kz7xYQUB5eWm1eOVTu+Bq6c29MzynTvRJi1WCumILDUQ29LciC9Y6A9VmVrHFoehtzqIpfsXpn1pTP+8RZCfS4Pt+yVyWzJKx1AkbT+cgi0wjAhQxnpdqMmp3kBfb1XZgi3qBz2Cm+Q8GRI3b0Xj7ahhYmMzJWS5qHn57jXsjxxYQuFMIScm2L6x+RhP1aE5Y/RBWW2xLQ3WCN252wWHFvWfKKCAMOXaSJKImdGwDnr0cIUbDyJhzbjPSPOjP1P0t05YK/cqK6t7BQBvcFPvXJCLBD7ZAO5t7w== derek.key.pub
|
41
|
+
</pre>
|
42
|
+
|
43
|
+
On OSX you will also need to add the user account to the Sharing preference pane to allow them to log in
|
44
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
5
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
6
|
+
end
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
9
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
10
|
+
spec.rcov = true
|
11
|
+
spec.rcov_opts = %q[--exclude "spec"]
|
12
|
+
end
|
13
|
+
|
14
|
+
task :default => :spec
|
data/bin/pairzone
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
|
8
|
+
require 'pairzone'
|
9
|
+
|
10
|
+
require 'gli'
|
11
|
+
|
12
|
+
include GLI
|
13
|
+
|
14
|
+
config_file '.pairzone/config'
|
15
|
+
|
16
|
+
desc 'Show debug output'
|
17
|
+
switch [:d, :debug]
|
18
|
+
|
19
|
+
desc 'Specifies the pairzone web service to connect to'
|
20
|
+
arg_name 'host'
|
21
|
+
flag [:s, :server]
|
22
|
+
|
23
|
+
desc 'Specifies the pairzone config directory'
|
24
|
+
arg_name 'directory'
|
25
|
+
default_value "#{Dir.home}/.pairzone"
|
26
|
+
flag [:config]
|
27
|
+
|
28
|
+
desc 'Specifies the private key to use as your identity'
|
29
|
+
arg_name 'private key'
|
30
|
+
default_value "~/.ssh/id_rsa"
|
31
|
+
flag [:i, :identity]
|
32
|
+
|
33
|
+
pre do |globals, command, options, args|
|
34
|
+
Pairzone::Logger.configure_from(globals)
|
35
|
+
true
|
36
|
+
end
|
37
|
+
|
38
|
+
def local_project_name
|
39
|
+
File.basename(Dir.pwd)
|
40
|
+
end
|
41
|
+
|
42
|
+
def connect_with(globals)
|
43
|
+
key = Pairzone::Authenticate.retrieve_key(globals[:config], globals[:s])
|
44
|
+
Pairzone::Api::Base.connect_to(globals[:s], username: key, password: 'x', default: true)
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'Display Pairzone info'
|
48
|
+
long_desc 'Display information about the Pairzone for the current directory.'
|
49
|
+
command [:info] do |c|
|
50
|
+
c.action do |globals, options, args|
|
51
|
+
connect_with globals
|
52
|
+
Pairzone::Commands::Info.new(local_project_name).execute
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'Start a new Pairzone'
|
57
|
+
long_desc 'Start a new Pairzone for the current directory, or reconnect to a running one.'
|
58
|
+
command [:start] do |c|
|
59
|
+
c.desc 'Specify a comma seperated list of collaborators to add to this pairzone.'
|
60
|
+
c.arg_name 'collaborators'
|
61
|
+
c.flag [:c]
|
62
|
+
|
63
|
+
c.desc 'Do not connect to this pairzone, but leave it running in the background.'
|
64
|
+
c.switch [:b, :background]
|
65
|
+
c.action do |globals, options, args|
|
66
|
+
connect_with globals
|
67
|
+
Pairzone::Commands::Start.new(local_project_name, globals[:i], options).execute
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
desc 'Join an existing pairzone'
|
72
|
+
long_desc 'Allows an owner or collaborator to join a running pairzone instance.'
|
73
|
+
command [:join] do |c|
|
74
|
+
c.action do |globals, options, args|
|
75
|
+
connect_with globals
|
76
|
+
name = args[0]
|
77
|
+
identity = globals[:i]
|
78
|
+
Pairzone::Commands::Join.new(name, identity).execute
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
GLI.run(ARGV)
|
83
|
+
|
data/config/cucumber.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
@api_server
|
2
|
+
Feature: Collaborator joins pairzone
|
3
|
+
In order to pair on writing code
|
4
|
+
As a collaborator
|
5
|
+
I want to join existing pairzones that I am listed as a collaborator on
|
6
|
+
|
7
|
+
Scenario: Developer starts, then joins pairzone
|
8
|
+
Given "bob" has already started a pairzone
|
9
|
+
When "bob" runs "pairzone join bob-aruba" in test mode
|
10
|
+
Then "bob" should be connected to "bob-aruba"
|
11
|
+
|
12
|
+
Scenario: Collaborator joins pairzone
|
13
|
+
Given "bob" has already started a pairzone with "derek" as a collaborator
|
14
|
+
When "derek" runs "pairzone join bob-aruba" in test mode
|
15
|
+
Then "derek" should be connected to "bob-aruba"
|
16
|
+
|
17
|
+
Scenario: Collaborator cannot join pairzone where they're not listed
|
18
|
+
Given "bob" has already started a pairzone
|
19
|
+
When "derek" runs "pairzone join bob-aruba" in test mode
|
20
|
+
Then "derek" should not be able to connect
|
@@ -0,0 +1,11 @@
|
|
1
|
+
@api_server
|
2
|
+
Feature: Developer signs in
|
3
|
+
In order to be securely identified to pairzone
|
4
|
+
As a developer
|
5
|
+
I want the pairzone gem to use my public key to get an API key from pairzone
|
6
|
+
|
7
|
+
Scenario: Derek signs in for first time
|
8
|
+
When "derek" runs "pairzone info" in test mode with no api key
|
9
|
+
And "derek" supplies his credentials
|
10
|
+
Then his API key is saved
|
11
|
+
And he sees information about his pairzone account
|
@@ -0,0 +1,35 @@
|
|
1
|
+
@api_server @announce
|
2
|
+
Feature: Developer starts pairzone
|
3
|
+
|
4
|
+
Scenario:
|
5
|
+
Given I have a local git repository
|
6
|
+
When "bob" runs "pairzone start" in test mode
|
7
|
+
Then a new pairzone is started for "bob"
|
8
|
+
And the code in my current directory is pushed to the server
|
9
|
+
And an SSH connection is made to my new pairzone
|
10
|
+
And the code is downloaded to a "pairzone" branch when I quit the session
|
11
|
+
|
12
|
+
Scenario: Developer starts pairzone in the background
|
13
|
+
Given I have a local git repository
|
14
|
+
When "bob" runs "pairzone start --background" in test mode
|
15
|
+
Then a new pairzone is started for "bob" in the background
|
16
|
+
|
17
|
+
Scenario: Developer rejoins previously started pairzone
|
18
|
+
Given I have a local git repository
|
19
|
+
When "bob" runs "pairzone start --background" in test mode
|
20
|
+
And "bob" runs "pairzone start" in test mode
|
21
|
+
Then "bob" should be connected to "bob-aruba"
|
22
|
+
|
23
|
+
Scenario: Developer adds collaborator
|
24
|
+
Given I have a local git repository
|
25
|
+
When "bob" runs "pairzone start -c derek" in test mode
|
26
|
+
Then "derek" is added as a collaborator on my new pairzone
|
27
|
+
When "bob" runs "pairzone start -c derek,jim" in test mode
|
28
|
+
Then "derek" is added as a collaborator on my new pairzone
|
29
|
+
And "jim" is added as a collaborator on my new pairzone
|
30
|
+
|
31
|
+
Scenario: Developer adds non-existent collaborator
|
32
|
+
Given I have a local git repository
|
33
|
+
When "bob" runs "pairzone start -c derek,invalid_collaborator" in test mode
|
34
|
+
Then "derek" is added as a collaborator on my new pairzone
|
35
|
+
And "invalid_collaborator" is not added as a collaborator on my new pairzone
|
@@ -0,0 +1,12 @@
|
|
1
|
+
-----BEGIN DSA PRIVATE KEY-----
|
2
|
+
MIIBuwIBAAKBgQDw+Z3Cy6Pl9RiJDl2PVUPH1nharXe8UkLyznwDWId7ueZqy+MV
|
3
|
+
awWlPMJLt1gThfIV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1LO4BXnN1zwC6ARLWvWmH7rhmRz0Y9YodEu7Kz7xYQUB5eWm1eOVTu+Bq6c29MzynTvRJi1WCumILDUQ29LciC9Y6A9VmVrHFoehtzqIpfsXpn1pTP+8RZCfS4Pt+yVyWzJKx1AkbT+cgi0wjAhQxnpdqMmp3kBfb1XZgi3qBz2Cm+Q8GRI3b0Xj7ahhYmMzJWS5qHn57jXsjxxYQuFMIScm2L6x+RhP1aE5Y/RBWW2xLQ3WCN252wWHFvWfKKCAMOXaSJKImdGwDnr0cIUbDyJhzbjPSPOjP1P0t05YK/cqK6t7BQBvcFPvXJCLBD7ZAO5t7w== chris@chris3.local
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'json/add/rails'
|
3
|
+
require 'rack/contrib'
|
4
|
+
|
5
|
+
before do
|
6
|
+
if (request.env["PATH_INFO"] != '/users/find_key')
|
7
|
+
auth = Rack::Auth::Basic::Request.new(request.env)
|
8
|
+
@key = auth.credentials.first
|
9
|
+
halt 401 unless @key =~ /pairzone-test-api-key/
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
use Rack::NestedParams
|
14
|
+
|
15
|
+
PAIRZONES = {
|
16
|
+
'derek-aruba' => {
|
17
|
+
:ip => '127.0.0.1',
|
18
|
+
:name => 'derek-aruba',
|
19
|
+
:owner => 'derek',
|
20
|
+
:collaborators => ['dave', 'edward']
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
USERS = {
|
25
|
+
'pairzone-test-api-key-derek' => {
|
26
|
+
:username => 'derek',
|
27
|
+
:apikey => 'pairzone-test-api-key-derek'
|
28
|
+
},
|
29
|
+
'pairzone-test-api-key-bob' => {
|
30
|
+
:username => 'bob',
|
31
|
+
:apikey => 'pairzone-test-api-key-bob'
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
def username
|
36
|
+
USERS[@key][:username]
|
37
|
+
end
|
38
|
+
|
39
|
+
get '/pairzones/:name.json' do |name|
|
40
|
+
pairzone = PAIRZONES[name]
|
41
|
+
halt 404 if pairzone.nil?
|
42
|
+
halt 404 unless pairzone[:owner] == username || pairzone[:collaborators].include?(username)
|
43
|
+
pairzone.to_json
|
44
|
+
end
|
45
|
+
|
46
|
+
post '/pairzones' do
|
47
|
+
params['pairzone']['collaborators'].delete('invalid_collaborator') if (params['pairzone']['collaborators'])
|
48
|
+
pairzone = params['pairzone']
|
49
|
+
pairzone['ip'] = '127.0.0.1'
|
50
|
+
pairzone['owner'] = username
|
51
|
+
pairzone['status'] = 'started'
|
52
|
+
pairzone['name'] = username + '-' + pairzone['project_name']
|
53
|
+
pairzone['collaborators'] ||= []
|
54
|
+
PAIRZONES[pairzone['name']] = pairzone
|
55
|
+
pairzone.to_json
|
56
|
+
end
|
57
|
+
|
58
|
+
get '/current_user' do
|
59
|
+
USERS[@key].to_json
|
60
|
+
end
|
61
|
+
|
62
|
+
post '/users/find_key' do
|
63
|
+
match = USERS.values.select do |user|
|
64
|
+
user[:username] == params[:username]
|
65
|
+
end
|
66
|
+
halt 404 if match.empty?
|
67
|
+
match.first.to_json
|
68
|
+
end
|
69
|
+
|
70
|
+
get /.*/ do
|
71
|
+
"RECEIVED GET: #{request.url.inspect}"
|
72
|
+
end
|
73
|
+
|
74
|
+
post /.*/ do
|
75
|
+
"RECEIVED POST: #{request.url.inspect} WITH: #{request.body.string}"
|
76
|
+
end
|