Skip to content

Commit

Permalink
Add file and filename_changed? method
Browse files Browse the repository at this point in the history
  • Loading branch information
tmaier committed Dec 30, 2012
1 parent 3f414ed commit 6c78436
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/image_sorcery.rb
@@ -1,6 +1,8 @@
require 'gm_support'

class Sorcery
attr_reader :file

def initialize(file)
@file = file
end
Expand Down Expand Up @@ -79,11 +81,16 @@ def montage(sources, args={})
success = run(tokens)[1]
end

def filename_changed?
(@filename_changed)
end

private

def replace_file(format)
File.delete @file
@file = File.join File.dirname(@file), File.basename(@file, File.extname(@file)) + "." + format
@filename_changed = true
end

def convert_to_command(tokens)
Expand Down
10 changes: 10 additions & 0 deletions spec/image_sorcery_examples_spec.rb
Expand Up @@ -25,6 +25,10 @@
image.height.should == 120
end

its(:filename_changed?) { should be_false }

its(:file) { should eq "./spec/fixtures/dog-2.jpeg" }

describe "change of format" do
before :each do
image.manipulate!(:format => "png")
Expand All @@ -40,6 +44,10 @@
end

its(:identify) { should include "PNG 160x120" }

its(:filename_changed?) { should be_true }

its(:file) { should eq "./spec/fixtures/dog-2.png" }
end

describe "with multi page pdf" do
Expand All @@ -57,6 +65,8 @@
end

its(:identify) { should include "PNG 595x842" }

its(:filename_changed?) { should be_true }
end
end
end
Expand Down

0 comments on commit 6c78436

Please sign in to comment.