tumblr_client 0.8.1 → 0.8.2
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.
- checksums.yaml +4 -4
- data/lib/tumblr/post.rb +18 -8
- data/lib/tumblr/version.rb +1 -1
- data/spec/examples/post_spec.rb +15 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 928807e6f2d5769cdd3fb00545611a035f569575
|
4
|
+
data.tar.gz: f587e06329f739c36c3b8b66f4a0fc9ee48c45c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98c178bf683e4f627a8091a3f1a6fb1ce4eaed04b1ab67c1dfd369ea0df5a6fcad5cd9cf24d472939a9ad21bd849a131f7ed1031e29f398ede17251ce58efd7d
|
7
|
+
data.tar.gz: 452499e743723afd1b0fe30645a86423d4ad80c2a6f31d524e2ae194c03ccff0e35aa4b7639ea37bc369ab95cb05b4ff45d6a4b14e87a61670fd9bcccbbfa959
|
data/lib/tumblr/post.rb
CHANGED
@@ -102,18 +102,28 @@ module Tumblr
|
|
102
102
|
def extract_data!(options)
|
103
103
|
if options.has_key?(:data)
|
104
104
|
data = options.delete :data
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
else
|
111
|
-
mime_type = "application/octet-stream"
|
105
|
+
|
106
|
+
if Array === data
|
107
|
+
data.each.with_index do |filepath, idx|
|
108
|
+
mime_type = extract_mimetype(filepath)
|
109
|
+
options["data[#{idx}]"] = Faraday::UploadIO.new(filepath, mime_type)
|
112
110
|
end
|
113
|
-
|
111
|
+
else
|
112
|
+
mime_type = extract_mimetype(data)
|
113
|
+
options["data"] = Faraday::UploadIO.new(data, mime_type)
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
+
def extract_mimetype(filepath)
|
119
|
+
mime = MIME::Types.type_for(filepath)
|
120
|
+
if (mime.empty?)
|
121
|
+
mime_type = "application/octet-stream"
|
122
|
+
else
|
123
|
+
mime_type = MIME::Types.type_for(filepath)[0].content_type
|
124
|
+
end
|
125
|
+
mime_type
|
126
|
+
end
|
127
|
+
|
118
128
|
end
|
119
129
|
end
|
data/lib/tumblr/version.rb
CHANGED
data/spec/examples/post_spec.rb
CHANGED
@@ -104,8 +104,7 @@ describe Tumblr::Post do
|
|
104
104
|
|
105
105
|
end
|
106
106
|
|
107
|
-
context 'when passing data
|
108
|
-
|
107
|
+
context 'when passing data as an array of filepaths' do
|
109
108
|
before do
|
110
109
|
fakefile = OpenStruct.new :read => file_data
|
111
110
|
File.stub(:open).with(file_path + '.jpg').and_return(fakefile)
|
@@ -114,12 +113,25 @@ describe Tumblr::Post do
|
|
114
113
|
:type => type.to_s
|
115
114
|
}).and_return('post')
|
116
115
|
end
|
117
|
-
|
116
|
+
|
118
117
|
it 'should be able to pass data as an array of filepaths' do
|
119
118
|
r = client.send type, blog_name, :data => [file_path + ".jpg"]
|
120
119
|
r.should == 'post'
|
121
120
|
end
|
122
121
|
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'when passing data different ways' do
|
125
|
+
|
126
|
+
before do
|
127
|
+
fakefile = OpenStruct.new :read => file_data
|
128
|
+
File.stub(:open).with(file_path + '.jpg').and_return(fakefile)
|
129
|
+
client.should_receive(:post).once.with("v2/blog/#{blog_name}/post", {
|
130
|
+
'data' => kind_of(Faraday::UploadIO),
|
131
|
+
:type => type.to_s
|
132
|
+
}).and_return('post')
|
133
|
+
end
|
134
|
+
|
123
135
|
it 'should be able to pass data as a single filepath' do
|
124
136
|
r = client.send type, blog_name, :data => file_path + ".jpg"
|
125
137
|
r.should == 'post'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tumblr_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Bunting
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07
|
12
|
+
date: 2013-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|