custom_tag 0.3.0 → 0.3.2

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: a68c2e4baf5565bf8e4dacaf83246217ee69e1e7ed17d906eabd7f68f9410832
4
- data.tar.gz: 7c51503bb18ec0d03a8f1c89b02fc1c61cc683ff59ef67469b2d688f7ef4aa66
3
+ metadata.gz: 9b38b87a873c262f1debb263c19cfd0c04785d148577ea03cec23a55e3fab4b9
4
+ data.tar.gz: 68e43f9c45c7a4456d31f1e4ede35bd2bf2f913d088894145d39b544131f595b
5
5
  SHA512:
6
- metadata.gz: 7f1d41257b2e1401a9aae3d03a47cdba10c710993c06e97e35d2d0f9417fc89f36083fcc8e74ccf0bd3194fed7be734d69ec993996765ecfbdb48c9627314bef
7
- data.tar.gz: c9d43398388f799275dd4754146bda6ad5793d83e66c3fef85257753bc468c6e219329feaf7c55d34675c042b6ec913e9f4dbc8ac47cdb833a9b98e83dbadce8
6
+ metadata.gz: 684026852f4bfba3ee34d8b5ec2259ae94795b711c7cbcd25d68ec3d2bc077b7b2734bb5c33df59059b3fe193b98461ad98d2d2290a7636631a30eff0e004451
7
+ data.tar.gz: 3f1f7e326a353d72911f303247bf309d5948adeacc0e7365399bce7485cc53751ac0bfd6d63cf3409533010b67e96908d3e465bc5fc43412ab6565ab5884026f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # CHANGELOG for CustomTag
2
2
 
3
+ ## 0.3.2 - 16 August 2023
4
+
5
+ Minor tweaks in debugging as I go through a Rails application using it in anger.
6
+
7
+ ## 0.3.1 - 16 August 2023
8
+
9
+ Handling `ActionDispatch::Response::RackBody` as well as array body responses.
10
+
3
11
  ## 0.3.0 - 16 August 2023
4
12
 
5
13
  Configured Railtie to correctly use Rack middleware.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- custom_tag (0.2.0)
4
+ custom_tag (0.3.2)
5
5
  nokogiri
6
6
 
7
7
  GEM
@@ -26,12 +26,13 @@ module CustomTag
26
26
  build(tag_name, attrs, content)
27
27
  end
28
28
 
29
- doc = Nokogiri::XML.fragment(ret)
29
+ doc = Nokogiri::HTML.fragment(ret)
30
30
  doc.search("*").each do |element|
31
31
  if CustomTag::Base.tags[element.name]
32
- element.replace(CustomTag::Base.replace(element.name, element.attributes, element.content))
32
+ element.replace(CustomTag::Base.replace(element.name, element.attributes, element.children.to_html))
33
33
  end
34
34
  end
35
+
35
36
  doc.to_html.strip
36
37
  end
37
38
 
@@ -7,9 +7,20 @@ module CustomTag
7
7
  def call(env)
8
8
  code, headers, response = @app.call(env)
9
9
 
10
- response[0] = CustomTag.parse_and_replace(response[0]) if headers["Content-Type"]&.include?("text/html")
10
+ unless headers["Content-Type"]&.include?("text/html")
11
+ return [code, headers, response]
12
+ end
11
13
 
12
- [code, headers, response]
14
+ response_body = if response.respond_to?(:body)
15
+ response.body
16
+ else
17
+ response[0]
18
+ end
19
+
20
+ response_body = CustomTag.parse_and_replace(response_body)
21
+
22
+ headers["Content-Length"] = response_body.bytesize.to_s
23
+ [code, headers, [response_body]]
13
24
  end
14
25
  end
15
26
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CustomTag
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.2"
5
5
  end
data/lib/custom_tag.rb CHANGED
@@ -12,9 +12,9 @@ module CustomTag
12
12
  def self.parse_and_replace(content)
13
13
  doc = Nokogiri::HTML.parse(content)
14
14
  doc.search("*").each do |element|
15
- if CustomTag::Base.tags[element.name]
16
- element.replace(CustomTag::Base.replace(element.name, element.attributes, element.children.to_html))
17
- end
15
+ next unless CustomTag::Base.tags[element.name]
16
+
17
+ element.replace(CustomTag::Base.replace(element.name, element.attributes, element.children.to_html))
18
18
  end
19
19
  doc.to_html(save_with: 0)
20
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: custom_tag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jeffries