media_types 0.6.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/debian.yml +42 -0
  3. data/.github/workflows/ruby.yml +22 -0
  4. data/.gitignore +10 -10
  5. data/CHANGELOG.md +76 -41
  6. data/Gemfile +6 -6
  7. data/Gemfile.lock +17 -83
  8. data/LICENSE +21 -0
  9. data/README.md +364 -91
  10. data/Rakefile +12 -12
  11. data/lib/media_types.rb +58 -2
  12. data/lib/media_types/constructable.rb +36 -10
  13. data/lib/media_types/dsl.rb +110 -29
  14. data/lib/media_types/dsl/errors.rb +18 -0
  15. data/lib/media_types/errors.rb +19 -0
  16. data/lib/media_types/scheme.rb +153 -2
  17. data/lib/media_types/scheme/errors.rb +66 -0
  18. data/lib/media_types/scheme/links.rb +15 -0
  19. data/lib/media_types/scheme/missing_validation.rb +12 -4
  20. data/lib/media_types/scheme/output_empty_guard.rb +5 -4
  21. data/lib/media_types/scheme/output_iterator_with_predicate.rb +13 -2
  22. data/lib/media_types/scheme/output_type_guard.rb +1 -1
  23. data/lib/media_types/scheme/rules.rb +53 -1
  24. data/lib/media_types/scheme/rules_exhausted_guard.rb +15 -4
  25. data/lib/media_types/scheme/validation_options.rb +17 -5
  26. data/lib/media_types/testing/assertions.rb +20 -0
  27. data/lib/media_types/validations.rb +15 -5
  28. data/lib/media_types/version.rb +1 -1
  29. data/media_types.gemspec +4 -7
  30. metadata +20 -62
  31. data/.travis.yml +0 -19
  32. data/lib/media_types/defaults.rb +0 -31
  33. data/lib/media_types/integrations.rb +0 -32
  34. data/lib/media_types/integrations/actionpack.rb +0 -21
  35. data/lib/media_types/integrations/http.rb +0 -47
  36. data/lib/media_types/minitest/assert_media_type_format.rb +0 -10
  37. data/lib/media_types/minitest/assert_media_types_registered.rb +0 -166
  38. data/lib/media_types/registrar.rb +0 -148
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b854726c0783d1e7f27c66a195362a9df615500fb0bc329a935aa589d3451138
4
- data.tar.gz: 3699e6ea389a304a2a7970911a39ae269e0705b3283c8b816868f1ba76abc6fa
3
+ metadata.gz: d034c7e7a7fd3a142dd997efab0d1c3e61f2cbe3170078544f4f456c485ad4ec
4
+ data.tar.gz: 20dbb0fbdf7e9f93c79575239de5e9a4e2220dbd7d3a0fe1d41145c1b2a97b54
5
5
  SHA512:
6
- metadata.gz: 05a9e6bb7d2cf222148750830b4efb69fc73a7b955e4a7cf51de6dbe3ed4866187cc498c7b11c8060f0a3dc53eac76fa7bc762049ed6174bdaccc0ea3fa118c7
7
- data.tar.gz: c811c45d8ed2355a39f49f924d09a6a3326abe715e86b5ce4634d6a7dc1d2a18c565e6f1f6de60a769aa2fd6a863bd328da82a15ee3a8e6eaded39beab35856d
6
+ metadata.gz: b589dbf3292df73632d3d8c98b6b73ed2dec08099b64406b4a1ca2c2cbe19b5cf7161efefc2b05c3bff634b03b6056c6a8f4770ac038e559710415bbad663e10
7
+ data.tar.gz: 2ce0c0747e94f01de399e28cd262b921912097c9bfea2d205abcb11937f116d078366ebcee8a8f0999c12cada9a7b1ce1093ad51d80d397cfc73d5cd145424f8
@@ -0,0 +1,42 @@
1
+ name: Debian
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*'
7
+
8
+
9
+ jobs:
10
+ build:
11
+
12
+ runs-on: ubuntu-18.04
13
+
14
+ steps:
15
+ - uses: actions/checkout@v1
16
+ - name: Install dependencies
17
+ run: |
18
+ sudo apt-get update
19
+ DEBIAN_FRONTEND=noninteractive sudo apt-get --yes install gem2deb bundler ruby-{actionpack,awesome-print,http,minitest,minitest-reporters,oj,simplecov}
20
+ rm Gemfile.lock || true
21
+ bundle install --local
22
+ sudo apt-file update
23
+ - name: Build
24
+ run: |
25
+ bundle exec rake build
26
+ mkdir debpkg
27
+ cp pkg/media_types-*.gem media_types.gem
28
+ #(cd debpkg; gem2tgz media_types.gem)
29
+ #(cd debpkg; dh-make-ruby media_types-*.tar.gz)
30
+ #(cd debpkg; dh-make-ruby media_types-*.tar.gz)
31
+ (cd pkg; gem2deb media_types*.gem)
32
+ mv pkg/ruby-media-types_*_all.deb ruby-media-types.deb
33
+ - name: Upload gem
34
+ uses: actions/upload-artifact@v1
35
+ with:
36
+ name: media_types.gem
37
+ path: media_types.gem
38
+ - name: Upload deb
39
+ uses: actions/upload-artifact@v1
40
+ with:
41
+ name: ruby-media-types.deb
42
+ path: ruby-media-types.deb
@@ -0,0 +1,22 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v1
12
+ - name: Set up Ruby 2.6
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6.x
16
+ - name: Build and test with Rake
17
+ run: |
18
+ sudo apt-get update
19
+ DEBIAN_FRONTEND=noninteractive sudo apt-get install --yes bundler
20
+ rm Gemfile.lock || true
21
+ bundle install --jobs 4 --retry 3
22
+ bundle exec rake
data/.gitignore CHANGED
@@ -1,10 +1,10 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- .idea/
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ .idea/
data/CHANGELOG.md CHANGED
@@ -1,13 +1,48 @@
1
- # 0.6.2
1
+ # Changelog
2
+
3
+ ## 2.1.0
4
+
5
+ - Add `override_suffix` to force a specific suffix
6
+ - Fix all deprecation warnings
7
+
8
+ ## 2.0.1
9
+
10
+ - Views can now be accessed indifferently.
11
+ - Attribute keys no longer match indifferently.
12
+ - Fixed infinite loop when validating non-hash, non-array items.
13
+
14
+ ## 2.0.0
15
+
16
+ - Removed ability to set default suffix. All suffixes now default to `+json`.
17
+ - Suffixes are now set for a given view and version instead of as a block.
18
+ - Added `suffix :yoursuffix` command to override the default `:json` suffix.
19
+ - Removed defaults block.
20
+ - Removed registrations block.
21
+
22
+ ## 1.0.0
23
+
24
+ - Added the ability to do inline tests when defining validations using `assert_pass '<json>'` and `assert_fail '<json>'`.
25
+ - `media_type` has been replaced with `use_name`.
26
+ - It is no longer possible to set a default version. Please use `version <x> do` instead.
27
+ - You no longer need to specify a custom format string. If you set an organisation with `def self.organisation` or set a module wide organisation with `MediaTypes::set_organisation <module>, '<organisation>'` the library will generate identifiers for you.
28
+ - `self.base_format` has been replaced by `identifier_format do |type:, view:, version:, suffix:|`.
29
+ - Added the `empty` validation to mark an empty object as valid.
30
+ - Added the `identifier` function to get the [Media Type Identifier](https://en.wikipedia.org/wiki/Media_type) for the validator.
31
+ - Added `version(x)` and `view(x)` functions.
32
+ - Added an `available_validations` functions that returns all defined validations.
33
+ - Fixed an issue where validations could accidentally merge if defined with a bad `base_format`.
34
+ - Fixed an issue where undefined validations would accept an empty object.
35
+
36
+ ## 0.6.2
2
37
 
3
38
  - Fix handling empty collections
4
39
 
5
- # 0.6.1
40
+ ## 0.6.1
6
41
 
7
42
  - Fix no `validations` error on `validatable?` (now returns `false`)
8
43
  - Update `bundler` to `2.x`
9
44
 
10
- # 0.6.0
45
+ ## 0.6.0
11
46
 
12
47
  - Change default expected type for `attribute` to Object
13
48
  - Remove default `actionpack` calls for `.register`
@@ -15,28 +50,28 @@
15
50
  - Add integration for registering with `http` (http.rb)
16
51
  - Fix stack overflow for cyclic schema
17
52
 
18
- # 0.5.5
53
+ ## 0.5.5
19
54
 
20
55
  - Fix an issue with `attribute(optional:, &block)` not passing `optional:` to the created `collection`.
21
56
 
22
- # 0.5.4
57
+ ## 0.5.4
23
58
 
24
59
  - Fix formatter reworked template when fields are not present
25
60
 
26
- # 0.5.3
61
+ ## 0.5.3
27
62
 
28
63
  - Remove `require 'awesome_print'` in library code as it's marked as a development dependency onlvy
29
64
 
30
- # 0.5.2
65
+ ## 0.5.2
31
66
 
32
67
  - Add requires in files with missing requires
33
68
 
34
- # 0.5.1
69
+ ## 0.5.1
35
70
 
36
71
  - Fix merging optional attributes
37
72
  - Change `#inspect` to look like a tree
38
73
 
39
- # 0.5.0
74
+ ## 0.5.0
40
75
 
41
76
  - Change internal representation of key to symbol
42
77
  - Change default type from `nil` to `Object`, removing special behaviour for nil
@@ -55,11 +90,11 @@
55
90
  - Raise error if `self.base_format` is not available at time of `Dsl.media_type` call
56
91
  - Fix `expected_type` guard for arrays, nil, or arrays with nil.
57
92
 
58
- # 0.4.1
93
+ ## 0.4.1
59
94
 
60
95
  - Use strings for `:_links`, matching the other validation keys
61
96
 
62
- # 0.4.0
97
+ ## 0.4.0
63
98
 
64
99
  - Simplify `assert_media_type_format` by dumping views completely
65
100
  - Add test for `merge`
@@ -67,59 +102,59 @@
67
102
  - Add test for `validatable?`
68
103
  - Add block passing to `Scheme.new`
69
104
 
70
- # 0.3.0
105
+ ## 0.3.0
71
106
 
72
107
  - Add `merge` dsl to merge two `Scheme`
73
108
 
74
- # 0.2.6
109
+ ## 0.2.6
75
110
 
76
111
  - Change validation to accept both symbolised and stringified input ánd validations
77
112
 
78
- # 0.2.5
113
+ ## 0.2.5
79
114
 
80
115
  - Add automatic require for `media_types/scheme/any_of`
81
116
 
82
- # 0.2.4
117
+ ## 0.2.4
83
118
 
84
119
  - Change messages for `assert_media_types_registered` to be more informative and consistent
85
120
 
86
- # 0.2.3
121
+ ## 0.2.3
87
122
 
88
123
  - Fix an issue with `Hash#compact` which was introduce in 2.4+. Now works with Ruby 2.3
89
124
 
90
- # 0.2.2
125
+ ## 0.2.2
91
126
 
92
127
  - Fix an issue with `Registrar#versions`
93
128
  - Fix link in the gemspec to Github
94
129
 
95
- # 0.2.1
130
+ ## 0.2.1
96
131
 
97
- - Fix an issue with `Constructable#valid?` and `Constructable#validate!`
132
+ - Fix an issue with `Constructable#valid?` and `Constructable#validate!`
98
133
 
99
- # 0.2.0
134
+ ## 0.2.0
100
135
 
101
136
  Breaking changes to update public API and usage
102
137
 
103
- - Remove `Base` class (use `MediaTypes::Dsl` instead)
104
- - Remove a lot of configuration options as they are deemed unneeded
105
- - Remove `active_support` dependency
106
- - Rename `ConstructableMimeType` to `Constructable`
107
- - Moved global scheme types to `Scheme` as subtype
108
- - Add `MediaTypes::Dsl`
109
- - Add `validations` block to capture schemes
110
- - Add `registrations` block to capture register intent
111
- - Add `defaults` block to capture mime type defaults
112
- - Add `MediaTypes.register` class method to call `Mime::Type.register`
113
- - Add `Registerable` capture class
114
- - Add type / base setting for `Constructable`
115
- - Add versioned validations
116
- - Add forced types of `collection`s
117
- - Add `attribute` with block
118
- - Add `EnumerationOfType` for schema typed arrays
119
- - Add `AnyOf` for scheme enum types
120
- - Add non-block calls for `Scheme` dsl
121
- - Add yard documentation to `/docs`
122
-
123
- # 0.1.0
138
+ - Remove `Base` class (use `MediaTypes::Dsl` instead)
139
+ - Remove a lot of configuration options as they are deemed unneeded
140
+ - Remove `active_support` dependency
141
+ - Rename `ConstructableMimeType` to `Constructable`
142
+ - Moved global scheme types to `Scheme` as subtype
143
+ - Add `MediaTypes::Dsl`
144
+ - Add `validations` block to capture schemes
145
+ - Add `registrations` block to capture register intent
146
+ - Add `defaults` block to capture mime type defaults
147
+ - Add `MediaTypes.register` class method to call `Mime::Type.register`
148
+ - Add `Registerable` capture class
149
+ - Add type / base setting for `Constructable`
150
+ - Add versioned validations
151
+ - Add forced types of `collection`s
152
+ - Add `attribute` with block
153
+ - Add `EnumerationOfType` for schema typed arrays
154
+ - Add `AnyOf` for scheme enum types
155
+ - Add non-block calls for `Scheme` dsl
156
+ - Add yard documentation to `/docs`
157
+
158
+ ## 0.1.0
124
159
 
125
160
  :baby: initial release
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 media_types.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 media_types.gemspec
6
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,109 +1,43 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- media_types (0.6.2)
4
+ media_types (2.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actionpack (5.2.3)
10
- actionview (= 5.2.3)
11
- activesupport (= 5.2.3)
12
- rack (~> 2.0)
13
- rack-test (>= 0.6.3)
14
- rails-dom-testing (~> 2.0)
15
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
16
- actionview (5.2.3)
17
- activesupport (= 5.2.3)
18
- builder (~> 3.1)
19
- erubi (~> 1.4)
20
- rails-dom-testing (~> 2.0)
21
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
22
- activesupport (5.2.3)
23
- concurrent-ruby (~> 1.0, >= 1.0.2)
24
- i18n (>= 0.7, < 2)
25
- minitest (~> 5.1)
26
- tzinfo (~> 1.1)
27
- addressable (2.6.0)
28
- public_suffix (>= 2.0.2, < 4.0)
29
9
  ansi (1.5.0)
30
- awesome_print (1.8.0)
31
- builder (3.2.3)
32
- concurrent-ruby (1.1.5)
33
- crass (1.0.4)
34
- docile (1.3.1)
35
- domain_name (0.5.20180417)
36
- unf (>= 0.0.5, < 1.0.0)
37
- erubi (1.8.0)
38
- http (4.1.1)
39
- addressable (~> 2.3)
40
- http-cookie (~> 1.0)
41
- http-form_data (~> 2.0)
42
- http_parser.rb (~> 0.6.0)
43
- http-cookie (1.0.3)
44
- domain_name (~> 0.5)
45
- http-form_data (2.1.1)
46
- http_parser.rb (0.6.0)
47
- i18n (1.6.0)
48
- concurrent-ruby (~> 1.0)
49
- json (2.2.0)
50
- loofah (2.2.3)
51
- crass (~> 1.0.2)
52
- nokogiri (>= 1.5.9)
53
- mini_portile2 (2.4.0)
54
- minitest (5.11.3)
55
- minitest-ci (3.4.0)
56
- minitest (>= 5.0.6)
57
- minitest-reporters (1.3.6)
10
+ awesome_print (1.9.2)
11
+ builder (3.2.4)
12
+ docile (1.4.0)
13
+ minitest (5.14.4)
14
+ minitest-reporters (1.4.3)
58
15
  ansi
59
16
  builder
60
17
  minitest (>= 5.0)
61
18
  ruby-progressbar
62
- nokogiri (1.10.3)
63
- mini_portile2 (~> 2.4.0)
64
- nokogiri (1.10.3-x64-mingw32)
65
- mini_portile2 (~> 2.4.0)
66
- oj (3.7.12)
67
- public_suffix (3.0.3)
68
- rack (2.0.6)
69
- rack-test (1.1.0)
70
- rack (>= 1.0, < 3)
71
- rails-dom-testing (2.0.3)
72
- activesupport (>= 4.2.0)
73
- nokogiri (>= 1.6)
74
- rails-html-sanitizer (1.0.4)
75
- loofah (~> 2.2, >= 2.2.2)
76
- rake (12.3.2)
77
- ruby-progressbar (1.10.0)
78
- simplecov (0.16.1)
19
+ oj (3.13.1)
20
+ rake (13.0.6)
21
+ ruby-progressbar (1.11.0)
22
+ simplecov (0.21.2)
79
23
  docile (~> 1.1)
80
- json (>= 1.8, < 3)
81
- simplecov-html (~> 0.10.0)
82
- simplecov-html (0.10.2)
83
- thread_safe (0.3.6)
84
- tzinfo (1.2.5)
85
- thread_safe (~> 0.1)
86
- unf (0.1.4)
87
- unf_ext
88
- unf_ext (0.0.7.5)
89
- unf_ext (0.0.7.5-x64-mingw32)
24
+ simplecov-html (~> 0.11)
25
+ simplecov_json_formatter (~> 0.1)
26
+ simplecov-html (0.12.3)
27
+ simplecov_json_formatter (0.1.3)
90
28
 
91
29
  PLATFORMS
92
- ruby
93
30
  x64-mingw32
94
31
 
95
32
  DEPENDENCIES
96
- actionpack
97
33
  awesome_print
98
- bundler (~> 2)
99
- http
34
+ bundler (>= 2)
100
35
  media_types!
101
36
  minitest (~> 5.0)
102
- minitest-ci
103
37
  minitest-reporters
104
38
  oj
105
- rake (~> 12.3)
39
+ rake (>= 12.0)
106
40
  simplecov
107
41
 
108
42
  BUNDLED WITH
109
- 2.0.1
43
+ 2.2.7
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Derk-Jan Karrenbeld
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.