media_types-serialization 1.1.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7eabad722268eb76ce511245770ef7fb6a4c07c9d0ce8be05ac0995a4ebe309
4
- data.tar.gz: f749dfcbc363662ddb7e7a2d81162168fa1dea8bb086aa57074d1a51d3bfc5c5
3
+ metadata.gz: 7c72aa611b03ba3537f1c12eb44b31596f58d21ba3fe0dd5596b8d37d613d132
4
+ data.tar.gz: '084a4733e9d015fe1816399772d3fcfaed898368507d9785df89bdb296b34171'
5
5
  SHA512:
6
- metadata.gz: e64bafc043adbb81c87475e2898687f1495b7e15f8bb71dbb73fe2a0ea9f39556d4644f60f3f6658d196efe533f8cf8a504b7b8936e7812dc607bce628f400e4
7
- data.tar.gz: e4aa0a59bc0e3a8f785feda5d99b15a5f193984b3fd6deb5b06577e90b0c8628f615c7214258c0d08383bd5fc171a7249d8985a14d0fadc4f32734899981572a
6
+ metadata.gz: 67d43c2377d4ac849997886fa547d9b6c22ee7880eca6e1acfebd73db3cbe18a189823ca79bec0a009ab2feb83aa6b7d2d4a7e50ac44e9e0f37207fe4c07bb87
7
+ data.tar.gz: 2d9825fca6e6d77f84609b691d5dcd113424b41adf971efe87fe7bcd56220dd34a6aaec6a7ce905474131ed398e5fed8decf11f4e2209752b3a9cfbfbd80933f
data/.gitignore CHANGED
@@ -1,12 +1,12 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- .idea/workspace.xml
11
- .idea/usage.statistics.xml
12
- .idea/tasks.xml
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ .idea/workspace.xml
11
+ .idea/usage.statistics.xml
12
+ .idea/tasks.xml
data/.idea/.rakeTasks CHANGED
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <Settings><!--This file was automatically generated by Ruby plugin.
3
- You are allowed to:
4
- 1. Remove rake task
5
- 2. Add existing rake tasks
6
- To add existing rake tasks automatically delete this file and reload the project.
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
7
  --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build media_types-serialization-0.5.1.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install media_types-serialization-0.5.1.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install media_types-serialization-0.5.1.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.5.1 and build and push media_types-serialization-0.5.1.gem to rubygems.org" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run tests" fullCmd="test" taksId="test" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
@@ -1,6 +1,6 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
5
- </profile>
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
5
+ </profile>
6
6
  </component>
@@ -1,20 +1,20 @@
1
- <component name="ProjectRunConfigurationManager">
2
- <configuration default="false" name="test" type="RakeRunConfigurationType" factoryName="Rake">
3
- <module name="media_types-serialization" />
4
- <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="" />
5
- <RAKE_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
6
- <RAKE_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
7
- <RAKE_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
8
- <RAKE_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
9
- <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
10
- <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
11
- <EXTENSION ID="RubyCoverageRunConfigurationExtension" track_test_folders="true" runner="rcov" />
12
- <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_NAME" VALUE="test" />
13
- <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ARGS" VALUE="" />
14
- <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ATTACHED_TEST_FRAMEWORKS" VALUE=":test_unit " />
15
- <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_TRACE" VALUE="false" />
16
- <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_DRYRUN" VALUE="false" />
17
- <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_PREREQS" VALUE="false" />
18
- <method v="2" />
19
- </configuration>
1
+ <component name="ProjectRunConfigurationManager">
2
+ <configuration default="false" name="test" type="RakeRunConfigurationType" factoryName="Rake">
3
+ <module name="media_types-serialization" />
4
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="" />
5
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
6
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
7
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
8
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
9
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
10
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
11
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" track_test_folders="true" runner="rcov" />
12
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_NAME" VALUE="test" />
13
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ARGS" VALUE="" />
14
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ATTACHED_TEST_FRAMEWORKS" VALUE=":test_unit " />
15
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_TRACE" VALUE="false" />
16
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_DRYRUN" VALUE="false" />
17
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_PREREQS" VALUE="false" />
18
+ <method v="2" />
19
+ </configuration>
20
20
  </component>
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.0
4
+
5
+ - ✨ Add `view:` to `output_html` which renders a specific rails view.
6
+
3
7
  ## 1.1.0
4
8
 
5
9
  - ✨ Add _allow_output_html_: Fallback to rails rendering.
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in media_types-serialization.gemspec
4
- gemspec
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in media_types-serialization.gemspec
4
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- media_types-serialization (1.0.3)
4
+ media_types-serialization (1.1.0)
5
5
  actionpack (>= 4.0.0)
6
6
  activesupport (>= 4.0.0)
7
7
  media_types (>= 2.0.0, < 3.0.0)
@@ -75,7 +75,7 @@ GEM
75
75
  racc (~> 1.4)
76
76
  nokogiri (1.11.7-x86_64-linux)
77
77
  racc (~> 1.4)
78
- oj (3.11.7)
78
+ oj (3.12.1)
79
79
  racc (1.5.2)
80
80
  rack (2.2.3)
81
81
  rack-test (1.1.0)
@@ -104,7 +104,7 @@ GEM
104
104
  method_source
105
105
  rake (>= 0.8.7)
106
106
  thor (>= 0.19.0, < 2.0)
107
- rake (13.0.3)
107
+ rake (13.0.6)
108
108
  sprockets (4.0.2)
109
109
  concurrent-ruby (~> 1.0)
110
110
  rack (> 1, < 3)
data/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2019 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
13
- all 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
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -348,7 +348,7 @@ class BookController < ActionController::API
348
348
  end
349
349
 
350
350
  def create
351
- json = deserialize(request, context: self) # does validation for us
351
+ json = deserialize(request) # does validation for us
352
352
  puts json
353
353
  end
354
354
  end
@@ -394,7 +394,7 @@ class BookController < ActionController::API
394
394
  end
395
395
 
396
396
  def create
397
- book = deserialize(request, context: self)
397
+ book = deserialize(request)
398
398
  book.save!
399
399
 
400
400
  render media: serialize_media(book), content_type request.format.to_s
@@ -497,7 +497,7 @@ class BookController < ActionController::API
497
497
  end
498
498
 
499
499
  def create
500
- json = deserialize(request, context: self) # does validation for us
500
+ json = deserialize(request) # does validation for us
501
501
  puts json
502
502
  end
503
503
  end
@@ -688,13 +688,13 @@ Configure the controller to allow the client to request responses emitted by the
688
688
 
689
689
  Accepts the same filters as `before_action`.
690
690
 
691
- #### `allow_output_html( as: nil, layout: nil, **filters )`
691
+ #### `allow_output_html( as: nil, view: nil, layout: nil, **filters )`
692
692
 
693
693
  Allows falling back to the default Rails view rendering when the client asks for the media type in the `as:` parameter or `text/html` if `as:` is unset.
694
694
 
695
695
  The `Content-Type` of the response will be `text/html` if the `as:` parameter is unset. If the `as:` parameter is set, it will include it in the variant parameter: `text/html; variant=application/vnd.xpbytes.borderless`.
696
696
 
697
- Accepts the same filters as `before_action`.
697
+ Accepts the same filters as `before_action`. You can set the template to use using the `view:` parameter.
698
698
 
699
699
  #### `allow_output_docs( description, **filters )`
700
700
 
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
8
- end
9
-
10
- task :default => :test
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console CHANGED
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "media_types/serialization"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "media_types/serialization"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ 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
@@ -184,7 +184,7 @@ module MediaTypes
184
184
  end
185
185
  end
186
186
 
187
- def allow_output_html(as: nil, layout: nil, **filter_opts)
187
+ def allow_output_html(as: nil, view: nil, layout: nil, **filter_opts)
188
188
  before_action(**filter_opts) do
189
189
  raise SerializersAlreadyFrozenError if defined? @serialization_frozen
190
190
 
@@ -198,9 +198,17 @@ module MediaTypes
198
198
 
199
199
  block = lambda { |_, _, controller|
200
200
  if layout.nil?
201
- controller.render_to_string
201
+ if view.nil?
202
+ controller.render_to_string
203
+ else
204
+ controller.render_to_string(template: view)
205
+ end
202
206
  else
203
- controller.render_to_string(layout: layout)
207
+ if view.nil?
208
+ controller.render_to_string(layout: layout)
209
+ else
210
+ controller.render_to_string(template: view, layout: layout)
211
+ end
204
212
  end
205
213
  }
206
214
 
@@ -1,5 +1,5 @@
1
1
  module MediaTypes
2
2
  module Serialization
3
- VERSION = '1.1.0'.freeze
3
+ VERSION = '1.2.0'.freeze
4
4
  end
5
5
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.metadata['homepage_uri'] = spec.homepage
22
22
  spec.metadata['source_code_uri'] = spec.homepage
23
- spec.metadata['changelog_uri'] = spec.homepage + '/CHANGELOG.md'
23
+ spec.metadata['changelog_uri'] = spec.homepage + '/blob/master/CHANGELOG.md'
24
24
  else
25
25
  raise 'RubyGems 2.0 or newer is required to protect against ' \
26
26
  'public gem pushes.'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: media_types-serialization
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derk-Jan Karrenbeld
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-06-29 00:00:00.000000000 Z
12
+ date: 2021-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -197,7 +197,7 @@ licenses:
197
197
  metadata:
198
198
  homepage_uri: https://github.com/XPBytes/media_types-serialization
199
199
  source_code_uri: https://github.com/XPBytes/media_types-serialization
200
- changelog_uri: https://github.com/XPBytes/media_types-serialization/CHANGELOG.md
200
+ changelog_uri: https://github.com/XPBytes/media_types-serialization/blob/master/CHANGELOG.md
201
201
  post_install_message:
202
202
  rdoc_options: []
203
203
  require_paths: