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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85e2a013fa7e390e522e3832dbaae337e3a4ff88
4
- data.tar.gz: a250c8be007a9165f57ab0b69fb1f790da93f78c
3
+ metadata.gz: 928807e6f2d5769cdd3fb00545611a035f569575
4
+ data.tar.gz: f587e06329f739c36c3b8b66f4a0fc9ee48c45c3
5
5
  SHA512:
6
- metadata.gz: b33406cfec5727d2f3c7960843b00d0bcfa79e3042d90739b08e98fcb33c0abeebe469283b89918b9a3960140e96ca3380065c9b8a9e546cdccebbeb12128499
7
- data.tar.gz: 588baf76498eb98cc75ba6a83ab8d1c2df1adaf939d99b7a5736f9a5fa1ee3b57a3bbce4bd0a7d19e3e752add705b32b4754236246be41b1b08ef42ba5af32ef
6
+ metadata.gz: 98c178bf683e4f627a8091a3f1a6fb1ce4eaed04b1ab67c1dfd369ea0df5a6fcad5cd9cf24d472939a9ad21bd849a131f7ed1031e29f398ede17251ce58efd7d
7
+ data.tar.gz: 452499e743723afd1b0fe30645a86423d4ad80c2a6f31d524e2ae194c03ccff0e35aa4b7639ea37bc369ab95cb05b4ff45d6a4b14e87a61670fd9bcccbbfa959
@@ -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
- data = [data] unless Array === data
106
- data.each.with_index do |filepath, idx|
107
- mime = MIME::Types.type_for(filepath)
108
- if (!mime.empty?)
109
- mime_type = MIME::Types.type_for(filepath)[0].content_type
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
- options["data[#{idx}]"] = Faraday::UploadIO.new(filepath, mime_type)
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
@@ -1,5 +1,5 @@
1
1
  module Tumblr
2
2
 
3
- VERSION = '0.8.1'
3
+ VERSION = '0.8.2'
4
4
 
5
5
  end
@@ -104,8 +104,7 @@ describe Tumblr::Post do
104
104
 
105
105
  end
106
106
 
107
- context 'when passing data different ways' do
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.1
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-26 00:00:00.000000000 Z
12
+ date: 2013-08-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday