copy_tuner_client 0.8.0 → 0.8.1

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: 264af961181ce5a021556bb69739e1db4ca2ac1910da7dda22e14c9b959acda1
4
- data.tar.gz: 814fc09372ec9ef826609631e104db8b9df0c5e36d1dc75f85be1e3eae865eff
3
+ metadata.gz: 757532de573065d4b93a08c8bd5061a17c8fbef293d5f14a8ff24bb3815f3323
4
+ data.tar.gz: 5d6ceefe8fcb9b2d21ad9592e07d8e0ac68c9ef8684824e57e2a24d5f22afeb1
5
5
  SHA512:
6
- metadata.gz: 8bf796f105c5db21aebf649ce5a141b9e0f32eb2ebb9b79f50e5508a276439410389ff9ffadb1b77287ed3d206be812a9b8229188f59ae25e1573aa992827604
7
- data.tar.gz: 2176d41612626e59cf8ce7708a18cb32d60f2ce3635306b68c124c377353bbef4e4a247bdda2c92268673d75b846f1bfdf340c7531771f977a9baf122359d0d7
6
+ metadata.gz: e1effa31089ac5b0b480196ff1fb9700b92b80a2137393467923c84150a252688c2bc4b33f5a1a63c84a58af9128866a22a784111dcd16842a24b0a00437e11f
7
+ data.tar.gz: 8e987b21c4b30714b056f2685f57b9b4157f505fb4ef6857b853ab1dd82b3bbaffd442f8add04c8ffed8d0c80d1f52e2eb00d2a452be6859cd42aa048c5ef602
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.8.1
2
+
3
+ - Fix bug in `CopyrayMiddleware`
4
+
1
5
  ## 0.8.0
2
6
 
3
7
  - Change the default value of config.upload_disabled_environments
data/Gemfile.lock CHANGED
@@ -14,7 +14,7 @@ GIT
14
14
  PATH
15
15
  remote: .
16
16
  specs:
17
- copy_tuner_client (0.8.0)
17
+ copy_tuner_client (0.8.1)
18
18
  i18n (>= 0.5.0)
19
19
  json
20
20
 
@@ -37,14 +37,14 @@ module CopyTunerClient
37
37
  if CopyTunerClient::TranslationLog.initialized?
38
38
  json = CopyTunerClient::TranslationLog.translations.to_json
39
39
  # Use block to avoid back reference \?
40
- html.sub('</body>') { "<div id='copy-tuner-data' data-copy-tuner-translation-log='#{ERB::Util.html_escape json}' data-copy-tuner-url='#{CopyTunerClient.configuration.project_url}'></div></body>" }
40
+ append_to_html_body(html, "<div id='copy-tuner-data' data-copy-tuner-translation-log='#{ERB::Util.html_escape json}' data-copy-tuner-url='#{CopyTunerClient.configuration.project_url}'></div>")
41
41
  else
42
42
  html
43
43
  end
44
44
  end
45
45
 
46
46
  def inject_copy_tuner_bar(html)
47
- html.sub(/<body[^>]*>/) { "#{Regexp.last_match}\n#{render_copy_tuner_bar}" }
47
+ append_to_html_body(html, render_copy_tuner_bar)
48
48
  end
49
49
 
50
50
  def render_copy_tuner_bar
@@ -59,19 +59,25 @@ module CopyTunerClient
59
59
  end
60
60
 
61
61
  def append_css(html)
62
- html.sub(/<body[^>]*>/) { "#{Regexp.last_match}\n#{css_tag}" }
62
+ append_to_html_body(html, css_tag)
63
63
  end
64
64
 
65
65
  def append_js(html)
66
- html.sub(%r{</body>}) do
67
- "#{helpers.javascript_include_tag(:copyray)}\n#{Regexp.last_match}"
68
- end
66
+ append_to_html_body(html, helpers.javascript_include_tag(:copyray))
69
67
  end
70
68
 
71
69
  def css_tag
72
70
  helpers.stylesheet_link_tag :copyray, media: :all
73
71
  end
74
72
 
73
+ def append_to_html_body(html, content)
74
+ content = content.html_safe if content.respond_to?(:html_safe)
75
+ return html unless html.include?('</body>')
76
+
77
+ position = html.rindex('</body>')
78
+ html.insert(position, content + "\n")
79
+ end
80
+
75
81
  def file?(headers)
76
82
  headers["Content-Transfer-Encoding"] == "binary"
77
83
  end
@@ -1,6 +1,6 @@
1
1
  module CopyTunerClient
2
2
  # Client version
3
- VERSION = '0.8.0'.freeze
3
+ VERSION = '0.8.1'.freeze
4
4
 
5
5
  # API version being used to communicate with the server
6
6
  API_VERSION = '2.0'.freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copy_tuner_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SonicGarden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-01 00:00:00.000000000 Z
11
+ date: 2021-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n