From 53e7552124ebd7037ba159ce46fd43a2ef586615 Mon Sep 17 00:00:00 2001 From: byork Date: Wed, 28 Feb 2018 10:55:13 -0400 Subject: [PATCH 1/2] Changed pairs_for to generate pairs around files when passed a nested hash containing a file handle, filename, and mimetype (filename and mimetype are optional) --- lib/ethon/easy/queryable.rb | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/ethon/easy/queryable.rb b/lib/ethon/easy/queryable.rb index cd59828..d03e7f1 100644 --- a/lib/ethon/easy/queryable.rb +++ b/lib/ethon/easy/queryable.rb @@ -129,16 +129,30 @@ def encode_rack_array_pairs(h, prefix, pairs) end end - def encode_multi_array_pairs(h, prefix, pairs) - h.each_with_index do |v, i| - key = prefix - pairs_for(v, key, pairs) + def encode_multi_array_pairs(h, prefix, pairs) + h.each_with_index do |v, i| + key = prefix + pairs_for(v, key, pairs) + end end - end def pairs_for(v, key, pairs) case v - when Hash, Array + when Hash + + # If the hash element contains an entry named "filehandle" then we + # have a file with a potentially specified filename and mimetype. + # handle this special case. + if !v[:filehandle].nil? and v[:filehandle].is_a? File + fileinfo = file_info(v[:filehandle]) + + if !v[:filename].nil? then fileinfo[0] = v[:filename] end + if !v[:mimetype].nil? then fileinfo[1] = v[:mimetype] end + pairs << [key, fileinfo] + else + recursively_generate_pairs(v, key, pairs) + end + when Array recursively_generate_pairs(v, key, pairs) when File, Tempfile pairs << [key, file_info(v)] From 225e2902cae095b66a8aed1a3b9fbdda3c9a66e1 Mon Sep 17 00:00:00 2001 From: byork Date: Wed, 28 Feb 2018 10:56:12 -0400 Subject: [PATCH 2/2] Ignoring .idea folder from git commits. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 40c6683..75a08dc 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ Gemfile.lock .yardoc doc coverage +.idea