turbot 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/turbot/command.rb +3 -2
- data/lib/turbot/command/bots.rb +27 -13
- data/lib/turbot/version.rb +1 -1
- data/templates/LICENSE.txt +22 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTQzMWUxY2MwYjQzYTZlYjhlMDIxZDRjYjk4MTU0NjI1MzFmYTYwMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YThhNWFlNTA3ZDFhMTVlYmUwYTk5MDQyNmE2MGM3ZDU0ODVkOGZlNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGUyZmVlNGRlNzExZjdkOTk2NDdiM2Q3YWY2OWY3NGFjYWVjN2RlNTVlY2Fj
|
10
|
+
YjhkN2FjNzkzZDliODljZmE1ZDhjNDRlMWFiNGQ4M2NkYWFhMjlhODI4Yzcy
|
11
|
+
N2IzZjU4NDk3YWQxYjU5ZTRjZGQ4ZWFjNTVlMDlmMDAyYWE0MGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2NhNjVlMGMzMjgzNTQ3YTU2YTAyYTdlNGNmOTNlMzNhODZjZmU5ODY4MDE1
|
14
|
+
ZWRlMjk4M2ViYmUxNmEzZjRmNWE3YTQyMDM0ZDZjNGNlZmY1ZThhMzgyZDgx
|
15
|
+
ZDQ4YTEzMGRjY2ZiMjQzMDEyODZkMmU1MzEwMTI5NDcxNGI5MGU=
|
data/lib/turbot/command.rb
CHANGED
@@ -230,8 +230,6 @@ module Turbot
|
|
230
230
|
run "login"
|
231
231
|
retry
|
232
232
|
end
|
233
|
-
rescue Turbot::API::Errors::VerificationRequired, RestClient::PaymentRequired => e
|
234
|
-
retry if Turbot::Helpers.confirm_billing
|
235
233
|
rescue Turbot::API::Errors::NotFound => e
|
236
234
|
error extract_error(e.response.body) {
|
237
235
|
e.response.body =~ /^([\w\s]+ not found).?$/ ? $1 : "Resource not found"
|
@@ -252,6 +250,9 @@ module Turbot
|
|
252
250
|
arguments << '--confirm' << bot
|
253
251
|
retry
|
254
252
|
end
|
253
|
+
rescue RestClient::PaymentRequired => e
|
254
|
+
# We've repurposed a 402 as a general error
|
255
|
+
error extract_error(e.http_body)
|
255
256
|
rescue Turbot::API::Errors::Timeout, RestClient::RequestTimeout
|
256
257
|
error "API request timed out. Please try again, or contact support@turbot.com if this issue persists."
|
257
258
|
rescue Turbot::API::Errors::ErrorWithResponse => e
|
data/lib/turbot/command/bots.rb
CHANGED
@@ -24,10 +24,10 @@ class Turbot::Command::Bots < Turbot::Command::Base
|
|
24
24
|
#
|
25
25
|
def index
|
26
26
|
validate_arguments!
|
27
|
-
bots = api.list_bots
|
27
|
+
bots = api.list_bots.data
|
28
28
|
unless bots.empty?
|
29
29
|
styled_header("Bots")
|
30
|
-
styled_array(bots.map{|bot| bot[
|
30
|
+
styled_array(bots.map{|bot| bot[:bot_id]})
|
31
31
|
else
|
32
32
|
display("You have no bots.")
|
33
33
|
end
|
@@ -92,7 +92,6 @@ class Turbot::Command::Bots < Turbot::Command::Base
|
|
92
92
|
# Created new bot template at my_amazing_bot!
|
93
93
|
|
94
94
|
def generate
|
95
|
-
puts "running generate"
|
96
95
|
validate_arguments!
|
97
96
|
language = options[:language] || "ruby"
|
98
97
|
puts "Generating #{language} code..."
|
@@ -105,18 +104,25 @@ class Turbot::Command::Bots < Turbot::Command::Base
|
|
105
104
|
end
|
106
105
|
manifest_template = File.expand_path("../../../../templates/manifest.json", __FILE__)
|
107
106
|
scraper_template = File.expand_path("../../../../templates/#{scraper}", __FILE__)
|
107
|
+
license_template = File.expand_path("../../../../templates/LICENSE.txt", __FILE__)
|
108
108
|
manifest = JSON.parse(open(manifest_template).read.sub(/{{bot_id}}/, bot))
|
109
109
|
|
110
110
|
FileUtils.cp(scraper_template, "#{bot}/#{scraper}")
|
111
|
+
FileUtils.cp(license_template, "#{bot}/LICENSE.txt")
|
111
112
|
open("#{bot}/manifest.json", "w") do |f|
|
112
113
|
f.write(manifest.to_json)
|
113
114
|
end
|
114
115
|
|
115
|
-
api.create_bot(bot, manifest)
|
116
|
+
response = api.create_bot(bot, manifest)
|
116
117
|
|
117
|
-
|
118
|
-
|
119
|
-
|
118
|
+
case response
|
119
|
+
when Turbot::API::SuccessResponse
|
120
|
+
display("Created new bot template at #{bot}!")
|
121
|
+
when Turbot::API::FailureResponse
|
122
|
+
display('Could not create new bot')
|
123
|
+
display(response.message)
|
124
|
+
FileUtils.rm_r(bot)
|
125
|
+
end
|
120
126
|
end
|
121
127
|
|
122
128
|
|
@@ -142,9 +148,17 @@ class Turbot::Command::Bots < Turbot::Command::Base
|
|
142
148
|
manifest['files'].each { |f| zipfile.add(f, File.join(working_dir,f)) }
|
143
149
|
end
|
144
150
|
|
145
|
-
File.open(archive_path) do |file|
|
151
|
+
response = File.open(archive_path) do |file|
|
146
152
|
api.update_code(bot, file)
|
147
153
|
end
|
154
|
+
|
155
|
+
case response
|
156
|
+
when Turbot::API::SuccessResponse
|
157
|
+
display('Successfully pushed bot code')
|
158
|
+
when Turbot::API::FailureResponse
|
159
|
+
display('Failed to push bot code')
|
160
|
+
display(response.message)
|
161
|
+
end
|
148
162
|
end
|
149
163
|
|
150
164
|
alias_command "push", "bots:push"
|
@@ -255,16 +269,16 @@ class Turbot::Command::Bots < Turbot::Command::Base
|
|
255
269
|
batch << JSON.parse(line)
|
256
270
|
spinner(count)
|
257
271
|
if count % 20 == 0
|
258
|
-
result = api.update_draft_data(bot, config, batch.to_json)
|
272
|
+
result = api.update_draft_data(bot, config, batch.to_json).data
|
259
273
|
batch = []
|
260
274
|
end
|
261
275
|
count += 1
|
262
276
|
end
|
263
277
|
if !batch.empty?
|
264
|
-
result = api.update_draft_data(bot, config, batch.to_json)
|
278
|
+
result = api.update_draft_data(bot, config, batch.to_json).data
|
265
279
|
end
|
266
280
|
puts "Sent #{count} records."
|
267
|
-
puts "View your records at #{result[
|
281
|
+
puts "View your records at #{result[:url]}"
|
268
282
|
end
|
269
283
|
|
270
284
|
private
|
@@ -324,7 +338,7 @@ class Turbot::Command::Bots < Turbot::Command::Base
|
|
324
338
|
end
|
325
339
|
|
326
340
|
def scraper_file(dir)
|
327
|
-
Dir.glob("scraper*").first
|
341
|
+
Dir.glob("scraper*").reject{|n| !n.match(/(rb|py)$/)}.first
|
328
342
|
end
|
329
343
|
|
330
344
|
def manifest_path
|
@@ -333,6 +347,6 @@ class Turbot::Command::Bots < Turbot::Command::Base
|
|
333
347
|
|
334
348
|
def get_schema(type)
|
335
349
|
hyphenated_name = type.to_s.gsub("_", "-").gsub(" ", "-")
|
336
|
-
|
350
|
+
File.expand_path("../../../../schema/schemas/#{hyphenated_name}-schema.json", __FILE__)
|
337
351
|
end
|
338
352
|
end
|
data/lib/turbot/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) <date> <your name here>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
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-
|
11
|
+
date: 2014-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: netrc
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: turbot-api
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 0.0.3
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 0.0.3
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: excon
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,6 +195,7 @@ files:
|
|
195
195
|
- spec/turbot/helpers_spec.rb
|
196
196
|
- spec/turbot/plugin_spec.rb
|
197
197
|
- spec/turbot/updater_spec.rb
|
198
|
+
- templates/LICENSE.txt
|
198
199
|
- templates/manifest.json
|
199
200
|
- templates/scraper.py
|
200
201
|
- templates/scraper.rb
|