postmark-mitt 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
data/lib/postmark/mitt.rb CHANGED
@@ -101,7 +101,9 @@ module Postmark
101
101
  end
102
102
 
103
103
  def read
104
- Base64.decode64(source["Content"])
104
+ tempfile = MittTempfile.new(file_name, content_type)
105
+ tempfile.write(Base64.decode64(source["Content"]))
106
+ tempfile
105
107
  end
106
108
 
107
109
  def size
@@ -123,4 +125,19 @@ module Postmark
123
125
  end
124
126
  end
125
127
  end
128
+
129
+ class MittTempfile < Tempfile
130
+ def initialize(basename, content_type, tmpdir=Dir::tmpdir)
131
+ super(basename, tmpdir)
132
+ @basename = basename
133
+ @content_type = content_type
134
+ end
135
+
136
+ # The content type of the "uploaded" file
137
+ attr_accessor :content_type
138
+
139
+ def original_filename
140
+ @basename || File.basename(path)
141
+ end
142
+ end
126
143
  end
data/lib/postmark_mitt.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  $LOAD_PATH.unshift File.dirname(__FILE__)
2
2
  require 'multi_json'
3
3
  require 'base64'
4
+ require 'tempfile'
4
5
  require 'postmark/mitt'
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{postmark-mitt}
8
- s.version = "0.0.4"
8
+ s.version = "0.0.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Randy Schmidt"]
@@ -105,8 +105,18 @@ describe Postmark::Mitt do
105
105
  attachment.file_name.should == 'chart.png'
106
106
  end
107
107
 
108
- it "should read the content" do
109
- attachment.read.should_not be_empty
108
+ describe "read" do
109
+ it "should read the content" do
110
+ attachment.read.class.name.should == "Postmark::MittTempfile"
111
+ end
112
+
113
+ it "should have a content_type" do
114
+ attachment.read.content_type.should == 'image/png'
115
+ end
116
+
117
+ it "should have a original_filename" do
118
+ attachment.read.original_filename.should == 'chart.png'
119
+ end
110
120
  end
111
121
 
112
122
  it "should have a size" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 4
9
- version: 0.0.4
8
+ - 5
9
+ version: 0.0.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Randy Schmidt
@@ -150,7 +150,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
150
150
  requirements:
151
151
  - - ">="
152
152
  - !ruby/object:Gem::Version
153
- hash: 1655568524372582428
153
+ hash: -2222716141611575805
154
154
  segments:
155
155
  - 0
156
156
  version: "0"