transcriptic 0.1.0 → 0.1.2
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/lib/transcriptic/api.rb +4 -4
- data/lib/transcriptic/auth.rb +4 -5
- data/lib/transcriptic/client.rb +25 -26
- data/lib/transcriptic/command/analyze.rb +0 -8
- data/lib/transcriptic/command/base.rb +0 -38
- data/lib/transcriptic/command/keys.rb +115 -0
- data/lib/transcriptic/command/run.rb +11 -17
- data/lib/transcriptic/command/status.rb +3 -0
- data/lib/transcriptic/helpers.rb +2 -26
- data/lib/transcriptic/version.rb +1 -1
- data/lib/vendor/transcriptic/okjson.rb +15 -15
- metadata +74 -99
data/lib/transcriptic/api.rb
CHANGED
@@ -13,15 +13,15 @@ module Transcriptic
|
|
13
13
|
user_pass = ":#{@api_key}"
|
14
14
|
options = {
|
15
15
|
:headers => {},
|
16
|
-
:host => '
|
16
|
+
:host => 'transcriptic.com',
|
17
17
|
:scheme => 'https'
|
18
18
|
}.merge(options)
|
19
19
|
options[:headers] = {
|
20
20
|
'Accept' => 'application/json',
|
21
21
|
'Accept-Encoding' => 'gzip',
|
22
|
-
|
23
|
-
'Authorization' => "
|
24
|
-
'User-Agent' => "transcriptic-
|
22
|
+
'Accept-Language' => 'en-US, en;q=0.8',
|
23
|
+
'Authorization' => "Token token=\"#{@api_key}\"",
|
24
|
+
'User-Agent' => "transcriptic-cli/#{Transcriptic::API::VERSION}",
|
25
25
|
'X-Transcriptic-API-Version' => '3',
|
26
26
|
'X-Ruby-Version' => RUBY_VERSION,
|
27
27
|
'X-Ruby-Platform' => RUBY_PLATFORM
|
data/lib/transcriptic/auth.rb
CHANGED
@@ -8,7 +8,7 @@ class Transcriptic::Auth
|
|
8
8
|
|
9
9
|
def client
|
10
10
|
@client ||= begin
|
11
|
-
client = Transcriptic::Client.new(user,
|
11
|
+
client = Transcriptic::Client.new(user, api_key, host)
|
12
12
|
client.on_warning { |msg| self.display("\n#{msg}\n\n") }
|
13
13
|
client
|
14
14
|
end
|
@@ -52,7 +52,7 @@ class Transcriptic::Auth
|
|
52
52
|
@credentials[0]
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
55
|
+
def api_key # :nodoc:
|
56
56
|
get_credentials
|
57
57
|
@credentials[1]
|
58
58
|
end
|
@@ -94,7 +94,6 @@ class Transcriptic::Auth
|
|
94
94
|
print "Password: "
|
95
95
|
password = running_on_windows? ? ask_for_password_on_windows : ask_for_password
|
96
96
|
api_key = Transcriptic::Client.auth(user, password, host)['api_key']
|
97
|
-
|
98
97
|
[user, api_key]
|
99
98
|
end
|
100
99
|
|
@@ -143,7 +142,7 @@ class Transcriptic::Auth
|
|
143
142
|
end
|
144
143
|
|
145
144
|
def check_for_associated_ssh_key
|
146
|
-
return unless client.
|
145
|
+
return unless client.get_keys.length.zero?
|
147
146
|
associate_or_generate_ssh_key
|
148
147
|
end
|
149
148
|
|
@@ -184,7 +183,7 @@ class Transcriptic::Auth
|
|
184
183
|
|
185
184
|
def associate_key(key)
|
186
185
|
display "Uploading ssh public key #{key}"
|
187
|
-
client.add_key(File.read(key))
|
186
|
+
client.add_key(File.read(key)).inspect
|
188
187
|
end
|
189
188
|
|
190
189
|
def available_ssh_public_keys
|
data/lib/transcriptic/client.rb
CHANGED
@@ -28,40 +28,36 @@ class Transcriptic::Client
|
|
28
28
|
"transcriptic-gem/#{version}"
|
29
29
|
end
|
30
30
|
|
31
|
-
attr_accessor :host, :user, :
|
31
|
+
attr_accessor :host, :user, :api_key
|
32
32
|
|
33
33
|
def self.auth(user, password, host = Transcriptic::Auth.default_host)
|
34
|
-
client = new(user,
|
34
|
+
client = new(user, nil, host)
|
35
35
|
json_decode client.post('/users/sign_in', { 'user[email]' => user, 'user[password]' => password }, :accept => 'json').to_s
|
36
36
|
end
|
37
37
|
|
38
|
-
def initialize(user,
|
38
|
+
def initialize(user, api_key, host = Transcriptic::Auth.default_host)
|
39
39
|
@user = user
|
40
|
-
@
|
40
|
+
@api_key = api_key
|
41
41
|
@host = host
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
doc = xml(get("/apps/#{name_or_domain}").to_s)
|
47
|
-
attrs = hash_from_xml_doc(doc)[:app]
|
48
|
-
attrs.merge!(:collaborators => list_collaborators(attrs[:name]))
|
49
|
-
attrs.merge!(:addons => installed_addons(attrs[:name]))
|
44
|
+
def get_keys
|
45
|
+
json_decode get("/api/keys").to_s
|
50
46
|
end
|
51
47
|
|
52
48
|
# Add an ssh public key to the current user.
|
53
49
|
def add_key(key)
|
54
|
-
post("/
|
50
|
+
json_decode post("/api/keys", key, { 'Content-Type' => 'text/ssh-authkey' }).to_s
|
55
51
|
end
|
56
52
|
|
57
53
|
# Remove an existing ssh public key from the current user.
|
58
54
|
def remove_key(key)
|
59
|
-
delete("/
|
55
|
+
json_decode delete("/api/keys/#{escape(key)}").to_s
|
60
56
|
end
|
61
57
|
|
62
58
|
# Clear all keys on the current user.
|
63
59
|
def remove_all_keys
|
64
|
-
delete("/
|
60
|
+
json_decode delete("/api/keys").to_s
|
65
61
|
end
|
66
62
|
|
67
63
|
# Get a list of stacks available to the app, with the current one marked.
|
@@ -74,16 +70,11 @@ class Transcriptic::Client
|
|
74
70
|
).to_s
|
75
71
|
end
|
76
72
|
|
77
|
-
class
|
73
|
+
class ProtocolException < RuntimeError; end
|
78
74
|
|
79
75
|
# Show a list of projects which you are a collaborator on.
|
80
76
|
def list
|
81
|
-
|
82
|
-
doc.elements.to_a("//apps/app").map do |a|
|
83
|
-
name = a.elements.to_a("name").first
|
84
|
-
owner = a.elements.to_a("owner").first
|
85
|
-
[name.text, owner.text]
|
86
|
-
end
|
77
|
+
json_decode get('/api/runs.json').to_s
|
87
78
|
end
|
88
79
|
|
89
80
|
# Show info such as mode, custom domain, and collaborators on an app.
|
@@ -126,7 +117,7 @@ class Transcriptic::Client
|
|
126
117
|
@interval = 0
|
127
118
|
self
|
128
119
|
rescue RestClient::RequestFailed => e
|
129
|
-
raise
|
120
|
+
raise ProtocolException, e.http_body if e.http_code == 502
|
130
121
|
raise
|
131
122
|
end
|
132
123
|
|
@@ -175,6 +166,10 @@ class Transcriptic::Client
|
|
175
166
|
json_decode resource("/runs/#{run_id}/status").get(:accept => 'application/json').to_s
|
176
167
|
end
|
177
168
|
|
169
|
+
def create_run(fd)
|
170
|
+
json_decode post("/api/runs", File.open(fd).read, { 'Content-Type' => 'application/zip; charset=UTF-8' }).to_s
|
171
|
+
end
|
172
|
+
|
178
173
|
# Get a Protocol instance to execute commands against.
|
179
174
|
def protocol(run_id, upid)
|
180
175
|
Protocol.new(self, run_id, upid)
|
@@ -216,7 +211,7 @@ class Transcriptic::Client
|
|
216
211
|
|
217
212
|
def resource(uri, options={})
|
218
213
|
RestClient.proxy = ENV['HTTP_PROXY'] || ENV['http_proxy']
|
219
|
-
resource = RestClient::Resource.new(realize_full_uri(uri), options
|
214
|
+
resource = RestClient::Resource.new(realize_full_uri(uri), options)
|
220
215
|
resource
|
221
216
|
end
|
222
217
|
|
@@ -249,7 +244,7 @@ class Transcriptic::Client
|
|
249
244
|
error " ! Unable to connect to #{host}"
|
250
245
|
rescue RestClient::SSLCertificateNotVerified => ex
|
251
246
|
host = URI.parse(realize_full_uri(uri)).host
|
252
|
-
|
247
|
+
error "WARNING: Unable to verify SSL certificate for #{host}\nTo disable SSL verification, run with TRANSCRIPTIC_SSL_VERIFY=disable"
|
253
248
|
end
|
254
249
|
|
255
250
|
extract_warning(response)
|
@@ -269,12 +264,14 @@ class Transcriptic::Client
|
|
269
264
|
end
|
270
265
|
|
271
266
|
def transcriptic_headers # :nodoc:
|
272
|
-
{
|
267
|
+
headers = {
|
273
268
|
'X-Transcriptic-API-Version' => '1',
|
274
269
|
'User-Agent' => self.class.gem_version_string,
|
275
270
|
'X-Ruby-Version' => RUBY_VERSION,
|
276
271
|
'X-Ruby-Platform' => RUBY_PLATFORM
|
277
272
|
}
|
273
|
+
headers = headers.merge({'Authorization' => "Token token=\"#{@api_key}\""}) if @api_key
|
274
|
+
headers
|
278
275
|
end
|
279
276
|
|
280
277
|
def xml(raw) # :nodoc:
|
@@ -308,8 +305,10 @@ class Transcriptic::Client
|
|
308
305
|
def default_resource_options_for_uri(uri)
|
309
306
|
if ENV["TRANSCRIPTIC_SSL_VERIFY"] == "disable"
|
310
307
|
{}
|
311
|
-
elsif realize_full_uri(uri) =~ %r|^https://
|
312
|
-
|
308
|
+
elsif realize_full_uri(uri) =~ %r|^https://transcriptic.com|
|
309
|
+
# OpenSSL::SSL::VERIFY_PEER
|
310
|
+
{ }
|
311
|
+
#{ :verify_ssl => OpenSSL::SSL::VERIFY_NONE, :ssl_ca_file => local_ca_file }
|
313
312
|
else
|
314
313
|
{}
|
315
314
|
end
|
@@ -145,44 +145,6 @@ protected
|
|
145
145
|
options[:confirm] && (options[:confirm] != options[:app])
|
146
146
|
end
|
147
147
|
|
148
|
-
def extract_app_in_dir(dir)
|
149
|
-
return unless remotes = git_remotes(dir)
|
150
|
-
|
151
|
-
if remote = options[:remote]
|
152
|
-
remotes[remote]
|
153
|
-
elsif remote = extract_app_from_git_config
|
154
|
-
remotes[remote]
|
155
|
-
else
|
156
|
-
apps = remotes.values.uniq
|
157
|
-
if apps.size == 1
|
158
|
-
apps.first
|
159
|
-
else
|
160
|
-
raise(Transcriptic::Command::CommandFailed, "Multiple apps in folder and no app specified.\nSpecify which app to use with --app <app name>")
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
def extract_app_from_git_config
|
166
|
-
remote = git("config transcriptic.remote")
|
167
|
-
remote == "" ? nil : remote
|
168
|
-
end
|
169
|
-
|
170
|
-
def git_remotes(base_dir=Dir.pwd)
|
171
|
-
remotes = {}
|
172
|
-
original_dir = Dir.pwd
|
173
|
-
Dir.chdir(base_dir)
|
174
|
-
|
175
|
-
git("remote -v").split("\n").each do |remote|
|
176
|
-
name, url, method = remote.split(/\s/)
|
177
|
-
if url =~ /^git@#{transcriptic.host}:([\w\d-]+)\.git$/
|
178
|
-
remotes[name] = $1
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
Dir.chdir(original_dir)
|
183
|
-
remotes
|
184
|
-
end
|
185
|
-
|
186
148
|
def escape(value)
|
187
149
|
transcriptic.escape(value)
|
188
150
|
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require "transcriptic/command/base"
|
2
|
+
|
3
|
+
module Transcriptic::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
|
+
# $ transcriptic keys
|
18
|
+
# === email@example.com Keys
|
19
|
+
# ssh-rsa ABCDEFGHIJK...OPQRSTUV== email@example.com
|
20
|
+
#
|
21
|
+
# $ transcriptic 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 = transcriptic.get_keys
|
28
|
+
if keys.length > 0
|
29
|
+
display("#{Transcriptic::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
|
+
# $ transcriptic 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
|
+
# $ transcriptic 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
|
+
Transcriptic::Auth.associate_key(keyfile)
|
64
|
+
else
|
65
|
+
# make sure we have credentials
|
66
|
+
Transcriptic::Auth.get_credentials
|
67
|
+
Transcriptic::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
|
+
# $ transcriptic 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: transcriptic 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
|
+
# $ transcriptic keys:cleare
|
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
|
@@ -13,22 +13,25 @@ module Transcriptic::Command
|
|
13
13
|
#
|
14
14
|
def index
|
15
15
|
path = args.shift
|
16
|
-
|
16
|
+
fd = create_protocol_fd_for_path(path)
|
17
|
+
display "Uploading `#{path}` to Transcriptic..."
|
18
|
+
run_id = transcriptic.create_run(fd)["run_id"]
|
19
|
+
display "Run launched (#{run_id})"
|
17
20
|
end
|
18
21
|
|
19
|
-
def
|
22
|
+
def create_protocol_fd_for_path(path)
|
20
23
|
begin
|
21
24
|
stat = File.stat(path)
|
22
25
|
rescue
|
23
|
-
|
26
|
+
display "No such path: #{path}"
|
24
27
|
return
|
25
28
|
end
|
29
|
+
upfile = Tempfile.new('protocol')
|
26
30
|
if stat.directory?
|
27
31
|
files = Pathname.glob("#{path}/**/**")
|
28
32
|
file_count = files.reject(&:directory?).length
|
29
33
|
dir_count = files.reject(&:file?).length
|
30
|
-
|
31
|
-
upfile = Tempfile.new('protocol')
|
34
|
+
display "Package detected, compressing #{file_count} files (#{dir_count} directories)..."
|
32
35
|
Zip::Archive.open(upfile.path, Zip::CREATE) do |ar|
|
33
36
|
ar.add_dir(path)
|
34
37
|
Dir.glob("#{path}/**/**").each do |path|
|
@@ -40,20 +43,11 @@ module Transcriptic::Command
|
|
40
43
|
end
|
41
44
|
end
|
42
45
|
else
|
43
|
-
upfile
|
44
|
-
|
45
|
-
puts "Uploading `#{path}` to Transcriptic..."
|
46
|
-
url = URI.parse('http://client.transcriptic.com/receive')
|
47
|
-
File.open(upfile) do |zf|
|
48
|
-
req = Net::HTTP::Post::Multipart.new url.path,
|
49
|
-
"file" => UploadIO.new(zf, "application/zip", "protocol.zip")
|
50
|
-
res = Net::HTTP.start(url.host, url.port) do |http|
|
51
|
-
http.request(req)
|
52
|
-
end
|
53
|
-
if res.code != 200
|
54
|
-
puts "HTTP Error: #{res.message} (#{res.code})"
|
46
|
+
Zip::Archive.open(upfile.path, Zip::CREATE) do |ar|
|
47
|
+
ar.add_file(path, path)
|
55
48
|
end
|
56
49
|
end
|
50
|
+
upfile
|
57
51
|
end
|
58
52
|
|
59
53
|
end
|
data/lib/transcriptic/helpers.rb
CHANGED
@@ -40,10 +40,9 @@ module Transcriptic
|
|
40
40
|
def confirm_billing
|
41
41
|
display
|
42
42
|
display "This action will cause your account to be billed at the end of the month"
|
43
|
-
display "For more information, see http://devcenter.heroku.com/articles/billing"
|
44
43
|
display "Are you sure you want to do this? (y/n) ", false
|
45
44
|
if ask.downcase == 'y'
|
46
|
-
|
45
|
+
transcriptic.confirm_billing
|
47
46
|
return true
|
48
47
|
end
|
49
48
|
end
|
@@ -84,7 +83,7 @@ module Transcriptic
|
|
84
83
|
end
|
85
84
|
|
86
85
|
def ask
|
87
|
-
gets.strip
|
86
|
+
STDIN.gets.strip
|
88
87
|
end
|
89
88
|
|
90
89
|
def shell(cmd)
|
@@ -107,17 +106,6 @@ module Transcriptic
|
|
107
106
|
end
|
108
107
|
end
|
109
108
|
|
110
|
-
def has_git?
|
111
|
-
%x{ git --version }
|
112
|
-
$?.success?
|
113
|
-
end
|
114
|
-
|
115
|
-
def git(args)
|
116
|
-
return "" unless has_git?
|
117
|
-
flattened_args = [args].flatten.compact.join(" ")
|
118
|
-
%x{ git #{flattened_args} 2>&1 }.strip
|
119
|
-
end
|
120
|
-
|
121
109
|
def time_ago(elapsed)
|
122
110
|
if elapsed < 60
|
123
111
|
"#{elapsed.floor}s ago"
|
@@ -152,18 +140,6 @@ module Transcriptic
|
|
152
140
|
"%d %s" % [ num, num.to_i == 1 ? string : "#{string}s" ]
|
153
141
|
end
|
154
142
|
|
155
|
-
def create_git_remote(app, remote)
|
156
|
-
return unless has_git?
|
157
|
-
return if git('remote').split("\n").include?(remote)
|
158
|
-
return unless File.exists?(".git")
|
159
|
-
git "remote add #{remote} git@#{heroku.host}:#{app}.git"
|
160
|
-
display "Git remote #{remote} added"
|
161
|
-
end
|
162
|
-
|
163
|
-
def app_urls(name)
|
164
|
-
"http://#{name}.heroku.com/ | git@heroku.com:#{name}.git"
|
165
|
-
end
|
166
|
-
|
167
143
|
def longest(items)
|
168
144
|
items.map { |i| i.to_s.length }.sort.last
|
169
145
|
end
|
data/lib/transcriptic/version.rb
CHANGED
@@ -43,7 +43,7 @@ module Transcriptic
|
|
43
43
|
ts = lex(s)
|
44
44
|
v, ts = textparse(ts)
|
45
45
|
if ts.length > 0
|
46
|
-
raise
|
46
|
+
raise Transcriptic::OkJson::ParserError, 'trailing garbage'
|
47
47
|
end
|
48
48
|
v
|
49
49
|
end
|
@@ -55,7 +55,7 @@ module Transcriptic
|
|
55
55
|
# except that it does not accept atomic values.
|
56
56
|
def textparse(ts)
|
57
57
|
if ts.length < 0
|
58
|
-
raise
|
58
|
+
raise Transcriptic::OkJson::ParserError, 'empty'
|
59
59
|
end
|
60
60
|
|
61
61
|
typ, _, val = ts[0]
|
@@ -71,7 +71,7 @@ module Transcriptic
|
|
71
71
|
# Returns the parsed value and any trailing tokens.
|
72
72
|
def valparse(ts)
|
73
73
|
if ts.length < 0
|
74
|
-
raise
|
74
|
+
raise Transcriptic::OkJson::ParserError, 'empty'
|
75
75
|
end
|
76
76
|
|
77
77
|
typ, _, val = ts[0]
|
@@ -80,7 +80,7 @@ module Transcriptic
|
|
80
80
|
when '[' then arrparse(ts)
|
81
81
|
when :val,:str then [val, ts[1..-1]]
|
82
82
|
else
|
83
|
-
raise
|
83
|
+
raise Transcriptic::OkJson::ParserError, "unexpected #{val.inspect}"
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -120,7 +120,7 @@ module Transcriptic
|
|
120
120
|
def pairparse(ts)
|
121
121
|
(typ, _, k), ts = ts[0], ts[1..-1]
|
122
122
|
if typ != :str
|
123
|
-
raise
|
123
|
+
raise Transcriptic::OkJson::ParserError, "unexpected #{k.inspect}"
|
124
124
|
end
|
125
125
|
ts = eat(':', ts)
|
126
126
|
v, ts = valparse(ts)
|
@@ -160,7 +160,7 @@ module Transcriptic
|
|
160
160
|
|
161
161
|
def eat(typ, ts)
|
162
162
|
if ts[0][0] != typ
|
163
|
-
raise
|
163
|
+
raise Transcriptic::OkJson::ParserError, "expected #{typ} (got #{ts[0].inspect})"
|
164
164
|
end
|
165
165
|
ts[1..-1]
|
166
166
|
end
|
@@ -173,7 +173,7 @@ module Transcriptic
|
|
173
173
|
while s.length > 0
|
174
174
|
typ, lexeme, val = tok(s)
|
175
175
|
if typ == nil
|
176
|
-
raise
|
176
|
+
raise Transcriptic::OkJson::ParserError, "invalid character at #{s[0,10].inspect}"
|
177
177
|
end
|
178
178
|
if typ != :space
|
179
179
|
ts << [typ, lexeme, val]
|
@@ -240,7 +240,7 @@ module Transcriptic
|
|
240
240
|
def strtok(s)
|
241
241
|
m = /"([^"\\]|\\["\/\\bfnrt]|\\u[0-9a-fA-F]{4})*"/.match(s)
|
242
242
|
if ! m
|
243
|
-
raise
|
243
|
+
raise Transcriptic::OkJson::ParserError, "invalid string literal at #{abbrev(s)}"
|
244
244
|
end
|
245
245
|
[:str, m[0], unquote(m[0])]
|
246
246
|
end
|
@@ -257,7 +257,7 @@ module Transcriptic
|
|
257
257
|
|
258
258
|
# Converts a quoted json string literal q into a UTF-8-encoded string.
|
259
259
|
# The rules are different than for Ruby, so we cannot use eval.
|
260
|
-
# Unquote will raise
|
260
|
+
# Unquote will raise Transcriptic::OkJson::ParserError, an error if q contains control characters.
|
261
261
|
def unquote(q)
|
262
262
|
q = q[1...-1]
|
263
263
|
a = q.dup # allocate a big enough string
|
@@ -268,7 +268,7 @@ module Transcriptic
|
|
268
268
|
when c == ?\\
|
269
269
|
r += 1
|
270
270
|
if r >= q.length
|
271
|
-
raise
|
271
|
+
raise Transcriptic::OkJson::ParserError, "string literal ends with a \"\\\": \"#{q}\""
|
272
272
|
end
|
273
273
|
|
274
274
|
case q[r]
|
@@ -285,7 +285,7 @@ module Transcriptic
|
|
285
285
|
uchar = begin
|
286
286
|
hexdec4(q[r,4])
|
287
287
|
rescue RuntimeError => e
|
288
|
-
raise
|
288
|
+
raise Transcriptic::OkJson::ParserError, "invalid escape sequence \\u#{q[r,4]}: #{e}"
|
289
289
|
end
|
290
290
|
r += 4
|
291
291
|
if surrogate? uchar
|
@@ -300,10 +300,10 @@ module Transcriptic
|
|
300
300
|
end
|
301
301
|
w += ucharenc(a, w, uchar)
|
302
302
|
else
|
303
|
-
raise
|
303
|
+
raise Transcriptic::OkJson::ParserError, "invalid escape char #{q[r]} in \"#{q}\""
|
304
304
|
end
|
305
305
|
when c == ?", c < Spc
|
306
|
-
raise
|
306
|
+
raise Transcriptic::OkJson::ParserError, "invalid character in string literal \"#{q}\""
|
307
307
|
else
|
308
308
|
# Copy anything else byte-for-byte.
|
309
309
|
# Valid UTF-8 will remain valid UTF-8.
|
@@ -319,7 +319,7 @@ module Transcriptic
|
|
319
319
|
|
320
320
|
def hexdec4(s)
|
321
321
|
if s.length != 4
|
322
|
-
raise
|
322
|
+
raise Transcriptic::OkJson::ParserError, 'short'
|
323
323
|
end
|
324
324
|
(nibble(s[0])<<12) | (nibble(s[1])<<8) | (nibble(s[2])<<4) | nibble(s[3])
|
325
325
|
end
|
@@ -353,7 +353,7 @@ module Transcriptic
|
|
353
353
|
when ?a <= c && c <= ?z then c.ord - ?a.ord + 10
|
354
354
|
when ?A <= c && c <= ?Z then c.ord - ?A.ord + 10
|
355
355
|
else
|
356
|
-
raise
|
356
|
+
raise Transcriptic::OkJson::ParserError, "invalid hex code #{c}"
|
357
357
|
end
|
358
358
|
end
|
359
359
|
|
metadata
CHANGED
@@ -1,110 +1,89 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: transcriptic
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
version: 0.1.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Transcriptic
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-10-24 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: thrift
|
22
|
-
|
23
|
-
|
24
|
-
requirements:
|
16
|
+
requirement: &70219859440740 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
25
19
|
- - ~>
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
- 0
|
29
|
-
- 8
|
30
|
-
version: "0.8"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.8'
|
31
22
|
type: :runtime
|
32
|
-
version_requirements: *id001
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: netrc
|
35
23
|
prerelease: false
|
36
|
-
|
37
|
-
|
24
|
+
version_requirements: *70219859440740
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: netrc
|
27
|
+
requirement: &70219859440240 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
38
30
|
- - ~>
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
segments:
|
41
|
-
- 0
|
42
|
-
- 7
|
43
|
-
- 7
|
31
|
+
- !ruby/object:Gem::Version
|
44
32
|
version: 0.7.7
|
45
33
|
type: :runtime
|
46
|
-
version_requirements: *id002
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: rest-client
|
49
34
|
prerelease: false
|
50
|
-
|
51
|
-
|
35
|
+
version_requirements: *70219859440240
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rest-client
|
38
|
+
requirement: &70219859439780 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
52
41
|
- - ~>
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
segments:
|
55
|
-
- 1
|
56
|
-
- 6
|
57
|
-
- 1
|
42
|
+
- !ruby/object:Gem::Version
|
58
43
|
version: 1.6.1
|
59
44
|
type: :runtime
|
60
|
-
version_requirements: *id003
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: launchy
|
63
45
|
prerelease: false
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
46
|
+
version_requirements: *70219859439780
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: launchy
|
49
|
+
requirement: &70219859439320 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
72
54
|
version: 0.3.2
|
73
55
|
type: :runtime
|
74
|
-
version_requirements: *id004
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: zipruby
|
77
56
|
prerelease: false
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
57
|
+
version_requirements: *70219859439320
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: zipruby
|
60
|
+
requirement: &70219859438940 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
85
66
|
type: :runtime
|
86
|
-
version_requirements: *id005
|
87
|
-
- !ruby/object:Gem::Dependency
|
88
|
-
name: multipart-post
|
89
67
|
prerelease: false
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
68
|
+
version_requirements: *70219859438940
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: multipart-post
|
71
|
+
requirement: &70219859438480 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
97
77
|
type: :runtime
|
98
|
-
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70219859438480
|
99
80
|
description: Client library and command-line tool to work with Transcriptic Platform.
|
100
81
|
email: support@transcriptic.com
|
101
|
-
executables:
|
82
|
+
executables:
|
102
83
|
- transcriptic
|
103
84
|
extensions: []
|
104
|
-
|
105
85
|
extra_rdoc_files: []
|
106
|
-
|
107
|
-
files:
|
86
|
+
files:
|
108
87
|
- lib/transcriptic.rb
|
109
88
|
- lib/transcriptic/api.rb
|
110
89
|
- lib/transcriptic/api/errors.rb
|
@@ -120,6 +99,7 @@ files:
|
|
120
99
|
- lib/transcriptic/command/data.rb
|
121
100
|
- lib/transcriptic/command/help.rb
|
122
101
|
- lib/transcriptic/command/history.rb
|
102
|
+
- lib/transcriptic/command/keys.rb
|
123
103
|
- lib/transcriptic/command/login.rb
|
124
104
|
- lib/transcriptic/command/run.rb
|
125
105
|
- lib/transcriptic/command/sequences.rb
|
@@ -127,35 +107,30 @@ files:
|
|
127
107
|
- lib/transcriptic/helpers.rb
|
128
108
|
- lib/transcriptic/version.rb
|
129
109
|
- lib/vendor/transcriptic/okjson.rb
|
130
|
-
|
110
|
+
- bin/transcriptic
|
131
111
|
homepage: https://www.transcriptic.com/
|
132
112
|
licenses: []
|
133
|
-
|
134
113
|
post_install_message:
|
135
114
|
rdoc_options: []
|
136
|
-
|
137
|
-
require_paths:
|
115
|
+
require_paths:
|
138
116
|
- lib
|
139
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
requirements:
|
148
|
-
- -
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
|
151
|
-
- 0
|
152
|
-
version: "0"
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ! '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
153
129
|
requirements: []
|
154
|
-
|
155
130
|
rubyforge_project:
|
156
|
-
rubygems_version: 1.
|
131
|
+
rubygems_version: 1.8.6
|
157
132
|
signing_key:
|
158
133
|
specification_version: 3
|
159
134
|
summary: Client library and CLI tool for Transcriptic.
|
160
135
|
test_files: []
|
161
|
-
|
136
|
+
has_rdoc:
|