blackstack_commons 1.1.41 → 1.1.42

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/extend_string.rb +26 -3
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5c3c238d33d3d4c366b1364178a6528467d81d1
4
- data.tar.gz: c4394a462575874d317f2b836a2f2f6863c281b0
3
+ metadata.gz: 4f72ddf1432211dec45c5288eb7ccd1a3c51824f
4
+ data.tar.gz: 23eb0b0027a1b9e3bd07a5798c92760ce2bccb75
5
5
  SHA512:
6
- metadata.gz: 9968fb30305ca9a039281dd8fa7cf4a63fb8819036f8fb55688151850141e6ebce24acd327c947b371b1d08bf8deffba3230680b2ddf836b8d968c8132bd68ed
7
- data.tar.gz: 4ab64b6387a58d8f406e762fa4b8e51837c499e56e6cc716fbbeecaa25e07f6c0be8c96e1569fdfbf505f9ba7288ba1eb5ae88cacc55f1c4eebba34e91f42c69
6
+ metadata.gz: 5ed23e9086cd0dd9e9d0d746b4308142d2443c7fdaefff25297ca0a8d3a3088fbc458233b703a9c50d7d88f71893433c1c405945856c59135880188bd0f3f02c
7
+ data.tar.gz: 6f6c9203a3c3fdd0e04c7c14fd7325eae02db3d848e52e99407be302040cfeffd6f7db1f5db1c2b9401c3156fdfd9044c20fa0d1f08cd7f20c4e30464ba972cd
data/lib/extend_string.rb CHANGED
@@ -110,11 +110,34 @@ class String
110
110
 
111
111
  # Escapes carriage returns and single and double quotes for JavaScript segments.
112
112
  # reference: https://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html
113
+ #
114
+ # Example:
115
+ # <%
116
+ # s = 'Hello World!'
117
+ # %>
118
+ # text = "<%=s.escape_javascript%>"
119
+ #
120
+ # Never use single-quotation marks, because this method is not supporting it.
121
+ # <%
122
+ # s = 'Hello World!'
123
+ # %>
124
+ # text = '<%=s.escape_javascript%>'
125
+ #
113
126
  def escape_javascript
114
127
  s = self.dup
115
- js_escape_map = { '\\' => '\\\\', "</" => '<\/', "\r\n" => '\n', "\n" => '\n', "\r" => '\n', '"' => '\\"', "'" => "\\'", "`" => "\\`", "$" => "\\$" }
116
- js_escape_map.each { | x, y | s.gsub!(x,y) }
117
- s
128
+ js_escape_map = {
129
+ '\\' => '\\\\',
130
+ "</" => '<\/',
131
+ "\r\n" => '\n',
132
+ "\n" => '\n',
133
+ "\r" => '\n',
134
+ '"' => '\\"',
135
+ "'" => "\'",
136
+ "`" => "\`",
137
+ "$" => "\\$",
138
+ }
139
+ js_escape_map.each { | x, y | s.gsub!(x,y) }
140
+ s
118
141
  end
119
142
 
120
143
  end # class String
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blackstack_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.41
4
+ version: 1.1.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-03 00:00:00.000000000 Z
11
+ date: 2021-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: content_spinning