mixpal 0.4.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mixpal/integration.rb +1 -1
- data/lib/mixpal/util.rb +12 -2
- data/lib/mixpal/version.rb +1 -1
- data/spec/lib/mixpal/util_spec.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a28fcdf5ca00ceb1a7abed59a6f90d8dcd7d7216c204ad76a87497a656dd4a7
|
4
|
+
data.tar.gz: 7c510ab982f230147a03bab655c8a7fb8da373310b817ead61fc6ea06d77f358
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd6c7aa7a15bdec83398610de7431f0d185f9650522a614204b7bb63bcaa7470147faa7ed301f3cbd9c5967164ab2d92ebaa90a5b8e4445947e2073864261f72
|
7
|
+
data.tar.gz: ec9c80f83fe4b8e20735c61c359306d68dbf0a60b7d9ba74515dcb60be7d7f5f237ab14a1d1e7951e75280158ea8c78f42f886c497decc5416159b04713533fa
|
data/lib/mixpal/integration.rb
CHANGED
data/lib/mixpal/util.rb
CHANGED
@@ -5,12 +5,22 @@ module Mixpal
|
|
5
5
|
hash.reject! { |_, v| v.nil? }
|
6
6
|
|
7
7
|
contents = hash.map do |k, v|
|
8
|
-
|
9
|
-
"\"#{k}\": #{js_value}"
|
8
|
+
"\"#{k}\": #{escape_js_object_value(v)}"
|
10
9
|
end.join(',').html_safe
|
11
10
|
|
12
11
|
"{#{contents}}"
|
13
12
|
end
|
13
|
+
|
14
|
+
def escape_js_object_value(value)
|
15
|
+
case value
|
16
|
+
when String
|
17
|
+
value.dump
|
18
|
+
when Time
|
19
|
+
"\"#{value}\""
|
20
|
+
else
|
21
|
+
value
|
22
|
+
end
|
23
|
+
end
|
14
24
|
end
|
15
25
|
end
|
16
26
|
end
|
data/lib/mixpal/version.rb
CHANGED
@@ -24,5 +24,10 @@ describe Mixpal::Util do
|
|
24
24
|
expect(subject.hash_to_js_object_string(age: 21, gender: nil))
|
25
25
|
.to eq '{"age": 21}'
|
26
26
|
end
|
27
|
+
|
28
|
+
it 'escapes double quotes in values' do
|
29
|
+
expect(subject.hash_to_js_object_string(key: 'value "with" quotes'))
|
30
|
+
.to eq '{"key": "value \"with\" quotes"}'
|
31
|
+
end
|
27
32
|
end
|
28
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixpal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- patbenatar
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-11-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|