apollo_upload_server 2.0.0.alpha.3 → 2.0.0.alpha.4

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.

Potentially problematic release.


This version of apollo_upload_server might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32cfcc7742b384585c8bd79c7bcc0731c5853c27
4
- data.tar.gz: e0821f7a45c3c970bbb619e7bb2210c9f34964a7
3
+ metadata.gz: 10005a86d023dffcbe955f801d693d3ba62b7ab1
4
+ data.tar.gz: e60aea89cf3a64e889f694e1ac1ddf60fef1d926
5
5
  SHA512:
6
- metadata.gz: f0d8453925923b5005337bda8f1d86d0d131b252f2ed63ccaf9358146d611f50a4be4106073951bbaf2bc17bb7264bc941fdbc8668f57c29b6991850a80c77d3
7
- data.tar.gz: 3c47649e500705926d8056d506bf32feac8eef80b5815320990ec461178287cf9e59a8df6b760b08d199f2d0a84068fa20556aba161d228ce47a5d501a13b797
6
+ metadata.gz: 5a15c667570265b4945dae967168b975eba54f32037cfaa608ca1b3b78493f380ddbbecd7b500662016f3a488c7cdb961e5767cf032ce46117ab354652547895
7
+ data.tar.gz: 102231ab9e60219d655d6b990542a01cdba6d2990b166615bfe9b8428a124ff51ab0340adc26831f47d7748c597d0dabad6b17ad421348295817feee997e8751
@@ -21,9 +21,10 @@ module ApolloUploadServer
21
21
  file_mapper.each do |file_index, paths|
22
22
  paths.each do |path|
23
23
  splited_path = path.split('.')
24
- # splited_path => 'variables.input.profile_photo'; splited_path[0..-2] => ['variables', 'input']
25
- # dig from first to penultimate key, and merge last key with value as file
26
- operations.dig(*splited_path[0..-2]).merge!(splited_path.last => params[file_index])
24
+ # splited_path => 'variables.input.profile_photo'; splited_path[0..-2] => ['variables', 'input']
25
+ # dig from first to penultimate key, and merge last key with value as file
26
+ field = operations.dig(*splited_path[0..-2])
27
+ assign_file(field, splited_path, params[file_index])
27
28
  end
28
29
  end
29
30
  operations
@@ -34,8 +35,9 @@ module ApolloUploadServer
34
35
  file_mapper.each do |file_index, paths|
35
36
  paths.each do |path|
36
37
  splited_path = path.split('.')
37
- # dig from second to penultimate key, and merge last key with value as file to operation with first key index
38
- operations[splited_path.first.to_i].dig(*splited_path[1..-2]).merge!(splited_path.last => params[file_index])
38
+ # dig from second to penultimate key, and merge last key with value as file to operation with first key index
39
+ field = operations[splited_path.first.to_i].dig(*splited_path[1..-2])
40
+ assign_file(field, splited_path, params[file_index])
39
41
  end
40
42
  end
41
43
  operations
@@ -46,5 +48,13 @@ module ApolloUploadServer
46
48
  rescue JSON::ParserError
47
49
  nil
48
50
  end
51
+
52
+ def assign_file(field, splited_path, file)
53
+ if field.is_a? Hash
54
+ field.merge!(splited_path.last => file)
55
+ elsif field.is_a? Array
56
+ field[splited_path.last.to_i] = file
57
+ end
58
+ end
49
59
  end
50
60
  end
@@ -1,3 +1,3 @@
1
1
  module ApolloUploadServer
2
- VERSION = '2.0.0.alpha.3'.freeze
2
+ VERSION = '2.0.0.alpha.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apollo_upload_server
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.alpha.3
4
+ version: 2.0.0.alpha.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - JetRuby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-14 00:00:00.000000000 Z
11
+ date: 2018-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails