media_types 1.0.0 → 2.1.1

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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/debian.yml +43 -0
  3. data/.github/workflows/ruby.yml +3 -0
  4. data/.gitignore +10 -10
  5. data/CHANGELOG.md +80 -54
  6. data/Gemfile +6 -6
  7. data/Gemfile.lock +43 -114
  8. data/LICENSE +21 -0
  9. data/README.md +278 -85
  10. data/Rakefile +12 -12
  11. data/lib/media_types.rb +46 -3
  12. data/lib/media_types/constructable.rb +15 -9
  13. data/lib/media_types/dsl.rb +66 -31
  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 +127 -13
  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 +29 -7
  28. data/lib/media_types/version.rb +1 -1
  29. data/media_types.gemspec +4 -7
  30. metadata +19 -63
  31. data/.travis.yml +0 -19
  32. data/lib/media_types/.dsl.rb.swp +0 -0
  33. data/lib/media_types/defaults.rb +0 -31
  34. data/lib/media_types/integrations.rb +0 -32
  35. data/lib/media_types/integrations/actionpack.rb +0 -21
  36. data/lib/media_types/integrations/http.rb +0 -47
  37. data/lib/media_types/minitest/assert_media_type_format.rb +0 -10
  38. data/lib/media_types/minitest/assert_media_types_registered.rb +0 -166
  39. data/lib/media_types/registrar.rb +0 -148
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8285f897870c9a66139c5129db60c7abf31f870ef20103e6d21da6be99c139b8
4
- data.tar.gz: a62bbb54c1e1de59cdbef2c98050f1aa0d040dc6aa15a7559aa8e016014d26b0
3
+ metadata.gz: 610b654c6f47fc159c8f104246edd4a0314d2f3439b3f136da1740ae198a7f08
4
+ data.tar.gz: 325234c6d61a3dd660895d607e92ee8d3849b373b4871d77272a991f5dcad457
5
5
  SHA512:
6
- metadata.gz: 132ca0f0f8acf1dcd915c75c7b7b283ee3cc3a896d3fb53acffd8adc958300535bf7dde1d030e26865b317905c5da62ad18e507dbb1f04829ef5582bd4b187b3
7
- data.tar.gz: ee0d5bd2f3e51f492d5530bbfa45e1acfb067ebc2a690a4b4cdf02d1284792bed60eebfaa6757c0b8a36fb520566932da784c9434d235fa59fb7c58f97231da3
6
+ metadata.gz: 743edfc0e1d4c6d2eb277ea931d180721042b40cf3c2e060bf902a6277dce7cacf8446be6c712806947d2240345fc82abc60a2bee424548dde6c8100f5456136
7
+ data.tar.gz: 744f67b305bdcd413420c640316531b74a74e09e4ebb045c42666508d20545790359499c6fff1ebcccd7a59740b6edc341356fad56f03f618e35fc138cb2344a
@@ -0,0 +1,43 @@
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
+ gem install bundler
22
+ bundle install --local
23
+ sudo apt-file update
24
+ - name: Build
25
+ run: |
26
+ bundle exec rake build
27
+ mkdir debpkg
28
+ cp pkg/media_types-*.gem media_types.gem
29
+ #(cd debpkg; gem2tgz media_types.gem)
30
+ #(cd debpkg; dh-make-ruby media_types-*.tar.gz)
31
+ #(cd debpkg; dh-make-ruby media_types-*.tar.gz)
32
+ (cd pkg; gem2deb media_types*.gem)
33
+ mv pkg/ruby-media-types_*_all.deb ruby-media-types.deb
34
+ - name: Upload gem
35
+ uses: actions/upload-artifact@v1
36
+ with:
37
+ name: media_types.gem
38
+ path: media_types.gem
39
+ - name: Upload deb
40
+ uses: actions/upload-artifact@v1
41
+ with:
42
+ name: ruby-media-types.deb
43
+ path: ruby-media-types.deb
@@ -15,6 +15,9 @@ jobs:
15
15
  ruby-version: 2.6.x
16
16
  - name: Build and test with Rake
17
17
  run: |
18
+ sudo apt-get update
19
+ DEBIAN_FRONTEND=noninteractive sudo apt-get install --yes bundler
20
+ rm Gemfile.lock || true
18
21
  gem install bundler
19
22
  bundle install --jobs 4 --retry 3
20
23
  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,26 +1,52 @@
1
- # 1.0.0
2
- - Added the ability to do inline tests when defining validations using `assert_pass '<json>'` and `assert_fail '<json>'`.
3
- - `media_type` has been replaced with `use_name`.
4
- - It is no longer possible to set a default version. Please use `version <x> do` instead.
5
- - 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.
6
- - `self.base_format` has been replaced by `identifier_format do |type:, view:, version:, suffix:|`.
7
- - Added the `empty` validation to mark an empty object as valid.
8
- - Added the `identifier` function to get the [Media Type Identifier](https://en.wikipedia.org/wiki/Media_type) for the validator.
9
- - Added `version(x)` and `view(x)` functions.
10
- - Added an `available_validations` functions that returns all defined validations.
11
- - Fixed an issue where validations could accidentally merge if defined with a bad `base_format`.
12
- - Fixed an issue where undefined validations would accept an empty object.
13
-
14
- # 0.6.2
1
+ # Changelog
2
+
3
+ ## 2.1.1
4
+
5
+ - Fix Ruby 2.6 to 2.7 incompatible change
6
+
7
+ ## 2.1.0
8
+
9
+ - Add `override_suffix` to force a specific suffix
10
+ - Fix all deprecation warnings
11
+
12
+ ## 2.0.1
13
+
14
+ - Views can now be accessed indifferently.
15
+ - Attribute keys no longer match indifferently.
16
+ - Fixed infinite loop when validating non-hash, non-array items.
17
+
18
+ ## 2.0.0
19
+
20
+ - Removed ability to set default suffix. All suffixes now default to `+json`.
21
+ - Suffixes are now set for a given view and version instead of as a block.
22
+ - Added `suffix :yoursuffix` command to override the default `:json` suffix.
23
+ - Removed defaults block.
24
+ - Removed registrations block.
25
+
26
+ ## 1.0.0
27
+
28
+ - Added the ability to do inline tests when defining validations using `assert_pass '<json>'` and `assert_fail '<json>'`.
29
+ - `media_type` has been replaced with `use_name`.
30
+ - It is no longer possible to set a default version. Please use `version <x> do` instead.
31
+ - 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.
32
+ - `self.base_format` has been replaced by `identifier_format do |type:, view:, version:, suffix:|`.
33
+ - Added the `empty` validation to mark an empty object as valid.
34
+ - Added the `identifier` function to get the [Media Type Identifier](https://en.wikipedia.org/wiki/Media_type) for the validator.
35
+ - Added `version(x)` and `view(x)` functions.
36
+ - Added an `available_validations` functions that returns all defined validations.
37
+ - Fixed an issue where validations could accidentally merge if defined with a bad `base_format`.
38
+ - Fixed an issue where undefined validations would accept an empty object.
39
+
40
+ ## 0.6.2
15
41
 
16
42
  - Fix handling empty collections
17
43
 
18
- # 0.6.1
44
+ ## 0.6.1
19
45
 
20
46
  - Fix no `validations` error on `validatable?` (now returns `false`)
21
47
  - Update `bundler` to `2.x`
22
48
 
23
- # 0.6.0
49
+ ## 0.6.0
24
50
 
25
51
  - Change default expected type for `attribute` to Object
26
52
  - Remove default `actionpack` calls for `.register`
@@ -28,28 +54,28 @@
28
54
  - Add integration for registering with `http` (http.rb)
29
55
  - Fix stack overflow for cyclic schema
30
56
 
31
- # 0.5.5
57
+ ## 0.5.5
32
58
 
33
59
  - Fix an issue with `attribute(optional:, &block)` not passing `optional:` to the created `collection`.
34
60
 
35
- # 0.5.4
61
+ ## 0.5.4
36
62
 
37
63
  - Fix formatter reworked template when fields are not present
38
64
 
39
- # 0.5.3
65
+ ## 0.5.3
40
66
 
41
67
  - Remove `require 'awesome_print'` in library code as it's marked as a development dependency onlvy
42
68
 
43
- # 0.5.2
69
+ ## 0.5.2
44
70
 
45
71
  - Add requires in files with missing requires
46
72
 
47
- # 0.5.1
73
+ ## 0.5.1
48
74
 
49
75
  - Fix merging optional attributes
50
76
  - Change `#inspect` to look like a tree
51
77
 
52
- # 0.5.0
78
+ ## 0.5.0
53
79
 
54
80
  - Change internal representation of key to symbol
55
81
  - Change default type from `nil` to `Object`, removing special behaviour for nil
@@ -68,11 +94,11 @@
68
94
  - Raise error if `self.base_format` is not available at time of `Dsl.media_type` call
69
95
  - Fix `expected_type` guard for arrays, nil, or arrays with nil.
70
96
 
71
- # 0.4.1
97
+ ## 0.4.1
72
98
 
73
99
  - Use strings for `:_links`, matching the other validation keys
74
100
 
75
- # 0.4.0
101
+ ## 0.4.0
76
102
 
77
103
  - Simplify `assert_media_type_format` by dumping views completely
78
104
  - Add test for `merge`
@@ -80,59 +106,59 @@
80
106
  - Add test for `validatable?`
81
107
  - Add block passing to `Scheme.new`
82
108
 
83
- # 0.3.0
109
+ ## 0.3.0
84
110
 
85
111
  - Add `merge` dsl to merge two `Scheme`
86
112
 
87
- # 0.2.6
113
+ ## 0.2.6
88
114
 
89
115
  - Change validation to accept both symbolised and stringified input ánd validations
90
116
 
91
- # 0.2.5
117
+ ## 0.2.5
92
118
 
93
119
  - Add automatic require for `media_types/scheme/any_of`
94
120
 
95
- # 0.2.4
121
+ ## 0.2.4
96
122
 
97
123
  - Change messages for `assert_media_types_registered` to be more informative and consistent
98
124
 
99
- # 0.2.3
125
+ ## 0.2.3
100
126
 
101
127
  - Fix an issue with `Hash#compact` which was introduce in 2.4+. Now works with Ruby 2.3
102
128
 
103
- # 0.2.2
129
+ ## 0.2.2
104
130
 
105
131
  - Fix an issue with `Registrar#versions`
106
132
  - Fix link in the gemspec to Github
107
133
 
108
- # 0.2.1
134
+ ## 0.2.1
109
135
 
110
- - Fix an issue with `Constructable#valid?` and `Constructable#validate!`
136
+ - Fix an issue with `Constructable#valid?` and `Constructable#validate!`
111
137
 
112
- # 0.2.0
138
+ ## 0.2.0
113
139
 
114
140
  Breaking changes to update public API and usage
115
141
 
116
- - Remove `Base` class (use `MediaTypes::Dsl` instead)
117
- - Remove a lot of configuration options as they are deemed unneeded
118
- - Remove `active_support` dependency
119
- - Rename `ConstructableMimeType` to `Constructable`
120
- - Moved global scheme types to `Scheme` as subtype
121
- - Add `MediaTypes::Dsl`
122
- - Add `validations` block to capture schemes
123
- - Add `registrations` block to capture register intent
124
- - Add `defaults` block to capture mime type defaults
125
- - Add `MediaTypes.register` class method to call `Mime::Type.register`
126
- - Add `Registerable` capture class
127
- - Add type / base setting for `Constructable`
128
- - Add versioned validations
129
- - Add forced types of `collection`s
130
- - Add `attribute` with block
131
- - Add `EnumerationOfType` for schema typed arrays
132
- - Add `AnyOf` for scheme enum types
133
- - Add non-block calls for `Scheme` dsl
134
- - Add yard documentation to `/docs`
135
-
136
- # 0.1.0
142
+ - Remove `Base` class (use `MediaTypes::Dsl` instead)
143
+ - Remove a lot of configuration options as they are deemed unneeded
144
+ - Remove `active_support` dependency
145
+ - Rename `ConstructableMimeType` to `Constructable`
146
+ - Moved global scheme types to `Scheme` as subtype
147
+ - Add `MediaTypes::Dsl`
148
+ - Add `validations` block to capture schemes
149
+ - Add `registrations` block to capture register intent
150
+ - Add `defaults` block to capture mime type defaults
151
+ - Add `MediaTypes.register` class method to call `Mime::Type.register`
152
+ - Add `Registerable` capture class
153
+ - Add type / base setting for `Constructable`
154
+ - Add versioned validations
155
+ - Add forced types of `collection`s
156
+ - Add `attribute` with block
157
+ - Add `EnumerationOfType` for schema typed arrays
158
+ - Add `AnyOf` for scheme enum types
159
+ - Add non-block calls for `Scheme` dsl
160
+ - Add yard documentation to `/docs`
161
+
162
+ ## 0.1.0
137
163
 
138
164
  :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,114 +1,43 @@
1
- PATH
2
- remote: .
3
- specs:
4
- media_types (1.0.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- actionpack (5.2.4)
10
- actionview (= 5.2.4)
11
- activesupport (= 5.2.4)
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.4)
17
- activesupport (= 5.2.4)
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.4)
23
- concurrent-ruby (~> 1.0, >= 1.0.2)
24
- i18n (>= 0.7, < 2)
25
- minitest (~> 5.1)
26
- tzinfo (~> 1.1)
27
- addressable (2.7.0)
28
- public_suffix (>= 2.0.2, < 5.0)
29
- 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.5)
34
- docile (1.3.2)
35
- domain_name (0.5.20190701)
36
- unf (>= 0.0.5, < 1.0.0)
37
- erubi (1.9.0)
38
- ffi (1.11.1)
39
- ffi (1.11.1-x64-mingw32)
40
- ffi-compiler (1.0.1)
41
- ffi (>= 1.0.0)
42
- rake
43
- http (4.2.0)
44
- addressable (~> 2.3)
45
- http-cookie (~> 1.0)
46
- http-form_data (~> 2.0)
47
- http-parser (~> 1.2.0)
48
- http-cookie (1.0.3)
49
- domain_name (~> 0.5)
50
- http-form_data (2.1.1)
51
- http-parser (1.2.1)
52
- ffi-compiler (>= 1.0, < 2.0)
53
- i18n (1.7.0)
54
- concurrent-ruby (~> 1.0)
55
- json (2.2.0)
56
- loofah (2.4.0)
57
- crass (~> 1.0.2)
58
- nokogiri (>= 1.5.9)
59
- mini_portile2 (2.4.0)
60
- minitest (5.13.0)
61
- minitest-ci (3.4.0)
62
- minitest (>= 5.0.6)
63
- minitest-reporters (1.4.2)
64
- ansi
65
- builder
66
- minitest (>= 5.0)
67
- ruby-progressbar
68
- nokogiri (1.10.7)
69
- mini_portile2 (~> 2.4.0)
70
- nokogiri (1.10.7-x64-mingw32)
71
- mini_portile2 (~> 2.4.0)
72
- oj (3.10.0)
73
- public_suffix (4.0.1)
74
- rack (2.0.7)
75
- rack-test (1.1.0)
76
- rack (>= 1.0, < 3)
77
- rails-dom-testing (2.0.3)
78
- activesupport (>= 4.2.0)
79
- nokogiri (>= 1.6)
80
- rails-html-sanitizer (1.3.0)
81
- loofah (~> 2.3)
82
- rake (13.0.1)
83
- ruby-progressbar (1.10.1)
84
- simplecov (0.17.1)
85
- docile (~> 1.1)
86
- json (>= 1.8, < 3)
87
- simplecov-html (~> 0.10.0)
88
- simplecov-html (0.10.2)
89
- thread_safe (0.3.6)
90
- tzinfo (1.2.5)
91
- thread_safe (~> 0.1)
92
- unf (0.1.4)
93
- unf_ext
94
- unf_ext (0.0.7.6)
95
-
96
- PLATFORMS
97
- ruby
98
- x64-mingw32
99
-
100
- DEPENDENCIES
101
- actionpack
102
- awesome_print
103
- bundler (~> 2)
104
- http
105
- media_types!
106
- minitest (~> 5.0)
107
- minitest-ci
108
- minitest-reporters
109
- oj
110
- rake (~> 13.0)
111
- simplecov
112
-
113
- BUNDLED WITH
114
- 2.0.1
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ media_types (2.1.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ansi (1.5.0)
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)
15
+ ansi
16
+ builder
17
+ minitest (>= 5.0)
18
+ ruby-progressbar
19
+ oj (3.13.1)
20
+ rake (13.0.6)
21
+ ruby-progressbar (1.11.0)
22
+ simplecov (0.21.2)
23
+ docile (~> 1.1)
24
+ simplecov-html (~> 0.11)
25
+ simplecov_json_formatter (~> 0.1)
26
+ simplecov-html (0.12.3)
27
+ simplecov_json_formatter (0.1.3)
28
+
29
+ PLATFORMS
30
+ x64-mingw32
31
+
32
+ DEPENDENCIES
33
+ awesome_print
34
+ bundler (>= 2)
35
+ media_types!
36
+ minitest (~> 5.0)
37
+ minitest-reporters
38
+ oj
39
+ rake (>= 12.0)
40
+ simplecov
41
+
42
+ BUNDLED WITH
43
+ 2.2.17