transloadit 2.0.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +23 -0
  3. data/.standard.yml +0 -0
  4. data/CHANGELOG.md +68 -57
  5. data/Gemfile +1 -1
  6. data/README.md +162 -86
  7. data/Rakefile +12 -17
  8. data/examples/README.md +94 -55
  9. data/examples/basic/audio-concat-transcoder.rb +29 -19
  10. data/examples/basic/audio-transcoder.rb +32 -22
  11. data/examples/basic/image-transcoder.rb +22 -17
  12. data/examples/basic/main.rb +31 -37
  13. data/examples/basic/media-transcoder.rb +2 -7
  14. data/lib/transloadit/api_model.rb +13 -13
  15. data/lib/transloadit/assembly.rb +27 -24
  16. data/lib/transloadit/exception.rb +2 -4
  17. data/lib/transloadit/request.rb +58 -52
  18. data/lib/transloadit/response/assembly.rb +14 -13
  19. data/lib/transloadit/response.rb +10 -10
  20. data/lib/transloadit/step.rb +13 -13
  21. data/lib/transloadit/template.rb +5 -5
  22. data/lib/transloadit/version.rb +1 -1
  23. data/lib/transloadit.rb +24 -24
  24. data/test/fixtures/cassettes/cancel_assembly.yml +3 -3
  25. data/test/fixtures/cassettes/create_template.yml +1 -1
  26. data/test/fixtures/cassettes/delete_template.yml +1 -1
  27. data/test/fixtures/cassettes/fetch_assemblies.yml +1 -1
  28. data/test/fixtures/cassettes/fetch_assembly_aborted.yml +3 -3
  29. data/test/fixtures/cassettes/fetch_assembly_errors.yml +3 -3
  30. data/test/fixtures/cassettes/fetch_assembly_executing.yml +3 -3
  31. data/test/fixtures/cassettes/fetch_assembly_notifications.yml +1 -1
  32. data/test/fixtures/cassettes/fetch_assembly_ok.yml +6 -6
  33. data/test/fixtures/cassettes/fetch_assembly_uploading.yml +3 -3
  34. data/test/fixtures/cassettes/fetch_billing.yml +1 -1
  35. data/test/fixtures/cassettes/fetch_root.yml +3 -3
  36. data/test/fixtures/cassettes/fetch_template.yml +1 -1
  37. data/test/fixtures/cassettes/fetch_templates.yml +1 -1
  38. data/test/fixtures/cassettes/post_assembly.yml +2 -2
  39. data/test/fixtures/cassettes/rate_limit_fail.yml +3 -3
  40. data/test/fixtures/cassettes/rate_limit_succeed.yml +4 -4
  41. data/test/fixtures/cassettes/replay_assembly.yml +2 -2
  42. data/test/fixtures/cassettes/replay_assembly_notification.yml +1 -1
  43. data/test/fixtures/cassettes/submit_assembly.yml +3 -3
  44. data/test/fixtures/cassettes/update_template.yml +1 -1
  45. data/test/test_helper.rb +10 -10
  46. data/test/unit/test_transloadit.rb +66 -66
  47. data/test/unit/transloadit/test_api.rb +35 -33
  48. data/test/unit/transloadit/test_assembly.rb +148 -112
  49. data/test/unit/transloadit/test_request.rb +41 -42
  50. data/test/unit/transloadit/test_response.rb +76 -76
  51. data/test/unit/transloadit/test_step.rb +52 -52
  52. data/test/unit/transloadit/test_template.rb +49 -54
  53. data/transloadit.gemspec +25 -26
  54. metadata +25 -41
  55. data/.travis.yml +0 -13
@@ -1,128 +1,128 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  describe Transloadit do
4
4
  before do
5
- @key = 'a'
6
- @secret = 'b'
5
+ @key = "a"
6
+ @secret = "b"
7
7
  @duration = 10
8
8
  @max_size = 100
9
9
  end
10
10
 
11
- it 'must allow initialization' do
12
- t = Transloadit.new(:key => @key, :secret => @secret)
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 'must not be initialized with no arguments' do
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 'must require a key' do
21
- lambda { Transloadit.new(:secret => @secret) }.must_raise ArgumentError
20
+ it "must require a key" do
21
+ _(lambda { Transloadit.new(secret: @secret) }).must_raise ArgumentError
22
22
  end
23
23
 
24
- it 'must not require a secret' do
25
- t = Transloadit.new(:key => @key)
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 'must provide a default duration' do
30
- Transloadit.new(:key => @key).duration.wont_be_nil
29
+ it "must provide a default duration" do
30
+ _(Transloadit.new(key: @key).duration).wont_be_nil
31
31
  end
32
32
 
33
- describe 'when initialized' do
33
+ describe "when initialized" do
34
34
  before do
35
35
  @transloadit = Transloadit.new(
36
- :key => @key,
37
- :secret => @secret,
38
- :duration => @duration,
39
- :max_size => @max_size
36
+ key: @key,
37
+ secret: @secret,
38
+ duration: @duration,
39
+ max_size: @max_size
40
40
  )
41
41
  end
42
42
 
43
- it 'must allow access to the key' do
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 'must allow access to the secret' do
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 'must allow access to the duration' do
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 'must allow access to the max_size' do
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 'must create steps' do
60
- step = @transloadit.step('resize', '/image/resize', :width => 320)
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. must_equal 'resize'
64
- step.robot. must_equal '/image/resize'
65
- step.options.must_equal :width => 320
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 'must create assembly api instances' do
69
- step = @transloadit.step(nil, nil)
70
- assembly = @transloadit.assembly :steps => step
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 'must create assemblies with multiple steps' do
76
+ it "must create assemblies with multiple steps" do
77
77
  steps = [
78
- @transloadit.step(nil, nil),
79
- @transloadit.step(nil, nil),
78
+ @transloadit.step("step1", nil),
79
+ @transloadit.step("step2", nil)
80
80
  ]
81
81
 
82
- assembly = @transloadit.assembly :steps => steps
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 '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'
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 'must create template api instances' do
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 'must inspect like a hash' do
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 '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}
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 'must produce Transloadit-compatible JSON output' do
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 'with no secret' do
115
+ describe "with no secret" do
116
116
  before do
117
- @transloadit = Transloadit.new(:key => @key)
117
+ @transloadit = Transloadit.new(key: @key)
118
118
  end
119
119
 
120
- it 'must not include a secret in its hash output' do
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 'must not include a secret in its JSON output' do
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 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  describe Transloadit::ApiModel do
4
- let(:foo) { 'foo' }
5
- let(:bar) { 'bar' }
6
- let(:transloadit) { Transloadit.new(:key => '') }
7
-
8
- let(:api) { Transloadit::ApiModel.new(
9
- transloadit,
10
- :foo => foo,
11
- :bar => bar
12
- )}
13
-
14
- it 'must allow initialization' do
15
- Transloadit::ApiModel.new(transloadit).
16
- must_be_kind_of Transloadit::ApiModel
17
-
18
- Transloadit::Template.new(transloadit).
19
- must_be_kind_of Transloadit::Template
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 'when initialized' do
23
- it 'must store a pointer to the transloadit instance' do
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 'must remember the options passed' do
28
- api.options.must_equal(
29
- :foo => foo,
30
- :bar => bar
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 'must inspect like a hash' do
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 'must produce Transloadit-compatible hash output' do
39
- api.to_hash.must_equal(
40
- :auth => transloadit.to_hash,
41
- :foo => foo,
42
- :bar => bar
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 'must produce Transloadit-compatible JSON output' do
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