sapoci 0.3.1 → 0.3.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sapoci/document.rb +14 -3
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1874225daa64d92bae4734aaf991d43b64c58dca
4
- data.tar.gz: ae9ba882198c07506f95e951d1e11682624a2d71
3
+ metadata.gz: c12055d2beee9d77786cffcaa2dffdb0b5927f39
4
+ data.tar.gz: 578dd20f749267121ddc9ac26b216b9f10e43b6b
5
5
  SHA512:
6
- metadata.gz: 436fe98d93a451d50ff4b0a56ed812bac323c2c3f705016c74253b839207fc537981d46f7bb2522624ec633d7907a2b1b7d8e1d16690a84314e90f30eb07fae0
7
- data.tar.gz: 4280c1591bfba1f2cae4e1d3dc46e3cb7f6c18ffbc9f7f1d51ef4cfd00c1f656d8260b6c6aa4c19b36b32d5477b53760d08476124affcf0570938f23e98c3745
6
+ metadata.gz: fa08b4cc251910dcb87cbc66bd0946f861b47a4a09235863b2975763be6cd89425fb1cf9eb737691f3072e3237bed4057afc1f09f56c304e199d3e720dfeed03
7
+ data.tar.gz: 3697e339e894b3aa51781e3c3f8e4a9751c636397f727d5d4ba7eb8ae1794fd63fbf500ef49b70bf8d0d3a8713a8d312e55cdb796d8d2a625d4ca3de5e117aa6
@@ -69,6 +69,11 @@ module SAPOCI
69
69
  value = item_node.attribute("value").value
70
70
  items[index] = Item.new(index) unless items[index]
71
71
  items[index].longtext = value
72
+ elsif /NEW_ITEM-LONGTEXT(.*)\[(\d+)\]/.match(name)
73
+ index = $2.to_i - 1
74
+ value = item_node.attribute("value").value
75
+ items[index] = Item.new(index) unless items[index]
76
+ items[index].longtext = value
72
77
  end
73
78
  end
74
79
  items.inject([]) { |memo, (_, value)| memo << value }.sort_by(&:index)
@@ -80,11 +85,11 @@ module SAPOCI
80
85
  items = {}
81
86
  (params || {}).each do |oci_name, oci_values|
82
87
  if oci_name =~ /NEW_ITEM-/
83
- # Parse anything but NEW_ITEM-LONGTEXT (which is special, see below)
88
+ # Parse anything but NEW_ITEM-LONGTEXT_... (which is special, see below)
84
89
  oci_values.each do |index, value|
85
90
  index = index.to_i - 1 rescue next
86
91
  property = /NEW_ITEM-(\w+)/.match(oci_name)[1]
87
- next if property =~ /LONGTEXT/
92
+ next if property =~ /LONGTEXT_/ # <- notice the underscore here!
88
93
  method = (property+'=').downcase.to_sym
89
94
  items[index] = Item.new(index) unless items[index]
90
95
  items[index].send(method, value) if items[index].respond_to?(method)
@@ -102,7 +107,13 @@ module SAPOCI
102
107
  if oci_values.is_a?(Array)
103
108
  # NEW_ITEM-LONGTEXT_1:132[]
104
109
  items[index] = Item.new(index) unless items[index]
105
- items[index].longtext = oci_values.first
110
+ if oci_values.first.is_a?(Hash)
111
+ # <input type="hidden" name="NEW_ITEM-LONGTEXT_1:132[][1]" value="Longtext">
112
+ # "NEW_ITEM-LONGTEXT_1:132"=>[{"1"=>"Longtext"}]
113
+ items[index].longtext = oci_values.first.values[0]
114
+ else
115
+ items[index].longtext = oci_values.first
116
+ end
106
117
  elsif oci_values.is_a?(String)
107
118
  # NEW_ITEM-LONGTEXT_1:132 <= invalid but parsed!
108
119
  items[index] = Item.new(index) unless items[index]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sapoci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oliver Eilhard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-12 00:00:00.000000000 Z
11
+ date: 2017-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: 1.3.6
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.5.1
109
+ rubygems_version: 2.5.2
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: SAP OCI enables users to parse SAP OCI compliant data from online shops.