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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 51844f6de69eb87292ee3a8b34a0121c5b39024b
4
- data.tar.gz: e9239659a9091051cdfcb602ba14ec6fea973340
2
+ SHA256:
3
+ metadata.gz: c0001e9da3cd516d632f1f64b19e3c1a543b3fcb8b3d595ef357b1378be78575
4
+ data.tar.gz: c835af092c5046f590b6cd57570ee10b12aef5b8679da544f61217f5a349a8c1
5
5
  SHA512:
6
- metadata.gz: 981c5131b6c960744a952ffcc1a7eebbf867d17ee239adb5edd229676bc1f1ce515e33591c75256de0d918776ebb91add176c4d3d6dd6969d558b7f34030b4d5
7
- data.tar.gz: 3b72a678ff9d20769dfc4180fb5c302ef13b5e49c126a8e2a30ce25f427d3a9137d72ffe38fb9600ff7706d35d7d58dd2827b6f17c7203c41a335e3685e4e22a
6
+ metadata.gz: 179ec53008ed5bd7525a422bd3bdb6fe69ef4b665cb6fdfd1c6490ceb91ce9452c965ee5476a51494e144f1d8f02fda5344121763a0a0ea2bfaf0315b48633b4
7
+ data.tar.gz: 9b599ab52a8d44016cd4e9dcaf954fd845a4ae881f1c85b4efcb1d1a867e006eb433cd3b09333cbafa8f03f7ef8860ae3cd7668f72ce2415cb3cdb7256a1a3d8
@@ -0,0 +1,23 @@
1
+ name: CI
2
+ on: push
3
+ jobs:
4
+ ci:
5
+ runs-on: ubuntu-latest
6
+ strategy:
7
+ matrix:
8
+ ruby:
9
+ - 3.0
10
+ - 3.1
11
+ - 3.2
12
+ - jruby
13
+ # - jruby-head
14
+ - truffleruby
15
+ # - truffleruby-head
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby }}
21
+ bundler-cache: true
22
+ - run: bundle exec standardrb
23
+ - run: COVERAGE=false bundle exec rake test
data/.standard.yml ADDED
File without changes
data/CHANGELOG.md CHANGED
@@ -1,89 +1,100 @@
1
- ### 2.0.1 / 2017-01-23 ###
1
+ ### 3.0.0 / 2024-01-10
2
2
 
3
- * Use the ssl enabled url as the API base url (@ifedapoolarewaju)
3
+ - BREAKING: Drop support for EOL'd Ruby 2.x
4
+ - Ensure that signature is sent before files [#65](https://github.com/transloadit/ruby-sdk/pull/65) (@Acconut)
5
+ - Send requests via HTTPS by default [#64](https://github.com/transloadit/ruby-sdk/pull/64) (@Acconut)
6
+ - Prevent duplicate assembly steps [#49](https://github.com/transloadit/ruby-sdk/issues/27) (@ifedapoolarewaju)
7
+ - Send "Transloadit-Client" header for every request (@ifedapoolarewaju)
8
+ - Send all requests via HTTPS by default
9
+ - Position signature before any files in requests [#51](https://github.com/transloadit/ruby-sdk/issues/51)
4
10
 
5
- ### 2.0.0 / 2016-12-03 ###
11
+ ### 2.0.1 / 2017-01-23
6
12
 
7
- * Drop support for EOL'd Ruby 1.9.x and Ruby 2.0, please use version 1.2.0 if you need support for older
13
+ - Use the ssl enabled url as the API base url (@ifedapoolarewaju)
14
+
15
+ ### 2.0.0 / 2016-12-03
16
+
17
+ - Drop support for EOL'd Ruby 1.9.x and Ruby 2.0, please use version 1.2.0 if you need support for older
8
18
  Ruby versions.
9
- * Fix compatibility to Ruby >=2.1 and Rails 5.
10
- * Remove bored instance logic (thanks @ifedapoolarewaju for the PR). This shouldn't affect users at all and removes
19
+ - Fix compatibility to Ruby >=2.1 and Rails 5.
20
+ - Remove bored instance logic (thanks @ifedapoolarewaju for the PR). This shouldn't affect users at all and removes
11
21
  the need for another HTTP request before the actual HTTP request.
12
- * We now have the `transloadit.bill` method to retrieve billing reports. (@ifedapoolarewaju)
13
- * Deprecate `assembly.submit!` method for `assembly.create!`. This shouldn't affect users as the `submit!` method remains
22
+ - We now have the `transloadit.bill` method to retrieve billing reports. (@ifedapoolarewaju)
23
+ - Deprecate `assembly.submit!` method for `assembly.create!`. This shouldn't affect users as the `submit!` method remains
14
24
  as an alias for `create!`. (@ifedapoolarewaju)
15
- * Add support for new `assembly` methods (Thanks @ifedapoolarewaju):
16
- * list to get a list of all assemblies.
17
- * get to retrieve a particular assembly. Requires assembly id to be passed as argument.
18
- * replay to replay a particular assembly. Requires assembly id to be passed as argument.
19
- * get_notifications to get a list of all assembly notifications.
20
- * replay_notification to replay the notification of a particular assembly. Requires assembly id to be passed as argument.
21
- * We now have a Template api with the following methods:
22
- * create to create a new template.
23
- * list to get a list of all templates.
24
- * get to retrieve a particular template.
25
- * update to update a particular template.
26
- * delete to delete a particular template.
27
- * Add rate limit feature to implicitly retry assembly creation when the rate limit is reached.
28
- * Add `assembly.reload_until_finished!` which calls `reload!` once per second until assembly is finished (@gbuesing)
29
- * Added example files with a [small tutorial](examples/README.md) in `examples` (@jasonaibrahim)
25
+ - Add support for new `assembly` methods (Thanks @ifedapoolarewaju):
26
+ - list to get a list of all assemblies.
27
+ - get to retrieve a particular assembly. Requires assembly id to be passed as argument.
28
+ - replay to replay a particular assembly. Requires assembly id to be passed as argument.
29
+ - get_notifications to get a list of all assembly notifications.
30
+ - replay_notification to replay the notification of a particular assembly. Requires assembly id to be passed as argument.
31
+ - We now have a Template api with the following methods:
32
+ - create to create a new template.
33
+ - list to get a list of all templates.
34
+ - get to retrieve a particular template.
35
+ - update to update a particular template.
36
+ - delete to delete a particular template.
37
+ - Add rate limit feature to implicitly retry assembly creation when the rate limit is reached.
38
+ - Add `assembly.reload_until_finished!` which calls `reload!` once per second until assembly is finished (@gbuesing)
39
+ - Added example files with a [small tutorial](examples/README.md) in `examples` (@jasonaibrahim)
30
40
 
31
- ### 1.2.0 / 2015-12-28 ###
41
+ ### 1.2.0 / 2015-12-28
32
42
 
33
- * allow custom fields to be passed to Transloadit and received back in the response (thanks @Acconut for the pull request)
43
+ - allow custom fields to be passed to Transloadit and received back in the response (thanks @Acconut for the pull request)
34
44
 
35
- ### 1.1.4 / 2015-12-14 ###
45
+ ### 1.1.4 / 2015-12-14
36
46
 
37
- * fix Ruby 1.9.x compatibility by explicitly requiring mime-types 2.99
47
+ - fix Ruby 1.9.x compatibility by explicitly requiring mime-types 2.99
38
48
 
39
- ### 1.1.3 / 2014-08-21 ###
49
+ ### 1.1.3 / 2014-08-21
40
50
 
41
- * Use rest-client < 1.7.0 for Ruby version below 1.9 to stay 1.8 compatible.
51
+ - Use rest-client < 1.7.0 for Ruby version below 1.9 to stay 1.8 compatible.
42
52
 
43
- ### 1.1.2 / 2014-06-17 ###
53
+ ### 1.1.2 / 2014-06-17
44
54
 
45
- * Fix deprecation warning on Ruby 2.1.0 for OpenSSL::Digest (thanks @pekeler for the patch)
55
+ - Fix deprecation warning on Ruby 2.1.0 for OpenSSL::Digest (thanks @pekeler for the patch)
46
56
 
47
- ### 1.1.1 / 2013-06-25 ###
57
+ ### 1.1.1 / 2013-06-25
48
58
 
49
- * request.get with secret (thanks @miry for the patch)
59
+ - request.get with secret (thanks @miry for the patch)
50
60
 
51
- ### 1.1.0 / 2013-04-22 ###
61
+ ### 1.1.0 / 2013-04-22
52
62
 
53
- * We now have more statuses available in the response:
54
- * finished? to check if processing is finished
55
- * error? to check if processing failed with errors
56
- * canceled? to check if processing was canceled
57
- * aborted? to check if processing was aborted
58
- * executing? to check if processing is still executing
59
- * uploading? to check if the upload is still going
60
- * Please use `finished?` to check if procssing is finished and `completed?` to
63
+ - We now have more statuses available in the response:
64
+ - finished? to check if processing is finished
65
+ - error? to check if processing failed with errors
66
+ - canceled? to check if processing was canceled
67
+ - aborted? to check if processing was aborted
68
+ - executing? to check if processing is still executing
69
+ - uploading? to check if the upload is still going
70
+ - Please use `finished?` to check if procssing is finished and `completed?` to
61
71
  check if completed successfully
62
72
 
63
- ### 1.0.5 / 2013-03-13 ###
73
+ ### 1.0.5 / 2013-03-13
64
74
 
65
- * Use MultiJSON so everyone can use the JSON parser they like. (thanks @kselden for the patch)
66
- * Switch to Kramdown for RDoc formatting
67
- * Support jRuby 1.8/1.9 and MRI 2.0.0 too
75
+ - Use MultiJSON so everyone can use the JSON parser they like. (thanks @kselden for the patch)
76
+ - Switch to Kramdown for RDoc formatting
77
+ - Support jRuby 1.8/1.9 and MRI 2.0.0 too
68
78
 
69
- ### 1.0.4 / 2013-03-06 ###
79
+ ### 1.0.4 / 2013-03-06
70
80
 
71
- * allow symbols as keys for response attributes (thanks @gbuesing for reporting)
81
+ - allow symbols as keys for response attributes (thanks @gbuesing for reporting)
72
82
 
73
- ### 1.0.3 / 2012-11-10 ###
83
+ ### 1.0.3 / 2012-11-10
74
84
 
75
- * Support max_size option
85
+ - Support max_size option
76
86
 
77
- ### 1.0.1 / 2011-02-08 ###
87
+ ### 1.0.1 / 2011-02-08
78
88
 
79
89
  [Full list of changes](https://github.com/transloadit/ruby-sdk/compare/v1.0.0...v1.0.1)
80
90
 
81
- * Enhancements
82
- * support custom form fields for Transloadit::Assembly
91
+ - Enhancements
92
+
93
+ - support custom form fields for Transloadit::Assembly
83
94
 
84
- * New Maintainers
85
- * Robin Mehner <robin@coding-robin.de>
95
+ - New Maintainers
96
+ - Robin Mehner <robin@coding-robin.de>
86
97
 
87
- ### 1.0.0 / 2011-09-06 ###
98
+ ### 1.0.0 / 2011-09-06
88
99
 
89
- * Initial release
100
+ - Initial release
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
data/README.md CHANGED
@@ -1,18 +1,17 @@
1
- [![Build Status](https://travis-ci.org/transloadit/ruby-sdk.png?branch=master)](https://travis-ci.org/transloadit/ruby-sdk)
1
+ [![Build Status](https://github.com/transloadit/ruby-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/transloadit/ruby-sdk/actions/workflows/ci.yml)
2
2
  [![Code Climate](https://codeclimate.com/github/transloadit/ruby-sdk.png)](https://codeclimate.com/github/transloadit/ruby-sdk)
3
- [![Dependency Status](https://gemnasium.com/transloadit/ruby-sdk.png)](https://gemnasium.com/transloadit/ruby-sdk)
4
3
 
5
- # transloadit
4
+ ## ruby-sdk
6
5
 
7
- Fantastic file uploading for your web application.
6
+ A **Ruby** Integration for [Transloadit](https://transloadit.com)'s file uploading and encoding service
8
7
 
9
- ## Description
8
+ ## Intro
10
9
 
11
- This is the official Ruby gem for [Transloadit](http://transloadit.com). It allows
12
- you to automate uploading files through the Transloadit REST API.
10
+ [Transloadit](https://transloadit.com) is a service that helps you handle file uploads, resize, crop and watermark your images, make GIFs, transcode your videos, extract thumbnails, generate audio waveforms, and so much more. In short, [Transloadit](https://transloadit.com) is the Swiss Army Knife for your files.
13
11
 
14
- If you run Ruby on Rails and are looking to integrate with the browser for file uploads,
15
- checkout the [rails-sdk](https://github.com/transloadit/rails-sdk).
12
+ This is a **Ruby** SDK to make it easy to talk to the [Transloadit](https://transloadit.com) REST API.
13
+
14
+ *If you run Ruby on Rails and are looking to integrate with the browser for file uploads, checkout the [rails-sdk](https://github.com/transloadit/rails-sdk).*
16
15
 
17
16
  ## Install
18
17
 
@@ -20,7 +19,7 @@ checkout the [rails-sdk](https://github.com/transloadit/rails-sdk).
20
19
  gem install transloadit
21
20
  ```
22
21
 
23
- ## Getting started
22
+ ## Usage
24
23
 
25
24
  To get started, you need to require the 'transloadit' gem:
26
25
 
@@ -30,56 +29,64 @@ $ irb -rubygems
30
29
  => true
31
30
  ```
32
31
 
33
- Then create a Transloadit instance, which will maintain your authentication
34
- credentials and allow us to make requests to the API.
32
+ Then create a Transloadit instance, which will maintain your
33
+ [authentication credentials](https://transloadit.com/accounts/credentials)
34
+ and allow us to make requests to [the API](https://transloadit.com/docs/api/).
35
35
 
36
36
  ```ruby
37
37
  transloadit = Transloadit.new(
38
- :key => 'transloadit-auth-key',
39
- :secret => 'transloadit-auth-secret'
38
+ :key => 'YOUR_TRANSLOADIT_KEY',
39
+ :secret => 'YOUR_TRANSLOADIT_SECRET'
40
40
  )
41
41
  ```
42
42
 
43
43
  ### 1. Resize and store an image
44
44
 
45
- This example demonstrates how you can create an assembly to resize an image
46
- and store the result on [Amazon S3](http://aws.amazon.com/s3/).
47
-
48
- First, we create two steps: one to resize the image to 320x240, and another to
49
- store the image in our S3 bucket.
45
+ This example demonstrates how you can create an <dfn>Assembly</dfn> to resize an image
46
+ and store the result on [Amazon S3](https://aws.amazon.com/s3/).
50
47
 
51
48
  ```ruby
49
+ require 'transloadit'
50
+
51
+ transloadit = Transloadit.new(
52
+ :key => 'YOUR_TRANSLOADIT_KEY',
53
+ :secret => 'YOUR_TRANSLOADIT_SECRET'
54
+ )
55
+
56
+ # First, we create two steps: one to resize the image to 320x240, and another to
57
+ # store the image in our S3 bucket.
52
58
  resize = transloadit.step 'resize', '/image/resize',
53
59
  :width => 320,
54
60
  :height => 240
55
61
 
56
62
  store = transloadit.step 'store', '/s3/store',
57
- :key => 'aws-access-key-id',
58
- :secret => 'aws-secret-access-key',
59
- :bucket => 's3-bucket-name'
60
- ```
61
-
62
- Now that we have the steps, we create an assembly (which is just a request to
63
- process a file or set of files) and let Transloadit do the rest.
63
+ :key => 'YOUR_AWS_KEY',
64
+ :secret => 'YOUR_AWS_SECRET',
65
+ :bucket => 'YOUR_S3_BUCKET'
64
66
 
65
- ```ruby
67
+ # Now that we have the steps, we create an assembly (which is just a request to
68
+ # process a file or set of files) and let Transloadit do the rest.
66
69
  assembly = transloadit.assembly(
67
70
  :steps => [ resize, store ]
68
71
  )
69
72
 
70
- response = assembly.create! open('lolcat.jpg')
73
+ response = assembly.create! open('/PATH/TO/FILE.jpg')
71
74
 
72
75
  # reloads the response once per second until all processing is finished
73
76
  response.reload_until_finished!
74
77
 
75
78
  if response.error?
76
- # handle error
79
+ # handle error
77
80
  else
78
- # handle other cases
81
+ # handle other cases
82
+ puts response
79
83
  end
80
84
  ```
81
- *(note: the assembly method `submit!` has been deprecated and replaced with `create!`.
82
- The submit! method remains as an alias of `create!` for backward Compatibility)*
85
+
86
+ <div class="alert alert-note">
87
+ <strong>Note:</strong> The <dfn>Assembly</dfn> method <code>submit!</code> has been deprecated and replaced with <code>create!</code>.
88
+ The <code>submit!</code> method remains as an alias of <code>create!</code> for backward Compatibility.
89
+ </div>
83
90
 
84
91
  When the `create!` method returns, the file has been uploaded but may not yet
85
92
  be done processing. We can use the returned object to check if processing has
@@ -90,7 +97,7 @@ completed, or examine other attributes of the request.
90
97
  response[:assembly_id] # => '9bd733a...'
91
98
 
92
99
  # returns the API URL endpoint for the assembly
93
- response[:assembly_url] # => 'http://api2.vivian.transloadit.com/assemblies/9bd733a...'
100
+ response[:assembly_ssl_url] # => 'https://api2.vivian.transloadit.com/assemblies/9bd733a...'
94
101
 
95
102
  # checks how many bytes were expected / received by transloadit
96
103
  response[:bytes_expected] # => 92933
@@ -102,7 +109,7 @@ response.finished? # => false
102
109
  # cancels further processing on the assembly
103
110
  response.cancel! # => true
104
111
 
105
- # checks if processing was succesfully completed
112
+ # checks if processing was successfully completed
106
113
  response.completed? # => true
107
114
 
108
115
  # checks if the processing returned with an error
@@ -111,21 +118,21 @@ response.error? # => false
111
118
 
112
119
  It's important to note that none of these queries are "live" (with the
113
120
  exception of the `cancel!` method). They all check the response given by the
114
- API at the time the assembly was created. You have to explicitly ask the
115
- assembly to reload its results from the API.
121
+ API at the time the <dfn>Assembly</dfn> was created. You have to explicitly ask the
122
+ <dfn>Assembly</dfn> to reload its results from the API.
116
123
 
117
124
  ```ruby
118
125
  # reloads the response's contents from the REST API
119
126
  response.reload!
120
127
 
121
128
  # reloads once per second until all processing is finished, up to number of
122
- # times specified in :tries option, othewise will raise ReloadLimitReached
129
+ # times specified in :tries option, otherwise will raise ReloadLimitReached
123
130
  response.reload_until_finished! tries: 300 # default is 600
124
131
  ```
125
132
 
126
133
  In general, you use hash accessor syntax to query any direct attribute from
127
- the [response](http://transloadit.com/docs/assemblies#response-format).
128
- Methods suffixed by a question mark provide a more readable way of quering
134
+ the [response](https://transloadit.com/docs/api/#assembly-status-response).
135
+ Methods suffixed by a question mark provide a more readable way of querying
129
136
  state (e.g., `assembly.completed?` vs. checking the result of
130
137
  `assembly[:ok]`). Methods suffixed by a bang make a live query against the
131
138
  Transloadit HTTP API.
@@ -133,10 +140,17 @@ Transloadit HTTP API.
133
140
  ### 2. Uploading multiple files
134
141
 
135
142
  Multiple files can be given to the `create!` method in order to upload more
136
- than one file in the same request. You can also pass a single step for the
143
+ than one file in the same request. You can also pass a single <dfn>Step</dfn> for the
137
144
  `steps` parameter, without having to wrap it in an Array.
138
145
 
139
146
  ```ruby
147
+ require 'transloadit'
148
+
149
+ transloadit = Transloadit.new(
150
+ :key => 'YOUR_TRANSLOADIT_KEY',
151
+ :secret => 'YOUR_TRANSLOADIT_SECRET'
152
+ )
153
+
140
154
  assembly = transloadit.assembly(steps: store)
141
155
 
142
156
  response = assembly.create!(
@@ -146,7 +160,9 @@ response = assembly.create!(
146
160
  )
147
161
  ```
148
162
 
149
- You can also pass an array of files to the `create!` method. Just unpack the array using the splat `*` operator.
163
+ You can also pass an array of files to the `create!` method.
164
+ Just unpack the array using the splat `*` operator.
165
+
150
166
  ```ruby
151
167
  files = [open('puppies.jpg'), open('kittens.jpg'), open('ferrets.jpg')]
152
168
  response = assembly.create! *files
@@ -155,10 +171,17 @@ response = assembly.create! *files
155
171
  ### 3. Parallel Assembly
156
172
 
157
173
  Transloadit allows you to perform several processing steps in parallel. You
158
- simply need to `use` other steps. Following
159
- [their example](http://transloadit.com/docs/assemblies#special-parameters):
174
+ simply need to `use` other <dfn>Steps</dfn>. Following
175
+ [their example](https://transloadit.com/docs/#special-parameters):
160
176
 
161
177
  ```ruby
178
+ require 'transloadit'
179
+
180
+ transloadit = Transloadit.new(
181
+ :key => 'YOUR_TRANSLOADIT_KEY',
182
+ :secret => 'YOUR_TRANSLOADIT_SECRET'
183
+ )
184
+
162
185
  encode = transloadit.step 'encode', '/video/encode', { ... }
163
186
  thumbs = transloadit.step 'thumbs', '/video/thumbs', { ... }
164
187
  export = transloadit.step 'store', '/s3/store', { ... }
@@ -167,60 +190,91 @@ export.use [ encode, thumbs ]
167
190
 
168
191
  transloadit.assembly(
169
192
  :steps => [ encode, thumbs, export ]
170
- ).create! open('ninja-cat.mpg')
193
+ ).create! open('/PATH/TO/FILE.mpg')
171
194
  ```
172
195
 
173
196
  You can also tell a step to use the original uploaded file by passing the
174
197
  Symbol `:original` instead of another step.
175
198
 
176
199
  Check the YARD documentation for more information on using
177
- [use](http://rubydoc.info/gems/transloadit/frames/Transloadit/Step#use-instance_method).
200
+ [use](https://rubydoc.info/gems/transloadit/frames/Transloadit/Step#use-instance_method).
178
201
 
179
202
  ### 4. Creating an Assembly with Templates
180
203
 
181
- Transloadit allows you to use custom [templates](https://github.com/transloadit/ruby-sdk/blob/master/README.md#8-templates)
204
+ Transloadit allows you to use custom [templates](https://github.com/transloadit/ruby-sdk/blob/main/README.md#8-templates)
182
205
  for recurring encoding tasks. In order to use these do the following:
183
206
 
184
207
  ```ruby
208
+ require 'transloadit'
209
+
210
+ transloadit = Transloadit.new(
211
+ :key => 'YOUR_TRANSLOADIT_KEY',
212
+ :secret => 'YOUR_TRANSLOADIT_SECRET'
213
+ )
214
+
185
215
  transloadit.assembly(
186
216
  :template_id => 'YOUR_TEMPLATE_ID'
187
- ).create! open('ninja-cat.mpg')
217
+ ).create! open('/PATH/TO/FILE.mpg')
188
218
  ```
189
219
 
190
220
  You can use your steps together with this template and even use variables.
191
- The [Transloadit documentation](http://transloadit.com/docs/templates#passing-variables-into-a-template) has some nice
192
- examples for that.
221
+ The [Transloadit documentation](https://transloadit.com/docs/#passing-variables-into-a-template)
222
+ has some nice examples for that.
193
223
 
194
224
  ### 5. Using fields
195
225
 
196
226
  Transloadit allows you to submit form field values that you'll get back in the
197
- notification. This is quite handy if you want to add additional custom meta data
227
+ notification. This is quite handy if you want to add additional custom metadata
198
228
  to the upload itself. You can use fields like the following:
199
229
 
200
230
  ```ruby
231
+ require 'transloadit'
232
+
233
+ transloadit = Transloadit.new(
234
+ :key => 'YOUR_TRANSLOADIT_KEY',
235
+ :secret => 'YOUR_TRANSLOADIT_SECRET'
236
+ )
237
+
201
238
  transloadit.assembly(
202
- :fields => {:tag => 'ninjacats'}
203
- ).create! open('ninja-cat.mpg')
239
+ :fields => {
240
+ :tag => 'some_tag_name',
241
+ :field_name => 'field_value'
242
+ }
243
+ ).create! open('/PATH/TO/FILE.mpg')
204
244
  ```
205
245
 
206
246
  ### 6. Notify URL
207
247
 
208
248
  If you want to be notified when the processing is finished you can provide
209
- a notify url for the assembly.
249
+ a Notify URL for the <dfn>Assembly</dfn>.
210
250
 
211
251
  ```ruby
252
+ require 'transloadit'
253
+
254
+ transloadit = Transloadit.new(
255
+ :key => 'YOUR_TRANSLOADIT_KEY',
256
+ :secret => 'YOUR_TRANSLOADIT_SECRET'
257
+ )
258
+
212
259
  transloadit.assembly(
213
- :notify_url => 'http://example.com/processing_finished'
214
- ).create! open('ninja-cat.mpg')
260
+ :notify_url => 'https://example.com/processing_finished'
261
+ ).create! open('/PATH/TO/FILE.mpg')
215
262
  ```
216
263
 
217
- Read up more on the notifications [on Transloadit's documentation page](http://transloadit.com/docs/notifications-vs-redirect-url)
264
+ Read up more on the <dfn>Notifications</dfn> [on Transloadit's documentation page](https://transloadit.com/docs/#notifications)
218
265
 
219
266
  ### 7. Other Assembly methods
220
267
 
221
- Transloadit also provides methods to retrieve/replay assemblies and their notifications.
268
+ Transloadit also provides methods to retrieve/replay <dfn>Assemblies</dfn> and their <dfn>Notifications</dfn>.
222
269
 
223
270
  ```ruby
271
+ require 'transloadit'
272
+
273
+ transloadit = Transloadit.new(
274
+ :key => 'YOUR_TRANSLOADIT_KEY',
275
+ :secret => 'YOUR_TRANSLOADIT_SECRET'
276
+ )
277
+
224
278
  assembly = transloadit.assembly
225
279
 
226
280
  # returns a list of all assemblies
@@ -243,10 +297,17 @@ assembly.replay_notification 'YOUR_ASSEMBLY_ID'
243
297
 
244
298
  ### 8. Templates
245
299
 
246
- Transloadit provides a [templates api](https://transloadit.com/docs/templates)
247
- for recurring encoding tasks. Here's how you would create a template:
300
+ Transloadit provides a [templates api](https://transloadit.com/docs/#templates)
301
+ for recurring encoding tasks. Here's how you would create a <dfn>Template</dfn>:
248
302
 
249
303
  ```ruby
304
+ require 'transloadit'
305
+
306
+ transloadit = Transloadit.new(
307
+ :key => 'YOUR_TRANSLOADIT_KEY',
308
+ :secret => 'YOUR_TRANSLOADIT_SECRET'
309
+ )
310
+
250
311
  template = transloadit.template
251
312
 
252
313
  # creates a new template
@@ -264,9 +325,18 @@ template.create(
264
325
  )
265
326
  ```
266
327
 
267
- There are also some other methods to retrieve, update and delete a template.
328
+ There are also some other methods to retrieve, update and delete a <dfn>Template</dfn>.
268
329
 
269
330
  ```ruby
331
+ require 'transloadit'
332
+
333
+ transloadit = Transloadit.new(
334
+ :key => 'YOUR_TRANSLOADIT_KEY',
335
+ :secret => 'YOUR_TRANSLOADIT_SECRET'
336
+ )
337
+
338
+ template = transloadit.template
339
+
270
340
  # returns a list of all templates.
271
341
  template.list
272
342
 
@@ -293,57 +363,63 @@ template.delete 'YOUR_TEMPLATE_ID'
293
363
 
294
364
  ### 9. Getting Bill reports
295
365
 
296
- If you want to retrieve your transloadit account billing report for a particular month and year
366
+ If you want to retrieve your Transloadit account billing report for a particular month and year
297
367
  you can use the `bill` method passing the required month and year like the following:
298
368
 
299
369
  ```ruby
370
+ require 'transloadit'
371
+
372
+ transloadit = Transloadit.new(
373
+ :key => 'YOUR_TRANSLOADIT_KEY',
374
+ :secret => 'YOUR_TRANSLOADIT_SECRET'
375
+ )
376
+
300
377
  # returns bill report for February, 2016.
301
378
  transloadit.bill(2, 2016)
302
379
  ```
380
+
303
381
  Not specifying the `month` or `year` would default to the current month or year.
304
382
 
305
383
  ### 10. Rate limits
306
384
 
307
385
  Transloadit enforces rate limits to guarantee that no customers are adversely affected by the usage
308
- of any given customer. See [Rate Limiting](https://transloadit.com/docs/api-docs/#rate-limiting).
386
+ of any given customer. See [Rate Limiting](https://transloadit.com/docs/api/#rate-limiting).
309
387
 
310
- While creating an assembly, if a rate limit error is received, by default, 2 more attempts would be made for a succesful
311
- response. If after these attempts the rate limit error persists, a `RateLimitReached` exception will be raised.
388
+ While creating an <dfn>Assembly</dfn>, if a rate limit error is received, by default, 2 more attempts would be made for a successful response. If after these attempts the rate limit error persists, a `RateLimitReached` exception will be raised.
312
389
 
313
- To change the number of attempts that will be made when creating an assembly, you may pass the `tries` option to your
314
- assembly like so.
390
+ To change the number of attempts that will be made when creating an <dfn>Assembly</dfn>, you may pass the `tries` option to your <dfn>Assembly</dfn> like so.
315
391
 
316
392
  ```ruby
393
+ require 'transloadit'
394
+
395
+ transloadit = Transloadit.new(
396
+ :key => 'YOUR_TRANSLOADIT_KEY',
397
+ :secret => 'YOUR_TRANSLOADIT_SECRET'
398
+ )
399
+
317
400
  # would make one extra attempt after a failed attempt.
318
- transloadit.assembly(:tries => 2).create! open('ninja-cat.mpg')
401
+ transloadit.assembly(:tries => 2).create! open('/PATH/TO/FILE.mpg')
319
402
 
320
403
  # Would make no attempt at all. Your request would not be sent.
321
- transloadit.assembly(:tries => 0).create! open('ninja-cat.mpg')
404
+ transloadit.assembly(:tries => 0).create! open('/PATH/TO/FILE.mpg')
322
405
  ```
323
406
 
324
- ## Documentation
407
+ ## Example
325
408
 
326
- Up-to-date YARD documentation is automatically generated. You can view the
327
- docs for the [released gem](http://rubydoc.info/gems/transloadit/frames) or
328
- for the latest [git master](http://rubydoc.info/github/transloadit/ruby-sdk/master/frames).
409
+ A small sample tutorial of using the Transloadit ruby-sdk to optimize an image, encode MP3 audio, add ID3 tags,
410
+ and more can be found [here](https://github.com/transloadit/ruby-sdk/tree/main/examples).
329
411
 
330
- ## Examples
412
+ ## Documentation
331
413
 
332
- An small sample tutorial of using the Transloadit ruby-sdk to optimize an image, encode MP3 audio, add ID3 tags,
333
- and more can be found [here](examples/README.md).
414
+ Up-to-date YARD documentation is automatically generated. You can view the
415
+ docs for the <a href="https://rubydoc.info/gems/transloadit/frames" rel="canonical">released gem</a> or
416
+ for the latest [git main](https://rubydoc.info/github/transloadit/ruby-sdk/main/frames).
334
417
 
335
418
  ## Compatibility
336
419
 
337
- At a minimum, this gem should work on MRI 2.3.0, 2.2.0, 2.1.0, Rubinius,
338
- and JRuby. It may also work on older ruby versions, but support for those
339
- Rubies is not guaranteed. If it doesn't work on one of the officially supported Rubies, please file a
340
- [bug report](https://github.com/transloadit/ruby-sdk/issues). Compatibility patches for other Rubies
341
- are welcome.
342
-
343
- Testing against these versions is performed automatically by
344
- [Travis CI](https://travis-ci.org/transloadit/ruby-sdk).
420
+ Please see [ci.yml](https://github.com/transloadit/ruby-sdk/tree/main/.github/workflows/ci.yml) for a list of supported ruby versions. It may also work on older Rubies, but support for those is not guaranteed. If it doesn't work on one of the officially supported Rubies, please file a
421
+ [bug report](https://github.com/transloadit/ruby-sdk/issues). Compatibility patches for other Rubies are welcome.
345
422
 
346
- ### Ruby 1.9.x & 2.0
423
+ ### Ruby 2.x
347
424
 
348
- If you still need support for older versions of Ruby, 1.2.0 is the last version that
349
- supports those.
425
+ If you still need support for Ruby 2.x, 2.0.1 is the last version that supports it.