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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39a6249dabc233910c10ce5fc1b9d08a6ab27e76
4
- data.tar.gz: 27827777b772dc0743bd9f40e8264cf032d04ffa
3
+ metadata.gz: 16afaa58ffab652e8ce6ab718d2f82085cc82aee
4
+ data.tar.gz: 75bd0c5c38ae5d776cf5d4497585035365bb15df
5
5
  SHA512:
6
- metadata.gz: a74621476633dc10b0ee9915bdf2cbb4024d735e6adc3056d1f488e8e22727e645c14ac5a11c0a2da394b4b6dab5dabbaa0496c0f142f0f58966011218bb7264
7
- data.tar.gz: 4dacd09613d1fc06604613348d9a66acb69dae6b1d2e9607e1f2158bfba082b470a53e0f48a9f2912adaf168db1ae6dc00199fd38cfdbff2b439ccc4a684668d
6
+ metadata.gz: 5058bff9591159ffdfa722b72874c3ae4fb9904088f43121819af0395cc70746d68cd80616cf6e0c1ab97782832ca2cfbc59b4b98a161df9f792f090f8f88d61
7
+ data.tar.gz: 4c3401cacf0ae2a10fcc147fa2ac082a4fb7094f479d3b865ebee8c400e08c4d8157030053fbede184e610028468adbceac601c1b9584c8aa2d5560864b9df75
@@ -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 TRANSFORMABLE_TYPES.include?(v.class)
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
@@ -1,3 +1,3 @@
1
1
  module HTTMultiParty
2
- VERSION = '0.3.13'
2
+ VERSION = '0.3.14'
3
3
  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.13
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-03-24 00:00:00.000000000 Z
11
+ date: 2014-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty