dot-properties 0.1.0 → 0.1.1
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.
- data/README.md +2 -1
- data/lib/dot_properties.rb +1 -1
- data/lib/dot_properties/version.rb +1 -1
- data/spec/dot_properties_spec.rb +7 -4
- data/spec/fixtures/sample.properties +6 -0
- metadata +3 -8
data/README.md
CHANGED
@@ -28,7 +28,7 @@ Or install it yourself as:
|
|
28
28
|
require 'dot_properties'
|
29
29
|
|
30
30
|
# Load a .properties file
|
31
|
-
props = DotProperties.
|
31
|
+
props = DotProperties.load('sample.properties')
|
32
32
|
|
33
33
|
# Get a value
|
34
34
|
props['foo']
|
@@ -58,6 +58,7 @@ See the spec tests and fixture data for more examples.
|
|
58
58
|
|
59
59
|
## History
|
60
60
|
|
61
|
+
- <b>0.1.1</b> - Fix mishandled keys with leading whitespace (#1)
|
61
62
|
- <b>0.1.0</b> - Initial release
|
62
63
|
|
63
64
|
## Copyright
|
data/lib/dot_properties.rb
CHANGED
@@ -124,7 +124,7 @@ class DotProperties
|
|
124
124
|
elsif item =~ /^\s*$/
|
125
125
|
{ type: :blank, value: item }
|
126
126
|
else
|
127
|
-
key, delimiter, value = item.split /(\s*(?<!\\)[\s:=]\s*)/, 2
|
127
|
+
key, delimiter, value = item.strip.split /(\s*(?<!\\)[\s:=]\s*)/, 2
|
128
128
|
{ type: :value, key: unescape(key), delimiter: delimiter, value: value.to_s.gsub(/\\\n\s*/,'') }
|
129
129
|
end
|
130
130
|
end
|
data/spec/dot_properties_spec.rb
CHANGED
@@ -10,15 +10,15 @@ describe DotProperties do
|
|
10
10
|
let(:propfile) { File.expand_path('../fixtures/sample.properties', __FILE__) }
|
11
11
|
subject { DotProperties.load(propfile) }
|
12
12
|
|
13
|
-
let(:properties) {
|
14
|
-
let(:comments) {
|
15
|
-
let(:blanks) {
|
13
|
+
let(:properties) { 19 }
|
14
|
+
let(:comments) { 15 }
|
15
|
+
let(:blanks) { 10 }
|
16
16
|
|
17
17
|
it { should be_an_instance_of(DotProperties) }
|
18
18
|
|
19
19
|
describe "values" do
|
20
20
|
it "should have the right number of properties" do
|
21
|
-
expect(subject.keys.length).to eq(
|
21
|
+
expect(subject.keys.length).to eq(properties)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should have the right values" do
|
@@ -32,6 +32,9 @@ describe DotProperties do
|
|
32
32
|
expect(subject['foo bar:baz= quux']).to eq('this is getting ridiculous')
|
33
33
|
expect(subject['lots of fruit']).to eq('apple, peach, kiwi, mango, banana, strawberry, raspberry')
|
34
34
|
expect(subject['some.veggies']).to eq('carrot, potato, broccoli')
|
35
|
+
expect(subject['space.key1']).to eq('space.Value1')
|
36
|
+
expect(subject['space.key2']).to eq('space.Value2')
|
37
|
+
expect(subject['space.key3']).to eq('space.Multi word value')
|
35
38
|
expect(subject['foo.empty']).to be_empty
|
36
39
|
expect(subject['bar.empty']).to be_empty
|
37
40
|
expect(subject['baz.empty']).to be_empty
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dot-properties
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -123,18 +123,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
123
|
- - ! '>='
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
|
-
segments:
|
127
|
-
- 0
|
128
|
-
hash: -1306251061274732022
|
129
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
127
|
none: false
|
131
128
|
requirements:
|
132
129
|
- - ! '>='
|
133
130
|
- !ruby/object:Gem::Version
|
134
131
|
version: '0'
|
135
|
-
segments:
|
136
|
-
- 0
|
137
|
-
hash: -1306251061274732022
|
138
132
|
requirements: []
|
139
133
|
rubyforge_project:
|
140
134
|
rubygems_version: 1.8.23
|
@@ -145,3 +139,4 @@ summary: Read/write .properties files, respecting comments and existing formatti
|
|
145
139
|
test_files:
|
146
140
|
- spec/dot_properties_spec.rb
|
147
141
|
- spec/fixtures/sample.properties
|
142
|
+
has_rdoc:
|