templater 0.4.2 → 0.4.3

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/lib/templater.rb CHANGED
@@ -44,6 +44,6 @@ module Templater
44
44
  class MalformattedArgumentError < ArgumentError #:nodoc:
45
45
  end
46
46
 
47
- VERSION = '0.4.2'
47
+ VERSION = '0.4.3'
48
48
 
49
49
  end
@@ -49,7 +49,7 @@ module Templater
49
49
  when :hash
50
50
  if argument.is_a?(String)
51
51
  return argument.split(',').inject({}) do |h, pair|
52
- key, value = pair.split(':')
52
+ key, value = pair.strip.split(':')
53
53
  raise Templater::MalformattedArgumentError, "Expected '#{argument.inspect}' to be a key/value pair" unless key and value
54
54
  h[key] = value
55
55
  h
@@ -204,6 +204,14 @@ describe Templater::Generator, '.argument as hash' do
204
204
  instance.llama['river'].should == 'road'
205
205
  end
206
206
 
207
+ it "should strip key/value pairs" do
208
+ instance = @generator_class.new('/tmp', {}, 'a monkey', 'test:unit, john:silver, river:road, silver:bullet')
209
+ instance.llama['test'].should == 'unit'
210
+ instance.llama['john'].should == 'silver'
211
+ instance.llama['river'].should == 'road'
212
+ instance.llama['silver'].should == 'bullet'
213
+ end
214
+
207
215
  it "should raise an error if one of the remaining arguments is not a key/value pair" do
208
216
  lambda { @generator_class.new('/tmp', {}, 'a monkey', 'a:llama,duck:llama,not_a_pair,pair:blah') }.should raise_error(Templater::MalformattedArgumentError)
209
217
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: templater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Nicklas