turbot-api 0.0.3 → 0.0.4

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NjU2MDg2NjAxMmU0NjYxYTk2ODY2Y2UxYWJiZDBhZWUxMThkY2ZhNw==
4
+ Y2JmZTI2YTYwMmNmYTc3YWQ2N2FlY2I4NjBmNjI3YTZkMDYxOWI3NA==
5
5
  data.tar.gz: !binary |-
6
- MThmYjQ4MmFhYTVjYjFmMDk2NmFjNzE0YjA1NzJjODA4YzQxOTNkNQ==
6
+ ZThlMmExNzUyMGY5MmYwMzg4YzJjYzNmZjIyNmYwNWIzOWMwYzNkZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTA4NDAzNDNlZWE0ZTY1YjJmMGZmZTljZTAzNDExMmU1YTVkNzczYmJiMjMz
10
- NTlhNmUzOGVlZDBjMjUxZGRiZmUxY2I2ZGViNDE2ZDNlZDNjZDIwYTlmZjY5
11
- YmVmYzAxY2RkZTA4MTZmZTllNjc3NTY5YmMxZTQwYWZkNzgyNDQ=
9
+ ZThjZmMyNzkxNDJiZTYyZTQ2YjM5MDVlMWZkMDc1ZGUzNWVhNmZkNWQwNGJm
10
+ MzUzNmQyZmVlMGQxZTcyNTMwMGUzMjk1ZTg1MGQ1MzA2ZWU1YjY1MGRlZDk3
11
+ OTE4YTRiNjM2YjNlNTM2OWY1ZWU0OWFlMmE4MTIyOGRlZWE4NzQ=
12
12
  data.tar.gz: !binary |-
13
- MmI2NjA4OGYzY2M5YjMyMTFjZmZhYjVkYjBlMzc4MzNhMjEyOGMyMWU4M2Qz
14
- Y2ZhYWM0OGRjYzBiMDdkOTIxYWNhMDJlZDIwZTdmNDBkYmQ0NGQyYjAxMjM3
15
- MWMxZDhlODRmNDE4ZTI0NzY3ZTcwNzhhMjk5MjljNzkwMzYwY2I=
13
+ NTI2NjJiMWI2ZGY2OGQ1M2FlMjU3YjY0MmFiNzdhZDdmNjUwYzEwZDU1ZmE0
14
+ OGFlODY3ZDJjOWZiODkxZGFjMTMzNzhlMTA5YTRkMzA5ZmU4ODI2MTA5MTQ2
15
+ N2IwOTc4OTFmODNjMjk0MTI3ZTg1YTgzNTVmNWJiMGFhNzRhOTY=
@@ -22,6 +22,9 @@ module Turbot
22
22
  resources :bots, :only => [:index, :create] do
23
23
  resource :code, :only => [:update], :controller => 'code'
24
24
  resource :draft_data, :only => [:update]
25
+
26
+ post 'run/start', :to => 'api/runs#start'
27
+ post 'run/stop', :to => 'api/runs#stop'
25
28
  end
26
29
 
27
30
  resource :user, :only => [:show] do
@@ -73,6 +76,14 @@ module Turbot
73
76
  request(:put, :bot_code, :bot_id => bot_id, :archive => archive)
74
77
  end
75
78
 
79
+ def start_run(bot_id)
80
+ request(:post, :bot_run_start, :bot_id => bot_id)
81
+ end
82
+
83
+ def stop_run(bot_id)
84
+ request(:post, :bot_run_stop, :bot_id => bot_id)
85
+ end
86
+
76
87
  def get_ssh_keys
77
88
  []
78
89
  end
@@ -100,7 +111,7 @@ module Turbot
100
111
  begin
101
112
  url = @routes.url_helpers.send("api_#{named_route}_url")
102
113
  rescue ActionController::UrlGenerationError
103
- url = @routes.url_helpers.send("api_#{named_route}_url", :bot_id => params[:bot_id])
114
+ url = @routes.url_helpers.send("api_#{named_route}_url", :bot_id => params.delete(:bot_id))
104
115
  end
105
116
 
106
117
  begin
@@ -1,3 +1,3 @@
1
1
  module Turbot
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/spec/api_spec.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'turbot_api'
2
+
3
+ describe Turbot::API do
4
+ before do
5
+ @api = Turbot::API.new(:api_key => 'key', :host => 'http://example.com')
6
+ end
7
+
8
+ describe '#start_run' do
9
+ it 'starts a run' do
10
+ RestClient.should_receive(:post).
11
+ with('http://example.com/api/bots/test-bot/run/start', :api_key => 'key').
12
+ and_return(double(:body => {}.to_json))
13
+ @api.start_run('test-bot')
14
+ end
15
+ end
16
+
17
+ describe '#stop_run' do
18
+ it 'stops a run' do
19
+ RestClient.should_receive(:post).
20
+ with('http://example.com/api/bots/test-bot/run/stop', :api_key => 'key').
21
+ and_return(double(:body => {}.to_json))
22
+ @api.stop_run('test-bot')
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbot-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Turbot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-03 00:00:00.000000000 Z
11
+ date: 2014-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -63,6 +63,7 @@ files:
63
63
  - lib/turbot_api/api.rb
64
64
  - lib/turbot_api/errors.rb
65
65
  - lib/turbot_api/version.rb
66
+ - spec/api_spec.rb
66
67
  homepage: http://opencorporates.com/
67
68
  licenses:
68
69
  - MIT