king_placeholder 1.0.0 → 1.0.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/Gemfile +0 -1
- data/lib/king_placeholder/parser.rb +2 -2
- data/lib/king_placeholder/version.rb +1 -1
- data/spec/king_placeholder_spec.rb +8 -0
- data/spec/spec_helper.rb +1 -0
- metadata +4 -4
data/Gemfile
CHANGED
@@ -94,8 +94,8 @@ module KingPlaceholder
|
|
94
94
|
else
|
95
95
|
obj.send @field
|
96
96
|
end
|
97
|
-
|
98
|
-
@result.gsub!(@placeholder, value.to_s)
|
97
|
+
value = '' if value.nil?
|
98
|
+
@result.gsub!(@placeholder, value.to_s)
|
99
99
|
end
|
100
100
|
|
101
101
|
# Namespaced notation, for related objects. E.g an invoice belonging to a
|
@@ -127,17 +127,25 @@ describe 'Placeholder substitution' do
|
|
127
127
|
it 'should parse multiple steps' do
|
128
128
|
@detail1.expand_placeholders('[master.side.field]').should == '123'
|
129
129
|
end
|
130
|
+
|
130
131
|
end
|
131
132
|
|
132
133
|
context 'with empty fields' do
|
134
|
+
|
133
135
|
it 'should expand valid but empty placeholder group with empty string' do
|
134
136
|
master = Master.new
|
135
137
|
master.details = []
|
136
138
|
master.expand_placeholders('[details][int_field][/details]').should == ''
|
137
139
|
end
|
140
|
+
|
138
141
|
it 'should expand single item group with empty string' do
|
139
142
|
@master.expand_placeholders('[details.10.int_field]').should == ''
|
140
143
|
end
|
144
|
+
|
145
|
+
it 'should parse related object field with empty string' do
|
146
|
+
@master.string_field = nil
|
147
|
+
@detail1.expand_placeholders('[master.string_field]').should == ''
|
148
|
+
end
|
141
149
|
end
|
142
150
|
|
143
151
|
context 'with collection' do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: king_placeholder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.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: 2012-07-
|
12
|
+
date: 2012-07-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: statemachine
|
@@ -173,7 +173,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
173
|
version: '0'
|
174
174
|
segments:
|
175
175
|
- 0
|
176
|
-
hash:
|
176
|
+
hash: -1913045486927404314
|
177
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
178
|
none: false
|
179
179
|
requirements:
|
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
182
|
version: '0'
|
183
183
|
segments:
|
184
184
|
- 0
|
185
|
-
hash:
|
185
|
+
hash: -1913045486927404314
|
186
186
|
requirements: []
|
187
187
|
rubyforge_project:
|
188
188
|
rubygems_version: 1.8.24
|