Skip to content

Commit

Permalink
Rearranged stuff and added a gem build/deploy process. Official relea…
Browse files Browse the repository at this point in the history
…se of 2.1.0.
  • Loading branch information
Jon Yurek committed Apr 18, 2008
1 parent c44048d commit c6ccb54
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
*.swp
tmp
s3.yml
17 changes: 16 additions & 1 deletion Rakefile
Expand Up @@ -3,6 +3,9 @@ require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'

$LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
require 'paperclip'

desc 'Default: run unit tests.'
task :default => [:clean, :test]

Expand Down Expand Up @@ -44,7 +47,7 @@ end

spec = Gem::Specification.new do |s|
s.name = "paperclip"
s.version = "2.1.0"
s.version = Paperclip::VERSION
s.author = "Jon Yurek"
s.email = "jyurek@thoughtbot.com"
s.homepage = "http://www.thoughtbot.com/"
Expand All @@ -67,3 +70,15 @@ end
Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_tar = true
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
2 changes: 0 additions & 2 deletions init.rb
@@ -1,3 +1 @@
require File.join(File.dirname(__FILE__), "lib", "paperclip")
ActiveRecord::Base.extend( Paperclip::ClassMethods )
File.send :include, Paperclip::Upfile
9 changes: 9 additions & 0 deletions lib/paperclip.rb
Expand Up @@ -35,6 +35,9 @@

# The base module that gets included in ActiveRecord::Base.
module Paperclip

VERSION = "2.1.0"

class << self
# 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
Expand Down Expand Up @@ -198,3 +201,9 @@ def destroy_attached_files
end

end

# Set it all up.
if Object.const_defined?("ActiveRecord")
ActiveRecord::Base.send(:include, Paperclip)
File.send(:include, Paperclip::Upfile)
end
18 changes: 18 additions & 0 deletions test/test_attachment.rb
Expand Up @@ -81,6 +81,7 @@ class AttachmentTest < Test::Unit::TestCase
Paperclip::Attachment.default_options.merge!({
:path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension"
})
FileUtils.rm_rf("tmp")
@instance = stub
@instance.stubs(:id).returns(41)
@instance.stubs(:class).returns(Dummy)
Expand Down Expand Up @@ -172,6 +173,23 @@ class AttachmentTest < Test::Unit::TestCase
should "still have its #file attribute not be nil" do
assert ! @attachment.file.nil?
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
Expand Down

0 comments on commit c6ccb54

Please sign in to comment.