diff --git a/Rakefile b/Rakefile index 12a4fe0..9025edd 100644 --- a/Rakefile +++ b/Rakefile @@ -47,24 +47,26 @@ task :clean do Dir.glob("paperclip-*.gem").each{|f| FileUtils.rm f } end -include_file_globs = ["README*", - "LICENSE", - "Rakefile", - "init.rb", - "{generators,lib,tasks,test,shoulda_macros}/**/*"] -exclude_file_globs = ["test/s3.yml", - "test/debug.log", - "test/paperclip.db", - "test/doc", - "test/doc/*", - "test/pkg", - "test/pkg/*", - "test/tmp", - "test/tmp/*"] def spec # TODO: require 'paperclip/version' require 'paperclip' + + include_file_globs = ["README*", + "LICENSE", + "Rakefile", + "init.rb", + "{generators,lib,tasks,test,shoulda_macros}/**/*"] + exclude_file_globs = ["test/s3.yml", + "test/debug.log", + "test/paperclip.db", + "test/doc", + "test/doc/*", + "test/pkg", + "test/pkg/*", + "test/tmp", + "test/tmp/*"] + Gem::Specification.new do |s| s.name = "paperclip" s.version = Paperclip::VERSION diff --git a/lib/paperclip.rb b/lib/paperclip.rb index 22ee9c4..dc6a765 100644 --- a/lib/paperclip.rb +++ b/lib/paperclip.rb @@ -344,6 +344,6 @@ end # Set it all up. if Object.const_defined?("ActiveRecord") - ActiveRecord::Base.send(:include, Paperclip) - File.send(:include, Paperclip::Upfile) + ActiveRecord::Base.include(Paperclip) + File.include(Paperclip::Upfile) end diff --git a/lib/paperclip/storage/filesystem.rb b/lib/paperclip/storage/filesystem.rb index 17bd035..113f2a0 100644 --- a/lib/paperclip/storage/filesystem.rb +++ b/lib/paperclip/storage/filesystem.rb @@ -56,7 +56,7 @@ module Paperclip # ignore file-not-found, let everything else pass end begin - while(true) + loop do path = File.dirname(path) if Dir.entries(path).empty? FileUtils.rmdir(path) diff --git a/test/attachment_test.rb b/test/attachment_test.rb index db9d149..5db8815 100644 --- a/test/attachment_test.rb +++ b/test/attachment_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class Dummy +class Dummy # rubocop:disable Lint/EmptyClass # This is a dummy class end diff --git a/test/paperclip_test.rb b/test/paperclip_test.rb index 358cc6b..8a5241a 100644 --- a/test/paperclip_test.rb +++ b/test/paperclip_test.rb @@ -16,7 +16,7 @@ class PaperclipTest < Test::Unit::TestCase should "execute the right command" do Paperclip.expects(:path_for_command).with("convert").returns("/usr/bin/convert") Paperclip.expects(:bit_bucket).returns("/dev/null") - Paperclip.expects(:"`").with("timeout 30 /usr/bin/convert #{@file_path} #{@file_path2} 2>/dev/null") + Paperclip.expects(:`).with("timeout 30 /usr/bin/convert #{@file_path} #{@file_path2} 2>/dev/null") Paperclip.run("convert", "#{@file_path} #{@file_path2}") end end @@ -33,7 +33,7 @@ class PaperclipTest < Test::Unit::TestCase should "execute the right command" do Paperclip.expects(:path_for_command).with("convert").returns("convert") Paperclip.expects(:bit_bucket).returns("/dev/null") - Paperclip.expects(:"`").with("timeout 30 convert #{@file_path} #{@file_path2} 2>/dev/null") + Paperclip.expects(:`).with("timeout 30 convert #{@file_path} #{@file_path2} 2>/dev/null") Paperclip.run("convert", "#{@file_path} #{@file_path2}") end @@ -41,7 +41,7 @@ class PaperclipTest < Test::Unit::TestCase Paperclip.options[:log_command] = true Paperclip.expects(:bit_bucket).returns("/dev/null") Paperclip.expects(:log).with("convert #{@file_path} #{@file_path2} 2>/dev/null") - Paperclip.expects(:"`").with("timeout 30 convert #{@file_path} #{@file_path2} 2>/dev/null") + Paperclip.expects(:`).with("timeout 30 convert #{@file_path} #{@file_path2} 2>/dev/null") Paperclip.run("convert", "#{@file_path} #{@file_path2}") end end @@ -110,7 +110,7 @@ class PaperclipTest < Test::Unit::TestCase context "a validation with an if guard clause" do setup do - Dummy.send(:"validates_attachment_presence", :avatar, :if => lambda{|i| i.foo }) + Dummy.send(:validates_attachment_presence, :avatar, :if => lambda{|i| i.foo }) @dummy = Dummy.new end @@ -129,7 +129,7 @@ class PaperclipTest < Test::Unit::TestCase context "a validation with an unless guard clause" do setup do - Dummy.send(:"validates_attachment_presence", :avatar, :unless => lambda{|i| i.foo }) + Dummy.send(:validates_attachment_presence, :avatar, :unless => lambda{|i| i.foo }) @dummy = Dummy.new end diff --git a/test/plural_cache_test.rb b/test/plural_cache_test.rb index 6b67b48..b9207cb 100644 --- a/test/plural_cache_test.rb +++ b/test/plural_cache_test.rb @@ -1,7 +1,7 @@ require 'test_helper' class PluralCacheTest < Test::Unit::TestCase - class BigBox; end + class BigBox; end # rubocop:disable Lint/EmptyClass should 'cache pluralizations' do cache = Paperclip::Interpolations::PluralCache.new diff --git a/test/thumbnail_test.rb b/test/thumbnail_test.rb index 2feb7a3..cc558d5 100644 --- a/test/thumbnail_test.rb +++ b/test/thumbnail_test.rb @@ -65,7 +65,7 @@ class ThumbnailTest < Test::Unit::TestCase should "send the right command to convert when sent #make" do Paperclip::Thumbnail.any_instance.stubs(:gamma_correction_if_needed).returns("PNG\nPaletteAlpha") - Paperclip.expects(:"`").with do |arg| + Paperclip.expects(:`).with do |arg| arg.match? %r{convert\s+"#{File.expand_path(@thumb.file.path)}\[0\]"\s+-auto-orient\s+-resize\s+\"x50\"\s+-crop\s+\"100x50\+114\+0\"\s+\+repage\s+} end @thumb.make @@ -90,7 +90,7 @@ class ThumbnailTest < Test::Unit::TestCase should "send the right command to convert when sent #make" do Paperclip::Thumbnail.any_instance.stubs(:gamma_correction_if_needed).returns("PNG\nPaletteAlpha") - Paperclip.expects(:"`").with do |arg| + Paperclip.expects(:`).with do |arg| arg.match? %r{convert\s+"#{File.expand_path(@thumb.file.path)}\[0\]"\s+-auto-orient\s+-resize\s+"x50"\s+-crop\s+"100x50\+114\+0"\s+\+repage\s+-strip\s+-depth\s+8\s+} end @thumb.make