ruby-properties-file 0.0.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 19eeaa7bc5d7261ae5df49f7a40e7391333bde0e
4
+ data.tar.gz: 3f0552aebef1fbd745bd4c41d5b4615abec4caf0
5
+ SHA512:
6
+ metadata.gz: 2480fec357b58d648117d547a51f443a5ae7145604da6ad02d1c7b5491204cc051f18c6fc01beed1db0d0c38d6c749b56bddda2ac1154e9432d4712fe8a1c370
7
+ data.tar.gz: 1176ce2e219c2c8fbc14282738fb4a10d85e9ce4cf0a865dcbc1088eb5f2a5ea08aab1d25cb7ce610c0bdcbb59380d478e6c650a5b648d2dbe58a5a31b8d9e55
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Jonas Thiel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,110 @@
1
+ # JavaProperties
2
+
3
+ [![Build Status](http://img.shields.io/travis/jnbt/java-properties.png)](https://travis-ci.org/jnbt/jnbt/java-properties)
4
+ [![Code Climate](http://img.shields.io/codeclimate/github/jnbt/java-properties.png)](https://codeclimate.com/github/jnbt/java-properties)
5
+ [![Coveralls](http://img.shields.io/coveralls/jnbt/java-properties.png)](https://coveralls.io/r/jnbt/java-properties)
6
+ [![RubyGems](http://img.shields.io/gem/v/java-properties.png)](http://rubygems.org/gems/java-properties)
7
+ [![Gemnasium](http://img.shields.io/gemnasium/jnbt/java-properties.png)](https://gemnasium.com/jnbt/java-properties)
8
+ [![Inline docs](http://inch-ci.org/github/jnbt/java-properties.png)](http://inch-ci.org/github/jnbt/java-properties)
9
+
10
+ A ruby library to read and write [Java properties files](http://en.wikipedia.org/wiki/.properties).
11
+
12
+ ## Installation
13
+
14
+ Install via Rubygems
15
+
16
+ ```bash
17
+ $ gem install java-properties
18
+ ```
19
+
20
+ ... or add to your Gemfile
21
+
22
+ ```ruby
23
+ gem "java-properties"
24
+ ```
25
+
26
+ ## Loading files
27
+
28
+ You can load a valid Java properties file from the file system using a path:
29
+
30
+ ```ruby
31
+ properties = JavaProperties.load("path/to/my.properties")
32
+ properties[:foo] # => "bar"
33
+ ```
34
+
35
+ If have already the content of the properties file at hand than parse the content as:
36
+
37
+ ```ruby
38
+ properties = JavaProperties.load("foo=bar")
39
+ properties[:foo] # => "bar"
40
+ ```
41
+
42
+ ## Writing files
43
+
44
+ You can write any Hash-like structure as a properties file:
45
+
46
+ ```ruby
47
+ hash = {:foo => "bar"}
48
+ JavaProperties.write(hash, "path/to/my.properties")
49
+ ```
50
+
51
+ Or if you want to omit the file you can receive the content directly:
52
+
53
+ ```ruby
54
+ hash = {:foo => "bar"}
55
+ JavaProperties.generate(hash) # => "foo=bar"
56
+ ```
57
+
58
+ ## Encodings and special chars
59
+
60
+ As Java properties files normally hold UTF-8 chars in their escaped representation this tool tries to convert them:
61
+
62
+ ```
63
+ "ה" <=> "\u05d4"
64
+ ```
65
+
66
+ The tool also escaped every '=', ' ' and ':' in the name part of a property line:
67
+
68
+ ```ruby
69
+ JavaProperties.generate({"i : like=strange" => "bar"})
70
+ # => "i\ \:\ like\=strange=bar"
71
+ ```
72
+
73
+ ## Multi line and line breaks
74
+
75
+ In Java properties files a string can be multi line but line breaks have to be escaped.
76
+
77
+ Assume the following input:
78
+
79
+ ```ini
80
+ my=This is a multi \
81
+ line content with only \n one line break
82
+ ```
83
+
84
+ The parses would read:
85
+
86
+ ```ruby
87
+ {:my => "This is a multi line content which only \n one line break"}
88
+ ```
89
+
90
+ In the opposite direction line breaks will be correctly escaped but the generator will never use multi line values.
91
+
92
+ ## Contributing
93
+
94
+ 1. [Fork it!](https://github.com/jnbt/java-properties/fork)
95
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
96
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
97
+ 4. Push to the branch (`git push origin my-new-feature`)
98
+ 5. Create new Pull Request
99
+
100
+ ## Author
101
+
102
+ Jonas Thiel (@jonasthiel)
103
+
104
+ ## References
105
+
106
+ For more information about the properties file format have a look at the [Java Plattform documenation](http://docs.oracle.com/javase/6/docs/api/java/util/Properties.html).
107
+
108
+ ## License
109
+
110
+ This gem is released under the MIT License. See the LICENSE file for further details.
@@ -0,0 +1,12 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rake/testtask'
4
+
5
+ desc 'Run tests'
6
+ task :default => :spec
7
+
8
+ Rake::TestTask.new(:spec) do |test|
9
+ test.test_files = FileList['spec/**/*_spec.rb']
10
+ test.libs << 'spec'
11
+ test.verbose = true
12
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ # coding: utf-8
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'java-properties/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "ruby-properties-file"
9
+ spec.version = JavaProperties::VERSION.dup
10
+ spec.authors = ["Jonas Thiel", "Joe Mifsud"]
11
+ spec.email = ["jonas@thiel.io"]
12
+ spec.summary = %q{Loader and writer for *.properties files}
13
+ spec.description = %q{Tool for loading and writing Java properties files}
14
+ spec.homepage = "https://github.com/jnbt/java-properties"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = %w(LICENSE README.md Rakefile java-properties.gemspec)
18
+ spec.files += Dir.glob("lib/**/*.rb")
19
+ spec.test_files = Dir.glob("spec/**/*.rb")
20
+ spec.test_files = Dir.glob("spec/fixtures/**/*.properties")
21
+
22
+ spec.required_rubygems_version = '>= 1.3.5'
23
+ end
@@ -0,0 +1,45 @@
1
+ require 'stringio'
2
+ require 'java-properties/version'
3
+ require 'java-properties/properties'
4
+ require 'java-properties/encoding'
5
+ require 'java-properties/parsing'
6
+ require 'java-properties/generating'
7
+
8
+ # A module to read and write Java properties files
9
+ module JavaProperties
10
+
11
+ # Parses the content of a Java properties file
12
+ # @see Parsing::Parser
13
+ # @param text [String]
14
+ # @return [Properties]
15
+ def self.parse(text)
16
+ Parsing::Parser.parse(text)
17
+ end
18
+
19
+ # Generates the content of a Java properties file
20
+ # @see Generating::Generator
21
+ # @param hash [Hash]
22
+ # @param options [Hash] options for the generator
23
+ # @return [String]
24
+ def self.generate(hash, options = {})
25
+ Generating::Generator.generate(hash, options)
26
+ end
27
+
28
+ # Loads and parses a Java properties file
29
+ # @see Parsing::Parser
30
+ # @param path [String]
31
+ # @return [Properties]
32
+ def self.load(path)
33
+ parse(File.read(path))
34
+ end
35
+
36
+ # Generates a Java properties file
37
+ # @see Generating::Generator
38
+ # @param hash [Hash]
39
+ # @param path [String]
40
+ # @param options [Hash] options for the generator
41
+ def self.write(hash, path, options = {})
42
+ File.write(path, generate(hash, options))
43
+ end
44
+
45
+ end
@@ -0,0 +1,56 @@
1
+ require 'java-properties/encoding/special_chars'
2
+ require 'java-properties/encoding/separators'
3
+ require 'java-properties/encoding/unicode'
4
+
5
+ module JavaProperties
6
+ # Module to encode and decode
7
+ #
8
+ # Usage:
9
+ # encoded = Encoding.encode!("Some text to be encoded")
10
+ # decoded = Encoding.decode!("Some text to be decoded")
11
+ #
12
+ # You can disable separate encoding (and decoding) steps,
13
+ # by passing in additional flags:
14
+ #
15
+ # * SKIP_SEPARATORS: Do not code the separators (space,:,=)
16
+ # * SKIP_UNICODE: Do not code unicode chars
17
+ # * SKIP_SPECIAL_CHARS: Do not code newlines, tab stops, ...
18
+ #
19
+ module Encoding
20
+
21
+ # Flag for skipping separators encodings / decoding
22
+ # @return [Symbol]
23
+ SKIP_SEPARATORS=:skip_separators
24
+
25
+ # Flag for skipping separators encodings / decoding
26
+ # @return [Symbol]
27
+ SKIP_UNICODE=:skip_unicode
28
+
29
+ # Flag for skipping separators encodings / decoding
30
+ # @return [Symbol]
31
+ SKIP_SPECIAL_CHARS=:skip_special_chars
32
+
33
+ # Encode a given text in place
34
+ # @param text [String]
35
+ # @param *flags [Array] Optional flags to skip encoding steps
36
+ # @return [String] The encoded text for chaining
37
+ def self.encode!(text, *flags)
38
+ SpecialChars.encode!(text) unless flags.include?(SKIP_SPECIAL_CHARS)
39
+ Separators.encode!(text) unless flags.include?(SKIP_SEPARATORS)
40
+ Unicode.encode!(text) unless flags.include?(SKIP_UNICODE)
41
+ text
42
+ end
43
+
44
+ # Decodes a given text in place
45
+ # @param text [String]
46
+ # @param *flags [Array] Optional flags to skip decoding steps
47
+ # @return [String] The decoded text for chaining
48
+ def self.decode!(text, *flags)
49
+ Unicode.decode!(text) unless flags.include?(SKIP_UNICODE)
50
+ Separators.decode!(text) unless flags.include?(SKIP_SEPARATORS)
51
+ SpecialChars.decode!(text) unless flags.include?(SKIP_SPECIAL_CHARS)
52
+ text
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,52 @@
1
+ module JavaProperties
2
+ module Encoding
3
+ # Module to escape separators as : or =
4
+ # @see JavaProperties::Encoding
5
+ module Separators
6
+
7
+ # Marker for all separators
8
+ # @return [Regexp]
9
+ ENCODE_SEPARATOR_MARKER = /[ :=]/
10
+
11
+ # Marker for already escaped separators
12
+ # @return [Regexp]
13
+ ESCAPING_MARKER = /\\/
14
+
15
+ # Char to use for escaping
16
+ # @return [String]
17
+ ESCAPE = "\\"
18
+
19
+ # Marker for all escaped separators
20
+ # @return [Regexp]
21
+ DECODE_SEPARATOR_MARKER = /\\([ :=])/
22
+
23
+ # Escapes all not already escaped separators
24
+ # @param text [text]
25
+ # @return [String] The escaped text for chaining
26
+ def self.encode!(text)
27
+ buffer = StringIO.new
28
+ last_token = ''
29
+ text.each_char do |char|
30
+ if char =~ ENCODE_SEPARATOR_MARKER && last_token !~ ESCAPING_MARKER
31
+ buffer << ESCAPE
32
+ end
33
+ buffer << char
34
+ last_token = char
35
+ end
36
+ text.replace buffer.string
37
+ text
38
+ end
39
+
40
+ # Removes escapes from escaped separators
41
+ # @param text [text]
42
+ # @return [String] The unescaped text for chaining
43
+ def self.decode!(text)
44
+ text.gsub!(DECODE_SEPARATOR_MARKER) do
45
+ $1
46
+ end
47
+ text
48
+ end
49
+
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,48 @@
1
+ module JavaProperties
2
+ module Encoding
3
+ # Module to escape and unescape special chars
4
+ # @see JavaProperties::Encoding
5
+ module SpecialChars
6
+
7
+ # Lookup table for escaping special chars
8
+ # @return [Hash]
9
+ ESCAPING = {
10
+ "\t" => '\\t',
11
+ "\r" => '\\r',
12
+ "\n" => '\\n',
13
+ "\f" => '\\f'
14
+ }.freeze
15
+
16
+ # Lookup table to remove escaping from special chars
17
+ # @return [Hash]
18
+ DESCAPING = ESCAPING.invert.freeze
19
+
20
+ # Marks a segment which has is an encoding special char
21
+ # @return [Regexp]
22
+ DESCAPING_MARKER = /\\./
23
+
24
+ # Encodes the content a text by escaping all special chars
25
+ # @param text [String]
26
+ # @return [String] The escaped text for chaining
27
+ def self.encode!(text)
28
+ buffer = StringIO.new
29
+ text.each_char do |char|
30
+ buffer << ESCAPING.fetch(char, char)
31
+ end
32
+ text.replace buffer.string
33
+ text
34
+ end
35
+
36
+ # Decodes the content a text by removing all escaping from special chars
37
+ # @param text [String]
38
+ # @return [String] The unescaped text for chaining
39
+ def self.decode!(text)
40
+ text.gsub!(DESCAPING_MARKER) do |match|
41
+ DESCAPING.fetch(match, match)
42
+ end
43
+ text
44
+ end
45
+
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,61 @@
1
+ module JavaProperties
2
+ module Encoding
3
+ # Module to encode and decode unicode chars
4
+ # @see JavaProperties::Encoding
5
+ module Unicode
6
+
7
+ # Marker for encoded unicode chars
8
+ # @return [Regexp]
9
+ UNICODE_MARKER = /\\[uU]([0-9a-fA-F]{4,5}|10[0-9a-fA-F]{4})/
10
+
11
+ # Escape char for unicode chars
12
+ # @return [String]
13
+ UNICODE_ESCAPE = "\\u"
14
+
15
+ # Decodes all unicode chars from escape sequences in place
16
+ # @param text [String]
17
+ # @return [String] The encoded text for chaining
18
+ def self.decode!(text)
19
+ text.gsub!(UNICODE_MARKER) do
20
+ unicode($1.hex)
21
+ end
22
+ text
23
+ end
24
+
25
+ # Decodes all unicode chars into escape sequences in place
26
+ # @param text [String]
27
+ # @return [String] The decoded text for chaining
28
+ def self.encode!(text)
29
+ buffer = StringIO.new
30
+ text.each_char do |char|
31
+ if char.ascii_only?
32
+ buffer << char
33
+ else
34
+ buffer << UNICODE_ESCAPE
35
+ buffer << hex(char.codepoints.first)
36
+ end
37
+ end
38
+ text.replace buffer.string
39
+ text
40
+ end
41
+
42
+ private
43
+
44
+ def self.unicode(code)
45
+ [code].pack("U")
46
+ end
47
+
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}"
54
+ else
55
+ hex
56
+ end
57
+ end
58
+
59
+ end
60
+ end
61
+ end
@@ -0,0 +1 @@
1
+ require 'java-properties/generating/generator'
@@ -0,0 +1,62 @@
1
+ module JavaProperties
2
+ module Generating
3
+ # This module allows generating the content of a properties file
4
+ # base on a {Properties} object (or any other hash like structure)
5
+ #
6
+ # @example
7
+ # Generator.generate({:item => "something ה"}) => "item=something \u05d4"
8
+ #
9
+ module Generator
10
+ # Character used for key-value separation
11
+ # @return [String]
12
+ KEY_VALUE_SEPARATOR = '='
13
+
14
+ # Default options
15
+ # @return [Hash]
16
+ DEFAULT_OPTIONS = {
17
+ :skip_encode_unicode => false,
18
+ :skip_encode_separators => false,
19
+ :skip_encode_special_chars => false
20
+ }.freeze
21
+
22
+ # Generates a properties file content based on a hash
23
+ # @param properties [Properties] or simple hash
24
+ # @param options [Hash]
25
+ # @option options skip_encode_unicode [Boolean] Skip unicode encoding
26
+ # @option options skip_encode_separators [Boolean] Skip seperators encoding
27
+ # @option options skip_encode_special_chars [Boolean] Skip special char encoding
28
+ # @return [String]
29
+ def self.generate(properties, options = {})
30
+ options = DEFAULT_OPTIONS.merge(options)
31
+ lines = []
32
+ properties.each do |k, v|
33
+ build_group(k, v, lines, options)
34
+ end
35
+ lines.join("\n")
36
+ end
37
+
38
+ private
39
+
40
+ def self.build_group(key, current_nest, lines, options)
41
+ if current_nest.class == Hash
42
+ current_nest.each do |k, v|
43
+ build_group(key + "." + k, v, lines, options)
44
+ end
45
+ else
46
+ encoded_key = Encoding.encode!(key.to_s.dup, *encoding_skips(false, options))
47
+ encoded_value = Encoding.encode!(current_nest.to_s.dup, *encoding_skips(true, options))
48
+
49
+ lines << encoded_key + KEY_VALUE_SEPARATOR + encoded_value
50
+ end
51
+ end
52
+
53
+ def self.encoding_skips(is_value, options)
54
+ skips = []
55
+ skips << Encoding::SKIP_SEPARATORS if is_value || options[:skip_encode_separators]
56
+ skips << Encoding::SKIP_UNICODE if options[:skip_encode_unicode]
57
+ skips << Encoding::SKIP_SPECIAL_CHARS if options[:skip_encode_special_chars]
58
+ skips
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,2 @@
1
+ require 'java-properties/parsing/normalizer'
2
+ require 'java-properties/parsing/parser'
@@ -0,0 +1,74 @@
1
+ module JavaProperties
2
+ module Parsing
3
+ # Module to normalize the content of a properties file
4
+ #
5
+ # @example Normalizes:
6
+ # # Comment 1
7
+ # ! Comment 2
8
+ # item0
9
+ # item1 = item1
10
+ # item2 : item2
11
+ # item3=line 1 \
12
+ # line 2
13
+ #
14
+ # @example Into:
15
+ #
16
+ # item0
17
+ # item1=item1
18
+ # item2=item2
19
+ # item3=line 1 line 2
20
+ #
21
+ module Normalizer
22
+
23
+ # Describes a single normalization rule by replacing content
24
+ class Rule
25
+ # Initializes a new rules base on a matching regexp
26
+ # and a replacement as substitution
27
+ # @param matcher [Regexp]
28
+ # @param replacement [String]
29
+ def initialize(matcher, replacement = '')
30
+ @matcher = matcher
31
+ @replacement = replacement
32
+ end
33
+
34
+ # Apply the substitution to the text in place
35
+ # @param text [string]
36
+ # @return [String]
37
+ def apply!(text)
38
+ text.gsub!(@matcher, @replacement)
39
+ end
40
+ end
41
+
42
+ # Collection of ordered rules
43
+ RULES = []
44
+
45
+ # Removes comments
46
+ RULES << Rule.new(/^\s*[!\#].*$/)
47
+
48
+ # Removes leading whitepsace
49
+ RULES << Rule.new(/^\s+/)
50
+
51
+ # Removes tailing whitepsace
52
+ RULES << Rule.new(/\s+$/)
53
+
54
+ # Strings ending with \ are concatenated
55
+ RULES << Rule.new(/\\\s*$[\n\r]+/)
56
+
57
+ # Remove whitespace around delimiters and replace with =
58
+ RULES << Rule.new(/^((?:(?:\\[=: \t])|[^=: \t])+)[ \t]*[=: \t][ \t]*/, '\1=')
59
+
60
+ RULES.freeze
61
+
62
+ # Normalizes the content of a properties file content by applying the RULES
63
+ # @param text [String]
64
+ # @return [String]
65
+ def self.normalize!(text)
66
+ RULES.each do |rule|
67
+ rule.apply!(text)
68
+ end
69
+ text
70
+ end
71
+
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,75 @@
1
+ # coding: utf-8
2
+ module JavaProperties
3
+ module Parsing
4
+ # This module allows parsing of a properties file content string
5
+ # into a {Properties} object
6
+ #
7
+ # @example
8
+ # Parser.parse("item=something \u05d4") => {:item => "something ה"}
9
+ #
10
+ module Parser
11
+
12
+ # Symbol which separates key from value after normalization
13
+ # @return [String]
14
+ KEY_VALUE_MARKER = '='
15
+
16
+ # Symbol which escapes a KEY_VALUE_MARKER in the key name
17
+ # @return [String]
18
+ KEY_ESCAPE = '\\'
19
+
20
+ # Marker for a line which only consists of an key w/o value
21
+ # @return [Regexp]
22
+ KEY_ONLY_MARKER = /^(\S+)$/
23
+
24
+ # Parses a string into a {Properties} object
25
+ # @param text [String]
26
+ # @return [Properties]
27
+ def self.parse(text)
28
+ properties = Properties.new
29
+ Normalizer.normalize!(text)
30
+ text.each_line do |line|
31
+ key, value = extract_key_and_value(line.chomp)
32
+ append_to_properties(properties, key, value)
33
+ end
34
+ properties
35
+ end
36
+
37
+ private
38
+
39
+ def self.extract_key_and_value(line)
40
+ # A line must be handled char by char to handled escaped '=' chars in the key name
41
+ key = StringIO.new
42
+ value = StringIO.new
43
+ key_complete = false
44
+ last_token = ''
45
+ line.each_char do |char|
46
+ if !key_complete && char == KEY_VALUE_MARKER && last_token != KEY_ESCAPE
47
+ key_complete = true
48
+ else
49
+ (key_complete ? value : key) << char
50
+ end
51
+ last_token = char
52
+ end
53
+ [key.string, value.string]
54
+ end
55
+
56
+ def self.append_to_properties(properties, key, value)
57
+ return if key.nil? || value.nil?
58
+
59
+ keys = key.split(".").map { |k| Encoding.decode!(k) }
60
+ current_nest = properties
61
+ while k = keys.shift
62
+ if keys.size == 0
63
+ current_nest[k] = Encoding.decode!(value, Encoding::SKIP_SEPARATORS)
64
+ else
65
+ if !current_nest.has_key? k
66
+ current_nest[k] = {}
67
+ end
68
+ end
69
+
70
+ current_nest = current_nest[k]
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,6 @@
1
+ module JavaProperties
2
+ # Simple representation of a properties file content
3
+ # by a simple ruby hash object
4
+ class Properties < Hash
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module JavaProperties
2
+
3
+ # Current version
4
+ # @return [String]
5
+ VERSION = "0.0.2".freeze
6
+
7
+ end
@@ -0,0 +1,33 @@
1
+ # Comment 1
2
+ ! Comment 2
3
+ item0
4
+ item1 = item1
5
+ item2 : item2
6
+ item3 item3
7
+
8
+ #Comment 3
9
+ ! Comment 4
10
+
11
+ it\ em4=item4
12
+ it\=em5:item5
13
+ item6 item6
14
+
15
+ !Comment 4
16
+ # Comment 5
17
+
18
+ item7 = line 1 \
19
+ line 2 \
20
+ line 3
21
+
22
+ item8 : line 1 \
23
+ line 2 \
24
+ line 3
25
+
26
+ item9 line 1 \
27
+ line 2 \
28
+ line 3
29
+
30
+ item10=test\n\ttest\u0050 \
31
+ test\n\ttest \
32
+ test\n\ttest = test
33
+
@@ -0,0 +1,11 @@
1
+ item0
2
+ item1=item1
3
+ item2=item2
4
+ item3=item3
5
+ it\ em4=item4
6
+ it\=em5=item5
7
+ item6=item6
8
+ item7=line 1 line 2 line 3
9
+ item8=line 1 line 2 line 3
10
+ item9=line 1 line 2 line 3
11
+ item10=test\n\ttest\u0050 test\n\ttest test\n\ttest = test
@@ -0,0 +1,11 @@
1
+ item0=
2
+ item1=item1
3
+ item2=item2
4
+ item3=item3
5
+ it\ em4=item4
6
+ it\=em5=item5
7
+ it\:em6=item6
8
+ item7=line 1 line 2 line 3
9
+ item8=line 1 line 2 line 3
10
+ item9=line 1 line 2 line 3
11
+ item10=test\n\ttest\u05d4 test\n\ttest test\n\ttest = test
@@ -0,0 +1,11 @@
1
+ item0=
2
+ item1=item1
3
+ item2=item2
4
+ item3=item3
5
+ it em4=item4
6
+ it=em5=item5
7
+ it:em6=item6
8
+ item7=line 1 line 2 line 3
9
+ item8=line 1 line 2 line 3
10
+ item9=line 1 line 2 line 3
11
+ item10=test\n\ttest\u05d4 test\n\ttest test\n\ttest = test
@@ -0,0 +1,14 @@
1
+ item0=
2
+ item1=item1
3
+ item2=item2
4
+ item3=item3
5
+ it\ em4=item4
6
+ it\=em5=item5
7
+ it\:em6=item6
8
+ item7=line 1 line 2 line 3
9
+ item8=line 1 line 2 line 3
10
+ item9=line 1 line 2 line 3
11
+ item10=test
12
+ test\u05d4 test
13
+ test test
14
+ test = test
@@ -0,0 +1,11 @@
1
+ item0=
2
+ item1=item1
3
+ item2=item2
4
+ item3=item3
5
+ it\ em4=item4
6
+ it\=em5=item5
7
+ it\:em6=item6
8
+ item7=line 1 line 2 line 3
9
+ item8=line 1 line 2 line 3
10
+ item9=line 1 line 2 line 3
11
+ item10=test\n\ttestה test\n\ttest test\n\ttest = test
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-properties-file
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Jonas Thiel
8
+ - Joe Mifsud
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-10-16 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Tool for loading and writing Java properties files
15
+ email:
16
+ - jonas@thiel.io
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - LICENSE
22
+ - README.md
23
+ - Rakefile
24
+ - java-properties.gemspec
25
+ - lib/java-properties.rb
26
+ - lib/java-properties/encoding.rb
27
+ - lib/java-properties/encoding/separators.rb
28
+ - lib/java-properties/encoding/special_chars.rb
29
+ - lib/java-properties/encoding/unicode.rb
30
+ - lib/java-properties/generating.rb
31
+ - lib/java-properties/generating/generator.rb
32
+ - lib/java-properties/parsing.rb
33
+ - lib/java-properties/parsing/normalizer.rb
34
+ - lib/java-properties/parsing/parser.rb
35
+ - lib/java-properties/properties.rb
36
+ - lib/java-properties/version.rb
37
+ - spec/fixtures/test.properties
38
+ - spec/fixtures/test_normalized.properties
39
+ - spec/fixtures/test_out.properties
40
+ - spec/fixtures/test_out_skip_separators.properties
41
+ - spec/fixtures/test_out_skip_special_chars.properties
42
+ - spec/fixtures/test_out_skip_unicode.properties
43
+ homepage: https://github.com/jnbt/java-properties
44
+ licenses:
45
+ - MIT
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.3.5
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.2.2
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: Loader and writer for *.properties files
67
+ test_files:
68
+ - spec/fixtures/test.properties
69
+ - spec/fixtures/test_normalized.properties
70
+ - spec/fixtures/test_out.properties
71
+ - spec/fixtures/test_out_skip_separators.properties
72
+ - spec/fixtures/test_out_skip_special_chars.properties
73
+ - spec/fixtures/test_out_skip_unicode.properties
74
+ has_rdoc: