Commit c6ccb54d by Jon Yurek

Rearranged stuff and added a gem build/deploy process. Official release of 2.1.0.

parent c44048d0
*.swp *.swp
tmp tmp
s3.yml
...@@ -3,6 +3,9 @@ require 'rake/testtask' ...@@ -3,6 +3,9 @@ require 'rake/testtask'
require 'rake/rdoctask' require 'rake/rdoctask'
require 'rake/gempackagetask' require 'rake/gempackagetask'
$LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
require 'paperclip'
desc 'Default: run unit tests.' desc 'Default: run unit tests.'
task :default => [:clean, :test] task :default => [:clean, :test]
...@@ -44,7 +47,7 @@ end ...@@ -44,7 +47,7 @@ end
spec = Gem::Specification.new do |s| spec = Gem::Specification.new do |s|
s.name = "paperclip" s.name = "paperclip"
s.version = "2.1.0" s.version = Paperclip::VERSION
s.author = "Jon Yurek" s.author = "Jon Yurek"
s.email = "jyurek@thoughtbot.com" s.email = "jyurek@thoughtbot.com"
s.homepage = "http://www.thoughtbot.com/" s.homepage = "http://www.thoughtbot.com/"
...@@ -67,3 +70,15 @@ end ...@@ -67,3 +70,15 @@ end
Rake::GemPackageTask.new(spec) do |pkg| Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_tar = true pkg.need_tar = true
end end
desc "Release new version"
task :release => [:test, :sync_docs, :gem] do
require 'rubygems'
require 'rubyforge'
r = RubyForge.new
r.login
r.add_release spec.rubyforge_project,
spec.name,
spec.version,
File.join("pkg", "#{spec.name}-#{spec.version}.gem")
end
require File.join(File.dirname(__FILE__), "lib", "paperclip") require File.join(File.dirname(__FILE__), "lib", "paperclip")
ActiveRecord::Base.extend( Paperclip::ClassMethods )
File.send :include, Paperclip::Upfile
\ No newline at end of file
...@@ -35,6 +35,9 @@ require 'paperclip/attachment' ...@@ -35,6 +35,9 @@ require 'paperclip/attachment'
# The base module that gets included in ActiveRecord::Base. # The base module that gets included in ActiveRecord::Base.
module Paperclip module Paperclip
VERSION = "2.1.0"
class << self class << self
# Provides configurability to Paperclip. There are a number of options available, such as: # Provides configurability to Paperclip. There are a number of options available, such as:
# * whiny_thumbnails: Will raise an error if Paperclip cannot process thumbnails of # * whiny_thumbnails: Will raise an error if Paperclip cannot process thumbnails of
...@@ -198,3 +201,9 @@ module Paperclip ...@@ -198,3 +201,9 @@ module Paperclip
end end
end end
# Set it all up.
if Object.const_defined?("ActiveRecord")
ActiveRecord::Base.send(:include, Paperclip)
File.send(:include, Paperclip::Upfile)
end
...@@ -81,6 +81,7 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -81,6 +81,7 @@ class AttachmentTest < Test::Unit::TestCase
Paperclip::Attachment.default_options.merge!({ Paperclip::Attachment.default_options.merge!({
:path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension" :path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension"
}) })
FileUtils.rm_rf("tmp")
@instance = stub @instance = stub
@instance.stubs(:id).returns(41) @instance.stubs(:id).returns(41)
@instance.stubs(:class).returns(Dummy) @instance.stubs(:class).returns(Dummy)
...@@ -172,6 +173,23 @@ class AttachmentTest < Test::Unit::TestCase ...@@ -172,6 +173,23 @@ class AttachmentTest < Test::Unit::TestCase
should "still have its #file attribute not be nil" do should "still have its #file attribute not be nil" do
assert ! @attachment.file.nil? assert ! @attachment.file.nil?
end end
context "and deleted" do
setup do
@existing_names = @attachment.styles.keys.collect do |style|
@attachment.path(style)
end
@instance.expects(:[]=).with(:test_file_name, nil)
@instance.expects(:[]=).with(:test_content_type, nil)
@instance.expects(:[]=).with(:test_file_size, nil)
@attachment.assign nil
@attachment.save
end
should "delete the files" do
@existing_names.each{|f| assert ! File.exists?(f) }
end
end
end end
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment