transcriptic 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/bin/transcriptic +2 -4
  3. data/lib/thor/monkies.rb +3 -0
  4. data/lib/thor/monkies/shell.rb +3 -0
  5. data/lib/transcriptic.rb +86 -2
  6. data/lib/transcriptic/auth.rb +2 -63
  7. data/lib/transcriptic/base_generator.rb +25 -0
  8. data/lib/transcriptic/cli.rb +199 -8
  9. data/lib/transcriptic/client.rb +45 -38
  10. data/lib/transcriptic/commands/project.rb +37 -0
  11. data/lib/transcriptic/core_ext.rb +3 -0
  12. data/lib/transcriptic/core_ext/file.rb +7 -0
  13. data/lib/transcriptic/core_ext/file_utils.rb +15 -0
  14. data/lib/transcriptic/core_ext/pathname.rb +13 -0
  15. data/lib/transcriptic/core_ext/string.rb +8 -0
  16. data/lib/transcriptic/dependencies_generator.rb +13 -0
  17. data/lib/transcriptic/errors.rb +32 -0
  18. data/lib/transcriptic/labfile.rb +73 -0
  19. data/lib/transcriptic/project_generator.rb +56 -0
  20. data/lib/transcriptic/sbt.rb +58 -0
  21. data/lib/transcriptic/templates/LICENSE.erb +20 -0
  22. data/lib/transcriptic/templates/Labfile.erb +12 -0
  23. data/lib/transcriptic/templates/README.erb +3 -0
  24. data/lib/transcriptic/templates/app/Main.erb +11 -0
  25. data/lib/transcriptic/templates/project/Build.erb +59 -0
  26. data/lib/transcriptic/templates/project/Dependencies.erb +10 -0
  27. data/lib/transcriptic/templates/project/build.properties +1 -0
  28. data/lib/transcriptic/templates/project/plugins.sbt +5 -0
  29. data/lib/transcriptic/templates/sbt +1 -0
  30. data/lib/transcriptic/{helpers.rb → ui.rb} +124 -109
  31. data/lib/transcriptic/version.rb +2 -1
  32. data/lib/vendor/{transcriptic/okjson.rb → okjson.rb} +0 -0
  33. metadata +203 -46
  34. data/lib/transcriptic/command.rb +0 -233
  35. data/lib/transcriptic/command/base.rb +0 -157
  36. data/lib/transcriptic/command/console.rb +0 -10
  37. data/lib/transcriptic/command/data.rb +0 -29
  38. data/lib/transcriptic/command/help.rb +0 -124
  39. data/lib/transcriptic/command/login.rb +0 -35
  40. data/lib/transcriptic/command/run.rb +0 -108
@@ -1,3 +1,4 @@
1
1
  module Transcriptic
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
+ AUTOPROTOCOL_VERSION = "0.1.0"
3
4
  end
File without changes
metadata CHANGED
@@ -1,82 +1,225 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transcriptic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Transcriptic
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-10-29 00:00:00.000000000Z
11
+ date: 2013-06-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: thrift
16
- requirement: &70351850156680 !ruby/object:Gem::Requirement
17
- none: false
14
+ name: netrc
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: '0.8'
19
+ version: 0.7.7
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70351850156680
25
- - !ruby/object:Gem::Dependency
26
- name: netrc
27
- requirement: &70351850156180 !ruby/object:Gem::Requirement
28
- none: false
22
+ version_requirements: !ruby/object:Gem::Requirement
29
23
  requirements:
30
24
  - - ~>
31
25
  - !ruby/object:Gem::Version
32
26
  version: 0.7.7
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *70351850156180
36
27
  - !ruby/object:Gem::Dependency
37
28
  name: rest-client
38
- requirement: &70351850155720 !ruby/object:Gem::Requirement
39
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
40
30
  requirements:
41
31
  - - ~>
42
32
  - !ruby/object:Gem::Version
43
33
  version: 1.6.1
44
34
  type: :runtime
45
35
  prerelease: false
46
- version_requirements: *70351850155720
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.6.1
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: launchy
49
- requirement: &70351850155260 !ruby/object:Gem::Requirement
50
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
51
44
  requirements:
52
- - - ! '>='
45
+ - - '>='
53
46
  - !ruby/object:Gem::Version
54
47
  version: 0.3.2
55
48
  type: :runtime
56
49
  prerelease: false
57
- version_requirements: *70351850155260
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.3.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: solve
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.4.4
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.4.4
69
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.18.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.18.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: activesupport
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: 3.2.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: 3.2.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: addressable
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 2.3.4
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 2.3.4
111
+ - !ruby/object:Gem::Dependency
112
+ name: celluloid
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: 0.14.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: 0.14.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: chozo
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: 0.6.1
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: 0.6.1
139
+ - !ruby/object:Gem::Dependency
140
+ name: faraday
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: 0.8.5
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: 0.8.5
153
+ - !ruby/object:Gem::Dependency
154
+ name: hashie
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: 2.0.2
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: 2.0.2
167
+ - !ruby/object:Gem::Dependency
168
+ name: minitar
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: 0.5.4
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ~>
179
+ - !ruby/object:Gem::Version
180
+ version: 0.5.4
181
+ - !ruby/object:Gem::Dependency
182
+ name: retryable
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ~>
186
+ - !ruby/object:Gem::Version
187
+ version: 1.3.3
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ~>
193
+ - !ruby/object:Gem::Version
194
+ version: 1.3.3
58
195
  - !ruby/object:Gem::Dependency
59
196
  name: zipruby
60
- requirement: &70351850154880 !ruby/object:Gem::Requirement
61
- none: false
197
+ requirement: !ruby/object:Gem::Requirement
62
198
  requirements:
63
- - - ! '>='
199
+ - - '>='
64
200
  - !ruby/object:Gem::Version
65
201
  version: '0'
66
202
  type: :runtime
67
203
  prerelease: false
68
- version_requirements: *70351850154880
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - '>='
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
69
209
  - !ruby/object:Gem::Dependency
70
210
  name: multipart-post
71
- requirement: &70351850154420 !ruby/object:Gem::Requirement
72
- none: false
211
+ requirement: !ruby/object:Gem::Requirement
73
212
  requirements:
74
- - - ! '>='
213
+ - - '>='
75
214
  - !ruby/object:Gem::Version
76
215
  version: '0'
77
216
  type: :runtime
78
217
  prerelease: false
79
- version_requirements: *70351850154420
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - '>='
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
80
223
  description: Client library and command-line tool to work with Transcriptic Platform.
81
224
  email: support@transcriptic.com
82
225
  executables:
@@ -84,47 +227,61 @@ executables:
84
227
  extensions: []
85
228
  extra_rdoc_files: []
86
229
  files:
230
+ - lib/thor/monkies.rb
231
+ - lib/thor/monkies/shell.rb
87
232
  - lib/transcriptic.rb
88
233
  - lib/transcriptic/api.rb
89
234
  - lib/transcriptic/api/errors.rb
90
235
  - lib/transcriptic/api/version.rb
91
236
  - lib/transcriptic/auth.rb
237
+ - lib/transcriptic/base_generator.rb
92
238
  - lib/transcriptic/cli.rb
93
239
  - lib/transcriptic/client.rb
94
- - lib/transcriptic/command.rb
95
- - lib/transcriptic/command/base.rb
96
- - lib/transcriptic/command/console.rb
97
- - lib/transcriptic/command/data.rb
98
- - lib/transcriptic/command/help.rb
99
- - lib/transcriptic/command/login.rb
100
- - lib/transcriptic/command/run.rb
101
- - lib/transcriptic/helpers.rb
240
+ - lib/transcriptic/commands/project.rb
241
+ - lib/transcriptic/core_ext.rb
242
+ - lib/transcriptic/core_ext/file.rb
243
+ - lib/transcriptic/core_ext/file_utils.rb
244
+ - lib/transcriptic/core_ext/pathname.rb
245
+ - lib/transcriptic/core_ext/string.rb
246
+ - lib/transcriptic/dependencies_generator.rb
247
+ - lib/transcriptic/errors.rb
248
+ - lib/transcriptic/labfile.rb
249
+ - lib/transcriptic/project_generator.rb
250
+ - lib/transcriptic/sbt.rb
251
+ - lib/transcriptic/templates/LICENSE.erb
252
+ - lib/transcriptic/templates/Labfile.erb
253
+ - lib/transcriptic/templates/README.erb
254
+ - lib/transcriptic/templates/app/Main.erb
255
+ - lib/transcriptic/templates/project/Build.erb
256
+ - lib/transcriptic/templates/project/Dependencies.erb
257
+ - lib/transcriptic/templates/project/build.properties
258
+ - lib/transcriptic/templates/project/plugins.sbt
259
+ - lib/transcriptic/templates/sbt
260
+ - lib/transcriptic/ui.rb
102
261
  - lib/transcriptic/version.rb
103
- - lib/vendor/transcriptic/okjson.rb
262
+ - lib/vendor/okjson.rb
104
263
  - bin/transcriptic
105
264
  homepage: https://www.transcriptic.com/
106
265
  licenses: []
266
+ metadata: {}
107
267
  post_install_message:
108
268
  rdoc_options: []
109
269
  require_paths:
110
270
  - lib
111
271
  required_ruby_version: !ruby/object:Gem::Requirement
112
- none: false
113
272
  requirements:
114
- - - ! '>='
273
+ - - '>='
115
274
  - !ruby/object:Gem::Version
116
275
  version: '0'
117
276
  required_rubygems_version: !ruby/object:Gem::Requirement
118
- none: false
119
277
  requirements:
120
- - - ! '>='
278
+ - - '>='
121
279
  - !ruby/object:Gem::Version
122
280
  version: '0'
123
281
  requirements: []
124
282
  rubyforge_project:
125
- rubygems_version: 1.8.6
283
+ rubygems_version: 2.0.3
126
284
  signing_key:
127
- specification_version: 3
285
+ specification_version: 4
128
286
  summary: Client library and CLI tool for Transcriptic.
129
287
  test_files: []
130
- has_rdoc:
@@ -1,233 +0,0 @@
1
- require 'transcriptic/helpers'
2
- require "optparse"
3
-
4
- #Dir["#{File.dirname(__FILE__)}/commands/*.rb"].each { |c| require c }
5
-
6
- module Transcriptic
7
- module Command
8
- class InvalidCommand < RuntimeError; end
9
- class CommandFailed < RuntimeError; end
10
-
11
- extend Transcriptic::Helpers
12
-
13
- def self.load
14
- Dir[File.join(File.dirname(__FILE__), "command", "*.rb")].each do |file|
15
- require file
16
- end
17
- end
18
-
19
- def self.commands
20
- @@commands ||= {}
21
- end
22
-
23
- def self.command_aliases
24
- @@command_aliases ||= {}
25
- end
26
-
27
- def self.files
28
- @@files ||= Hash.new {|hash,key| hash[key] = File.readlines(key).map {|line| line.strip}}
29
- end
30
-
31
- def self.namespaces
32
- @@namespaces ||= {}
33
- end
34
-
35
- def self.register_command(command)
36
- commands[command[:command]] = command
37
- end
38
-
39
- def self.register_namespace(namespace)
40
- namespaces[namespace[:name]] = namespace
41
- end
42
-
43
- def self.current_command
44
- @current_command
45
- end
46
-
47
- def self.current_command=(new_current_command)
48
- @current_command = new_current_command
49
- end
50
-
51
- def self.current_args
52
- @current_args
53
- end
54
-
55
- def self.current_options
56
- @current_options
57
- end
58
-
59
- def self.global_options
60
- @global_options ||= []
61
- end
62
-
63
- def self.invalid_arguments
64
- @invalid_arguments
65
- end
66
-
67
- def self.shift_argument
68
- @invalid_arguments.shift.downcase rescue nil
69
- end
70
-
71
- def self.validate_arguments!
72
- unless invalid_arguments.empty?
73
- arguments = invalid_arguments.map {|arg| "\"#{arg}\""}
74
- if arguments.length == 1
75
- message = "Invalid argument: #{arguments.first}"
76
- elsif arguments.length > 1
77
- message = "Invalid arguments: "
78
- message << arguments[0...-1].join(", ")
79
- message << " and "
80
- message << arguments[-1]
81
- end
82
- $stderr.puts(format_with_bang(message))
83
- run(current_command, ["--help"])
84
- exit(1)
85
- end
86
- end
87
-
88
- def self.global_option(name, *args)
89
- global_options << { :name => name, :args => args }
90
- end
91
-
92
- global_option :confirm, "--confirm PROTOCOL"
93
- global_option :help, "--help", "-h"
94
- global_option :remote, "--remote REMOTE"
95
-
96
- def self.prepare_run(cmd, args=[])
97
- command = parse(cmd)
98
-
99
- unless command
100
- if %w( -v --version ).include?(cmd)
101
- display Transcriptic::VERSION
102
- exit
103
- end
104
-
105
- output_with_bang("`#{cmd}` is not a transcriptic command.")
106
-
107
- distances = {}
108
- (commands.keys + command_aliases.keys).each do |suggestion|
109
- distance = string_distance(cmd, suggestion)
110
- distances[distance] ||= []
111
- distances[distance] << suggestion
112
- end
113
-
114
- if distances.keys.min < 4
115
- suggestions = distances[distances.keys.min].sort
116
- if suggestions.length == 1
117
- output_with_bang("Perhaps you meant `#{suggestions.first}`.")
118
- else
119
- output_with_bang("Perhaps you meant #{suggestions[0...-1].map {|suggestion| "`#{suggestion}`"}.join(', ')} or `#{suggestions.last}`.")
120
- end
121
- end
122
-
123
- output_with_bang("See `transcriptic help` for additional details.")
124
- exit(1)
125
-
126
- end
127
-
128
- @current_command = cmd
129
-
130
- opts = {}
131
- invalid_options = []
132
-
133
- parser = OptionParser.new do |parser|
134
- # overwrite OptionParsers Officious['version'] to avoid conflicts
135
- # see: https://github.com/ruby/ruby/blob/trunk/lib/optparse.rb#L814
136
- parser.on("--version") do |value|
137
- invalid_options << "--version"
138
- end
139
- global_options.each do |global_option|
140
- parser.on(*global_option[:args]) do |value|
141
- global_option[:proc].call(value) if global_option[:proc]
142
- opts[global_option[:name]] = value
143
- end
144
- end
145
- command[:options].each do |name, option|
146
- parser.on("-#{option[:short]}", "--#{option[:long]}", option[:desc]) do |value|
147
- opts[name.gsub("-", "_").to_sym] = value
148
- end
149
- end
150
- end
151
-
152
- begin
153
- parser.order!(args) do |nonopt|
154
- invalid_options << nonopt
155
- end
156
- rescue OptionParser::InvalidOption => ex
157
- invalid_options << ex.args.first
158
- retry
159
- end
160
-
161
- if opts[:help]
162
- args.unshift cmd unless cmd =~ /^-.*/
163
- cmd = "help"
164
- command = parse(cmd)
165
- end
166
-
167
- args.concat(invalid_options)
168
-
169
- @current_args = args
170
- @current_options = opts
171
- @invalid_arguments = invalid_options
172
-
173
- [ command[:klass].new(args.dup, opts.dup), command[:method] ]
174
- end
175
-
176
- def self.run(cmd, arguments=[])
177
- object, method = prepare_run(cmd, arguments.dup)
178
- object.send(method)
179
- rescue RestClient::Unauthorized
180
- puts "Authentication failure"
181
- unless ENV['TRANSCRIPTIC_API_KEY']
182
- run "login"
183
- retry
184
- end
185
- rescue RestClient::PaymentRequired => e
186
- retry if run('account:confirm_billing', arguments.dup)
187
- rescue RestClient::ResourceNotFound => e
188
- error extract_error(e.http_body) {
189
- e.http_body =~ /^([\w\s]+ not found).?$/ ? $1 : "Resource not found"
190
- }
191
- rescue RestClient::Locked => e
192
- app = e.response.headers[:x_confirmation_required]
193
- if confirm_command(app, extract_error(e.response.body))
194
- arguments << '--confirm' << app
195
- retry
196
- end
197
- rescue RestClient::RequestTimeout
198
- error "API request timed out. Please try again, or contact support@transcriptic.com if this issue persists."
199
- rescue RestClient::RequestFailed => e
200
- error extract_error(e.http_body)
201
- rescue CommandFailed => e
202
- error e.message
203
- rescue OptionParser::ParseError => ex
204
- commands[cmd] ? run("help", [cmd]) : run("help")
205
- end
206
-
207
- def self.parse(cmd)
208
- commands[cmd] || commands[command_aliases[cmd]]
209
- end
210
-
211
- def self.extract_error(body, options={})
212
- default_error = block_given? ? yield : "Internal server error.\nRun 'try status' to check for known platform issues."
213
- parse_error_xml(body) || parse_error_json(body) || parse_error_plain(body) || default_error
214
- end
215
-
216
- def self.parse_error_xml(body)
217
- xml_errors = REXML::Document.new(body).elements.to_a("//errors/error")
218
- msg = xml_errors.map { |a| a.text }.join(" / ")
219
- return msg unless msg.empty?
220
- rescue Exception
221
- end
222
-
223
- def self.parse_error_json(body)
224
- json = json_decode(body.to_s) rescue false
225
- json ? json['error'] : nil
226
- end
227
-
228
- def self.parse_error_plain(body)
229
- return unless body.respond_to?(:headers) && body.headers[:content_type].to_s.include?("text/plain")
230
- body.to_s
231
- end
232
- end
233
- end