diff --git a/lib/spritely/options.rb b/lib/spritely/options.rb index e7e8ec4..5999f1d 100644 --- a/lib/spritely/options.rb +++ b/lib/spritely/options.rb @@ -23,8 +23,10 @@ def [](key) def options @options ||= stripped_hash.except(*GLOBAL_OPTIONS).inject({}) do |h, (key, value)| split_key = key.to_s.split('_') - option = global_options.merge(split_key.pop.to_sym => value) - h.deep_merge!(split_key.join('-') => option) + option = {split_key.pop.to_sym => value} + image = split_key.join('-') + h[image] ||= global_options.dup + h.deep_merge!(image => option) end end diff --git a/spec/spritely/options_spec.rb b/spec/spritely/options_spec.rb index 8fefd1b..e1b025f 100644 --- a/spec/spritely/options_spec.rb +++ b/spec/spritely/options_spec.rb @@ -2,18 +2,18 @@ describe Spritely::Options do let(:hash) { { + 'some_new_image_spacing' => Sass::Script::Number.new(789), 'some_new_image_x' => Sass::Script::Number.new(123), 'some_new_image_y' => Sass::Script::Number.new(456), - 'some_new_image_spacing' => Sass::Script::Number.new(789), 'another_image_repeat' => Sass::Script::Bool.new(true), 'yet_another_image_repeat' => Sass::Script::Bool.new(false), - 'spacing' => Sass::Script::Number.new(901) + 'spacing' => Sass::Script::Number.new(901), } } subject(:options) { Spritely::Options.new(hash) } its(:inspect) { should eq("# {spacing: 789, x: 123, y: 456}, 'another-image' => {spacing: 901, repeat: true}, 'yet-another-image' => {spacing: 901, repeat: false}}}>") } - its(:cache_key) { should eq({some_new_image_x: 123, some_new_image_y: 456, some_new_image_spacing: 789, another_image_repeat: true, yet_another_image_repeat: false, spacing: 901}.to_s) } + its(:cache_key) { should eq({some_new_image_spacing: 789, some_new_image_x: 123, some_new_image_y: 456, another_image_repeat: true, yet_another_image_repeat: false, spacing: 901}.to_s) } its(['some-new-image']) { should eq({spacing: 789, x: 123, y: 456}) } its(['another-image']) { should eq({spacing: 901, repeat: true}) }