httmultiparty 0.3.13 → 0.3.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/httmultiparty.rb +17 -3
- data/lib/httmultiparty/version.rb +1 -1
- 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: 16afaa58ffab652e8ce6ab718d2f82085cc82aee
|
4
|
+
data.tar.gz: 75bd0c5c38ae5d776cf5d4497585035365bb15df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5058bff9591159ffdfa722b72874c3ae4fb9904088f43121819af0395cc70746d68cd80616cf6e0c1ab97782832ca2cfbc59b4b98a161df9f792f090f8f88d61
|
7
|
+
data.tar.gz: 4c3401cacf0ae2a10fcc147fa2ac082a4fb7094f479d3b865ebee8c400e08c4d8157030053fbede184e610028468adbceac601c1b9584c8aa2d5560864b9df75
|
data/lib/httmultiparty.rb
CHANGED
@@ -27,8 +27,8 @@ module HTTMultiParty
|
|
27
27
|
detect_mime_type = options.fetch(:detect_mime_type, false)
|
28
28
|
Proc.new do |params|
|
29
29
|
HTTMultiParty.flatten_params(params).map do |(k,v)|
|
30
|
-
if
|
31
|
-
[k, HTTMultiParty.file_to_upload_io(v, detect_mime_type)]
|
30
|
+
if file_present_in_params?(params)
|
31
|
+
[k, TRANSFORMABLE_TYPES.include?(v.class) ? HTTMultiParty.file_to_upload_io(v, detect_mime_type) : v]
|
32
32
|
else
|
33
33
|
"#{k}=#{v}"
|
34
34
|
end
|
@@ -78,6 +78,20 @@ module HTTMultiParty
|
|
78
78
|
Basement.options(*args)
|
79
79
|
end
|
80
80
|
|
81
|
+
private
|
82
|
+
|
83
|
+
def self.file_present_in_params?(params)
|
84
|
+
params.values.any? do |v|
|
85
|
+
if v.is_a? Array
|
86
|
+
v.any? { |vv| TRANSFORMABLE_TYPES.include?(vv.class) || vv.is_a?(UploadIO) }
|
87
|
+
elsif v.is_a? Hash
|
88
|
+
v.values.any? { |vv| TRANSFORMABLE_TYPES.include?(vv.class) || vv.is_a?(UploadIO) }
|
89
|
+
else
|
90
|
+
TRANSFORMABLE_TYPES.include?(v.class) || v.is_a?(UploadIO)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
81
95
|
module ClassMethods
|
82
96
|
def post(path, options={})
|
83
97
|
method = Net::HTTP::Post
|
@@ -101,7 +115,7 @@ module HTTMultiParty
|
|
101
115
|
|
102
116
|
private
|
103
117
|
def hash_contains_files?(hash)
|
104
|
-
hash.is_a?(Hash) && HTTMultiParty.flatten_params(hash).select do |(k,v)|
|
118
|
+
hash.is_a?(Hash) && HTTMultiParty.flatten_params(hash).select do |(k,v)|
|
105
119
|
TRANSFORMABLE_TYPES.include?(v.class) || v.is_a?(UploadIO)
|
106
120
|
end.size > 0
|
107
121
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httmultiparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johannes Wagener
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|