cielo24 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,116 +1,126 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cielo24
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
- - Alan Johnson
8
+ - Evgeny Chistyakov
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-07-02 00:00:00.000000000 Z
12
+ date: 2014-07-21 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - "~>"
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
- version: '1.3'
21
+ version: '0'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - "~>"
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
- version: '1.3'
29
+ version: '0'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - ">="
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ">="
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: rspec
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - "~>"
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
- version: 2.14.1
53
+ version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - "~>"
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
- version: 2.14.1
61
+ version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: httpclient
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - "~>"
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
- version: 2.3.4.1
69
+ version: '0'
62
70
  type: :runtime
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - "~>"
75
+ - - ! '>='
67
76
  - !ruby/object:Gem::Version
68
- version: 2.3.4.1
69
- description: Library for submitting and requesting captions from Cielo24.
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: hashie
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: Cielo24 API interface gem.
70
95
  email:
71
- - alan@teamtreehouse.com
96
+ - support@cielo24.com
72
97
  executables: []
73
98
  extensions: []
74
99
  extra_rdoc_files: []
75
- files:
76
- - ".gitignore"
77
- - CHANGELOG
78
- - Gemfile
79
- - LICENSE.txt
80
- - README.md
81
- - Rakefile
82
- - cielo24.gemspec
83
- - lib/cielo24.rb
84
- - lib/cielo24/authentication.rb
85
- - lib/cielo24/client.rb
86
- - lib/cielo24/jobs.rb
87
- - lib/cielo24/version.rb
88
- - spec/jobs_spec.rb
89
- - spec/spec_helper.rb
90
- homepage: ''
100
+ files: []
101
+ homepage: http://www.cielo24.com/
91
102
  licenses:
92
103
  - MIT
93
- metadata: {}
94
104
  post_install_message:
95
105
  rdoc_options: []
96
106
  require_paths:
97
107
  - lib
98
108
  required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
99
110
  requirements:
100
- - - ">="
111
+ - - ! '>='
101
112
  - !ruby/object:Gem::Version
102
113
  version: '0'
103
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
104
116
  requirements:
105
- - - ">="
117
+ - - ! '>='
106
118
  - !ruby/object:Gem::Version
107
119
  version: '0'
108
120
  requirements: []
109
121
  rubyforge_project:
110
- rubygems_version: 2.2.2
122
+ rubygems_version: 1.8.28
111
123
  signing_key:
112
- specification_version: 4
113
- summary: Submit and request captions through Cielo24.
114
- test_files:
115
- - spec/jobs_spec.rb
116
- - spec/spec_helper.rb
124
+ specification_version: 3
125
+ summary: Cielo24 API interface gem.
126
+ test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 688492c209e5e419abe9c75cdbcd5f64e6a1a68a
4
- data.tar.gz: 0a7f8ceb04c9c35ad3c770328977b571fe10efe8
5
- SHA512:
6
- metadata.gz: 907ddbc758b372ce37d8eaca182e0945e6beb2bff62cfdf640829c2a91f889c4bb0ffd3349789bf0cfd8295a33755c1818e05260c708760bfb968c0be0e40bfa
7
- data.tar.gz: 97d8014a43aa4709a58e0bd33ba8c75a3a7116b8a224fce2b0a6bb97210c7d5a0ce6eda4bc578ec77b42e1d7b6c5e4b8199170c09eb17521a800fa0782ce4fd0
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- bin/
data/CHANGELOG DELETED
@@ -1,27 +0,0 @@
1
- # Changelog
2
-
3
- ## 0.0.3 - 2014-07-01
4
-
5
- Special thanks to [zackm](https://github.com/zackm) for his contributions on this release. It's pretty much
6
- all him!
7
-
8
- ### Added
9
-
10
- - The configure method now supports using logins with passwords or with longer
11
- term API keys, using the `api_key` option.
12
- - Added the `task_status` method.
13
- - Added the `get_transcript` method.
14
- - `perform_transcription` now supports an options hash for additional Cielo24
15
- options.
16
-
17
- ### Deprecated
18
-
19
- - Nothing.
20
-
21
- ### Removed
22
-
23
- - Nothing.
24
-
25
- ### Fixed
26
-
27
- - Nothing.
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in cielo24.gemspec
4
- gemspec
@@ -1,22 +0,0 @@
1
- Copyright (c) 2014 Alan Johnson
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.
data/README.md DELETED
@@ -1,108 +0,0 @@
1
- # Cielo24
2
-
3
- [ ![Codeship Status for commondream/cielo24](https://www.codeship.io/projects/3b4c3d90-e3ac-0131-3a67-06aaa1f2b67c/status)](https://www.codeship.io/projects/25486)
4
-
5
- Cielo24 is a service for creating video captions and transcripts. This library interacts with the Cielo24 API to submit and retrieve captions. Cielo24 API documentation is available [here](http://cielo24.com/static/cielo24/documents/Cielo24ServicesAPI-v1.4.9.pdf).
6
-
7
- This is currently an incomplete implementation fo the Cielo24 API to solve my personal needs. Feel free to send a pull request if you want to complete more of the API.
8
-
9
- ## Installation
10
-
11
- Add this line to your application's Gemfile:
12
-
13
- gem 'cielo24'
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install cielo24
22
-
23
- ## Usage
24
-
25
- ### Authentication:
26
-
27
- The Cielo24 team recommend password based authentication, so to configure your username and password:
28
-
29
- ```
30
- Cielo24::Client.configure({username: "user", password: "somepass"})
31
- ```
32
-
33
- Alternatively, you can login with your username and API key:
34
-
35
- ```
36
- Cielo24::Client.configure({username: "user", securekey: "api_key"})
37
- ```
38
-
39
- You may also authenticate through the Cielo24 sandbox with the following settings (use your own sandbox username and password):
40
-
41
- ```
42
- Cielo24::Client.configure(username: "username", password: "password",
43
- uri: "https://sandbox.cielo24.com", verify_mode: OpenSSL::SSL::VERIFY_NONE)
44
- ```
45
-
46
- ### Submitting a video for captioning:
47
-
48
- ```
49
- client = Cielo24::Client.new
50
- job_id = client.create_job("Test Job")
51
- client.add_media(job_id, "http://test.com/my-media.mp4")
52
- task_id = client.perform_transcription(job_id)
53
- ```
54
-
55
- Captioning defaults to professional fidelity and standard priority.
56
-
57
- ### Checking if captions are complete:
58
-
59
- ```
60
- client.task_complete?(task_id)
61
- ```
62
-
63
- ### Downloading captions:
64
-
65
- ```
66
- data = client.get_caption(job_id)
67
- ```
68
-
69
- #### Optional arguments
70
-
71
- ```
72
- format = "DFXP" # Defaults to "SRT"
73
- options = {:remove_sound_references => true} # add as many or as few options as you like
74
- data = client.get_caption(job_id, format, options)
75
- ```
76
-
77
- ### Downloading transcripts:
78
-
79
- ```
80
- data = client.get_transcript(job_id)
81
- ```
82
-
83
- #### Optional arguments
84
-
85
- ```
86
- options = {:remove_sound_references => true}
87
- data = client.get_transcript(job_id, options)
88
- ```
89
-
90
- ### Get Job Info:
91
-
92
- ```
93
- json_data = client.job_info(job_id)
94
- ```
95
-
96
- ### Get Task Status:
97
-
98
- ```
99
- json_data = client.task_status(task_id)
100
- ```
101
-
102
- ## Contributing
103
-
104
- 1. Fork it
105
- 2. Create your feature branch (`git checkout -b my-new-feature`)
106
- 3. Commit your changes (`git commit -am 'Add some feature'`)
107
- 4. Push to the branch (`git push origin my-new-feature`)
108
- 5. Create new Pull Request
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require "bundler/gem_tasks"
@@ -1,26 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'cielo24/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "cielo24"
8
- spec.version = Cielo24::VERSION
9
- spec.authors = ["Alan Johnson"]
10
- spec.email = ["alan@teamtreehouse.com"]
11
- spec.description = %q{Library for submitting and requesting captions from Cielo24.}
12
- spec.summary = %q{Submit and request captions through Cielo24.}
13
- spec.homepage = ""
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec", "~> 2.14.1"
24
-
25
- spec.add_dependency "httpclient", "~> 2.3.4.1"
26
- end
@@ -1,11 +0,0 @@
1
- require_relative 'cielo24/version'
2
- require_relative 'cielo24/authentication'
3
- require_relative 'cielo24/jobs'
4
- require_relative 'cielo24/client'
5
-
6
- require 'uri'
7
- require 'httpclient'
8
- require 'json'
9
-
10
- module Cielo24
11
- end
@@ -1,15 +0,0 @@
1
- module Cielo24
2
- # Methods for authenticating.
3
- module Authentication
4
-
5
- # Public: Get a api token for this session.
6
- #
7
- # options - a Hash with either of the following sets of keys:
8
- # username, password
9
- # username, securekey
10
- def log_in(options)
11
- data = get_json("/api/account/login", options)
12
- data["ApiToken"]
13
- end
14
- end
15
- end
@@ -1,90 +0,0 @@
1
- module Cielo24
2
-
3
- # Class for interacting with the Cielo24 API.
4
- class Client
5
- include Cielo24::Authentication
6
- include Cielo24::Jobs
7
-
8
- attr_accessor :connection
9
- attr_accessor :token
10
-
11
- DEFAULT_URI = "https://api.cielo24.com"
12
- VERSION = 1
13
- VERIFY_MODE = nil
14
-
15
- # Public: Configures the connection.
16
- #
17
- # options - the configuration options for use with Cielo24.
18
- # :username - The username to use for authentication.
19
- # :password - The password to use for authentication.
20
- # :api_key - The API key to use for authentication.
21
- # :uri - The uri to use for requests. Defaults to the Cielo24 API URI.
22
- def self.configure(options = {})
23
- @options = {uri: DEFAULT_URI, version: VERSION, verify_mode: VERIFY_MODE}.merge(options)
24
- end
25
-
26
- # Internal: Our configuration settings for Cielo24.
27
- def self.options
28
- @options ||= {}
29
- end
30
-
31
- def initialize
32
- self.connection = connect
33
-
34
- login_options = {username: self.class.options[:username]}
35
- if self.class.options[:api_key]
36
- login_options['securekey'] = self.class.options[:api_key]
37
- else
38
- login_options['password'] = self.class.options[:password]
39
- end
40
- # Go ahead and set up the single use token for this session
41
- @token = log_in(login_options)
42
- end
43
-
44
- # Internal: Returns an HTTPClient connection object.
45
- def connect
46
- connection = HTTPClient.new
47
- connection.cookie_manager = nil
48
-
49
- unless self.class.options[:verify_mode] == nil
50
- connection.ssl_config.verify_mode = self.class.options[:verify_mode]
51
- end
52
-
53
- return connection
54
- end
55
-
56
- # Internal: Makes a get request with the given parameters.
57
- #
58
- # path - The path to request.
59
- # params - The parameters to include with the request.
60
- #
61
- # Returns the JSON for the response we received.
62
- def get(path, params = {})
63
- uri = URI(self.class.options[:uri])
64
- uri.path = path
65
-
66
- # add api version to each request
67
- params = {v: self.class.options[:version]}.merge(params)
68
-
69
- # add token if possible
70
- if token
71
- params = {api_token: token}.merge(params)
72
- end
73
-
74
- response = connection.get(uri, params)
75
- if response.status_code == 200
76
- return response.body
77
- else
78
- # Cielo24 always returns error messages as JSON
79
- raise(JSON.parse(response.body)["ErrorComment"])
80
- end
81
- end
82
-
83
- # Internal: Makes a request to Cielo24 and returns JSON data
84
- def get_json(path, params)
85
- body = get(path, params)
86
-
87
- JSON.parse(body)
88
- end
89
- end
90
- end
@@ -1,94 +0,0 @@
1
- module Cielo24
2
- module Jobs
3
-
4
- # Public: Creates a new job.
5
- #
6
- # job_name - A human-readable name for the job to be created.
7
- # language - An RFC 5646 Language tag indicating native job language. Defaults to ‘en’.
8
- #
9
- # Returns a job id for the newly created job.
10
- def create_job(job_name, language = "en")
11
- data = get_json("/api/job/new", {job_name: job_name, language: language})
12
-
13
- return data["JobId"]
14
- end
15
-
16
- # Public: Attaches media to a job.
17
- #
18
- # job_id - The id of a job to attach media to.
19
- # media_url - The URL of the media file to attach to the job.
20
- #
21
- # Returns the task id for the media.
22
- def add_media(job_id, media_url)
23
- data = get_json("/api/job/add_media", {job_id: job_id, media_url: media_url})
24
-
25
- data["TaskId"]
26
- end
27
-
28
- # Public: Requests that a transcription be performed.
29
- #
30
- # job_id - The id of a job to attach media to.
31
- # fidelity - Should be one of MECHANICAL, PREMIUM, or PROFESSIONAL. Default: PROFESSIONAL
32
- # priority - Should be one of ECONOMY, STANDARD, or PRIORITY. Default: STANDARD
33
- # options - Additional optional parameters for perform the transcription. See the Cielo24 documentation
34
- # for the full list.
35
- #
36
- # Returns the task id for the transcription.
37
- def perform_transcription(job_id, fidelity = "PROFESSIONAL", priority = "STANDARD", options = {})
38
- options = options.merge(job_id: job_id, transcription_fidelity: fidelity, priority: priority)
39
- data = get_json("/api/job/perform_transcription", options)
40
-
41
- data["TaskId"]
42
- end
43
-
44
- # Public: Requests info about a particular job.
45
- #
46
- # job_id - The job to get info about.
47
- #
48
- # Returns the job info as JSON
49
- def job_info(job_id)
50
- get_json("/api/job/info", {job_id: job_id})
51
- end
52
-
53
- # Public: Requests the status info for a particular task.
54
- #
55
- # task_id - The task to get info about.
56
- #
57
- # Returns the task info as JSON
58
- def task_status(task_id)
59
- get_json("/api/job/task_status", {task_id: task_id})
60
- end
61
-
62
- # Public: Returns whether or not a task has completed.
63
- #
64
- # task_id - The task to check status for.
65
- #
66
- # Returns true if the task is complete, false otherwise.
67
- def task_complete?(task_id)
68
- task_status(task_id)["TaskStatus"] == "COMPLETE"
69
- end
70
-
71
- # Public: Gets the caption results from a job.
72
- #
73
- # job_id - The id of the job we're pulling captions for.
74
- # caption_format - THe format for the captions. SRT, SBV, DFXP, or QT. Defaults to SRT.
75
- # options - Additional optional parameters for requesting captions. See the Cielo24 documentation
76
- # for the list of optional parameters.
77
- #
78
- # Returns the caption data as text.
79
- def get_caption(job_id, caption_format = "SRT", options = {})
80
- get("/api/job/get_caption", options.merge(caption_format: caption_format, job_id: job_id))
81
- end
82
-
83
- # Public: Gets the transcript results from a job.
84
- #
85
- # job_id - The id of the job we're retrieving a transcription for.
86
- # options - Optional parameters for requesting transcripts. See the Cielo24 documentation
87
- # for the full list of parameters.
88
- #
89
- # Returns the transcript data as text.
90
- def get_transcript(job_id, options = {})
91
- get("/api/job/get_transcript", options.merge(job_id: job_id))
92
- end
93
- end
94
- end
@@ -1,3 +0,0 @@
1
- module Cielo24
2
- VERSION = "0.0.3"
3
- end
@@ -1,96 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Cielo24::Jobs" do
4
-
5
- let(:client) { Cielo24::Client.new }
6
-
7
- let(:job_id) do
8
- stub_get_json("/api/job/new", {"JobId" => "JOB123"})
9
- client.create_job("Test Job")
10
- end
11
-
12
- let(:job_with_media_id) do
13
- stub_get_json("/api/job/add_media", {"TaskId" => "TASK123"})
14
- client.add_media(job_id, "http://test.com/media.mp4")
15
-
16
- job_id
17
- end
18
-
19
- let(:transcribed_job_id) do
20
- stub_get_json("/api/job/perform_transcription", { "TaskId" => "TASK123"})
21
- client.perform_transcription(job_with_media_id)
22
-
23
- # it unfortunately takes a second to get a successful caption back from the
24
- # sandbox
25
- sleep(3) if test_sandbox?
26
- end
27
-
28
- describe "#create_job" do
29
- it "returns the job id for the newly created job" do
30
- stub_get_json("/api/job/new", {"JobId" => "JOB123"})
31
- expect(client.create_job("Some New Job")).to_not be_nil
32
- end
33
- end
34
-
35
- describe "#add_media" do
36
- it "returns the task id for the media that was added" do
37
- stub_get_json("/api/job/add_media", {"TaskId" => "TASK123"})
38
- expect(client.add_media(job_id, "http://test.com/test_media.mp4")).to_not be_nil
39
- end
40
- end
41
-
42
- describe "#perform_transcription" do
43
- it "returns the task id for the transcription" do
44
- stub_get_json("/api/job/perform_transcription", {"TaskId" => "TASK123"})
45
- expect(client.perform_transcription(job_with_media_id)).to_not be_nil
46
- end
47
- end
48
-
49
- describe "#task_complete?" do
50
- it "returns true if the task has completed" do
51
- pending("CANNOT GUARANTEE COMPLETED JOB IN SANDBOX") if test_sandbox?
52
-
53
- stub_get_json("/api/job/task_status", {"TaskStatus" => "COMPLETE"})
54
- expect(client.task_complete?("TASK123")).to be_true
55
- end
56
-
57
- it "returns false if the task hasn't completed" do
58
- pending("CANNOT GUARANTEE INCOMPLETE JOB IN SANDBOX") if test_sandbox?
59
-
60
- stub_get_json("/api/job/task_status", {"TaskStatus" => "INCOMPLETE"})
61
- expect(client.task_complete?("TASK123")).to be_false
62
- end
63
- end
64
-
65
- describe "#job_info" do
66
- it "returns job info" do
67
- stub_get_json("/api/job/info", {"JobId" => "JOB123", "JobName" => "A Test Job"})
68
- expect(client.job_info(job_id)).to_not be_nil
69
- end
70
- end
71
-
72
- describe "#task_status" do
73
- it "returns the task status" do
74
- stub_get_json("/api/job/task_status", {"TaskId" => "TASK123", "TaskType" => "JOB_PERFORM_TRANSCRIPT"})
75
- expect(client.task_status("TASK123")).to_not be_nil
76
- end
77
- end
78
-
79
- describe "#get_caption" do
80
- it "returns the captions" do
81
- pending("SANDBOX DOESN'T ALWAYS RETURN CAPTIONS CORRECTLY") if test_sandbox?
82
-
83
- stub_get("/api/job/get_caption", "SOME CAPTION DATA")
84
- expect(client.get_caption(transcribed_job_id)).to_not be_nil
85
- end
86
- end
87
-
88
- describe "#get_transcript" do
89
- it "returns the transcripts" do
90
- pending("SANDBOX DOESN'T ALWAYS RETURN TRANSCRIPTS CORRECTLY") if test_sandbox?
91
-
92
- stub_get("/api/job/get_transcript", "This is some transcript data.")
93
- expect(client.get_transcript(transcribed_job_id)).to_not be_nil
94
- end
95
- end
96
- end
@@ -1,58 +0,0 @@
1
- require_relative "../lib/cielo24"
2
-
3
- if ENV["CIELO24_SANDBOX"]
4
- Cielo24::Client.configure(username: ENV["CIELO24_SANDBOX_USERNAME"],
5
- password: ENV["CIELO24_SANDBOX_PASSWORD"],
6
- uri: "https://sandbox.cogi.com", verify_mode: OpenSSL::SSL::VERIFY_NONE)
7
- end
8
-
9
-
10
- module Cielo24
11
- module SpecHelpers
12
-
13
- # Internal: Returns whether or not we're testing against the sandbox.
14
- def test_sandbox?
15
- !ENV["CIELO24_SANDBOX"].nil?
16
- end
17
-
18
- # Internal: Stubs the get_json method unless we're testing against the sandbox.
19
- #
20
- # path - The api path to stub.
21
- # value - The value to return from the stubbed call.
22
- #
23
- # Examples:
24
- # stub_get_json("/api/job/new", {"JobId" => "12345"})
25
- # => get_json returns {"JobId" => "12345"}
26
- def stub_get_json(path, value)
27
- unless test_sandbox?
28
- Cielo24::Client.any_instance.stub(:get_json).with(path, an_instance_of(Hash)).and_return(value)
29
- end
30
- end
31
-
32
- # Internal: STubs the get method unless we're testing against the sandbox.
33
- #
34
- # path - The api path to stub.
35
- # value - The value to return from the stubbed call.
36
- #
37
- # Examples:
38
- # stub_get("/api/job/get_caption", "SOME CAPTION DATA")
39
- # => get returns "SOME CAPTION DATA"
40
- def stub_get(path, value)
41
- unless test_sandbox?
42
- Cielo24::Client.any_instance.stub(:get).with(path, an_instance_of(Hash)).and_return(value)
43
- end
44
- end
45
- end
46
- end
47
-
48
- RSpec.configure do |config|
49
- config.include Cielo24::SpecHelpers
50
-
51
- # Stub out logging in if needed
52
- config.before(:each) do
53
- unless test_sandbox?
54
- Cielo24::Client.any_instance.stub(:log_in).and_return("FOOBARTOKEN")
55
- end
56
- end
57
- end
58
-