escape_java_properties 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.bundle/config +2 -0
- data/.gitignore +2 -1
- data/lib/escape_java_properties/encoding/unicode.rb +10 -6
- data/lib/escape_java_properties/parsing/normalizer.rb +0 -3
- data/lib/escape_java_properties/version.rb +1 -1
- data/lib/escape_java_properties.rb +8 -1
- data/spec/fixtures/test_normalized.properties +2 -2
- data/spec/helper.rb +30 -3
- metadata +4 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5af913a6e35b72a5abb63b3e7d666663baef58504a2e418134acf45ee3313aa5
|
|
4
|
+
data.tar.gz: 42373d1e5aa1feeb38a2f7183397ec50c4bd42d07164b3a801054ded4f5e46e1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 228e0c1281e44b543dad3dc262f47da663c0e40232165c8dd4d8b4beb2ea0c0138fd20feb27dc91402f98270cc7806fb98e1347986f23721486df44cfd7e190f
|
|
7
|
+
data.tar.gz: b39738f9a5e20e1643c957ba027a7143a4ede36a235ff080dc669d076c11aa4535230fd2c771fdd3d528e8b7dadf81cd5a537bc53cd71afd3da0eee18979e342
|
data/.bundle/config
ADDED
data/.gitignore
CHANGED
|
@@ -46,13 +46,17 @@ module EscapeJavaProperties
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def self.hex(codepoint)
|
|
49
|
-
hex
|
|
50
|
-
|
|
51
|
-
#
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
# For BMP codepoints produce a 4-digit hex (\uXXXX).
|
|
50
|
+
# For supplementary codepoints produce a surrogate pair
|
|
51
|
+
# encoded as "XXXX\\uYYYY" so callers that prepend
|
|
52
|
+
# the "\\u" marker produce "\\uXXXX\\uYYYY".
|
|
53
|
+
if codepoint <= 0xFFFF
|
|
54
|
+
format('%04x', codepoint)
|
|
54
55
|
else
|
|
55
|
-
|
|
56
|
+
cp = codepoint - 0x10000
|
|
57
|
+
high = 0xD800 + (cp >> 10)
|
|
58
|
+
low = 0xDC00 + (cp & 0x3FF)
|
|
59
|
+
"#{format('%04x', high)}\\u#{format('%04x', low)}"
|
|
56
60
|
end
|
|
57
61
|
end
|
|
58
62
|
|
|
@@ -54,9 +54,6 @@ module EscapeJavaProperties
|
|
|
54
54
|
# Removes empty lines
|
|
55
55
|
RULES << Rule.new(/^$(\r\n?|\n)/)
|
|
56
56
|
|
|
57
|
-
# Unescape double backslashes
|
|
58
|
-
RULES << Rule.new(/\\\\/, '\\')
|
|
59
|
-
|
|
60
57
|
# Remove whitespace around delimiters and replace with =
|
|
61
58
|
RULES << Rule.new(/^((?:(?:\\[=: \t])|[^=: \t])+)[ \t]*[=: \t][ \t]*/, '\1=')
|
|
62
59
|
|
|
@@ -31,7 +31,14 @@ module EscapeJavaProperties
|
|
|
31
31
|
# @param allow_invalid_byte_sequence [Boolean]
|
|
32
32
|
# @return [Properties]
|
|
33
33
|
def self.load(path, encoding = 'UTF-8', allow_invalid_byte_sequence = true)
|
|
34
|
-
|
|
34
|
+
# Read as binary and then transcode to the desired encoding. Ruby 4 changed
|
|
35
|
+
# String#encode signature; use `encode` with keyword options when available.
|
|
36
|
+
content = File.binread(path)
|
|
37
|
+
if allow_invalid_byte_sequence
|
|
38
|
+
parse(content.encode(encoding, invalid: :replace, undef: :replace))
|
|
39
|
+
else
|
|
40
|
+
parse(content.encode(encoding))
|
|
41
|
+
end
|
|
35
42
|
end
|
|
36
43
|
|
|
37
44
|
# Generates a escape java properties file
|
|
@@ -9,6 +9,6 @@ item7=line 1 line 2 line 3
|
|
|
9
9
|
item8=line 1 #Not a Comment line 2 line 3
|
|
10
10
|
item9=line 1 line 2 line 3
|
|
11
11
|
item10=test\n\ttest\u0050 test\n\ttest test\n\ttest = test
|
|
12
|
-
item11=line 1
|
|
13
|
-
item12=line 1
|
|
12
|
+
item11=line 1 \\line 2 \\\\line 3 line 4
|
|
13
|
+
item12=line 1\\
|
|
14
14
|
item13=line 1
|
data/spec/helper.rb
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
require 'simplecov'
|
|
2
2
|
require 'coveralls'
|
|
3
3
|
|
|
4
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
|
|
5
5
|
Coveralls::SimpleCov::Formatter,
|
|
6
6
|
SimpleCov::Formatter::HTMLFormatter
|
|
7
|
-
]
|
|
7
|
+
])
|
|
8
8
|
SimpleCov.start
|
|
9
9
|
|
|
10
10
|
require 'minitest/autorun'
|
|
11
|
-
require '
|
|
11
|
+
require 'escape_java_properties'
|
|
12
12
|
|
|
13
13
|
class Minitest::Spec
|
|
14
14
|
|
|
@@ -17,3 +17,30 @@ class Minitest::Spec
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
end
|
|
20
|
+
|
|
21
|
+
# Provide simple expectation methods for older spec-style tests when running
|
|
22
|
+
# under newer Minitest/Ruby combinations.
|
|
23
|
+
TEST_ASSERTIONS = Object.new
|
|
24
|
+
TEST_ASSERTIONS.extend(Minitest::Assertions)
|
|
25
|
+
def TEST_ASSERTIONS.assertions
|
|
26
|
+
@assertions ||= 0
|
|
27
|
+
end
|
|
28
|
+
def TEST_ASSERTIONS.assertions=(n)
|
|
29
|
+
@assertions = n
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class Object
|
|
33
|
+
def must_equal(expected)
|
|
34
|
+
TEST_ASSERTIONS.assert_equal expected, self
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def wont_be_nil
|
|
38
|
+
TEST_ASSERTIONS.refute_nil self
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
class Proc
|
|
43
|
+
def must_raise(*klasses)
|
|
44
|
+
TEST_ASSERTIONS.assert_raises(*klasses) { call }
|
|
45
|
+
end
|
|
46
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: escape_java_properties
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- trace-devops
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rake
|
|
@@ -74,6 +73,7 @@ executables: []
|
|
|
74
73
|
extensions: []
|
|
75
74
|
extra_rdoc_files: []
|
|
76
75
|
files:
|
|
76
|
+
- ".bundle/config"
|
|
77
77
|
- ".gitignore"
|
|
78
78
|
- ".travis.yml"
|
|
79
79
|
- Gemfile
|
|
@@ -113,7 +113,6 @@ homepage: https://github.com/trace-devops/escape_java_properties
|
|
|
113
113
|
licenses:
|
|
114
114
|
- MIT
|
|
115
115
|
metadata: {}
|
|
116
|
-
post_install_message:
|
|
117
116
|
rdoc_options: []
|
|
118
117
|
require_paths:
|
|
119
118
|
- lib
|
|
@@ -128,8 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
128
127
|
- !ruby/object:Gem::Version
|
|
129
128
|
version: '0'
|
|
130
129
|
requirements: []
|
|
131
|
-
rubygems_version:
|
|
132
|
-
signing_key:
|
|
130
|
+
rubygems_version: 4.0.10
|
|
133
131
|
specification_version: 4
|
|
134
132
|
summary: Loader and writer for Java properties files
|
|
135
133
|
test_files:
|