paperclip-storage-tmp 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  gemfile: Gemfile.ci
3
3
  rvm:
4
+ - 1.8.7
4
5
  - 1.9.2
5
6
  - 1.9.3
@@ -1,16 +1,28 @@
1
+ ## Not released yet:
2
+
3
+ * (no changes)
4
+
5
+ ## 0.0.4 (2012-06-15):
6
+
7
+ * Ruby 1.8 compatability: use `Tempfile#path` when opening new file
8
+ instead passing `Tempfile` directly (mikz)
9
+ * Rewind the file queued for write before returning it (exviva)
10
+ * Unlink the file **and** close the file descriptor when clearing
11
+ the attachments (exviva)
12
+
1
13
  ## 0.0.3 (2012-05-15):
2
14
 
3
15
  * Depend on Paperclip `>= 2.4.2`, which properly handles
4
- `<attachment>_file_name` assignment from `Paperclip::Attachment`
16
+ `<attachment>_file_name` assignment from `Paperclip::Attachment` (exviva)
5
17
 
6
18
  ## 0.0.2 (2012-05-12):
7
19
 
8
20
  * Provide one-line testing helpers for RSpec and Cucumber;
9
21
  they require the gem and add after hooks which clear the
10
- tmp storage
22
+ tmp storage (exviva)
11
23
 
12
24
  ## 0.0.1 (2012-05-11):
13
25
 
14
26
  * Implement `Paperclip::Storage::Tmp.clear` which clears all
15
- attachments from the filesystem (and from the "virtual" filesystem)
16
- * Provide a `:tmp` storage option for Paperclip attachments
27
+ attachments from the filesystem (and from the "virtual" filesystem) (exviva)
28
+ * Provide a `:tmp` storage option for Paperclip attachments (exviva)
data/Gemfile.ci CHANGED
@@ -2,4 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'paperclip', '2.4.0'
5
+ gem 'paperclip', '2.7.0'
data/README.md CHANGED
@@ -100,7 +100,8 @@ Here are a couple of specs, which expose the expected behaviour of this gem. The
100
100
 
101
101
  describe User do
102
102
  describe 'avatar' do
103
- let(:user) { User.create!(avatar: File.new('spec/fixtures/hey_mom_its_me.png')) }
103
+ let(:avatar_file) { File.new('spec/fixtures/hey_mom_its_me.png') }
104
+ let(:user) { User.create!(avatar: avatar_file) }
104
105
  subject { user.avatar }
105
106
 
106
107
  it { should exist }
data/Rakefile CHANGED
@@ -4,4 +4,4 @@ require "bundler/gem_tasks"
4
4
  require 'rspec/core/rake_task'
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
7
- task default: :spec
7
+ task :default => :spec
@@ -1,7 +1,7 @@
1
1
  module Paperclip
2
2
  module Storage
3
3
  module Tmp
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.4"
5
5
  end
6
6
  end
7
7
  end
@@ -7,7 +7,7 @@ module Paperclip
7
7
 
8
8
  # Deletes the temporary files and releases references to them
9
9
  def self.clear
10
- fs.each_value {|f| f.unlink }
10
+ fs.each_value {|f| f.close! }
11
11
  @fs = nil
12
12
  end
13
13
 
@@ -16,7 +16,12 @@ module Paperclip
16
16
  end
17
17
 
18
18
  def to_file(style_name = default_style)
19
- @queued_for_write[style_name] || (File.new(Tmp.fs[path(style_name)], 'rb') if exists?(style_name))
19
+ if @queued_for_write[style_name]
20
+ @queued_for_write[style_name].rewind
21
+ @queued_for_write[style_name]
22
+ elsif exists?(style_name)
23
+ File.new(Tmp.fs[path(style_name)].path, 'rb')
24
+ end
20
25
  end
21
26
 
22
27
  def flush_writes
@@ -31,7 +36,7 @@ module Paperclip
31
36
  def flush_deletes
32
37
  @queued_for_delete.each do |path|
33
38
  if file = Tmp.fs.delete(path)
34
- file.unlink
39
+ file.close!
35
40
  end
36
41
  end
37
42
 
@@ -1,3 +1,3 @@
1
1
  class User < ActiveRecord::Base
2
- has_attached_file :avatar, storage: :tmp
2
+ has_attached_file :avatar, :storage => :tmp
3
3
  end
@@ -7,7 +7,7 @@ describe Paperclip::Storage::Tmp do
7
7
 
8
8
  [proc { user.avatar }, proc { user.reload.avatar }].each do |subject_proc|
9
9
  describe 'assigning an attachment' do
10
- let(:user) { User.create!(avatar: avatar_file) }
10
+ let(:user) { User.create!(:avatar => avatar_file) }
11
11
  subject(&subject_proc)
12
12
 
13
13
  it { should exist }
@@ -23,7 +23,7 @@ describe Paperclip::Storage::Tmp do
23
23
  end
24
24
 
25
25
  it 'copies the assigned file' do
26
- File.read(subject.to_file).should eq(File.read(avatar_file))
26
+ File.read(subject.to_file.path).should eq(File.read(avatar_file.path))
27
27
  end
28
28
 
29
29
  it 'stores the file in an imagemagick-friendly way' do
@@ -39,17 +39,17 @@ describe Paperclip::Storage::Tmp do
39
39
  end
40
40
 
41
41
  it 'can handle assignment from File' do
42
- new_user = User.new(avatar: avatar_file)
42
+ new_user = User.new(:avatar => avatar_file)
43
43
  new_user.avatar_file_name.should eq('hey_mom_its_me.png')
44
44
  end
45
45
 
46
46
  it 'can persist assignment from File' do
47
- new_user = User.create!(avatar: avatar_file)
47
+ new_user = User.create!(:avatar => avatar_file)
48
48
  new_user.reload.avatar_file_name.should eq('hey_mom_its_me.png')
49
49
  end
50
50
 
51
51
  it 'can handle assignment from Paperclip::Attachment' do
52
- new_user = User.new(avatar: subject)
52
+ new_user = User.new(:avatar => subject)
53
53
  new_user.avatar_file_name.should eq('hey_mom_its_me.png')
54
54
  end
55
55
  end
@@ -67,7 +67,7 @@ describe Paperclip::Storage::Tmp do
67
67
  end
68
68
 
69
69
  describe 'destroying an attachment' do
70
- let(:user) { User.create!(avatar: avatar_file) }
70
+ let(:user) { User.create!(:avatar => avatar_file) }
71
71
  subject do
72
72
  @path_before_destroy = user.avatar.to_file.path
73
73
  user.destroy
@@ -84,7 +84,7 @@ describe Paperclip::Storage::Tmp do
84
84
  end
85
85
 
86
86
  describe 'clear' do
87
- let(:user) { User.create!(avatar: avatar_file) }
87
+ let(:user) { User.create!(:avatar => avatar_file) }
88
88
  subject { Paperclip::Storage::Tmp.clear }
89
89
 
90
90
  it 'deletes files' do
@@ -2,7 +2,7 @@ require 'active_record'
2
2
  ActiveRecord::Base.send(:include, Paperclip::Glue)
3
3
  require 'fixtures/user'
4
4
 
5
- ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
5
+ ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
6
6
 
7
7
  ActiveRecord::Schema.define do
8
8
  create_table :users do |t|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-storage-tmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-15 00:00:00.000000000 Z
12
+ date: 2012-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: paperclip