jbuilder-schema 2.0.2 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 475aa6226a8439f15059d59b79e0e2b0fad03e725c75f462be7aea3b070f5b27
4
- data.tar.gz: c93e583024e7ad2af6208b3913f7e1c74b8166740c3ca3c3d2a4b8d4105ed2a6
3
+ metadata.gz: 2aea259ba4965ec62874b56ab4267ddc2f4cd2967babe536726397c53599c922
4
+ data.tar.gz: 71c9f200fb4cc481055ec0790e514b9a46108a6ae4cb0c0aad1ed09eba5f384e
5
5
  SHA512:
6
- metadata.gz: e286e0531d82ba6b3031925b0a82bd70b66e11497a086bd90abe47aeceff1d6c5d8438b82e98f632058a3953a16c1355638143732a97ef2bc36235071ff92270
7
- data.tar.gz: ea53e46e9a812b5345a4df0ff92df7fa91c2263de5e636c5afac16becad88febf445fdd0ee37d062a270a0b80f341c69e6302c1a53c2108cded1b1089374cd5f
6
+ metadata.gz: d0ac95a76f5630daad73debfd74f6056dd3e6b4f30e4075779a41306585d211c918d16140de6f32b01a60db3303ac21e1ccdf8c52b9ea4292e32c38a134e1e21
7
+ data.tar.gz: d88181a3d13d3748cfca995bbcc9de741bb9d5ecf98bd34af452b499aaeae2c0a6c44c5fc57ea88ee3892a2b6c2579f65a3310f1b59a83805067422ea20956c3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jbuilder-schema (2.0.2)
4
+ jbuilder-schema (2.0.4)
5
5
  jbuilder
6
6
  rails (>= 5.0.0)
7
7
 
@@ -89,8 +89,11 @@ GEM
89
89
  loofah (2.19.0)
90
90
  crass (~> 1.0.2)
91
91
  nokogiri (>= 1.5.9)
92
- mail (2.7.1)
92
+ mail (2.8.0)
93
93
  mini_mime (>= 0.1.1)
94
+ net-imap
95
+ net-pop
96
+ net-smtp
94
97
  marcel (1.0.2)
95
98
  method_source (1.0.0)
96
99
  mini_mime (1.1.2)
@@ -101,7 +104,7 @@ GEM
101
104
  net-protocol
102
105
  net-pop (0.1.2)
103
106
  net-protocol
104
- net-protocol (0.1.3)
107
+ net-protocol (0.2.0)
105
108
  timeout
106
109
  net-smtp (0.3.3)
107
110
  net-protocol
@@ -112,7 +115,7 @@ GEM
112
115
  parallel (1.22.1)
113
116
  parser (3.1.2.0)
114
117
  ast (~> 2.4.1)
115
- racc (1.6.0)
118
+ racc (1.6.1)
116
119
  rack (2.2.4)
117
120
  rack-test (2.0.2)
118
121
  rack (>= 1.3)
@@ -168,7 +171,7 @@ GEM
168
171
  rubocop (= 1.32.0)
169
172
  rubocop-performance (= 1.14.3)
170
173
  thor (1.2.1)
171
- timeout (0.3.0)
174
+ timeout (0.3.1)
172
175
  tzinfo (2.0.5)
173
176
  concurrent-ruby (~> 1.0)
174
177
  unicode-display_width (2.2.0)
@@ -18,8 +18,10 @@ class Jbuilder::Schema::Renderer
18
18
  end
19
19
 
20
20
  def render(object = nil, title: nil, description: nil, assigns: nil, **options)
21
- partial_path = object.respond_to?(:to_partial_path_for_jbuilder_schema) ? object.to_partial_path_for_jbuilder_schema : object.to_partial_path
22
- options.merge! partial: partial_path, object: object if object
21
+ if object
22
+ partial_path = object.respond_to?(:to_partial_path_for_jbuilder_schema) ? object.to_partial_path_for_jbuilder_schema : object.to_partial_path
23
+ options.merge! partial: partial_path, object: object
24
+ end
23
25
 
24
26
  options[:locals] ||= {}
25
27
  options[:locals].merge! @default_locals if @default_locals
@@ -10,7 +10,7 @@ class Jbuilder::Schema
10
10
 
11
11
  class Handler < ::JbuilderHandler
12
12
  def self.call(template, source = nil)
13
- super.sub("JbuilderTemplate.new(self", "Jbuilder::Schema::Template.new(self, **__jbuilder_schema_options").sub("target!", "schema!")
13
+ super.sub("JbuilderTemplate.new(self", "Jbuilder::Schema::Template.build(self, local_assigns")
14
14
  end
15
15
  end
16
16
 
@@ -18,6 +18,14 @@ class Jbuilder::Schema
18
18
  ::ActionView::Template.register_template_handler :jbuilder, ::Jbuilder::Schema::Template::Handler
19
19
  end
20
20
 
21
+ def self.build(view_context, local_assigns)
22
+ if (options = local_assigns[:__jbuilder_schema_options])
23
+ new(view_context, **options)
24
+ else
25
+ ::JbuilderTemplate.new(view_context)
26
+ end
27
+ end
28
+
21
29
  ModelScope = ::Struct.new(:model, :title, :description, keyword_init: true) do
22
30
  def initialize(**)
23
31
  super
@@ -49,6 +57,10 @@ class Jbuilder::Schema
49
57
  @ignore_nil = false
50
58
  end
51
59
 
60
+ def target!
61
+ schema!
62
+ end
63
+
52
64
  def schema!
53
65
  {type: type}.merge(type == :object ? _object(**attributes.merge) : attributes)
54
66
  end
@@ -1,4 +1,4 @@
1
1
  # We can't use the standard `Jbuilder::Schema::VERSION =` because
2
2
  # `Jbuilder` isn't a regular module namespace, but a class …which also loads Active Support.
3
3
  # So we use trickery, and assign the proper version once `jbuilder/schema.rb` is loaded.
4
- JBUILDER_SCHEMA_VERSION = "2.0.2"
4
+ JBUILDER_SCHEMA_VERSION = "2.0.4"
@@ -4,7 +4,7 @@ require "active_support/core_ext/module/delegation"
4
4
  require "jbuilder/schema/version"
5
5
 
6
6
  class Jbuilder::Schema
7
- VERSION = "2.0.2" # TODO Fix this. It's throwing errors when including the Ruby gem in downstream projects.
7
+ VERSION = "2.0.3" # TODO Fix this. It's throwing errors when including the Ruby gem in downstream projects.
8
8
 
9
9
  module IgnoreSchemaMeta
10
10
  ::Jbuilder.prepend self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbuilder-schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Sidorov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-08 00:00:00.000000000 Z
11
+ date: 2022-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jbuilder
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 3.3.7
79
+ rubygems_version: 3.3.16
80
80
  signing_key:
81
81
  specification_version: 4
82
82
  summary: Generate JSON Schema from Jbuilder files