soap-response_cutter 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/lib/soap/response_cutter/version.rb +6 -0
- data/lib/soap/response_cutter.rb +81 -0
- data/soap-response_cutter.gemspec +27 -0
- data/spec/lib/soap/response_cutter_spec.rb +29 -0
- data/spec/spec_helper.rb +21 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c0f969aafc0a1f671abe44b5a3a4aac4fb175980
|
4
|
+
data.tar.gz: e08dfad5c3d6c06a6e568ec0ec842fdca98e9a98
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ea88c32d7ef4bd06e55815af8882cbe67bb255827e2e16dd9975b5c611da5574854458e095b079eacab517e05e6cf31d2727e7e94a58f99edac74e1a0be31258
|
7
|
+
data.tar.gz: f1df64deab2b3e8df4660da58c3aa44afaad4f92f6b60157f301905685bbba187d848f99542edf2486000e0e08dfd5a891ddc52199ca416fe35b4256578a03ac
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Mikael Henriksson
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Shorter::Savon::Response
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'shorter-savon-response'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install shorter-savon-response
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/shorter-savon-response/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'soap/response_cutter/version'
|
2
|
+
require 'active_support/core_ext/hash'
|
3
|
+
module Soap
|
4
|
+
# Those are a crazy duplication and calls for some really ugly hacks
|
5
|
+
# to get the data you are reall interested in. Fuck SOAP!
|
6
|
+
#
|
7
|
+
# Examples:
|
8
|
+
# ResponseCutter.new(:soap_action, { somes: 'value'})
|
9
|
+
class ResponseCutter
|
10
|
+
attr_reader :action, :response
|
11
|
+
|
12
|
+
def initialize(action, response)
|
13
|
+
@action = action
|
14
|
+
@response = response.respond_to?(:body) ? response.body : response
|
15
|
+
@response = response.dup.deep_symbolize_keys!
|
16
|
+
end
|
17
|
+
|
18
|
+
# rubocop:disable MethodLength
|
19
|
+
def parse
|
20
|
+
@response = response_part
|
21
|
+
|
22
|
+
return response if response == true
|
23
|
+
return response unless response.is_a?(Hash)
|
24
|
+
|
25
|
+
@response = return_part
|
26
|
+
if response.is_a?(Hash)
|
27
|
+
if (res = return_part)
|
28
|
+
return res
|
29
|
+
end
|
30
|
+
end
|
31
|
+
response
|
32
|
+
end
|
33
|
+
# rubocop:enable MethodLength
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def response_part
|
38
|
+
response.fetch(response_key) do
|
39
|
+
response.fetch(reverse_response_key, true)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def response_key
|
44
|
+
key('response')
|
45
|
+
end
|
46
|
+
|
47
|
+
def reverse_response_key
|
48
|
+
reverse_key('response')
|
49
|
+
end
|
50
|
+
|
51
|
+
def return_part
|
52
|
+
response.fetch(return_key) do
|
53
|
+
response.fetch(reverse_return_key, true)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def return_key
|
58
|
+
key('return')
|
59
|
+
end
|
60
|
+
|
61
|
+
def reverse_return_key
|
62
|
+
reverse_key('return')
|
63
|
+
end
|
64
|
+
|
65
|
+
def key(suffix)
|
66
|
+
act = "#{action}"
|
67
|
+
version_pattern = /_v(\d)/
|
68
|
+
if act =~ version_pattern
|
69
|
+
version = act[version_pattern]
|
70
|
+
act = act.gsub(version_pattern, '')
|
71
|
+
return "#{act}_#{suffix}#{version}".to_sym
|
72
|
+
end
|
73
|
+
|
74
|
+
reverse_key(suffix)
|
75
|
+
end
|
76
|
+
|
77
|
+
def reverse_key(suffix)
|
78
|
+
"#{action}_#{suffix}".to_sym
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'soap/response_cutter/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'soap-response_cutter'
|
8
|
+
spec.version = Soap::ResponseCutter::VERSION
|
9
|
+
spec.authors = ['Mikael Henriksson']
|
10
|
+
spec.email = ['mikael@zoolutions.se']
|
11
|
+
spec.summary = %q{Gets rid of <SomethingResponse><SomethingResult> from soap responses}
|
12
|
+
spec.description = %q{}
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'activesupport', '>= 3.2'
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.1'
|
25
|
+
spec.add_development_dependency 'rspec-its'
|
26
|
+
spec.add_development_dependency 'rubocop', '~> 0.2'
|
27
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Soap::ResponseCutter do
|
4
|
+
describe '#parse' do
|
5
|
+
subject { Soap::ResponseCutter.new(:abc_v2, response) }
|
6
|
+
let(:expected) { 'expected' }
|
7
|
+
context 'normal response' do
|
8
|
+
let(:response) do
|
9
|
+
{
|
10
|
+
abc_v2_response: {
|
11
|
+
abc_v2_return: expected
|
12
|
+
}
|
13
|
+
}
|
14
|
+
end
|
15
|
+
its(:parse) { should eq(expected) }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'inverted response' do
|
19
|
+
let(:response) do
|
20
|
+
{
|
21
|
+
abc_response_v2: {
|
22
|
+
abc_return_v2: expected
|
23
|
+
}
|
24
|
+
}
|
25
|
+
end
|
26
|
+
its(:parse) { should eq(expected) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rspec/its'
|
2
|
+
require 'soap/response_cutter'
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.expect_with :rspec do |expectations|
|
6
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
7
|
+
end
|
8
|
+
|
9
|
+
config.mock_with :rspec do |mocks|
|
10
|
+
mocks.verify_partial_doubles = true
|
11
|
+
end
|
12
|
+
|
13
|
+
config.filter_run :focus
|
14
|
+
config.run_all_when_everything_filtered = true
|
15
|
+
# config.disable_monkey_patching!
|
16
|
+
config.warnings = true
|
17
|
+
config.default_formatter = 'doc' if config.files_to_run.one?
|
18
|
+
config.profile_examples = 10
|
19
|
+
config.order = :random
|
20
|
+
Kernel.srand config.seed
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: soap-response_cutter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mikael Henriksson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-its
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.2'
|
97
|
+
description: ''
|
98
|
+
email:
|
99
|
+
- mikael@zoolutions.se
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- lib/soap/response_cutter.rb
|
111
|
+
- lib/soap/response_cutter/version.rb
|
112
|
+
- soap-response_cutter.gemspec
|
113
|
+
- spec/lib/soap/response_cutter_spec.rb
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
homepage: ''
|
116
|
+
licenses:
|
117
|
+
- MIT
|
118
|
+
metadata: {}
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
requirements: []
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 2.2.2
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: Gets rid of <SomethingResponse><SomethingResult> from soap responses
|
139
|
+
test_files:
|
140
|
+
- spec/lib/soap/response_cutter_spec.rb
|
141
|
+
- spec/spec_helper.rb
|
142
|
+
has_rdoc:
|