mortar-api-ruby 0.1.0 → 0.2.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/Gemfile.lock CHANGED
@@ -9,6 +9,7 @@ GEM
9
9
  specs:
10
10
  diff-lcs (1.1.3)
11
11
  excon (0.15.4)
12
+ gem-release (0.4.1)
12
13
  rake (0.9.2.2)
13
14
  rr (1.0.4)
14
15
  rspec (2.11.0)
@@ -24,6 +25,7 @@ PLATFORMS
24
25
  ruby
25
26
 
26
27
  DEPENDENCIES
28
+ gem-release
27
29
  mortar-api-ruby!
28
30
  rake
29
31
  rr
@@ -32,11 +32,13 @@ module Mortar
32
32
  end
33
33
  end
34
34
 
35
+ class BadRequest < ErrorWithResponse; end
35
36
  class Unauthorized < ErrorWithResponse; end
36
37
  class VerificationRequired < ErrorWithResponse; end
37
38
  class Forbidden < ErrorWithResponse; end
38
39
  class NotFound < ErrorWithResponse; end
39
40
  class Timeout < ErrorWithResponse; end
41
+ class Conflict < ErrorWithResponse; end
40
42
  class Locked < ErrorWithResponse; end
41
43
  class RequestFailed < ErrorWithResponse; end
42
44
  end
@@ -99,5 +99,14 @@ module Mortar
99
99
  :path => versioned_path("/jobs/#{job_id}")
100
100
  )
101
101
  end
102
+
103
+ # DELETE /v2/jobs/:job_id
104
+ def stop_job(job_id)
105
+ request(
106
+ :expects => 200,
107
+ :method => :delete,
108
+ :path => versioned_path("/jobs/#{job_id}")
109
+ )
110
+ end
102
111
  end
103
112
  end
@@ -18,7 +18,7 @@ module Mortar
18
18
  class API
19
19
  # client version
20
20
  # see http://semver.org/
21
- VERSION = "0.1.0"
21
+ VERSION = "0.2.0"
22
22
 
23
23
  SERVER_API_VERSION = "2"
24
24
  end
data/lib/mortar/api.rb CHANGED
@@ -80,11 +80,13 @@ module Mortar
80
80
  response = @connection.request(params, &block)
81
81
  rescue Excon::Errors::HTTPStatusError => error
82
82
  klass = case error.response.status
83
+ when 400 then Mortar::API::Errors::BadRequest
83
84
  when 401 then Mortar::API::Errors::Unauthorized
84
85
  when 402 then Mortar::API::Errors::VerificationRequired
85
86
  when 403 then Mortar::API::Errors::Forbidden
86
87
  when 404 then Mortar::API::Errors::NotFound
87
88
  when 408 then Mortar::API::Errors::Timeout
89
+ when 409 then Mortar::API::Errors::Conflict
88
90
  when 422 then Mortar::API::Errors::RequestFailed
89
91
  when 423 then Mortar::API::Errors::Locked
90
92
  when /50./ then Mortar::API::Errors::RequestFailed
@@ -108,5 +108,13 @@ describe Mortar::API do
108
108
  jobs.length.should == 2
109
109
  end
110
110
 
111
+ it "stops a running job" do
112
+ job_id = "1234abc342221abc"
113
+ Excon.stub({:method => :delete, :path => "/v2/jobs/#{job_id}"}) do |params|
114
+ {:body => Mortar::API::OkJson.encode({"success" => true}), :status => 200}
115
+ end
116
+ response = @api.stop_job(job_id)
117
+ response.body["success"].should be_true
118
+ end
111
119
  end
112
120
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mortar-api-ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mortar Data
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-08-30 00:00:00 Z
18
+ date: 2012-08-31 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: excon