transloadit 2.0.0 → 3.0.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 +5 -5
- data/.github/workflows/ci.yml +23 -0
- data/.standard.yml +0 -0
- data/CHANGELOG.md +70 -55
- data/Gemfile +1 -1
- data/README.md +162 -86
- data/Rakefile +12 -17
- data/examples/README.md +94 -55
- data/examples/basic/audio-concat-transcoder.rb +29 -19
- data/examples/basic/audio-transcoder.rb +32 -22
- data/examples/basic/image-transcoder.rb +22 -17
- data/examples/basic/main.rb +31 -37
- data/examples/basic/media-transcoder.rb +2 -7
- data/lib/transloadit/api_model.rb +13 -13
- data/lib/transloadit/assembly.rb +27 -24
- data/lib/transloadit/exception.rb +2 -4
- data/lib/transloadit/request.rb +58 -52
- data/lib/transloadit/response/assembly.rb +14 -13
- data/lib/transloadit/response.rb +10 -10
- data/lib/transloadit/step.rb +13 -13
- data/lib/transloadit/template.rb +5 -5
- data/lib/transloadit/version.rb +1 -1
- data/lib/transloadit.rb +24 -24
- data/test/fixtures/cassettes/cancel_assembly.yml +3 -3
- data/test/fixtures/cassettes/create_template.yml +1 -1
- data/test/fixtures/cassettes/delete_template.yml +1 -1
- data/test/fixtures/cassettes/fetch_assemblies.yml +1 -1
- data/test/fixtures/cassettes/fetch_assembly_aborted.yml +3 -3
- data/test/fixtures/cassettes/fetch_assembly_errors.yml +3 -3
- data/test/fixtures/cassettes/fetch_assembly_executing.yml +3 -3
- data/test/fixtures/cassettes/fetch_assembly_notifications.yml +1 -1
- data/test/fixtures/cassettes/fetch_assembly_ok.yml +6 -6
- data/test/fixtures/cassettes/fetch_assembly_uploading.yml +3 -3
- data/test/fixtures/cassettes/fetch_billing.yml +1 -1
- data/test/fixtures/cassettes/fetch_root.yml +3 -3
- data/test/fixtures/cassettes/fetch_template.yml +1 -1
- data/test/fixtures/cassettes/fetch_templates.yml +1 -1
- data/test/fixtures/cassettes/post_assembly.yml +2 -2
- data/test/fixtures/cassettes/rate_limit_fail.yml +3 -3
- data/test/fixtures/cassettes/rate_limit_succeed.yml +4 -4
- data/test/fixtures/cassettes/replay_assembly.yml +2 -2
- data/test/fixtures/cassettes/replay_assembly_notification.yml +1 -1
- data/test/fixtures/cassettes/submit_assembly.yml +3 -3
- data/test/fixtures/cassettes/update_template.yml +1 -1
- data/test/test_helper.rb +10 -10
- data/test/unit/test_transloadit.rb +66 -66
- data/test/unit/transloadit/test_api.rb +35 -33
- data/test/unit/transloadit/test_assembly.rb +148 -112
- data/test/unit/transloadit/test_request.rb +41 -42
- data/test/unit/transloadit/test_response.rb +76 -76
- data/test/unit/transloadit/test_step.rb +52 -52
- data/test/unit/transloadit/test_template.rb +49 -54
- data/transloadit.gemspec +25 -26
- metadata +25 -41
- data/.travis.yml +0 -13
@@ -1,128 +1,128 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
describe Transloadit do
|
4
4
|
before do
|
5
|
-
@key
|
6
|
-
@secret
|
5
|
+
@key = "a"
|
6
|
+
@secret = "b"
|
7
7
|
@duration = 10
|
8
8
|
@max_size = 100
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
12
|
-
t = Transloadit.new(:
|
13
|
-
t.must_be_kind_of Transloadit
|
11
|
+
it "must allow initialization" do
|
12
|
+
t = Transloadit.new(key: @key, secret: @secret)
|
13
|
+
_(t).must_be_kind_of Transloadit
|
14
14
|
end
|
15
15
|
|
16
|
-
it
|
17
|
-
lambda { Transloadit.new }.must_raise ArgumentError
|
16
|
+
it "must not be initialized with no arguments" do
|
17
|
+
_(lambda { Transloadit.new }).must_raise ArgumentError
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
21
|
-
lambda { Transloadit.new(:
|
20
|
+
it "must require a key" do
|
21
|
+
_(lambda { Transloadit.new(secret: @secret) }).must_raise ArgumentError
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
25
|
-
t = Transloadit.new(:
|
26
|
-
t.must_be_kind_of Transloadit
|
24
|
+
it "must not require a secret" do
|
25
|
+
t = Transloadit.new(key: @key)
|
26
|
+
_(t).must_be_kind_of Transloadit
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
30
|
-
Transloadit.new(:
|
29
|
+
it "must provide a default duration" do
|
30
|
+
_(Transloadit.new(key: @key).duration).wont_be_nil
|
31
31
|
end
|
32
32
|
|
33
|
-
describe
|
33
|
+
describe "when initialized" do
|
34
34
|
before do
|
35
35
|
@transloadit = Transloadit.new(
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
36
|
+
key: @key,
|
37
|
+
secret: @secret,
|
38
|
+
duration: @duration,
|
39
|
+
max_size: @max_size
|
40
40
|
)
|
41
41
|
end
|
42
42
|
|
43
|
-
it
|
44
|
-
@transloadit.key.must_equal @key
|
43
|
+
it "must allow access to the key" do
|
44
|
+
_(@transloadit.key).must_equal @key
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
48
|
-
@transloadit.secret.must_equal @secret
|
47
|
+
it "must allow access to the secret" do
|
48
|
+
_(@transloadit.secret).must_equal @secret
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
52
|
-
@transloadit.duration.must_equal @duration
|
51
|
+
it "must allow access to the duration" do
|
52
|
+
_(@transloadit.duration).must_equal @duration
|
53
53
|
end
|
54
54
|
|
55
|
-
it
|
56
|
-
@transloadit.max_size.must_equal @max_size
|
55
|
+
it "must allow access to the max_size" do
|
56
|
+
_(@transloadit.max_size).must_equal @max_size
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
60
|
-
step = @transloadit.step(
|
59
|
+
it "must create steps" do
|
60
|
+
step = @transloadit.step("resize", "/image/resize", width: 320)
|
61
61
|
|
62
|
-
step.must_be_kind_of Transloadit::Step
|
63
|
-
step.name.
|
64
|
-
step.robot.
|
65
|
-
step.options.must_equal :
|
62
|
+
_(step).must_be_kind_of Transloadit::Step
|
63
|
+
_(step.name).must_equal "resize"
|
64
|
+
_(step.robot).must_equal "/image/resize"
|
65
|
+
_(step.options).must_equal width: 320
|
66
66
|
end
|
67
67
|
|
68
|
-
it
|
69
|
-
step
|
70
|
-
assembly = @transloadit.assembly :
|
68
|
+
it "must create assembly api instances" do
|
69
|
+
step = @transloadit.step(nil, nil)
|
70
|
+
assembly = @transloadit.assembly steps: step
|
71
71
|
|
72
|
-
assembly.must_be_kind_of Transloadit::Assembly
|
73
|
-
assembly.steps.must_equal step.to_hash
|
72
|
+
_(assembly).must_be_kind_of Transloadit::Assembly
|
73
|
+
_(assembly.steps).must_equal step.to_hash
|
74
74
|
end
|
75
75
|
|
76
|
-
it
|
76
|
+
it "must create assemblies with multiple steps" do
|
77
77
|
steps = [
|
78
|
-
@transloadit.step(
|
79
|
-
@transloadit.step(
|
78
|
+
@transloadit.step("step1", nil),
|
79
|
+
@transloadit.step("step2", nil)
|
80
80
|
]
|
81
81
|
|
82
|
-
assembly = @transloadit.assembly :
|
83
|
-
assembly.steps.must_equal steps.inject({}) {|h,s| h.merge s }
|
82
|
+
assembly = @transloadit.assembly steps: steps
|
83
|
+
_(assembly.steps).must_equal steps.inject({}) { |h, s| h.merge s }
|
84
84
|
end
|
85
85
|
|
86
|
-
it
|
87
|
-
VCR.use_cassette
|
88
|
-
bill = Transloadit.new(:
|
89
|
-
bill[
|
90
|
-
bill[
|
86
|
+
it "must get user billing report" do
|
87
|
+
VCR.use_cassette "fetch_billing" do
|
88
|
+
bill = Transloadit.new(key: "").bill(9, 2016)
|
89
|
+
_(bill["ok"]).must_equal "BILL_FOUND"
|
90
|
+
_(bill["invoice_id"]).must_equal "76fe5df1c93a0a530f3e583805cf98b4"
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
it
|
94
|
+
it "must create template api instances" do
|
95
95
|
template = @transloadit.template
|
96
|
-
template.must_be_kind_of Transloadit::Template
|
96
|
+
_(template).must_be_kind_of Transloadit::Template
|
97
97
|
end
|
98
98
|
|
99
|
-
it
|
100
|
-
@transloadit.inspect.must_equal @transloadit.to_hash.inspect
|
99
|
+
it "must inspect like a hash" do
|
100
|
+
_(@transloadit.inspect).must_equal @transloadit.to_hash.inspect
|
101
101
|
end
|
102
102
|
|
103
|
-
it
|
104
|
-
@transloadit.to_hash[:key]
|
105
|
-
@transloadit.to_hash[:max_size].must_equal @max_size
|
106
|
-
@transloadit.to_hash[:expires]
|
107
|
-
must_match %r{\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}\+00:00}
|
103
|
+
it "must produce Transloadit-compatible hash output" do
|
104
|
+
_(@transloadit.to_hash[:key]).must_equal @key
|
105
|
+
_(@transloadit.to_hash[:max_size]).must_equal @max_size
|
106
|
+
_(@transloadit.to_hash[:expires])
|
107
|
+
.must_match %r{\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}\+00:00}
|
108
108
|
end
|
109
109
|
|
110
|
-
it
|
111
|
-
@transloadit.to_json.must_equal MultiJson.dump(@transloadit.to_hash)
|
110
|
+
it "must produce Transloadit-compatible JSON output" do
|
111
|
+
_(@transloadit.to_json).must_equal MultiJson.dump(@transloadit.to_hash)
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
describe
|
115
|
+
describe "with no secret" do
|
116
116
|
before do
|
117
|
-
@transloadit = Transloadit.new(:
|
117
|
+
@transloadit = Transloadit.new(key: @key)
|
118
118
|
end
|
119
119
|
|
120
|
-
it
|
121
|
-
@transloadit.to_hash.keys.wont_include :secret
|
120
|
+
it "must not include a secret in its hash output" do
|
121
|
+
_(@transloadit.to_hash.keys).wont_include :secret
|
122
122
|
end
|
123
123
|
|
124
|
-
it
|
125
|
-
@transloadit.to_json.must_equal MultiJson.dump(@transloadit.to_hash)
|
124
|
+
it "must not include a secret in its JSON output" do
|
125
|
+
_(@transloadit.to_json).must_equal MultiJson.dump(@transloadit.to_hash)
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|
@@ -1,50 +1,52 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
describe Transloadit::ApiModel do
|
4
|
-
let(:foo) {
|
5
|
-
let(:bar) {
|
6
|
-
let(:transloadit) { Transloadit.new(:
|
7
|
-
|
8
|
-
let(:api) {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
4
|
+
let(:foo) { "foo" }
|
5
|
+
let(:bar) { "bar" }
|
6
|
+
let(:transloadit) { Transloadit.new(key: "") }
|
7
|
+
|
8
|
+
let(:api) {
|
9
|
+
Transloadit::ApiModel.new(
|
10
|
+
transloadit,
|
11
|
+
foo: foo,
|
12
|
+
bar: bar
|
13
|
+
)
|
14
|
+
}
|
15
|
+
|
16
|
+
it "must allow initialization" do
|
17
|
+
_(Transloadit::ApiModel.new(transloadit))
|
18
|
+
.must_be_kind_of Transloadit::ApiModel
|
19
|
+
|
20
|
+
_(Transloadit::Template.new(transloadit))
|
21
|
+
.must_be_kind_of Transloadit::Template
|
20
22
|
end
|
21
23
|
|
22
|
-
describe
|
23
|
-
it
|
24
|
-
api.transloadit.must_equal transloadit
|
24
|
+
describe "when initialized" do
|
25
|
+
it "must store a pointer to the transloadit instance" do
|
26
|
+
_(api.transloadit).must_equal transloadit
|
25
27
|
end
|
26
28
|
|
27
|
-
it
|
28
|
-
api.options.must_equal(
|
29
|
-
:
|
30
|
-
:
|
29
|
+
it "must remember the options passed" do
|
30
|
+
_(api.options).must_equal(
|
31
|
+
foo: foo,
|
32
|
+
bar: bar
|
31
33
|
)
|
32
34
|
end
|
33
35
|
|
34
|
-
it
|
35
|
-
api.inspect.must_equal api.to_hash.inspect
|
36
|
+
it "must inspect like a hash" do
|
37
|
+
_(api.inspect).must_equal api.to_hash.inspect
|
36
38
|
end
|
37
39
|
|
38
|
-
it
|
39
|
-
api.to_hash.must_equal(
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
40
|
+
it "must produce Transloadit-compatible hash output" do
|
41
|
+
_(api.to_hash).must_equal(
|
42
|
+
auth: transloadit.to_hash,
|
43
|
+
foo: foo,
|
44
|
+
bar: bar
|
43
45
|
)
|
44
46
|
end
|
45
47
|
|
46
|
-
it
|
47
|
-
api.to_json.must_equal MultiJson.dump(api.to_hash)
|
48
|
+
it "must produce Transloadit-compatible JSON output" do
|
49
|
+
_(api.to_json).must_equal MultiJson.dump(api.to_hash)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|