Class: Cielo24Command::Application
- Inherits:
-
Thor
- Object
- Thor
- Cielo24Command::Application
- Includes:
- Cielo24
- Defined in:
- lib/cielo24_command/application.rb
Instance Method Summary collapse
- #add_embedded_media_to_job ⇒ Object
- #add_media_to_job ⇒ Object
- #authorize ⇒ Object
- #create ⇒ Object
- #delete ⇒ Object
- #generate_api_key ⇒ Object
- #get_caption ⇒ Object
- #get_elementlist ⇒ Object
- #get_media ⇒ Object
- #get_transcript ⇒ Object
-
#help(arg = nil, arg2 = nil) ⇒ Object
Method override, so that an “always required” message can be printed out before everything else.
- #job_info ⇒ Object
- #list ⇒ Object
- #list_elementlists ⇒ Object
- #login ⇒ Object
- #logout ⇒ Object
- #remove_api_key ⇒ Object
- #update_password ⇒ Object
Instance Method Details
#add_embedded_media_to_job ⇒ Object
182 183 184 185 186 187 188 189 |
# File 'lib/cielo24_command/application.rb', line 182 def puts "Adding embedded media to job..." actions = initialize_actions token = get_token(actions) task_id = actions.(token, [:j], [:m]) puts "Task ID: " + task_id print_url() end |
#add_media_to_job ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/cielo24_command/application.rb', line 158 def add_media_to_job puts "Adding media to job..." actions = initialize_actions token = get_token(actions) if ![:m].nil? task_id = actions.add_media_to_job_url(token, [:j], [:m]) elsif ![:M].nil? file = File.new(File.absolute_path([:M]), "r") task_id = actions.add_media_to_job_file(token, [:j], file) else raise ArgumentError.new("Media URL or local file path must be supplied") end puts "Task ID: " + task_id print_url() end |
#authorize ⇒ Object
140 141 142 143 144 145 146 147 |
# File 'lib/cielo24_command/application.rb', line 140 def puts "Authorizing job..." actions = initialize_actions token = get_token(actions) actions.(token, [:j]) print_url() puts "Authorized successfully" end |
#create ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/cielo24_command/application.rb', line 81 def create if [:m].nil? and [:M].nil? puts "Media URL or local file path must be supplied" exit(1) end puts "Creating job..." actions = initialize_actions token = get_token(actions) mash = actions.create_job(token, [:n], [:l]) puts "Job ID: " + mash.JobId puts "Task ID: " + mash.TaskId print_url() puts "Adding media..." if ![:m].nil? task_id = actions.add_media_to_job_url(token, mash.JobId, [:m]) elsif ![:M].nil? file = File.new(File.absolute_path([:M]), "r") task_id = actions.add_media_to_job_file(token, mash.JobId, file) end puts "Task ID: " + task_id print_url() puts "Performing transcription..." # Parse option hash jobopts = PerformTranscriptionOptions.new jobopts.populate_from_hash([:J]) task_id = actions.perform_transcription(token, mash.JobId, [:f], [:P], [:C], [:T], [:t], jobopts) puts "Task ID: " + task_id print_url() end |
#delete ⇒ Object
124 125 126 127 128 129 130 131 |
# File 'lib/cielo24_command/application.rb', line 124 def delete puts "Deleting job..." actions = initialize_actions token = get_token(actions) task_id = actions.delete_job(token, [:j]) puts "Task ID: " + task_id print_url() end |
#generate_api_key ⇒ Object
309 310 311 312 313 314 315 316 |
# File 'lib/cielo24_command/application.rb', line 309 def generate_api_key puts "Generating API key..." actions = initialize_actions token = get_token(actions) key = actions.generate_api_key(token, [:u], [:F]) print_url() puts "API Secure Key: " + key end |
#get_caption ⇒ Object
232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/cielo24_command/application.rb', line 232 def get_caption puts "Getting caption..." actions = initialize_actions token = get_token(actions) # Parse options caption_opts = CaptionOptions.new caption_opts.populate_from_hash([:O]) caption = actions.get_caption(token, [:j], [:c], caption_opts) print_url() puts caption end |
#get_elementlist ⇒ Object
277 278 279 280 281 282 283 284 |
# File 'lib/cielo24_command/application.rb', line 277 def get_elementlist puts "Getting ELement List..." actions = initialize_actions token = get_token(actions) mash = actions.get_element_list(token, [:j], option[:e]) print_url() puts JSON.pretty_generate(JSON.parse(mash.to_json(nil))) end |
#get_media ⇒ Object
293 294 295 296 297 298 299 300 |
# File 'lib/cielo24_command/application.rb', line 293 def get_media puts "Getting media..." actions = initialize_actions token = get_token(actions) url = actions.get_media(token, [:j]) print_url() puts url end |
#get_transcript ⇒ Object
255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/cielo24_command/application.rb', line 255 def get_transcript puts "Getting transcript..." actions = initialize_actions token = get_token(actions) # Parse options transcription_opts = TranscriptionOptions.new transcription_opts.populate_from_hash([:O]) transcript = actions.get_transcript(token, [:j], transcription_opts) print_url() puts transcript end |
#help(arg = nil, arg2 = nil) ⇒ Object
Method override, so that an “always required” message can be printed out before everything else
367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'lib/cielo24_command/application.rb', line 367 def help(arg=nil, arg2=nil) super(arg, arg2) puts "\nAlways required options:" puts " -u=username \# cielo24 username" puts " [-s=serverurl] \# cielo24 server URL" puts " \# Default: https://api.cielo24.com" puts "\n ++Either one of the following:" puts " --------------------------------------------" puts " -p=password \# cielo24 password" puts " -k=securekey \# The API Secure Key" puts " -N=token \# The API token of the current session" puts " --------------------------------------------" end |
#job_info ⇒ Object
357 358 359 360 361 362 363 364 |
# File 'lib/cielo24_command/application.rb', line 357 def job_info puts "Getting Job Info..." actions = initialize_actions token = get_token(actions) mash = actions.get_job_info(token, [:j]) print_url() puts JSON.pretty_generate(JSON.parse(mash.to_json(nil))) end |
#list ⇒ Object
197 198 199 200 201 202 203 204 |
# File 'lib/cielo24_command/application.rb', line 197 def list puts "Retrieving list..." actions = initialize_actions token = get_token(actions) mash = actions.get_job_list(token) print_url() puts JSON.pretty_generate(JSON.parse(mash.to_json(nil))) end |
#list_elementlists ⇒ Object
213 214 215 216 217 218 219 220 |
# File 'lib/cielo24_command/application.rb', line 213 def list_elementlists puts "Listing Element Lists..." actions = initialize_actions token = get_token(actions) array = actions.get_list_of_element_lists(token, [:j]) print_url() puts JSON.pretty_generate(array) end |
#login ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/cielo24_command/application.rb', line 47 def login puts "Performing a login action..." actions = initialize_actions token = actions.login([:u], [:p], [:k], [:h]) print_url() puts "API token: " + token end |
#logout ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/cielo24_command/application.rb', line 57 def logout puts "Performing a logout action..." actions = initialize_actions actions.logout([:N]) print_url() puts "Logged out successfully" end |
#remove_api_key ⇒ Object
325 326 327 328 329 330 331 332 |
# File 'lib/cielo24_command/application.rb', line 325 def remove_api_key puts "Removing API key..." actions = initialize_actions token = get_token(actions) actions.remove_api_key(token, [:k]) print_url() puts "The key was successfully removed." end |
#update_password ⇒ Object
341 342 343 344 345 346 347 348 |
# File 'lib/cielo24_command/application.rb', line 341 def update_password puts "Updating password..." actions = initialize_actions token = get_token(actions) actions.update_password(token, [:d]) print_url() puts "Password was updated successfully." end |