savon-multipart 2.1.1 → 2.1.2

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
- SHA1:
3
- metadata.gz: 1453752c3356664f6f81bceaf030316157f4d7d4
4
- data.tar.gz: 9511e7c2d636c54af0eb11dcf1e6c6264422d2ed
2
+ SHA256:
3
+ metadata.gz: 206ff4ab739562cbbf2e15e23d4b7c3a762b08bc26a2fefb286de605603e18ca
4
+ data.tar.gz: e1c187a1fbe40e23be747a620ab8378d1dfec812f80b72ec9ae0964b02ce35bb
5
5
  SHA512:
6
- metadata.gz: f3b2cbf00edc90989ced02fa321cb5e370e7f3938ea092a91036d4fdddadf6acad9cbc7905445c12dd43a108f0cfe09913d0ac8909c71a2c3adf7f2b9a15b6bc
7
- data.tar.gz: 43975f967153b5107f1fa1050fa6c131991148c5ab81acb3434abfa98a12a2599b4cbbe231df02de9235af538ce3a921f814193fea3da3a797ae3849bce45924
6
+ metadata.gz: 3fa992c3e53d971d2ff58ef15a09f4ca96bb2b5f682eb11b40bf5848d2e1e487a2cb088455e923ac02d7da86d50d672a6a1c22ac0a2bc91a7aba5c9c6c5e6a4c
7
+ data.tar.gz: b85cef7fdcac332de45e1c58140a9855a18af9df988c2f20aefbc2c7630f88ebdf11f68305b0364d00472b29b2a6a72372ff1e9b9f9bf85776b7ec8493b8f315
@@ -0,0 +1,46 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+
6
+ push:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ # linting:
11
+ # runs-on: ubuntu-latest
12
+
13
+ # steps:
14
+ # - uses: actions/checkout@v1
15
+
16
+ # - name: Set up Ruby 2.7
17
+ # uses: ruby/setup-ruby@v1
18
+ # with:
19
+ # ruby-version: 2.7
20
+ # bundler-cache: true
21
+
22
+ # - name: Rubocop
23
+ # run: bundle exec rubocop --format progress
24
+
25
+ build:
26
+ # When we have linting, this is where we will place that
27
+ needs: []
28
+ runs-on: ubuntu-latest
29
+ strategy:
30
+ matrix:
31
+ ruby:
32
+ - 2.6
33
+ - 2.7
34
+ - '3.0'
35
+ - 3.1
36
+ - jruby-9.2
37
+ - jruby-9.3
38
+
39
+ steps:
40
+ - uses: actions/checkout@v1
41
+ - uses: ruby/setup-ruby@v1
42
+ with:
43
+ ruby-version: ${{ matrix.ruby }}
44
+ bundler-cache: true # 'bundle install' and cache
45
+ - name: Test
46
+ run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
- ## 2.1.1 (current)
1
+ ## 2.1.2 (2022-01-20)
2
2
 
3
- * Improve detection of multipart content-type header.s
3
+ * Loosen dependency on `mail` gem. ([#23](https://github.com/savonrb/savon-multipart/pull/23))
4
+
5
+ ## 2.1.1
6
+
7
+ * Improve detection of multipart content-type header.
4
8
 
5
9
  ## 2.1.0
6
10
 
data/Gemfile CHANGED
@@ -1,9 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
- platform :rbx do
5
- gem 'json'
6
- gem 'racc'
7
- gem 'rubysl'
8
- gem 'rubinius-coverage'
4
+ if RUBY_VERSION > "3.1"
5
+ # net-smtp, net-pop and net-imap were removed from ruby 3.1 standard gems. See: https://github.com/rails/rails/pull/42366
6
+ # Can drop when https://github.com/mikel/mail/pull/1439 is resolved
7
+ gem "net-imap", require: false
8
+ gem "net-pop", require: false
9
+ gem "net-smtp", require: false
9
10
  end
11
+ gem "rubocop", "~> 0.49.1"
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Savon Multipart [![Build Status](https://secure.travis-ci.org/savonrb/savon-multipart.png)](http://travis-ci.org/savonrb/savon-multipart)
1
+ Savon Multipart [![CI](https://github.com/savonrb/savon-multipart/actions/workflows/ci.yml/badge.svg)](https://github.com/savonrb/savon-multipart/actions/workflows/ci.yml)
2
2
  ===============
3
3
 
4
4
  Adds multipart support (SOAP with Attachments) to [Savon](https://github.com/savonrb/savon).
@@ -7,12 +7,18 @@ Please test and provide feedback so we can support as many multipart-soap messag
7
7
  Installation
8
8
  ------------
9
9
 
10
- Savon Multipart is available through [Rubygems](http://rubygems.org/gems/savon-multipart) and can be installed via:
10
+ Savon Multipart is available through [Rubygems](https://rubygems.org/gems/savon-multipart) and can be installed via:
11
11
 
12
12
  ```
13
13
  $ gem install savon-multipart
14
14
  ```
15
15
 
16
+ Or in your `Gemfile`:
17
+
18
+ ```ruby
19
+ gem 'savon-multipart'
20
+ ```
21
+
16
22
  Usage
17
23
  ------------
18
24
 
@@ -22,7 +22,12 @@ module Savon
22
22
  def xml
23
23
  if multipart?
24
24
  parse_body unless @has_parsed_body
25
- @parts.first.body.to_s
25
+ if xop?
26
+ parse_xop unless @has_parsed_xop
27
+ @xop_body
28
+ else
29
+ @parts.first.body.to_s
30
+ end
26
31
  else
27
32
  super
28
33
  end
@@ -33,6 +38,15 @@ module Savon
33
38
  !(http.headers['content-type'] =~ /^multipart/im).nil?
34
39
  end
35
40
 
41
+ def xop?
42
+ if multipart?
43
+ parse_body unless @has_parsed_body
44
+ !(@parts.first.header['content-type'].to_s =~ /^application\/xop\+xml/i).nil?
45
+ else
46
+ false
47
+ end
48
+ end
49
+
36
50
  def boundary
37
51
  return unless multipart?
38
52
  @boundary ||= Mail::Field.new('content-type', http.headers['content-type']).parameters['boundary']
@@ -45,6 +59,25 @@ module Savon
45
59
  ).body.split!(boundary).parts
46
60
  @has_parsed_body = true
47
61
  end
62
+
63
+ def parse_xop
64
+ xml = @parts.first.body.to_s
65
+ parsed = Nokogiri.XML(xml)
66
+ xop_elements = parsed.xpath('//xop:Include', xop: "http://www.w3.org/2004/08/xop/include")
67
+ if xop_elements.count == 0
68
+ @xop_body = @parts.first.body.to_s
69
+ @has_parsed_xop = true
70
+ return
71
+ end
72
+ xop_elements.each do |xop_element|
73
+ href = xop_element.attributes['href'].to_s
74
+ cid = href[4..-1]
75
+ data = @parts.find { |p| p.header['content-id'].to_s == "<#{cid}>" }.body.to_s
76
+ xop_element.parent.content = Base64.encode64(data).chomp
77
+ end
78
+ @xop_body = parsed.to_s
79
+ @has_parsed_xop = true
80
+ end
48
81
  end
49
82
  end
50
83
  end
@@ -1,5 +1,5 @@
1
1
  module Savon
2
2
  module Multipart
3
- VERSION = "2.1.1"
3
+ VERSION = "2.1.2"
4
4
  end
5
5
  end
@@ -13,16 +13,13 @@ Gem::Specification.new do |s|
13
13
  s.description = "Adds multipart support (SOAP with Attachments) to Savon"
14
14
  s.required_ruby_version = '>= 1.9.2'
15
15
 
16
- s.rubyforge_project = s.name
17
-
18
16
  s.add_dependency "savon", "~> 2"
19
- s.add_dependency "mail", "~> 2.5.4"
17
+ s.add_dependency "mail", "~> 2"
20
18
 
21
19
  s.add_development_dependency "rake"
22
20
  s.add_development_dependency "pry"
23
21
  s.add_development_dependency "rspec"
24
22
  s.add_development_dependency "autotest"
25
- s.add_development_dependency "transpec"
26
23
 
27
24
  s.files = `git ls-files`.split("\n")
28
25
  s.require_path = "lib"
@@ -0,0 +1,13 @@
1
+ ----==_mimepart_4d416ae62fd32_201a8043814c4724
2
+ Content-ID: <http://tempuri.org/0>
3
+ Content-Transfer-Encoding: 8bit
4
+ Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
5
+
6
+ <?xml version="1.0" encoding="UTF-8"?><envelope ><header></header><body><BinaryData><xop:Include href="cid:http://tempuri.org/1/123456789" xmlns:xop="http://www.w3.org/2004/08/xop/include"/></BinaryData></body></envelope>
7
+ ----==_mimepart_4d416ae62fd32_201a8043814c4724
8
+ Content-ID: <http://tempuri.org/1/123456789>
9
+ Content-Transfer-Encoding: binary
10
+ Content-Type: application/octet-stream
11
+
12
+ BinaryDataGoesHere
13
+ ----==_mimepart_4d416ae62fd32_201a8043814c4724--
@@ -1,6 +1,6 @@
1
1
  require 'savon-multipart'
2
2
 
3
- describe Savon::Multipart::Response do
3
+ RSpec.describe Savon::Multipart::Response do
4
4
 
5
5
  let(:header) {{ "Content-Type" => 'multipart/related; boundary="--==_mimepart_4d416ae62fd32_201a8043814c4724"; charset=UTF-8; type="text/xml"' }}
6
6
  let(:body) { File.read(path) }
@@ -53,6 +53,19 @@ describe Savon::Multipart::Response do
53
53
  end
54
54
  end
55
55
 
56
+ context "simple xop" do
57
+ let(:path) { File.expand_path('../../../fixtures/response/simple_xop.txt', __FILE__) }
58
+
59
+ it "returns a String from the #xml method" do
60
+ expect(response.xml.class).to eq(String)
61
+ end
62
+
63
+ it "returns a Hash from the #body method, include xop data" do
64
+ expect(response.body.class).to eq(Hash)
65
+ expect(response.body).to eq({:binary_data => Base64.encode64('BinaryDataGoesHere').chomp})
66
+ end
67
+ end
68
+
56
69
  describe "a multipart response with case sensitive headers" do
57
70
  let(:header) {{ "Content-Type" => 'MuLtIpArT/rElAtEd; boundary="--==_mimepart_4d416ae62fd32_201a8043814c4724"; charset=UTF-8; type="text/xml"' }}
58
71
  let(:path) { File.expand_path('../../../fixtures/response/simple_multipart.txt', __FILE__) }
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: savon-multipart
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Westin
8
8
  - Daniel Harrington
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-20 00:00:00.000000000 Z
12
+ date: 2022-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 2.5.4
34
+ version: '2'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 2.5.4
41
+ version: '2'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rake
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -95,20 +95,6 @@ dependencies:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
- - !ruby/object:Gem::Dependency
99
- name: transpec
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: '0'
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: '0'
112
98
  description: Adds multipart support (SOAP with Attachments) to Savon
113
99
  email:
114
100
  - martin@eimermusic.com
@@ -117,9 +103,9 @@ executables: []
117
103
  extensions: []
118
104
  extra_rdoc_files: []
119
105
  files:
106
+ - ".github/workflows/ci.yml"
120
107
  - ".gitignore"
121
108
  - ".rspec"
122
- - ".travis.yml"
123
109
  - CHANGELOG.md
124
110
  - Gemfile
125
111
  - LICENSE
@@ -132,12 +118,13 @@ files:
132
118
  - spec/fixtures/response/multipart.txt
133
119
  - spec/fixtures/response/not_multipart.txt
134
120
  - spec/fixtures/response/simple_multipart.txt
121
+ - spec/fixtures/response/simple_xop.txt
135
122
  - spec/fixtures/response/soap_fault.txt
136
123
  - spec/savon/soap/response_spec.rb
137
124
  homepage: http://savonrb.com
138
125
  licenses: []
139
126
  metadata: {}
140
- post_install_message:
127
+ post_install_message:
141
128
  rdoc_options: []
142
129
  require_paths:
143
130
  - lib
@@ -152,9 +139,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
139
  - !ruby/object:Gem::Version
153
140
  version: '0'
154
141
  requirements: []
155
- rubyforge_project: savon-multipart
156
- rubygems_version: 2.4.6
157
- signing_key:
142
+ rubygems_version: 3.2.7
143
+ signing_key:
158
144
  specification_version: 4
159
145
  summary: Heavy metal Ruby SOAP client with multipart support
160
146
  test_files: []
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- # https://github.com/travis-ci/travis-ci/wiki/.travis.yml-options
2
- language: "ruby"
3
- script: "bundle exec rake"
4
- rvm:
5
- - 1.9.3
6
- - 2.0
7
- - 2.1
8
- - 2.2
9
- - jruby-19mode
10
- - rbx-2