turbot 0.0.22 → 0.0.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/turbot/command/bots.rb +46 -28
- data/lib/turbot/version.rb +1 -1
- metadata +22 -44
- data/lib/turbot/command/config.rb +0 -123
- data/lib/turbot/command/keys.rb +0 -115
- data/lib/turbot/command/logs.rb +0 -34
- data/lib/turbot/command/status.rb +0 -50
- data/lib/turbot/command/update.rb +0 -47
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OTFkYjQ5ODY3ZGNiNjY1OWZiZjUxNDI0ODIzZjY5ZDVkNjQ3MTY4Yg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MGZlYWVkODdhNmE2ZmRmMTI5ODI4Y2E3ZWY4NmNjZjQwNjgzYzJkZA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NTkzODA2NjM4OWE3ZTkwNGE2NWQ1NTE5NDJkY2JmYTY0MjJlNzY1MWFkODM2
|
10
|
+
ZDQzZTA0YmM2MTc4ODhkZGI0ZDQ5ZjE0ODllOTAwYmM0ZWU1NzdlNzVmOTQ4
|
11
|
+
MGY1OTVlZDM4OWNhNjA3ZWFiYjY0MTIwNTc1ZjczOWQ1NzE1Mjk=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YzgyNmMzZGI2OTg2MzRhMWMzZTdmNjA3MjU5MjYwYWM2ZDVjOGM3NTk0YmYy
|
14
|
+
NGRmMGNkY2JkMDFiYzE0MDg4MGY3YmFmY2FiN2EzYjM5NDMwNjJkNzZkNzYx
|
15
|
+
YTIxNDc5Y2M0OTg4N2M4NTgwYjBhMjkxZmU2OWNmZTRiMmI4MDM=
|
data/lib/turbot/command/bots.rb
CHANGED
@@ -7,7 +7,7 @@ require 'open3'
|
|
7
7
|
require 'base64'
|
8
8
|
require 'shellwords'
|
9
9
|
|
10
|
-
# manage bots (create,
|
10
|
+
# manage bots (create, submit data and code)
|
11
11
|
#
|
12
12
|
class Turbot::Command::Bots < Turbot::Command::Base
|
13
13
|
|
@@ -209,7 +209,8 @@ class Turbot::Command::Bots < Turbot::Command::Base
|
|
209
209
|
end
|
210
210
|
puts line if opts[:dump]
|
211
211
|
if JSON.parse(line).slice(*config['identifying_fields']).blank?
|
212
|
-
error
|
212
|
+
error = "Couldn't find any of #{config['identifying_fields']}"
|
213
|
+
error("LINE WITH ERROR: #{line}\n\nERRORS: #{error}")
|
213
214
|
end
|
214
215
|
|
215
216
|
count += 1
|
@@ -229,28 +230,28 @@ class Turbot::Command::Bots < Turbot::Command::Base
|
|
229
230
|
validate(:dump => true)
|
230
231
|
end
|
231
232
|
|
232
|
-
# bots:single
|
233
|
-
#
|
234
|
-
# Execute bot in same way as OpenCorporates single-record update
|
235
|
-
#
|
236
|
-
# $ heroku bots:single
|
237
|
-
# Enter argument (as JSON object):
|
238
|
-
# {"id": "frob123"}
|
239
|
-
# {"id": "frob123", "stuff": "updated-data-for-this-record"}
|
240
|
-
|
241
|
-
def single
|
242
|
-
# This will need to be language-aware, eventually
|
243
|
-
scraper_path = shift_argument || scraper_file(Dir.pwd)
|
244
|
-
validate_arguments!
|
245
|
-
print 'Arguments (as JSON object, e.g. {"id":"ABC123"}: '
|
246
|
-
arg = ask
|
247
|
-
count = 0
|
248
|
-
run_scraper_each_line("#{scraper_path} #{bot} #{Shellwords.shellescape(arg)}") do |line|
|
249
|
-
raise "Your scraper returned more than one value!" if count > 1
|
250
|
-
puts line
|
251
|
-
count += 1
|
252
|
-
end
|
253
|
-
end
|
233
|
+
# # bots:single
|
234
|
+
# #
|
235
|
+
# # Execute bot in same way as OpenCorporates single-record update
|
236
|
+
# #
|
237
|
+
# # $ heroku bots:single
|
238
|
+
# # Enter argument (as JSON object):
|
239
|
+
# # {"id": "frob123"}
|
240
|
+
# # {"id": "frob123", "stuff": "updated-data-for-this-record"}
|
241
|
+
#
|
242
|
+
# def single
|
243
|
+
# # This will need to be language-aware, eventually
|
244
|
+
# scraper_path = shift_argument || scraper_file(Dir.pwd)
|
245
|
+
# validate_arguments!
|
246
|
+
# print 'Arguments (as JSON object, e.g. {"id":"ABC123"}: '
|
247
|
+
# arg = ask
|
248
|
+
# count = 0
|
249
|
+
# run_scraper_each_line("#{scraper_path} #{bot} #{Shellwords.shellescape(arg)}") do |line|
|
250
|
+
# raise "Your scraper returned more than one value!" if count > 1
|
251
|
+
# puts line
|
252
|
+
# count += 1
|
253
|
+
# end
|
254
|
+
# end
|
254
255
|
|
255
256
|
|
256
257
|
# bots:preview
|
@@ -269,14 +270,31 @@ class Turbot::Command::Bots < Turbot::Command::Base
|
|
269
270
|
|
270
271
|
api.destroy_draft_data(bot)
|
271
272
|
|
273
|
+
type = config["data_type"]
|
274
|
+
schema = get_schema(type)
|
275
|
+
|
272
276
|
result = ""
|
273
277
|
run_scraper_each_line("#{scraper_path} #{bot}") do |line|
|
274
|
-
batch << JSON.parse(line)
|
275
278
|
spinner(count)
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
+
|
280
|
+
errors = JSON::Validator.fully_validate(
|
281
|
+
schema,
|
282
|
+
line,
|
283
|
+
{:errors_as_objects => true})
|
284
|
+
|
285
|
+
if errors.empty?
|
286
|
+
batch << JSON.parse(line)
|
287
|
+
if count % 20 == 0
|
288
|
+
result = api.create_draft_data(bot, config, batch.to_json)
|
289
|
+
batch = []
|
290
|
+
end
|
291
|
+
else
|
292
|
+
puts "The following record was not sent to turbot because it didn't validate against the schema:"
|
293
|
+
puts line
|
294
|
+
puts "The validation error was:"
|
295
|
+
puts errors
|
279
296
|
end
|
297
|
+
|
280
298
|
count += 1
|
281
299
|
end
|
282
300
|
if !batch.empty?
|
data/lib/turbot/version.rb
CHANGED
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.23
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Turbot
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-14 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: netrc
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rest-client
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: launchy
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rubyzip
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ! '>='
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ! '>='
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: json-schema
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ! '>='
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :runtime
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ! '>='
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,7 +83,6 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: activesupport
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - '='
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,6 @@ dependencies:
|
|
102
90
|
type: :runtime
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - '='
|
108
95
|
- !ruby/object:Gem::Version
|
@@ -110,7 +97,6 @@ dependencies:
|
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: turbot-api
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
101
|
- - '='
|
116
102
|
- !ruby/object:Gem::Version
|
@@ -118,7 +104,6 @@ dependencies:
|
|
118
104
|
type: :runtime
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
108
|
- - '='
|
124
109
|
- !ruby/object:Gem::Version
|
@@ -126,7 +111,6 @@ dependencies:
|
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: excon
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
115
|
- - ! '>='
|
132
116
|
- !ruby/object:Gem::Version
|
@@ -134,7 +118,6 @@ dependencies:
|
|
134
118
|
type: :runtime
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
122
|
- - ! '>='
|
140
123
|
- !ruby/object:Gem::Version
|
@@ -162,13 +145,8 @@ files:
|
|
162
145
|
- lib/turbot/command/auth.rb
|
163
146
|
- lib/turbot/command/base.rb
|
164
147
|
- lib/turbot/command/bots.rb
|
165
|
-
- lib/turbot/command/config.rb
|
166
148
|
- lib/turbot/command/help.rb
|
167
|
-
- lib/turbot/command/keys.rb
|
168
|
-
- lib/turbot/command/logs.rb
|
169
149
|
- lib/turbot/command/ssl.rb
|
170
|
-
- lib/turbot/command/status.rb
|
171
|
-
- lib/turbot/command/update.rb
|
172
150
|
- lib/turbot/command/version.rb
|
173
151
|
- lib/turbot/deprecated.rb
|
174
152
|
- lib/turbot/deprecated/help.rb
|
@@ -183,6 +161,22 @@ files:
|
|
183
161
|
- lib/turbot/updater.rb
|
184
162
|
- lib/turbot/version.rb
|
185
163
|
- lib/vendor/turbot/okjson.rb
|
164
|
+
- schema/schemas/company-schema.json
|
165
|
+
- schema/schemas/includes/address.json
|
166
|
+
- schema/schemas/includes/base-statement.json
|
167
|
+
- schema/schemas/includes/company.json
|
168
|
+
- schema/schemas/includes/filing.json
|
169
|
+
- schema/schemas/includes/license-data.json
|
170
|
+
- schema/schemas/includes/officer.json
|
171
|
+
- schema/schemas/includes/previous_name.json
|
172
|
+
- schema/schemas/includes/share-parcel-data.json
|
173
|
+
- schema/schemas/includes/share-parcel.json
|
174
|
+
- schema/schemas/includes/subsidiary-relationship-data.json
|
175
|
+
- schema/schemas/includes/total-shares.json
|
176
|
+
- schema/schemas/licence-schema.json
|
177
|
+
- schema/schemas/primary-data-schema.json
|
178
|
+
- schema/schemas/share-parcel-schema.json
|
179
|
+
- schema/schemas/subsidiary-relationship-schema.json
|
186
180
|
- spec/helper/legacy_help.rb
|
187
181
|
- spec/helper/pg_dump_restore_spec.rb
|
188
182
|
- spec/schemas/dummy_schema.json
|
@@ -216,45 +210,29 @@ files:
|
|
216
210
|
- templates/manifest.json
|
217
211
|
- templates/python/scraper.py
|
218
212
|
- templates/ruby/scraper.rb
|
219
|
-
- schema/schemas/company-schema.json
|
220
|
-
- schema/schemas/includes/address.json
|
221
|
-
- schema/schemas/includes/base-statement.json
|
222
|
-
- schema/schemas/includes/company.json
|
223
|
-
- schema/schemas/includes/filing.json
|
224
|
-
- schema/schemas/includes/license-data.json
|
225
|
-
- schema/schemas/includes/officer.json
|
226
|
-
- schema/schemas/includes/previous_name.json
|
227
|
-
- schema/schemas/includes/share-parcel-data.json
|
228
|
-
- schema/schemas/includes/share-parcel.json
|
229
|
-
- schema/schemas/includes/subsidiary-relationship-data.json
|
230
|
-
- schema/schemas/includes/total-shares.json
|
231
|
-
- schema/schemas/licence-schema.json
|
232
|
-
- schema/schemas/primary-data-schema.json
|
233
|
-
- schema/schemas/share-parcel-schema.json
|
234
|
-
- schema/schemas/subsidiary-relationship-schema.json
|
235
213
|
homepage: http://turbot.com/
|
236
214
|
licenses:
|
237
215
|
- MIT
|
216
|
+
metadata: {}
|
238
217
|
post_install_message:
|
239
218
|
rdoc_options: []
|
240
219
|
require_paths:
|
241
220
|
- lib
|
242
221
|
required_ruby_version: !ruby/object:Gem::Requirement
|
243
|
-
none: false
|
244
222
|
requirements:
|
245
223
|
- - ! '>='
|
246
224
|
- !ruby/object:Gem::Version
|
247
225
|
version: 1.9.2
|
248
226
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
249
|
-
none: false
|
250
227
|
requirements:
|
251
228
|
- - ! '>='
|
252
229
|
- !ruby/object:Gem::Version
|
253
230
|
version: '0'
|
254
231
|
requirements: []
|
255
232
|
rubyforge_project:
|
256
|
-
rubygems_version:
|
233
|
+
rubygems_version: 2.2.2
|
257
234
|
signing_key:
|
258
|
-
specification_version:
|
235
|
+
specification_version: 4
|
259
236
|
summary: Client library and CLI to deploy apps on Turbot.
|
260
237
|
test_files: []
|
238
|
+
has_rdoc:
|
@@ -1,123 +0,0 @@
|
|
1
|
-
require "turbot/command/base"
|
2
|
-
|
3
|
-
# manage bot config vars
|
4
|
-
#
|
5
|
-
class Turbot::Command::Config < Turbot::Command::Base
|
6
|
-
|
7
|
-
# config
|
8
|
-
#
|
9
|
-
# display the config vars for an bot
|
10
|
-
#
|
11
|
-
# -s, --shell # output config vars in shell format
|
12
|
-
#
|
13
|
-
#Examples:
|
14
|
-
#
|
15
|
-
# $ turbot config
|
16
|
-
# A: one
|
17
|
-
# B: two
|
18
|
-
#
|
19
|
-
# $ turbot config --shell
|
20
|
-
# A=one
|
21
|
-
# B=two
|
22
|
-
#
|
23
|
-
def index
|
24
|
-
validate_arguments!
|
25
|
-
|
26
|
-
vars = api.get_config_vars(bot)
|
27
|
-
if vars.empty?
|
28
|
-
display("#{bot} has no config vars.")
|
29
|
-
else
|
30
|
-
vars.each {|key, value| vars[key] = value.to_s.strip}
|
31
|
-
if options[:shell]
|
32
|
-
vars.keys.sort.each do |key|
|
33
|
-
display(%{#{key}=#{vars[key]}})
|
34
|
-
end
|
35
|
-
else
|
36
|
-
styled_header("#{bot} Config Vars")
|
37
|
-
styled_hash(vars)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# config:set KEY1=VALUE1 [KEY2=VALUE2 ...]
|
43
|
-
#
|
44
|
-
# set one or more config vars
|
45
|
-
#
|
46
|
-
#Example:
|
47
|
-
#
|
48
|
-
# $ turbot config:set A=one
|
49
|
-
# Setting config vars and restarting example... done, v123
|
50
|
-
# A: one
|
51
|
-
#
|
52
|
-
# $ turbot config:set A=one B=two
|
53
|
-
# Setting config vars and restarting example... done, v123
|
54
|
-
# A: one
|
55
|
-
# B: two
|
56
|
-
#
|
57
|
-
def set
|
58
|
-
unless args.size > 0 and args.all? { |a| a.include?('=') }
|
59
|
-
error("Usage: turbot config:set KEY1=VALUE1 [KEY2=VALUE2 ...]\nMust specify KEY and VALUE to set.")
|
60
|
-
end
|
61
|
-
|
62
|
-
vars = args.inject({}) do |vars, arg|
|
63
|
-
key, value = arg.split('=', 2)
|
64
|
-
vars[key] = value
|
65
|
-
vars
|
66
|
-
end
|
67
|
-
|
68
|
-
action("Setting config vars and restarting #{bot}") do
|
69
|
-
api.put_config_vars(bot, vars)
|
70
|
-
end
|
71
|
-
|
72
|
-
vars.each {|key, value| vars[key] = value.to_s}
|
73
|
-
styled_hash(vars)
|
74
|
-
end
|
75
|
-
|
76
|
-
alias_command "config:add", "config:set"
|
77
|
-
|
78
|
-
# config:get KEY
|
79
|
-
#
|
80
|
-
# display a config value for an bot
|
81
|
-
#
|
82
|
-
#Examples:
|
83
|
-
#
|
84
|
-
# $ turbot config:get A
|
85
|
-
# one
|
86
|
-
#
|
87
|
-
def get
|
88
|
-
unless key = shift_argument
|
89
|
-
error("Usage: turbot config:get KEY\nMust specify KEY.")
|
90
|
-
end
|
91
|
-
validate_arguments!
|
92
|
-
|
93
|
-
vars = api.get_config_vars(bot)
|
94
|
-
key, value = vars.detect {|k,v| k == key}
|
95
|
-
display(value.to_s)
|
96
|
-
end
|
97
|
-
|
98
|
-
# config:unset KEY1 [KEY2 ...]
|
99
|
-
#
|
100
|
-
# unset one or more config vars
|
101
|
-
#
|
102
|
-
# $ turbot config:unset A
|
103
|
-
# Unsetting A and restarting example... done, v123
|
104
|
-
#
|
105
|
-
# $ turbot config:unset A B
|
106
|
-
# Unsetting A and restarting example... done, v123
|
107
|
-
# Unsetting B and restarting example... done, v124
|
108
|
-
#
|
109
|
-
def unset
|
110
|
-
if args.empty?
|
111
|
-
error("Usage: turbot config:unset KEY1 [KEY2 ...]\nMust specify KEY to unset.")
|
112
|
-
end
|
113
|
-
|
114
|
-
args.each do |key|
|
115
|
-
action("Unsetting #{key} and restarting #{bot}") do
|
116
|
-
api.delete_config_var(bot, key)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
alias_command "config:remove", "config:unset"
|
122
|
-
|
123
|
-
end
|
data/lib/turbot/command/keys.rb
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
require "turbot/command/base"
|
2
|
-
|
3
|
-
module Turbot::Command
|
4
|
-
|
5
|
-
# manage authentication keys
|
6
|
-
#
|
7
|
-
class Keys < Base
|
8
|
-
|
9
|
-
# keys
|
10
|
-
#
|
11
|
-
# display keys for the current user
|
12
|
-
#
|
13
|
-
# -l, --long # display extended information for each key
|
14
|
-
#
|
15
|
-
#Examples:
|
16
|
-
#
|
17
|
-
# $ turbot keys
|
18
|
-
# === email@example.com Keys
|
19
|
-
# ssh-rsa ABCDEFGHIJK...OPQRSTUV== email@example.com
|
20
|
-
#
|
21
|
-
# $ turbot keys --long
|
22
|
-
# === email@example.com Keys
|
23
|
-
# ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAp9AJD5QABmOcrkHm6SINuQkDefaR0MUrfgZ1Pxir3a4fM1fwa00dsUwbUaRuR7FEFD8n1E9WwDf8SwQTHtyZsJg09G9myNqUzkYXCmydN7oGr5IdVhRyv5ixcdiE0hj7dRnOJg2poSQ3Qi+Ka8SVJzF7nIw1YhuicHPSbNIFKi5s0D5a+nZb/E6MNGvhxoFCQX2IcNxaJMqhzy1ESwlixz45aT72mXYq0LIxTTpoTqma1HuKdRY8HxoREiivjmMQulYP+CxXFcMyV9kxTKIUZ/FXqlC6G5vSm3J4YScSatPOj9ID5HowpdlIx8F6y4p1/28r2tTl4CY40FFyoke4MQ== email@example.com
|
24
|
-
#
|
25
|
-
def index
|
26
|
-
validate_arguments!
|
27
|
-
keys = api.get_keys
|
28
|
-
if keys.length > 0
|
29
|
-
styled_header("#{Turbot::Auth.user} Keys")
|
30
|
-
keys = if options[:long]
|
31
|
-
keys.map {|key| key["contents"].strip}
|
32
|
-
else
|
33
|
-
keys.map {|key| format_key_for_display(key["contents"])}
|
34
|
-
end
|
35
|
-
styled_array(keys)
|
36
|
-
else
|
37
|
-
display("You have no keys.")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# keys:add [KEY]
|
42
|
-
#
|
43
|
-
# add a key for the current user
|
44
|
-
#
|
45
|
-
# if no KEY is specified, will try to find ~/.ssh/id_[rd]sa.pub
|
46
|
-
#
|
47
|
-
#Examples:
|
48
|
-
#
|
49
|
-
# $ turbot keys:add
|
50
|
-
# Could not find an existing public key.
|
51
|
-
# Would you like to generate one? [Yn] y
|
52
|
-
# Generating new SSH public key.
|
53
|
-
# Uploading SSH public key /.ssh/id_rsa.pub... done
|
54
|
-
#
|
55
|
-
# $ turbot keys:add /my/key.pub
|
56
|
-
# Uploading SSH public key /my/key.pub... done
|
57
|
-
#
|
58
|
-
def add
|
59
|
-
keyfile = shift_argument
|
60
|
-
validate_arguments!
|
61
|
-
|
62
|
-
if keyfile
|
63
|
-
Turbot::Auth.associate_key(keyfile)
|
64
|
-
else
|
65
|
-
# make sure we have credentials
|
66
|
-
Turbot::Auth.get_credentials
|
67
|
-
Turbot::Auth.associate_or_generate_ssh_key
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# keys:remove KEY
|
72
|
-
#
|
73
|
-
# remove a key from the current user
|
74
|
-
#
|
75
|
-
#Examples:
|
76
|
-
#
|
77
|
-
# $ turbot keys:remove email@example.com
|
78
|
-
# Removing email@example.com SSH key... done
|
79
|
-
#
|
80
|
-
def remove
|
81
|
-
key = shift_argument
|
82
|
-
if key.nil? || key.empty?
|
83
|
-
error("Usage: turbot keys:remove KEY\nMust specify KEY to remove.")
|
84
|
-
end
|
85
|
-
validate_arguments!
|
86
|
-
|
87
|
-
action("Removing #{key} SSH key") do
|
88
|
-
api.delete_key(key)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
# keys:clear
|
93
|
-
#
|
94
|
-
# remove all authentication keys from the current user
|
95
|
-
#
|
96
|
-
#Examples:
|
97
|
-
#
|
98
|
-
# $ turbot keys:clear
|
99
|
-
# Removing all SSH keys... done
|
100
|
-
#
|
101
|
-
def clear
|
102
|
-
validate_arguments!
|
103
|
-
|
104
|
-
action("Removing all SSH keys") do
|
105
|
-
api.delete_keys
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
protected
|
110
|
-
def format_key_for_display(key)
|
111
|
-
type, hex, local = key.strip.split(/\s/)
|
112
|
-
[type, hex[0,10] + '...' + hex[-10,10], local].join(' ')
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
data/lib/turbot/command/logs.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require "turbot/command/base"
|
2
|
-
require "turbot/helpers/log_displayer"
|
3
|
-
|
4
|
-
# display logs for an bot
|
5
|
-
#
|
6
|
-
class Turbot::Command::Logs < Turbot::Command::Base
|
7
|
-
|
8
|
-
# logs
|
9
|
-
#
|
10
|
-
# display recent log output
|
11
|
-
#
|
12
|
-
# -n, --num NUM # the number of lines to display
|
13
|
-
# -p, --ps PS # only display logs from the given process
|
14
|
-
# -s, --source SOURCE # only display logs from the given source
|
15
|
-
# -t, --tail # continually stream logs
|
16
|
-
#
|
17
|
-
#Example:
|
18
|
-
#
|
19
|
-
# $ turbot logs
|
20
|
-
# 2012-01-01T12:00:00+00:00 turbot[api]: Config add EXAMPLE by email@example.com
|
21
|
-
# 2012-01-01T12:00:01+00:00 turbot[api]: Release v1 created by email@example.com
|
22
|
-
#
|
23
|
-
def index
|
24
|
-
validate_arguments!
|
25
|
-
|
26
|
-
opts = []
|
27
|
-
opts << "tail=1" if options[:tail]
|
28
|
-
opts << "num=#{options[:num]}" if options[:num]
|
29
|
-
opts << "ps=#{URI.encode(options[:ps])}" if options[:ps]
|
30
|
-
opts << "source=#{URI.encode(options[:source])}" if options[:source]
|
31
|
-
log_displayer = ::Turbot::Helpers::LogDisplayer.new(api, bot, opts)
|
32
|
-
log_displayer.display_logs
|
33
|
-
end
|
34
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require "turbot/command/base"
|
2
|
-
|
3
|
-
# check status of turbot platform
|
4
|
-
#
|
5
|
-
class Turbot::Command::Status < Turbot::Command::Base
|
6
|
-
|
7
|
-
# status
|
8
|
-
#
|
9
|
-
# display current status of turbot platform
|
10
|
-
#
|
11
|
-
#Example:
|
12
|
-
#
|
13
|
-
# $ turbot status
|
14
|
-
# === Turbot Status
|
15
|
-
# Development: No known issues at this time.
|
16
|
-
# Production: No known issues at this time.
|
17
|
-
#
|
18
|
-
def index
|
19
|
-
validate_arguments!
|
20
|
-
|
21
|
-
require('excon')
|
22
|
-
status = json_decode(Excon.get("http://turbot.opencorporates.com/current-status.json", :nonblock => false).body)
|
23
|
-
|
24
|
-
styled_header("Turbot Status")
|
25
|
-
|
26
|
-
status['status'].each do |key, value|
|
27
|
-
if value == 'green'
|
28
|
-
status['status'][key] = 'No known issues at this time.'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
styled_hash(status['status'])
|
32
|
-
|
33
|
-
unless status['issues'].empty?
|
34
|
-
display
|
35
|
-
status['issues'].each do |issue|
|
36
|
-
duration = time_ago(issue['created_at']).gsub(' ago', '+')
|
37
|
-
styled_header("#{issue['title']} #{duration}")
|
38
|
-
changes = issue['updates'].map do |issue|
|
39
|
-
[
|
40
|
-
time_ago(issue['created_at']),
|
41
|
-
issue['update_type'],
|
42
|
-
issue['contents']
|
43
|
-
]
|
44
|
-
end
|
45
|
-
styled_array(changes, :sort => false)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require "turbot/command/base"
|
2
|
-
require "turbot/updater"
|
3
|
-
|
4
|
-
# update the turbot client
|
5
|
-
#
|
6
|
-
class Turbot::Command::Update < Turbot::Command::Base
|
7
|
-
|
8
|
-
# update
|
9
|
-
#
|
10
|
-
# update the turbot client
|
11
|
-
#
|
12
|
-
# Example:
|
13
|
-
#
|
14
|
-
# $ turbot update
|
15
|
-
# Updating from v1.2.3... done, updated to v2.3.4
|
16
|
-
#
|
17
|
-
def index
|
18
|
-
validate_arguments!
|
19
|
-
update_from_url("https://toolbelt.turbot.com/download/zip")
|
20
|
-
end
|
21
|
-
|
22
|
-
# update:beta
|
23
|
-
#
|
24
|
-
# update to the latest beta client
|
25
|
-
#
|
26
|
-
# $ turbot update
|
27
|
-
# Updating from v1.2.3... done, updated to v2.3.4.pre
|
28
|
-
#
|
29
|
-
def beta
|
30
|
-
validate_arguments!
|
31
|
-
update_from_url("https://toolbelt.turbot.com/download/beta-zip")
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def update_from_url(url)
|
37
|
-
Turbot::Updater.check_disabled!
|
38
|
-
action("Updating from #{Turbot::VERSION}") do
|
39
|
-
if new_version = Turbot::Updater.update(url)
|
40
|
-
status("updated to #{new_version}")
|
41
|
-
else
|
42
|
-
status("nothing to update")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|