postmark-mitt 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/postmark/mitt.rb +18 -1
- data/lib/postmark_mitt.rb +1 -0
- data/postmark-mitt.gemspec +1 -1
- data/spec/postmark/mitt_spec.rb +12 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
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
|
-
|
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
data/postmark-mitt.gemspec
CHANGED
data/spec/postmark/mitt_spec.rb
CHANGED
@@ -105,8 +105,18 @@ describe Postmark::Mitt do
|
|
105
105
|
attachment.file_name.should == 'chart.png'
|
106
106
|
end
|
107
107
|
|
108
|
-
|
109
|
-
|
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
|
-
-
|
9
|
-
version: 0.0.
|
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:
|
153
|
+
hash: -2222716141611575805
|
154
154
|
segments:
|
155
155
|
- 0
|
156
156
|
version: "0"
|