Skip to content

Commit 22b4c0c

Browse files
author
jyurek
committed
Rearranged stuff and added a gem build/deploy process. Official release of 2.1.0.
git-svn-id: https://svn.thoughtbot.com/plugins/paperclip/trunk@464 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
1 parent 77e91c0 commit 22b4c0c

File tree

5 files changed

+44
-3
lines changed

5 files changed

+44
-3
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*.swp
22
tmp
3+
s3.yml

Rakefile

+16-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ require 'rake/testtask'
33
require 'rake/rdoctask'
44
require 'rake/gempackagetask'
55

6+
$LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
7+
require 'paperclip'
8+
69
desc 'Default: run unit tests.'
710
task :default => [:clean, :test]
811

@@ -44,7 +47,7 @@ end
4447

4548
spec = Gem::Specification.new do |s|
4649
s.name = "paperclip"
47-
s.version = "2.1.0"
50+
s.version = Paperclip::VERSION
4851
s.author = "Jon Yurek"
4952
s.email = "jyurek@thoughtbot.com"
5053
s.homepage = "http://www.thoughtbot.com/"
@@ -67,3 +70,15 @@ end
6770
Rake::GemPackageTask.new(spec) do |pkg|
6871
pkg.need_tar = true
6972
end
73+
74+
desc "Release new version"
75+
task :release => [:test, :sync_docs, :gem] do
76+
require 'rubygems'
77+
require 'rubyforge'
78+
r = RubyForge.new
79+
r.login
80+
r.add_release spec.rubyforge_project,
81+
spec.name,
82+
spec.version,
83+
File.join("pkg", "#{spec.name}-#{spec.version}.gem")
84+
end

init.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
require File.join(File.dirname(__FILE__), "lib", "paperclip")
2-
ActiveRecord::Base.extend( Paperclip::ClassMethods )
3-
File.send :include, Paperclip::Upfile

lib/paperclip.rb

+9
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535

3636
# The base module that gets included in ActiveRecord::Base.
3737
module Paperclip
38+
39+
VERSION = "2.1.0"
40+
3841
class << self
3942
# Provides configurability to Paperclip. There are a number of options available, such as:
4043
# * whiny_thumbnails: Will raise an error if Paperclip cannot process thumbnails of
@@ -198,3 +201,9 @@ def destroy_attached_files
198201
end
199202

200203
end
204+
205+
# Set it all up.
206+
if Object.const_defined?("ActiveRecord")
207+
ActiveRecord::Base.send(:include, Paperclip)
208+
File.send(:include, Paperclip::Upfile)
209+
end

test/test_attachment.rb

+18
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class AttachmentTest < Test::Unit::TestCase
8181
Paperclip::Attachment.default_options.merge!({
8282
:path => ":rails_root/tmp/:attachment/:class/:style/:id/:basename.:extension"
8383
})
84+
FileUtils.rm_rf("tmp")
8485
@instance = stub
8586
@instance.stubs(:id).returns(41)
8687
@instance.stubs(:class).returns(Dummy)
@@ -172,6 +173,23 @@ class AttachmentTest < Test::Unit::TestCase
172173
should "still have its #file attribute not be nil" do
173174
assert ! @attachment.file.nil?
174175
end
176+
177+
context "and deleted" do
178+
setup do
179+
@existing_names = @attachment.styles.keys.collect do |style|
180+
@attachment.path(style)
181+
end
182+
@instance.expects(:[]=).with(:test_file_name, nil)
183+
@instance.expects(:[]=).with(:test_content_type, nil)
184+
@instance.expects(:[]=).with(:test_file_size, nil)
185+
@attachment.assign nil
186+
@attachment.save
187+
end
188+
189+
should "delete the files" do
190+
@existing_names.each{|f| assert ! File.exists?(f) }
191+
end
192+
end
175193
end
176194
end
177195
end

0 commit comments

Comments
 (0)