xway 0.0.1.beta → 0.0.2.beta
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/.travis.yml +1 -1
- data/README.md +6 -0
- data/lib/xway/api/endpoints.rb +47 -16
- data/lib/xway/api/http.rb +1 -1
- data/lib/xway/cli.rb +2 -0
- data/lib/xway/error.rb +4 -0
- data/lib/xway/parameter.rb +2 -4
- data/lib/xway/version.rb +1 -1
- data/spec/lib/xway/api/endpoints_spec.rb +106 -70
- data/spec/lib/xway/api/http_spec.rb +1 -1
- data/spec/lib/xway/parameter_spec.rb +0 -2
- metadata +2 -2
data/.travis.yml
CHANGED
data/README.md
CHANGED
|
@@ -34,6 +34,12 @@ Or install it yourself as:
|
|
|
34
34
|
4. Push to the branch (`git push origin my-new-feature`)
|
|
35
35
|
5. Create new Pull Request
|
|
36
36
|
|
|
37
|
+
### Development
|
|
38
|
+
|
|
39
|
+
To run the binary from the repository use the following command with ruby libray path:
|
|
40
|
+
|
|
41
|
+
RUBYLIB=lib bin/xway
|
|
42
|
+
|
|
37
43
|
### Coding guide
|
|
38
44
|
|
|
39
45
|
* Using global methods like `Xway.parameter`
|
data/lib/xway/api/endpoints.rb
CHANGED
|
@@ -9,36 +9,67 @@ module Xway
|
|
|
9
9
|
Request.new 'post', '/applications', options
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def find options={
|
|
13
|
-
|
|
12
|
+
def find options={}
|
|
13
|
+
require_options options, :name
|
|
14
|
+
options[:name] ||= ':name'
|
|
15
|
+
Request.new 'get', "/applications/#{options[:name]}"
|
|
14
16
|
end
|
|
15
17
|
|
|
16
|
-
def update options={
|
|
17
|
-
|
|
18
|
+
def update options={}
|
|
19
|
+
require_options options, :name
|
|
20
|
+
options[:name] ||= ':name'
|
|
21
|
+
Request.new 'put', "/applications/#{options[:name]}"
|
|
18
22
|
end
|
|
19
23
|
|
|
20
|
-
def delete options={
|
|
21
|
-
|
|
24
|
+
def delete options={}
|
|
25
|
+
require_options options, :name
|
|
26
|
+
options[:name] ||= ':name'
|
|
27
|
+
Request.new 'delete', "/applications/#{options[:name]}"
|
|
22
28
|
end
|
|
23
29
|
|
|
24
|
-
def log options={
|
|
25
|
-
|
|
30
|
+
def log options={}
|
|
31
|
+
require_options options, :name
|
|
32
|
+
options[:name] ||= ':name'
|
|
33
|
+
Request.new 'get', "/applications/#{options[:name]}/log"
|
|
26
34
|
end
|
|
27
35
|
|
|
28
|
-
def start options={
|
|
29
|
-
|
|
36
|
+
def start options={}
|
|
37
|
+
require_options options, :name
|
|
38
|
+
options[:name] ||= ':name'
|
|
39
|
+
Request.new 'post', "/applications/#{options[:name]}/start"
|
|
30
40
|
end
|
|
31
41
|
|
|
32
|
-
def stop options={
|
|
33
|
-
|
|
42
|
+
def stop options={}
|
|
43
|
+
require_options options, :name
|
|
44
|
+
options[:name] ||= ':name'
|
|
45
|
+
Request.new 'post', "/applications/#{options[:name]}/stop"
|
|
34
46
|
end
|
|
35
47
|
|
|
36
|
-
def restart options={
|
|
37
|
-
|
|
48
|
+
def restart options={}
|
|
49
|
+
require_options options, :name
|
|
50
|
+
options[:name] ||= ':name'
|
|
51
|
+
Request.new 'post', "/applications/#{options[:name]}/restart"
|
|
38
52
|
end
|
|
39
53
|
|
|
40
|
-
def redeploy options={
|
|
41
|
-
|
|
54
|
+
def redeploy options={}
|
|
55
|
+
require_options options, :name
|
|
56
|
+
options[:name] ||= ':name'
|
|
57
|
+
Request.new 'post', "/applications/#{options[:name]}/redeploy"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
private
|
|
61
|
+
|
|
62
|
+
def require_options options, *keys
|
|
63
|
+
missing_keys = []
|
|
64
|
+
keys.each do |key|
|
|
65
|
+
if !options || options[key] == nil || options[key] == ''
|
|
66
|
+
missing_keys << key
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
unless missing_keys.empty?
|
|
70
|
+
raise MissingParameter, "Missing app parameter(s): "\
|
|
71
|
+
"#{missing_keys.map(&:to_s).join(', ')}"
|
|
72
|
+
end
|
|
42
73
|
end
|
|
43
74
|
end
|
|
44
75
|
end
|
data/lib/xway/api/http.rb
CHANGED
data/lib/xway/cli.rb
CHANGED
data/lib/xway/error.rb
CHANGED
data/lib/xway/parameter.rb
CHANGED
|
@@ -8,11 +8,9 @@ module Xway
|
|
|
8
8
|
flag: 's',
|
|
9
9
|
description: 'all appway servers',
|
|
10
10
|
default: ['http://localhost:8000']
|
|
11
|
-
@param.define 'app.name',
|
|
12
|
-
flag: 'a',
|
|
11
|
+
@param.define 'app.name', flag: 'a',
|
|
13
12
|
description: 'name of your app'
|
|
14
|
-
@param.define 'app.manifest',
|
|
15
|
-
flag: 'm',
|
|
13
|
+
@param.define 'app.manifest', flag: 'm',
|
|
16
14
|
description: 'path to your app.way file'
|
|
17
15
|
@param.define :debug, flag: 'd',
|
|
18
16
|
description: 'print debug info to stdout',
|
data/lib/xway/version.rb
CHANGED
|
@@ -1,89 +1,125 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
|
+
require 'xway/error'
|
|
2
3
|
require 'xway/api/endpoints'
|
|
3
4
|
require 'xway/api/request'
|
|
4
5
|
|
|
5
6
|
describe Xway::Api::Endpoints do
|
|
6
7
|
subject('endpoints') { described_class.new }
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
its('method_name') { should eq 'get' }
|
|
11
|
-
its('path') { should eq '/applications' }
|
|
12
|
-
its('headers') { should eq('X-App' => 'appway') }
|
|
13
|
-
its('body') { should eq(nil) }
|
|
9
|
+
specify 'list doesnt require_options' do
|
|
10
|
+
expect{ subject.list }.not_to raise_error(Xway::MissingParameter)
|
|
14
11
|
end
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let('manifest') { File.join(ASSETS_PATH, 'appway-example.json') }
|
|
18
|
-
subject { endpoints.create manifest: manifest }
|
|
19
|
-
its('method_name') { should eq 'post' }
|
|
20
|
-
its('path') { should eq '/applications' }
|
|
21
|
-
its('headers') { should eq('X-App' => 'appway',
|
|
22
|
-
'Content-Type' => 'application/json') }
|
|
23
|
-
its('body') { should be_kind_of(Xway::Api::Request::Body) }
|
|
12
|
+
specify 'create doesnt require_options' do
|
|
13
|
+
expect{ subject.create }.not_to raise_error(Xway::MissingParameter)
|
|
24
14
|
end
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
subject { endpoints.find app: 'foo' }
|
|
28
|
-
its('method_name') { should eq 'get' }
|
|
29
|
-
its('path') { should eq '/applications/foo' }
|
|
30
|
-
its('headers') { should eq('X-App' => 'appway') }
|
|
31
|
-
its('body') { should eq(nil) }
|
|
15
|
+
specify 'find does require_options' do
|
|
16
|
+
expect{ subject.find }.to raise_error(Xway::MissingParameter)
|
|
32
17
|
end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
subject { endpoints.update app: 'foo' }
|
|
36
|
-
its('method_name') { should eq 'put' }
|
|
37
|
-
its('path') { should eq '/applications/foo' }
|
|
38
|
-
its('headers') { should eq('X-App' => 'appway') }
|
|
39
|
-
its('body') { should eq(nil) }
|
|
18
|
+
specify 'update does require_options' do
|
|
19
|
+
expect{ subject.update }.to raise_error(Xway::MissingParameter)
|
|
40
20
|
end
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
subject { endpoints.delete app: 'foo' }
|
|
44
|
-
its('method_name') { should eq 'delete' }
|
|
45
|
-
its('path') { should eq '/applications/foo' }
|
|
46
|
-
its('headers') { should eq('X-App' => 'appway') }
|
|
47
|
-
its('body') { should eq(nil) }
|
|
21
|
+
specify 'delete does require_options' do
|
|
22
|
+
expect{ subject.delete }.to raise_error(Xway::MissingParameter)
|
|
48
23
|
end
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
subject { endpoints.log app: 'foo' }
|
|
52
|
-
its('method_name') { should eq 'get' }
|
|
53
|
-
its('path') { should eq '/applications/foo/log' }
|
|
54
|
-
its('headers') { should eq('X-App' => 'appway') }
|
|
55
|
-
its('body') { should eq(nil) }
|
|
24
|
+
specify 'log does require_options' do
|
|
25
|
+
expect{ subject.log }.to raise_error(Xway::MissingParameter)
|
|
56
26
|
end
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
subject { endpoints.start app: 'foo' }
|
|
60
|
-
its('method_name') { should eq 'post' }
|
|
61
|
-
its('path') { should eq '/applications/foo/start' }
|
|
62
|
-
its('headers') { should eq('X-App' => 'appway') }
|
|
63
|
-
its('body') { should eq(nil) }
|
|
27
|
+
specify 'start does require_options' do
|
|
28
|
+
expect{ subject.start }.to raise_error(Xway::MissingParameter)
|
|
64
29
|
end
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
subject { endpoints.stop app: 'foo' }
|
|
68
|
-
its('method_name') { should eq 'post' }
|
|
69
|
-
its('path') { should eq '/applications/foo/stop' }
|
|
70
|
-
its('headers') { should eq('X-App' => 'appway') }
|
|
71
|
-
its('body') { should eq(nil) }
|
|
30
|
+
specify 'stop does require_options' do
|
|
31
|
+
expect{ subject.stop }.to raise_error(Xway::MissingParameter)
|
|
72
32
|
end
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
subject { endpoints.restart app: 'foo' }
|
|
76
|
-
its('method_name') { should eq 'post' }
|
|
77
|
-
its('path') { should eq '/applications/foo/restart' }
|
|
78
|
-
its('headers') { should eq('X-App' => 'appway') }
|
|
79
|
-
its('body') { should eq(nil) }
|
|
33
|
+
specify 'restart does require_options' do
|
|
34
|
+
expect{ subject.restart }.to raise_error(Xway::MissingParameter)
|
|
80
35
|
end
|
|
36
|
+
specify 'redeploy does require_options' do
|
|
37
|
+
expect{ subject.redeploy }.to raise_error(Xway::MissingParameter)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
context 'mock require_options' do
|
|
41
|
+
before { endpoints.stub('require_options') }
|
|
42
|
+
|
|
43
|
+
describe 'list' do
|
|
44
|
+
subject { endpoints.list({}) }
|
|
45
|
+
its('method_name') { should eq 'get' }
|
|
46
|
+
its('path') { should eq '/applications' }
|
|
47
|
+
its('headers') { should eq('X-App' => 'appway') }
|
|
48
|
+
its('body') { should eq(nil) }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe 'create' do
|
|
52
|
+
let('manifest') { File.join(ASSETS_PATH, 'appway-example.json') }
|
|
53
|
+
subject { endpoints.create manifest: manifest }
|
|
54
|
+
its('method_name') { should eq 'post' }
|
|
55
|
+
its('path') { should eq '/applications' }
|
|
56
|
+
its('headers') { should eq('X-App' => 'appway',
|
|
57
|
+
'Content-Type' => 'application/json') }
|
|
58
|
+
its('body') { should be_kind_of(Xway::Api::Request::Body) }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe 'find' do
|
|
62
|
+
subject { endpoints.find name: 'foo' }
|
|
63
|
+
its('method_name') { should eq 'get' }
|
|
64
|
+
its('path') { should eq '/applications/foo' }
|
|
65
|
+
its('headers') { should eq('X-App' => 'appway') }
|
|
66
|
+
its('body') { should eq(nil) }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
describe 'update' do
|
|
70
|
+
subject { endpoints.update name: 'foo' }
|
|
71
|
+
its('method_name') { should eq 'put' }
|
|
72
|
+
its('path') { should eq '/applications/foo' }
|
|
73
|
+
its('headers') { should eq('X-App' => 'appway') }
|
|
74
|
+
its('body') { should eq(nil) }
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
describe 'delete' do
|
|
78
|
+
subject { endpoints.delete name: 'foo' }
|
|
79
|
+
its('method_name') { should eq 'delete' }
|
|
80
|
+
its('path') { should eq '/applications/foo' }
|
|
81
|
+
its('headers') { should eq('X-App' => 'appway') }
|
|
82
|
+
its('body') { should eq(nil) }
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe 'log' do
|
|
86
|
+
subject { endpoints.log name: 'foo' }
|
|
87
|
+
its('method_name') { should eq 'get' }
|
|
88
|
+
its('path') { should eq '/applications/foo/log' }
|
|
89
|
+
its('headers') { should eq('X-App' => 'appway') }
|
|
90
|
+
its('body') { should eq(nil) }
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
describe 'start' do
|
|
94
|
+
subject { endpoints.start name: 'foo' }
|
|
95
|
+
its('method_name') { should eq 'post' }
|
|
96
|
+
its('path') { should eq '/applications/foo/start' }
|
|
97
|
+
its('headers') { should eq('X-App' => 'appway') }
|
|
98
|
+
its('body') { should eq(nil) }
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
describe 'stop' do
|
|
102
|
+
subject { endpoints.stop name: 'foo' }
|
|
103
|
+
its('method_name') { should eq 'post' }
|
|
104
|
+
its('path') { should eq '/applications/foo/stop' }
|
|
105
|
+
its('headers') { should eq('X-App' => 'appway') }
|
|
106
|
+
its('body') { should eq(nil) }
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
describe 'restart' do
|
|
110
|
+
subject { endpoints.restart name: 'foo' }
|
|
111
|
+
its('method_name') { should eq 'post' }
|
|
112
|
+
its('path') { should eq '/applications/foo/restart' }
|
|
113
|
+
its('headers') { should eq('X-App' => 'appway') }
|
|
114
|
+
its('body') { should eq(nil) }
|
|
115
|
+
end
|
|
81
116
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
117
|
+
describe 'redeploy' do
|
|
118
|
+
subject { endpoints.redeploy name: 'foo' }
|
|
119
|
+
its('method_name') { should eq 'post' }
|
|
120
|
+
its('path') { should eq '/applications/foo/redeploy' }
|
|
121
|
+
its('headers') { should eq('X-App' => 'appway') }
|
|
122
|
+
its('body') { should eq(nil) }
|
|
123
|
+
end
|
|
88
124
|
end
|
|
89
125
|
end
|
|
@@ -15,7 +15,7 @@ describe Xway::Api::Http do
|
|
|
15
15
|
it 'wraps errors' do
|
|
16
16
|
HTTParty.stub('get') { raise StandardError, 'foo' }
|
|
17
17
|
expect { subject.request 'http://foo', request }.to\
|
|
18
|
-
raise_error(Xway::
|
|
18
|
+
raise_error(Xway::ConnectionError)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
describe 'calls HTTParty' do
|
|
@@ -63,7 +63,6 @@ describe Xway::Parameter do
|
|
|
63
63
|
|
|
64
64
|
it 'defines app.name' do
|
|
65
65
|
param.should_receive('define').with('app.name',
|
|
66
|
-
type: String,
|
|
67
66
|
flag: 'a',
|
|
68
67
|
description: 'name of your app')
|
|
69
68
|
subject.reload!
|
|
@@ -71,7 +70,6 @@ describe Xway::Parameter do
|
|
|
71
70
|
|
|
72
71
|
it 'defines app.manifest' do
|
|
73
72
|
param.should_receive('define').with('app.manifest',
|
|
74
|
-
type: String,
|
|
75
73
|
flag: 'm',
|
|
76
74
|
description: 'path to your app.way file')
|
|
77
75
|
subject.reload!
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: xway
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2.beta
|
|
5
5
|
prerelease: 6
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-05-
|
|
12
|
+
date: 2013-05-13 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: configliere
|