Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

appending image files is now the job of the sprite class, and not the…

… dir processor
  • Loading branch information...
commit af1d4fcd4d761b2254fe8ec6ef7c8d1de3ed6bb8 1 parent 0c15552
@aberant authored
View
6 lib/css-spriter/directory_processor.rb
@@ -24,8 +24,10 @@ def images
def write
return unless @tracker.has_changes?
- images.each {|f| @sprite.append(PNG::Image.image_data(f))}
+ images.each {|f| @sprite.append_file(f)}
+
@sprite.write(sprite_file)
+
File.open(css_file, 'w') do |f|
f.write(css)
end
@@ -64,7 +66,7 @@ def image_loc
def truncate_abs_path
return @dir unless @options[:source]
path_elements = @options[:source].split('/')
- path_elements.pop #we want to remove everything above the root
+ path_elements.pop #we want to remove everything above the root
to_truncate = path_elements.join("/")
@dir.gsub(to_truncate, "")
end
View
4 lib/css-spriter/sprite.rb
@@ -18,6 +18,10 @@ def append( image )
@max_height = @images.map{ |i| i.height }.max
end
+ def append_file( filename )
+ append( PNG::Image.image_data( filename ))
+ end
+
def locations
@images.inject(0) do |x, image|
@locations[image.name.to_sym] = { :x => -(x),
View
6 spec/lib/sprite_spec.rb
@@ -36,4 +36,10 @@
@sprite.max_height.should == max_height
end
+ it "accepts file names to append to the sprite" do
+ PNG::Image.should_receive(:image_data).with("dog.png").and_return(@image1)
+
+ @sprite.append_file( "dog.png" )
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.