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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd225b2c845a7d716dc847b8e5b722d12d969477b972bfe8317e768cf64995b0
4
- data.tar.gz: 35c294ad227d74d390240d1b50457e4fb4098de2c8a3aade4c7e8b83006c6360
3
+ metadata.gz: 5af913a6e35b72a5abb63b3e7d666663baef58504a2e418134acf45ee3313aa5
4
+ data.tar.gz: 42373d1e5aa1feeb38a2f7183397ec50c4bd42d07164b3a801054ded4f5e46e1
5
5
  SHA512:
6
- metadata.gz: e92043fffcae2711238c80894d982c37685a3adf9b6410a6c8cdacf7d4cc9c4db4b2883a3da01de8c741ac47819bca90c5dce766662cd626d2700a142a26b9f6
7
- data.tar.gz: e88c210c224526b2fe86afabdcfef4f7a19ed61414b27ae8677a445bb6b21c36efae4a23f4384705f8645775d188e9098390a4bbb765c007a6b138bb20ff5564
6
+ metadata.gz: 228e0c1281e44b543dad3dc262f47da663c0e40232165c8dd4d8b4beb2ea0c0138fd20feb27dc91402f98270cc7806fb98e1347986f23721486df44cfd7e190f
7
+ data.tar.gz: b39738f9a5e20e1643c957ba027a7143a4ede36a235ff080dc669d076c11aa4535230fd2c771fdd3d528e8b7dadf81cd5a537bc53cd71afd3da0eee18979e342
data/.bundle/config ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_PATH: "vendor/bundle"
data/.gitignore CHANGED
@@ -2,4 +2,5 @@
2
2
  .ruby-gemset
3
3
  Gemfile.lock
4
4
  coverage
5
- pkg
5
+ pkg
6
+ vendor/
@@ -46,13 +46,17 @@ module EscapeJavaProperties
46
46
  end
47
47
 
48
48
  def self.hex(codepoint)
49
- hex = codepoint.to_s(16)
50
- size = hex.size
51
- # padding the hex value for uneven digest
52
- if (size % 2) == 1
53
- "0#{hex}"
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
- hex
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
 
@@ -1,3 +1,3 @@
1
1
  module EscapeJavaProperties
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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
- parse(File.read(path).encode(encoding, 'binary', allow_invalid_byte_sequence ? {invalid: :replace, undef: :replace} : {} ))
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 \line 2 \\line 3 line 4
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 'proper_properties'
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.3
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: 2020-01-28 00:00:00.000000000 Z
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: 3.0.3
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: