trailer_vote-media_types 2.1.0 → 2.2.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/.gitignore +12 -12
- data/.rubocop.yml +29 -29
- data/.travis.yml +18 -18
- data/CHANGELOG.md +82 -82
- data/Gemfile +6 -6
- data/Gemfile.lock +5 -5
- data/README.md +118 -118
- data/Rakefile +12 -12
- data/bin/console +16 -16
- data/bin/setup +8 -8
- data/lib/trailer_vote/media_types/audio_fragment.rb +108 -108
- data/lib/trailer_vote/media_types/base_text.rb +22 -22
- data/lib/trailer_vote/media_types/carousel.rb +42 -42
- data/lib/trailer_vote/media_types/client_configuration.rb +35 -35
- data/lib/trailer_vote/media_types/configuration.rb +139 -139
- data/lib/trailer_vote/media_types/errors.rb +31 -31
- data/lib/trailer_vote/media_types/feedback.rb +50 -50
- data/lib/trailer_vote/media_types/feedback_listing.rb +49 -49
- data/lib/trailer_vote/media_types/fingerprint_binary.rb +67 -67
- data/lib/trailer_vote/media_types/interactive_player.rb +33 -33
- data/lib/trailer_vote/media_types/issue.rb +64 -64
- data/lib/trailer_vote/media_types/ordered_fragment.rb +35 -35
- data/lib/trailer_vote/media_types/partials/image_links.rb +30 -30
- data/lib/trailer_vote/media_types/persona.rb +47 -47
- data/lib/trailer_vote/media_types/place.rb +143 -143
- data/lib/trailer_vote/media_types/product.rb +191 -191
- data/lib/trailer_vote/media_types/product_image.rb +96 -96
- data/lib/trailer_vote/media_types/product_lookup.rb +37 -37
- data/lib/trailer_vote/media_types/product_place_link.rb +36 -36
- data/lib/trailer_vote/media_types/product_video.rb +100 -100
- data/lib/trailer_vote/media_types/products_listing.rb +43 -43
- data/lib/trailer_vote/media_types/push_consent.rb +44 -44
- data/lib/trailer_vote/media_types/push_manifest.rb +44 -44
- data/lib/trailer_vote/media_types/push_token_android.rb +41 -41
- data/lib/trailer_vote/media_types/push_token_index.rb +42 -42
- data/lib/trailer_vote/media_types/push_token_ios.rb +41 -41
- data/lib/trailer_vote/media_types/push_trivial_campaign.rb +23 -1
- data/lib/trailer_vote/media_types/release_push_campaign.rb +29 -2
- data/lib/trailer_vote/media_types/sentiment_feedback.rb +100 -100
- data/lib/trailer_vote/media_types/types/boolean.rb +15 -15
- data/lib/trailer_vote/media_types/types/formatted_url.rb +51 -51
- data/lib/trailer_vote/media_types/types/http_url.rb +23 -23
- data/lib/trailer_vote/media_types/types/influx_db_connection_url.rb +10 -10
- data/lib/trailer_vote/media_types/types/iso8601.rb +10 -10
- data/lib/trailer_vote/media_types/types/local_time.rb +11 -11
- data/lib/trailer_vote/media_types/types/product_data_type.rb +15 -15
- data/lib/trailer_vote/media_types/types/product_image_type.rb +25 -25
- data/lib/trailer_vote/media_types/types/product_movie_handler.rb +16 -16
- data/lib/trailer_vote/media_types/types/product_movie_type.rb +17 -17
- data/lib/trailer_vote/media_types/types/uuid_v4.rb +10 -10
- data/lib/trailer_vote/media_types/types/vote_value.rb +17 -17
- data/lib/trailer_vote/media_types/version.rb +1 -1
- data/trailer_vote-media_types.gemspec +2 -2
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8d5fb985577a85efe9cea70dae0977968d35d11116b8305f7d0887f27e8cebe0
|
|
4
|
+
data.tar.gz: 606afe3ecef2b7b3892e37f3cd7350f2ba4ab2ce0b06223c54755d03f87ac90d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0e64dafd643e022ac7e2fe9f2f1a47911ec31052031e7b0dcd2b3b2623ad33be21f57d5c0c9e5045c553c1c0d6045cdf3aedf6992dbd663e9f30731b8941fc86
|
|
7
|
+
data.tar.gz: 918b8c8a7d8214f1fb98c139164cbcacbf3991253efcfa84936275003e69bd5a36e2e49a1790f8678ea825927a88bbec72021b79a0d24fa6fd393198898142d9
|
data/.gitignore
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/.bundle/
|
|
2
|
-
/.yardoc
|
|
3
|
-
/_yardoc/
|
|
4
|
-
/coverage/
|
|
5
|
-
/doc/
|
|
6
|
-
/pkg/
|
|
7
|
-
/test/reports/
|
|
8
|
-
/tmp/
|
|
9
|
-
|
|
10
|
-
/.byebug_history
|
|
11
|
-
/.rakeTasks
|
|
12
|
-
|
|
1
|
+
/.bundle/
|
|
2
|
+
/.yardoc
|
|
3
|
+
/_yardoc/
|
|
4
|
+
/coverage/
|
|
5
|
+
/doc/
|
|
6
|
+
/pkg/
|
|
7
|
+
/test/reports/
|
|
8
|
+
/tmp/
|
|
9
|
+
|
|
10
|
+
/.byebug_history
|
|
11
|
+
/.rakeTasks
|
|
12
|
+
|
data/.rubocop.yml
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
AllCops:
|
|
2
|
-
Include:
|
|
3
|
-
- '**/Rakefile'
|
|
4
|
-
- 'lib/**/*.rb'
|
|
5
|
-
Exclude:
|
|
6
|
-
- 'Gemfile'
|
|
7
|
-
- 'bin/**/*'
|
|
8
|
-
TargetRubyVersion: 2.5
|
|
9
|
-
|
|
10
|
-
Layout/EmptyLinesAroundClassBody:
|
|
11
|
-
Enabled: false
|
|
12
|
-
|
|
13
|
-
Layout/EndOfLine:
|
|
14
|
-
Enabled: false
|
|
15
|
-
|
|
16
|
-
Metrics/LineLength:
|
|
17
|
-
Max: 120
|
|
18
|
-
|
|
19
|
-
Metrics/MethodLength:
|
|
20
|
-
Max: 15
|
|
21
|
-
|
|
22
|
-
Style/Documentation:
|
|
23
|
-
Enabled: false
|
|
24
|
-
|
|
25
|
-
Style/EmptyMethod:
|
|
26
|
-
EnforcedStyle: expanded
|
|
27
|
-
|
|
28
|
-
Style/IfUnlessModifier:
|
|
29
|
-
Enabled: false
|
|
1
|
+
AllCops:
|
|
2
|
+
Include:
|
|
3
|
+
- '**/Rakefile'
|
|
4
|
+
- 'lib/**/*.rb'
|
|
5
|
+
Exclude:
|
|
6
|
+
- 'Gemfile'
|
|
7
|
+
- 'bin/**/*'
|
|
8
|
+
TargetRubyVersion: 2.5
|
|
9
|
+
|
|
10
|
+
Layout/EmptyLinesAroundClassBody:
|
|
11
|
+
Enabled: false
|
|
12
|
+
|
|
13
|
+
Layout/EndOfLine:
|
|
14
|
+
Enabled: false
|
|
15
|
+
|
|
16
|
+
Metrics/LineLength:
|
|
17
|
+
Max: 120
|
|
18
|
+
|
|
19
|
+
Metrics/MethodLength:
|
|
20
|
+
Max: 15
|
|
21
|
+
|
|
22
|
+
Style/Documentation:
|
|
23
|
+
Enabled: false
|
|
24
|
+
|
|
25
|
+
Style/EmptyMethod:
|
|
26
|
+
EnforcedStyle: expanded
|
|
27
|
+
|
|
28
|
+
Style/IfUnlessModifier:
|
|
29
|
+
Enabled: false
|
data/.travis.yml
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
sudo: false
|
|
2
|
-
language: ruby
|
|
3
|
-
cache: bundler
|
|
4
|
-
rvm:
|
|
5
|
-
- 2.5
|
|
6
|
-
- 2.6
|
|
7
|
-
- rbx-3
|
|
8
|
-
- ruby-head
|
|
9
|
-
matrix:
|
|
10
|
-
allow_failures:
|
|
11
|
-
- rvm: ruby-head
|
|
12
|
-
- rvm: rbx-3
|
|
13
|
-
- rvm: 2.6
|
|
14
|
-
before_install:
|
|
15
|
-
- gem update --system
|
|
16
|
-
- gem --version
|
|
17
|
-
install:
|
|
18
|
-
- bundle install --with development --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
|
|
1
|
+
sudo: false
|
|
2
|
+
language: ruby
|
|
3
|
+
cache: bundler
|
|
4
|
+
rvm:
|
|
5
|
+
- 2.5
|
|
6
|
+
- 2.6
|
|
7
|
+
- rbx-3
|
|
8
|
+
- ruby-head
|
|
9
|
+
matrix:
|
|
10
|
+
allow_failures:
|
|
11
|
+
- rvm: ruby-head
|
|
12
|
+
- rvm: rbx-3
|
|
13
|
+
- rvm: 2.6
|
|
14
|
+
before_install:
|
|
15
|
+
- gem update --system
|
|
16
|
+
- gem --version
|
|
17
|
+
install:
|
|
18
|
+
- bundle install --with development --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
|
data/CHANGELOG.md
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## 0.9.2
|
|
4
|
-
|
|
5
|
-
- Add vimeo as video handler
|
|
6
|
-
|
|
7
|
-
## 0.9.1
|
|
8
|
-
|
|
9
|
-
- Allow empty for various `index` and `collection` views
|
|
10
|
-
|
|
11
|
-
## 0.9.0
|
|
12
|
-
|
|
13
|
-
- Add `issue` media type
|
|
14
|
-
- Update `trailer_vote-fixtures` to 1.2.0
|
|
15
|
-
|
|
16
|
-
## 0.8.1
|
|
17
|
-
|
|
18
|
-
- Use external `trailer_vote-fixtures`
|
|
19
|
-
|
|
20
|
-
## 0.8.0
|
|
21
|
-
|
|
22
|
-
- Add `Issue` media type
|
|
23
|
-
- Add `issues` link to configuration media type
|
|
24
|
-
|
|
25
|
-
## 0.7.6
|
|
26
|
-
|
|
27
|
-
- Allow `content_*` to be `nil`
|
|
28
|
-
|
|
29
|
-
## 0.7.5
|
|
30
|
-
|
|
31
|
-
- Add `content_language` and `content_region` to assets
|
|
32
|
-
|
|
33
|
-
## 0.7.4
|
|
34
|
-
|
|
35
|
-
- Allow `type` on partial `image_links` (such as sentiment_feedback)
|
|
36
|
-
|
|
37
|
-
## 0.7.3
|
|
38
|
-
|
|
39
|
-
- Add `type` to image self link
|
|
40
|
-
- Add `type` to image index links
|
|
41
|
-
- Add `type` to video self link
|
|
42
|
-
- Add `type` to video index links
|
|
43
|
-
|
|
44
|
-
## 0.7.2
|
|
45
|
-
|
|
46
|
-
- Allow for `content_digest` and dimensions on image links (output)
|
|
47
|
-
|
|
48
|
-
## 0.7.1
|
|
49
|
-
|
|
50
|
-
- Fix version 2 of sentiment feedback not registering
|
|
51
|
-
- Change default version of sentiment feedback to v2
|
|
52
|
-
|
|
53
|
-
## 0.7.0
|
|
54
|
-
|
|
55
|
-
- Add `products` link to configuration v1
|
|
56
|
-
- Add scheme validation for `data` property of products
|
|
57
|
-
|
|
58
|
-
## 0.6.3
|
|
59
|
-
|
|
60
|
-
- Fix `product_video` create root key
|
|
61
|
-
|
|
62
|
-
## 0.6.2
|
|
63
|
-
|
|
64
|
-
- Loosen Gem dependency versions to allow any minor update, except for dogfooded gems, which are allowed major updates, until they hit 1.0.0
|
|
65
|
-
- Add metadata urls for gemspec
|
|
66
|
-
|
|
67
|
-
## 0.6.1
|
|
68
|
-
|
|
69
|
-
- Allow for http urls because not all services in all environments may operate with TLS enabled.
|
|
70
|
-
|
|
71
|
-
## 0.6.0
|
|
72
|
-
|
|
73
|
-
- Update `media_types` to `0.6.0` so that the integrations become available downstream.
|
|
74
|
-
- Rename all `deleted_at` to `expires_at` (#1)
|
|
75
|
-
- Add `Types::HttpsUrl`, `Types::InfluxDbConnectionUrl`, `Types.makeFormattedUrl`, `Types.Iso8601` to check format of string attributes. (#2)
|
|
76
|
-
- Add documentation for `updated_at` fields (#4)
|
|
77
|
-
- Add expected type for `ProductLookup` `identifier` (#5)
|
|
78
|
-
- Remove optional nil for analytics and metrics url by changing the type (#3)
|
|
79
|
-
|
|
80
|
-
## 0.5.0
|
|
81
|
-
|
|
82
|
-
:baby: initial public release. Not considered stable until version 1.0.0.
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.9.2
|
|
4
|
+
|
|
5
|
+
- Add vimeo as video handler
|
|
6
|
+
|
|
7
|
+
## 0.9.1
|
|
8
|
+
|
|
9
|
+
- Allow empty for various `index` and `collection` views
|
|
10
|
+
|
|
11
|
+
## 0.9.0
|
|
12
|
+
|
|
13
|
+
- Add `issue` media type
|
|
14
|
+
- Update `trailer_vote-fixtures` to 1.2.0
|
|
15
|
+
|
|
16
|
+
## 0.8.1
|
|
17
|
+
|
|
18
|
+
- Use external `trailer_vote-fixtures`
|
|
19
|
+
|
|
20
|
+
## 0.8.0
|
|
21
|
+
|
|
22
|
+
- Add `Issue` media type
|
|
23
|
+
- Add `issues` link to configuration media type
|
|
24
|
+
|
|
25
|
+
## 0.7.6
|
|
26
|
+
|
|
27
|
+
- Allow `content_*` to be `nil`
|
|
28
|
+
|
|
29
|
+
## 0.7.5
|
|
30
|
+
|
|
31
|
+
- Add `content_language` and `content_region` to assets
|
|
32
|
+
|
|
33
|
+
## 0.7.4
|
|
34
|
+
|
|
35
|
+
- Allow `type` on partial `image_links` (such as sentiment_feedback)
|
|
36
|
+
|
|
37
|
+
## 0.7.3
|
|
38
|
+
|
|
39
|
+
- Add `type` to image self link
|
|
40
|
+
- Add `type` to image index links
|
|
41
|
+
- Add `type` to video self link
|
|
42
|
+
- Add `type` to video index links
|
|
43
|
+
|
|
44
|
+
## 0.7.2
|
|
45
|
+
|
|
46
|
+
- Allow for `content_digest` and dimensions on image links (output)
|
|
47
|
+
|
|
48
|
+
## 0.7.1
|
|
49
|
+
|
|
50
|
+
- Fix version 2 of sentiment feedback not registering
|
|
51
|
+
- Change default version of sentiment feedback to v2
|
|
52
|
+
|
|
53
|
+
## 0.7.0
|
|
54
|
+
|
|
55
|
+
- Add `products` link to configuration v1
|
|
56
|
+
- Add scheme validation for `data` property of products
|
|
57
|
+
|
|
58
|
+
## 0.6.3
|
|
59
|
+
|
|
60
|
+
- Fix `product_video` create root key
|
|
61
|
+
|
|
62
|
+
## 0.6.2
|
|
63
|
+
|
|
64
|
+
- Loosen Gem dependency versions to allow any minor update, except for dogfooded gems, which are allowed major updates, until they hit 1.0.0
|
|
65
|
+
- Add metadata urls for gemspec
|
|
66
|
+
|
|
67
|
+
## 0.6.1
|
|
68
|
+
|
|
69
|
+
- Allow for http urls because not all services in all environments may operate with TLS enabled.
|
|
70
|
+
|
|
71
|
+
## 0.6.0
|
|
72
|
+
|
|
73
|
+
- Update `media_types` to `0.6.0` so that the integrations become available downstream.
|
|
74
|
+
- Rename all `deleted_at` to `expires_at` (#1)
|
|
75
|
+
- Add `Types::HttpsUrl`, `Types::InfluxDbConnectionUrl`, `Types.makeFormattedUrl`, `Types.Iso8601` to check format of string attributes. (#2)
|
|
76
|
+
- Add documentation for `updated_at` fields (#4)
|
|
77
|
+
- Add expected type for `ProductLookup` `identifier` (#5)
|
|
78
|
+
- Remove optional nil for analytics and metrics url by changing the type (#3)
|
|
79
|
+
|
|
80
|
+
## 0.5.0
|
|
81
|
+
|
|
82
|
+
:baby: initial public release. Not considered stable until version 1.0.0.
|
data/Gemfile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
4
|
-
|
|
5
|
-
# Specify your gem's dependencies in trailer_vote-api.gemspec
|
|
6
|
-
gemspec
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
4
|
+
|
|
5
|
+
# Specify your gem's dependencies in trailer_vote-api.gemspec
|
|
6
|
+
gemspec
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
trailer_vote-media_types (2.
|
|
4
|
+
trailer_vote-media_types (2.2.0)
|
|
5
5
|
media_types (>= 0.6.0, < 1)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -29,7 +29,7 @@ GEM
|
|
|
29
29
|
json (>= 1.8, < 3)
|
|
30
30
|
simplecov-html (~> 0.10.0)
|
|
31
31
|
simplecov-html (0.10.2)
|
|
32
|
-
trailer_vote-fixtures (1.
|
|
32
|
+
trailer_vote-fixtures (1.15.0)
|
|
33
33
|
|
|
34
34
|
PLATFORMS
|
|
35
35
|
ruby
|
|
@@ -37,15 +37,15 @@ PLATFORMS
|
|
|
37
37
|
|
|
38
38
|
DEPENDENCIES
|
|
39
39
|
awesome_print (~> 1.8)
|
|
40
|
-
bundler (~>
|
|
40
|
+
bundler (~> 2.0)
|
|
41
41
|
minitest (~> 5.0)
|
|
42
42
|
minitest-ci (~> 3.4)
|
|
43
43
|
minitest-reporters (~> 1.3)
|
|
44
44
|
oj (~> 3.6)
|
|
45
45
|
rake (~> 13.0)
|
|
46
46
|
simplecov (~> 0.16)
|
|
47
|
-
trailer_vote-fixtures (~> 1.
|
|
47
|
+
trailer_vote-fixtures (~> 1.15.0)
|
|
48
48
|
trailer_vote-media_types!
|
|
49
49
|
|
|
50
50
|
BUNDLED WITH
|
|
51
|
-
1.
|
|
51
|
+
2.1.0
|
data/README.md
CHANGED
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
# TrailerVote::MediaTypes
|
|
2
|
-
[](https://travis-ci.com/TrailerVote/trailervote-media-types)
|
|
3
|
-
[](https://badge.fury.io/rb/trailer_vote-media_types)
|
|
4
|
-
[](https://codeclimate.com/github/TrailerVote/trailervote-media-types/maintainability)
|
|
5
|
-
|
|
6
|
-
## Installation
|
|
7
|
-
|
|
8
|
-
Add this line to your application's Gemfile:
|
|
9
|
-
|
|
10
|
-
```ruby
|
|
11
|
-
gem 'trailer_vote-media_types'
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
And then execute:
|
|
15
|
-
|
|
16
|
-
$ bundle
|
|
17
|
-
|
|
18
|
-
Or install it yourself as:
|
|
19
|
-
|
|
20
|
-
$ gem install trailer_vote-media_types
|
|
21
|
-
|
|
22
|
-
## Notes
|
|
23
|
-
|
|
24
|
-
### `updated_at` vs `Last-Modified` headers
|
|
25
|
-
|
|
26
|
-
When this is used in conjunction with a TrailerVote service, the `updated_at` attributes inside the body of a response will take precedence over any `Last-Modified` header. The `updated_at` value **SHOULD** reflect the last time the resource was updated, whereas the `Last-Modified` value may change when the representation is updated.
|
|
27
|
-
|
|
28
|
-
### Are ids missing?
|
|
29
|
-
|
|
30
|
-
No, the `id` or `uuid` attributes are not missing. As per the [TrailerVote API considerations](https://docs.trailervote.com/reference) clients **SHOULD** not need to construct URLs. Both internally and externally, where possible, we refer to resources by their fully qualified URL which _is_ their identifier, instead of something like a UUID.
|
|
31
|
-
|
|
32
|
-
## Usage
|
|
33
|
-
|
|
34
|
-
This gem is based on [`media_types`](https://github.com/SleeplessByte/media-types-ruby), and inherits all the functionality from that gem. In general, you can use `trailer_vote-media_types` in the following ways:
|
|
35
|
-
|
|
36
|
-
### `Accept` and `Content-Type` construction
|
|
37
|
-
|
|
38
|
-
All the media types can be turned into a header value, both acceptable for the `Accept` and `Content-Type` headers:
|
|
39
|
-
|
|
40
|
-
```ruby
|
|
41
|
-
TrailerVote::MediaTypes::Configuration.to_constructable.version(2).to_s
|
|
42
|
-
# => "application/vnd.trailervote.configuration.v2+json"
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
The [`Constructable`](https://www.rubydoc.info/gems/media_types/MediaTypes/Constructable) result of `#to_constructable` allows for chaining the various options in our media types, namely `view` (e.g. `index`, `create`) and `version`. The default `suffix` is none for binary types and `json` for text type, as we don't support XML at the moment.
|
|
46
|
-
|
|
47
|
-
It is **recommended** to always include `.version(n)`, otherwise you will get the newest version, which might not be what you support in the code.
|
|
48
|
-
|
|
49
|
-
### `Accept` with quality parameter
|
|
50
|
-
|
|
51
|
-
If you want to have multiple `Accept` values, but with different priorities, `Constructable#to_s` accepts an additional parameter to set this. For example, if you want to make a fully qualified `Accept` header and you prefer product version 2, but accept version 1 as well:
|
|
52
|
-
|
|
53
|
-
```ruby
|
|
54
|
-
[
|
|
55
|
-
TrailerVote::MediaTypes::Product.to_constructable.version(2).to_s,
|
|
56
|
-
TrailerVote::MediaTypes::Product.to_constructable.version(1).to_s(0.9),
|
|
57
|
-
TrailerVote::MediaTypes::Errors.to_constructable.version(1).to_s(0.1)
|
|
58
|
-
].join(', ')
|
|
59
|
-
# => "application/vnd.trailervote.configuration.product.v2+json,
|
|
60
|
-
# application/vnd.trailervote.configuration.product.v1+json; q=0.9,
|
|
61
|
-
# application/vnd.trailervote.errors.v1+json; q=0.1"
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Data validation
|
|
65
|
-
|
|
66
|
-
All the media types come equipped with validations, for most known / expected permutations of views and versions. Validations are based on [`Scheme`](https://www.rubydoc.info/gems/media_types/MediaTypes/Scheme) from the [`media_types`](https://github.com/SleeplessByte/media-types-ruby) gem.
|
|
67
|
-
|
|
68
|
-
```ruby
|
|
69
|
-
media_type = TrailerVote::MediaTypes::ClientConfiguration.to_constructable.version(1)
|
|
70
|
-
# => application/vnd.trailervote.client_configuration.v1+json
|
|
71
|
-
|
|
72
|
-
media_type.valid?(
|
|
73
|
-
configuration: {
|
|
74
|
-
place: "https://fake.trailervote.com/api/places/435ec0b8-100d-4e92-8a17-04bc77e90880",
|
|
75
|
-
persona: "https://fake.trailervote.com/api/persona/e03a1c72-8bce-408c-a6e4-de215e73dd92"
|
|
76
|
-
}
|
|
77
|
-
)
|
|
78
|
-
# => true
|
|
79
|
-
|
|
80
|
-
media_type.validate!(
|
|
81
|
-
configuration: {
|
|
82
|
-
place: "https://fake.trailervote.com/api/places/435ec0b8-100d-4e92-8a17-04bc77e90880",
|
|
83
|
-
}
|
|
84
|
-
)
|
|
85
|
-
# => raises MediaTypes::Scheme::ExhaustedOutputError: Missing keys in output: [:persona] at [.->configuration]
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### `Mime::Type` registration
|
|
89
|
-
|
|
90
|
-
In case you use `action_dispatch/http/mime_type`, you may register the TrailerVote Media Types into the `Mime::Type` registry like so:
|
|
91
|
-
```ruby
|
|
92
|
-
TrailerVote::MediaTypes::Persona.register
|
|
93
|
-
# => [...] # Array of registered types, each version, each suffix permutation, all aliases
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
You can now look them up in the registry:
|
|
97
|
-
|
|
98
|
-
```ruby
|
|
99
|
-
media_type = TrailerVote::MediaTypes::Persona.to_constructable.version(1).to_s
|
|
100
|
-
# => "application/vnd.trailervote.persona.v1+json"
|
|
101
|
-
|
|
102
|
-
Mime::Type.lookup(media_type)
|
|
103
|
-
# => Mime::Type entry
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
## Development
|
|
107
|
-
|
|
108
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can
|
|
109
|
-
also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
110
|
-
|
|
111
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
|
|
112
|
-
version number in `version.rb`, and then run `bundle update trailer_vote-media_types` in any repository that depends on
|
|
113
|
-
this gem. If you have permissions, you may call `bundle exec rake release` to create a new git tag, push
|
|
114
|
-
git commits and tags, and push the `.gem` file to the rubygems gem server.
|
|
115
|
-
|
|
116
|
-
## Contributing
|
|
117
|
-
|
|
118
|
-
Bug reports and pull requests are welcome on GitHub at [TrailerVote/trailervote-media-types](https://github.com/TrailerVote/trailervote-media-types)
|
|
1
|
+
# TrailerVote::MediaTypes
|
|
2
|
+
[](https://travis-ci.com/TrailerVote/trailervote-media-types)
|
|
3
|
+
[](https://badge.fury.io/rb/trailer_vote-media_types)
|
|
4
|
+
[](https://codeclimate.com/github/TrailerVote/trailervote-media-types/maintainability)
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Add this line to your application's Gemfile:
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
gem 'trailer_vote-media_types'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
And then execute:
|
|
15
|
+
|
|
16
|
+
$ bundle
|
|
17
|
+
|
|
18
|
+
Or install it yourself as:
|
|
19
|
+
|
|
20
|
+
$ gem install trailer_vote-media_types
|
|
21
|
+
|
|
22
|
+
## Notes
|
|
23
|
+
|
|
24
|
+
### `updated_at` vs `Last-Modified` headers
|
|
25
|
+
|
|
26
|
+
When this is used in conjunction with a TrailerVote service, the `updated_at` attributes inside the body of a response will take precedence over any `Last-Modified` header. The `updated_at` value **SHOULD** reflect the last time the resource was updated, whereas the `Last-Modified` value may change when the representation is updated.
|
|
27
|
+
|
|
28
|
+
### Are ids missing?
|
|
29
|
+
|
|
30
|
+
No, the `id` or `uuid` attributes are not missing. As per the [TrailerVote API considerations](https://docs.trailervote.com/reference) clients **SHOULD** not need to construct URLs. Both internally and externally, where possible, we refer to resources by their fully qualified URL which _is_ their identifier, instead of something like a UUID.
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
This gem is based on [`media_types`](https://github.com/SleeplessByte/media-types-ruby), and inherits all the functionality from that gem. In general, you can use `trailer_vote-media_types` in the following ways:
|
|
35
|
+
|
|
36
|
+
### `Accept` and `Content-Type` construction
|
|
37
|
+
|
|
38
|
+
All the media types can be turned into a header value, both acceptable for the `Accept` and `Content-Type` headers:
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
TrailerVote::MediaTypes::Configuration.to_constructable.version(2).to_s
|
|
42
|
+
# => "application/vnd.trailervote.configuration.v2+json"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The [`Constructable`](https://www.rubydoc.info/gems/media_types/MediaTypes/Constructable) result of `#to_constructable` allows for chaining the various options in our media types, namely `view` (e.g. `index`, `create`) and `version`. The default `suffix` is none for binary types and `json` for text type, as we don't support XML at the moment.
|
|
46
|
+
|
|
47
|
+
It is **recommended** to always include `.version(n)`, otherwise you will get the newest version, which might not be what you support in the code.
|
|
48
|
+
|
|
49
|
+
### `Accept` with quality parameter
|
|
50
|
+
|
|
51
|
+
If you want to have multiple `Accept` values, but with different priorities, `Constructable#to_s` accepts an additional parameter to set this. For example, if you want to make a fully qualified `Accept` header and you prefer product version 2, but accept version 1 as well:
|
|
52
|
+
|
|
53
|
+
```ruby
|
|
54
|
+
[
|
|
55
|
+
TrailerVote::MediaTypes::Product.to_constructable.version(2).to_s,
|
|
56
|
+
TrailerVote::MediaTypes::Product.to_constructable.version(1).to_s(0.9),
|
|
57
|
+
TrailerVote::MediaTypes::Errors.to_constructable.version(1).to_s(0.1)
|
|
58
|
+
].join(', ')
|
|
59
|
+
# => "application/vnd.trailervote.configuration.product.v2+json,
|
|
60
|
+
# application/vnd.trailervote.configuration.product.v1+json; q=0.9,
|
|
61
|
+
# application/vnd.trailervote.errors.v1+json; q=0.1"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Data validation
|
|
65
|
+
|
|
66
|
+
All the media types come equipped with validations, for most known / expected permutations of views and versions. Validations are based on [`Scheme`](https://www.rubydoc.info/gems/media_types/MediaTypes/Scheme) from the [`media_types`](https://github.com/SleeplessByte/media-types-ruby) gem.
|
|
67
|
+
|
|
68
|
+
```ruby
|
|
69
|
+
media_type = TrailerVote::MediaTypes::ClientConfiguration.to_constructable.version(1)
|
|
70
|
+
# => application/vnd.trailervote.client_configuration.v1+json
|
|
71
|
+
|
|
72
|
+
media_type.valid?(
|
|
73
|
+
configuration: {
|
|
74
|
+
place: "https://fake.trailervote.com/api/places/435ec0b8-100d-4e92-8a17-04bc77e90880",
|
|
75
|
+
persona: "https://fake.trailervote.com/api/persona/e03a1c72-8bce-408c-a6e4-de215e73dd92"
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
# => true
|
|
79
|
+
|
|
80
|
+
media_type.validate!(
|
|
81
|
+
configuration: {
|
|
82
|
+
place: "https://fake.trailervote.com/api/places/435ec0b8-100d-4e92-8a17-04bc77e90880",
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
# => raises MediaTypes::Scheme::ExhaustedOutputError: Missing keys in output: [:persona] at [.->configuration]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### `Mime::Type` registration
|
|
89
|
+
|
|
90
|
+
In case you use `action_dispatch/http/mime_type`, you may register the TrailerVote Media Types into the `Mime::Type` registry like so:
|
|
91
|
+
```ruby
|
|
92
|
+
TrailerVote::MediaTypes::Persona.register
|
|
93
|
+
# => [...] # Array of registered types, each version, each suffix permutation, all aliases
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
You can now look them up in the registry:
|
|
97
|
+
|
|
98
|
+
```ruby
|
|
99
|
+
media_type = TrailerVote::MediaTypes::Persona.to_constructable.version(1).to_s
|
|
100
|
+
# => "application/vnd.trailervote.persona.v1+json"
|
|
101
|
+
|
|
102
|
+
Mime::Type.lookup(media_type)
|
|
103
|
+
# => Mime::Type entry
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Development
|
|
107
|
+
|
|
108
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can
|
|
109
|
+
also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
110
|
+
|
|
111
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the
|
|
112
|
+
version number in `version.rb`, and then run `bundle update trailer_vote-media_types` in any repository that depends on
|
|
113
|
+
this gem. If you have permissions, you may call `bundle exec rake release` to create a new git tag, push
|
|
114
|
+
git commits and tags, and push the `.gem` file to the rubygems gem server.
|
|
115
|
+
|
|
116
|
+
## Contributing
|
|
117
|
+
|
|
118
|
+
Bug reports and pull requests are welcome on GitHub at [TrailerVote/trailervote-media-types](https://github.com/TrailerVote/trailervote-media-types)
|
data/Rakefile
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'bundler/gem_tasks'
|
|
4
|
-
require 'rake/testtask'
|
|
5
|
-
|
|
6
|
-
Rake::TestTask.new(:test) do |t|
|
|
7
|
-
t.libs << 'test'
|
|
8
|
-
t.libs << 'lib'
|
|
9
|
-
t.test_files = FileList['test/**/*_test.rb']
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
task default: :test
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
require 'rake/testtask'
|
|
5
|
+
|
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
|
7
|
+
t.libs << 'test'
|
|
8
|
+
t.libs << 'lib'
|
|
9
|
+
t.test_files = FileList['test/**/*_test.rb']
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
task default: :test
|
data/bin/console
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require 'bundler/setup'
|
|
5
|
-
require 'trailer_vote/media_types'
|
|
6
|
-
require 'awesome_print'
|
|
7
|
-
|
|
8
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
|
9
|
-
# with your gem easier. You can also use a different console, if you like.
|
|
10
|
-
|
|
11
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
12
|
-
# require "pry"
|
|
13
|
-
# Pry.start
|
|
14
|
-
|
|
15
|
-
require 'irb'
|
|
16
|
-
IRB.start(__FILE__)
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require 'bundler/setup'
|
|
5
|
+
require 'trailer_vote/media_types'
|
|
6
|
+
require 'awesome_print'
|
|
7
|
+
|
|
8
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
9
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
10
|
+
|
|
11
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
12
|
+
# require "pry"
|
|
13
|
+
# Pry.start
|
|
14
|
+
|
|
15
|
+
require 'irb'
|
|
16
|
+
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -euo pipefail
|
|
3
|
-
IFS=$'\n\t'
|
|
4
|
-
set -vx
|
|
5
|
-
|
|
6
|
-
bundle install
|
|
7
|
-
|
|
8
|
-
# Do any other automated setup that you need to do here
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
IFS=$'\n\t'
|
|
4
|
+
set -vx
|
|
5
|
+
|
|
6
|
+
bundle install
|
|
7
|
+
|
|
8
|
+
# Do any other automated setup that you need to do here
|