fixer_client 0.0.2 → 0.1.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/README.md +23 -2
- data/examples/basic.rb +4 -3
- data/examples/sequence.rb +37 -0
- data/examples/transcode.rb +2 -1
- data/fixer_client.gemspec +1 -0
- data/lib/fixer/api.rb +2 -2
- data/lib/fixer/configuration.rb +1 -1
- data/lib/fixer/connection.rb +3 -7
- data/lib/fixer/version.rb +1 -1
- data/test/fixer/client_test.rb +42 -13
- data/test/minitest_helper.rb +8 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b2804caf3476551d2e77e70a3f4522faec86a2d
|
4
|
+
data.tar.gz: 2dbed2d9c37d72811806071fe515de5689576641
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6ef6ef9c05f6613645a5ed1151f8c04bec81c71db0a4995ac95c3e691dfb6325a450c2138bfb5ae4b5bfebfd45c59b8d772d8303ecca03da79e029273afb011
|
7
|
+
data.tar.gz: 8033f880b90362bee739fe5e3f4cf27c948d919a6c360f1eddcc2757706d24e21bd674fdd451e0f950757f9f95537025e595085cd15d4d39196cd4cfc8de782a
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# Fixer Client
|
2
2
|
|
3
|
-
|
3
|
+
[](http://opensource.org/licenses/MIT)
|
4
|
+
[](https://travis-ci.org/PRX/fixer_client)
|
5
|
+
[](https://codeclimate.com/github/PRX/fixer_client)
|
6
|
+
[](https://coveralls.io/r/PRX/fixer_client?branch=master)
|
7
|
+
[](https://gemnasium.com/PRX/fixer_client)
|
8
|
+
|
9
|
+
Client gem for the [Fixer](https://github.com/PRX/fixer.prx.org) application.
|
4
10
|
|
5
11
|
## Installation
|
6
12
|
|
@@ -76,8 +82,23 @@ j = client.jobs.create(job)
|
|
76
82
|
|
77
83
|
```
|
78
84
|
|
85
|
+
## License
|
86
|
+
[The MIT License](http://opensource.org/licenses/MIT)
|
87
|
+
|
79
88
|
## Contributing
|
80
89
|
|
90
|
+
In a local development environment, you can use a `.env-fixer_client` file that will be loaded to set the required environment variables.
|
91
|
+
|
92
|
+
For example:
|
93
|
+
```
|
94
|
+
touch .env-fixer_client
|
95
|
+
echo FIXER_CLIENT_ID=1111111111111111111111111111111111111111111111111111111111111111 >> .env-fixer_client
|
96
|
+
echo FIXER_CLIENT_SECRET=2222222222222222222222222222222222222222222222222222222222222222 >> .env-fixer_client
|
97
|
+
|
98
|
+
# you can also set useful values like this for debugging
|
99
|
+
echo EXCON_DEBUG=true
|
100
|
+
```
|
101
|
+
|
81
102
|
1. Fork it ( https://github.com/[my-github-username]/fixer_client/fork )
|
82
103
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
83
104
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
data/examples/basic.rb
CHANGED
@@ -2,11 +2,12 @@ require 'dotenv'
|
|
2
2
|
Dotenv.load '.env-fixer_client'
|
3
3
|
|
4
4
|
require 'fixer_client'
|
5
|
+
Fixer.reset!
|
5
6
|
|
6
7
|
Fixer.configure do |c|
|
7
|
-
c.client_id = '
|
8
|
-
c.client_secret = '
|
9
|
-
c.endpoint = 'http://fixer.prx.dev/api/'
|
8
|
+
c.client_id = ENV['FIXER_CLIENT_ID']
|
9
|
+
c.client_secret = ENV['FIXER_CLIENT_SECRET']
|
10
|
+
c.endpoint = 'http://fixer.prx.dev/api/'
|
10
11
|
end
|
11
12
|
|
12
13
|
client = Fixer::Client.new
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'dotenv'
|
2
|
+
Dotenv.load '.env-fixer_client'
|
3
|
+
|
4
|
+
require 'fixer_client'
|
5
|
+
Fixer.reset!
|
6
|
+
|
7
|
+
Fixer.configure do |c|
|
8
|
+
c.client_id = ENV['FIXER_CLIENT_ID']
|
9
|
+
c.client_secret = ENV['FIXER_CLIENT_SECRET']
|
10
|
+
c.endpoint = 'http://fixer.prx.dev/api/'
|
11
|
+
end
|
12
|
+
|
13
|
+
client = Fixer::Client.new
|
14
|
+
|
15
|
+
job = {
|
16
|
+
job: {
|
17
|
+
original: 's3://test-fixer/audio.wav',
|
18
|
+
job_type: 'audio',
|
19
|
+
tasks: [
|
20
|
+
sequence: {
|
21
|
+
tasks: [
|
22
|
+
{
|
23
|
+
task_type: 'cut',
|
24
|
+
options: { length: 30, fade: 0 }
|
25
|
+
},
|
26
|
+
{
|
27
|
+
task_type: 'transcode',
|
28
|
+
options: { format: 'mp3', bit_rate: 64, sample_rate: 44100 },
|
29
|
+
result: 's3://test-fixer/audio.mp3'
|
30
|
+
}
|
31
|
+
]
|
32
|
+
}
|
33
|
+
]
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
j = client.jobs.create(job)
|
data/examples/transcode.rb
CHANGED
@@ -2,11 +2,12 @@ require 'dotenv'
|
|
2
2
|
Dotenv.load '.env-fixer_client'
|
3
3
|
|
4
4
|
require 'fixer_client'
|
5
|
+
Fixer.reset!
|
5
6
|
|
6
7
|
Fixer.configure do |c|
|
7
8
|
c.client_id = ENV['FIXER_CLIENT_ID']
|
8
9
|
c.client_secret = ENV['FIXER_CLIENT_SECRET']
|
9
|
-
c.endpoint = 'http://fixer
|
10
|
+
c.endpoint = 'http://fixer.prx.dev/api/'
|
10
11
|
end
|
11
12
|
|
12
13
|
client = Fixer::Client.new
|
data/fixer_client.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency('rake')
|
31
31
|
spec.add_development_dependency('minitest')
|
32
32
|
spec.add_development_dependency('simplecov')
|
33
|
+
spec.add_development_dependency('coveralls')
|
33
34
|
spec.add_development_dependency('webmock')
|
34
35
|
spec.add_development_dependency('dotenv')
|
35
36
|
end
|
data/lib/fixer/api.rb
CHANGED
@@ -76,12 +76,12 @@ module Fixer
|
|
76
76
|
|
77
77
|
def create(params={})
|
78
78
|
self.current_options = current_options.merge(args_to_options(params))
|
79
|
-
request(:post, base_path, {data: params})
|
79
|
+
request(:post, base_path, { data: params } )
|
80
80
|
end
|
81
81
|
|
82
82
|
def update(params={})
|
83
83
|
self.current_options = current_options.merge(args_to_options(params))
|
84
|
-
request(:put, base_path, {data: params})
|
84
|
+
request(:put, base_path, { data: params } )
|
85
85
|
end
|
86
86
|
|
87
87
|
def delete(params={})
|
data/lib/fixer/configuration.rb
CHANGED
data/lib/fixer/connection.rb
CHANGED
@@ -20,8 +20,8 @@ module Fixer
|
|
20
20
|
options = {
|
21
21
|
headers: {
|
22
22
|
# generic http headers
|
23
|
-
'User-Agent'
|
24
|
-
'Accept'
|
23
|
+
'User-Agent' => user_agent,
|
24
|
+
'Accept' => 'application/json;charset=utf-8'
|
25
25
|
},
|
26
26
|
ssl: { verify: false },
|
27
27
|
url: endpoint
|
@@ -31,14 +31,10 @@ module Fixer
|
|
31
31
|
options.select{|k,v| ALLOWED_OPTIONS.include?(k.to_sym)}
|
32
32
|
end
|
33
33
|
|
34
|
-
def connection(opts={})
|
35
|
-
@token ||= get_token(opts)
|
36
|
-
end
|
37
|
-
|
38
34
|
def connection(options={})
|
39
35
|
Faraday::Connection.new(process_options(options)) do |connection|
|
40
36
|
connection.request :authorization, 'Bearer', get_token(options).token
|
41
|
-
connection.request :
|
37
|
+
connection.request :json
|
42
38
|
connection.response :mashify
|
43
39
|
connection.response :logger if options[:debug]
|
44
40
|
connection.response :json
|
data/lib/fixer/version.rb
CHANGED
data/test/fixer/client_test.rb
CHANGED
@@ -6,7 +6,7 @@ describe Fixer::Client do
|
|
6
6
|
|
7
7
|
let(:client) { Fixer::Client.new }
|
8
8
|
|
9
|
-
let(:
|
9
|
+
let(:job_params) do
|
10
10
|
{
|
11
11
|
job: {
|
12
12
|
job_type: 'test',
|
@@ -14,26 +14,55 @@ describe Fixer::Client do
|
|
14
14
|
retry_max: 10,
|
15
15
|
retry_delay: 300,
|
16
16
|
tasks: [
|
17
|
-
{
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
sequence: {
|
18
|
+
tasks: [
|
19
|
+
{
|
20
|
+
task_type: 'echo',
|
21
|
+
label: 'test1',
|
22
|
+
options: { foo: 'bar' },
|
23
|
+
call_back: 'http://cms.prx.dev/call_back'
|
24
|
+
},
|
25
|
+
{
|
26
|
+
task_type: 'echo',
|
27
|
+
label: 'test2',
|
28
|
+
options: { bar: 'foo' },
|
29
|
+
call_back: 'http://cms.prx.dev/call_back',
|
30
|
+
result: 'http://cms.prx.dev/echo.txt'
|
31
|
+
}
|
32
|
+
]
|
22
33
|
}
|
23
34
|
]
|
24
35
|
}
|
25
36
|
}
|
26
37
|
end
|
27
38
|
|
39
|
+
before do
|
40
|
+
stub_request(:post, "http://fixer.prx.dev/oauth/token").
|
41
|
+
with(:body => {"grant_type"=>"client_credentials"}).
|
42
|
+
to_return(
|
43
|
+
:status => 200,
|
44
|
+
:body => "{\"access_token\":\"4651f8250fb5d21f5dce575894446f003304e2856acad2292daf52a76de5c6e8\",\"token_type\":\"bearer\",\"expires_in\":7200,\"created_at\":#{Time.now.to_i}}",
|
45
|
+
:headers => {"Content-Type" => "application/json; charset=utf-8"}
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
28
49
|
it 'makes a new client' do
|
29
50
|
client.must_be_instance_of Fixer::Client
|
30
51
|
end
|
31
52
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
53
|
+
it 'gets a list of jobs' do
|
54
|
+
stub_request(:get, "http://fixer.prx.dev/api/jobs/").
|
55
|
+
with(:headers => {'Accept'=>'application/json;charset=utf-8'}).
|
56
|
+
to_return(:status => 200, :body => {}.to_json, :headers => {})
|
57
|
+
|
58
|
+
jobs = client.jobs.list
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'creates a complex job' do
|
62
|
+
stub_request(:post, "http://fixer.prx.dev/api/jobs/").
|
63
|
+
with(:headers => { 'Accept' => 'application/json;charset=utf-8', 'Content-Type' => 'application/json' } ).
|
64
|
+
to_return(:status => 200, :body => "", :headers => {})
|
36
65
|
|
37
|
-
|
38
|
-
|
39
|
-
end
|
66
|
+
j = client.jobs.create(job_params)
|
67
|
+
end
|
68
|
+
end
|
data/test/minitest_helper.rb
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
require 'simplecov'
|
4
4
|
SimpleCov.start
|
5
5
|
|
6
|
+
if ENV['TRAVIS']
|
7
|
+
require 'coveralls'
|
8
|
+
Coveralls.wear!
|
9
|
+
end
|
10
|
+
|
11
|
+
ENV['FIXER_CLIENT_ID'] = '1111111111111111111111111111111111111111111111111111111111111111'
|
12
|
+
ENV['FIXER_CLIENT_SECRET'] = '2222222222222222222222222222222222222222222222222222222222222222'
|
13
|
+
|
6
14
|
require 'dotenv'
|
7
15
|
Dotenv.load '.env-fixer_client'
|
8
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixer_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kuklewicz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: coveralls
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: webmock
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -200,11 +214,13 @@ extensions: []
|
|
200
214
|
extra_rdoc_files: []
|
201
215
|
files:
|
202
216
|
- ".gitignore"
|
217
|
+
- ".travis.yml"
|
203
218
|
- Gemfile
|
204
219
|
- LICENSE.txt
|
205
220
|
- README.md
|
206
221
|
- Rakefile
|
207
222
|
- examples/basic.rb
|
223
|
+
- examples/sequence.rb
|
208
224
|
- examples/transcode.rb
|
209
225
|
- fixer_client.gemspec
|
210
226
|
- lib/fixer.rb
|