wasabi 2.3.0 → 2.4.0
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.
- data/CHANGELOG.md +6 -0
- data/lib/wasabi.rb +1 -0
- data/lib/wasabi/document.rb +8 -15
- data/lib/wasabi/resolver.rb +46 -0
- data/lib/wasabi/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/fixture.rb +34 -12
- data/spec/wasabi/document/authentication_spec.rb +1 -1
- data/spec/wasabi/document/geotrust_spec.rb +1 -1
- data/spec/wasabi/document/inherited_spec.rb +1 -1
- data/spec/wasabi/document/multiple_namespaces_spec.rb +1 -1
- data/spec/wasabi/document/namespaced_actions_spec.rb +1 -1
- data/spec/wasabi/document/no_namespace_spec.rb +1 -1
- data/spec/wasabi/document/soap12_spec.rb +1 -1
- data/spec/wasabi/document/two_bindings_spec.rb +1 -1
- data/spec/wasabi/document_spec.rb +20 -1
- data/spec/wasabi/parser/multiple_namespaces_spec.rb +1 -1
- data/spec/wasabi/parser/no_namespace_spec.rb +1 -1
- data/spec/wasabi/parser/symbolic_endpoint_spec.rb +1 -1
- data/spec/wasabi/resolver_spec.rb +23 -0
- data/spec/wasabi/wasabi_spec.rb +1 -1
- data/wasabi.gemspec +1 -0
- metadata +29 -11
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 2.4.0 (2012-06-08)
|
2
|
+
|
3
|
+
* Feature: `Wasabi::Document` now accepts either a URL of a remote document,
|
4
|
+
a path to a local file or raw XML. The code for this was moved from Savon over
|
5
|
+
here as a first step towards supporting WSDL imports.
|
6
|
+
|
1
7
|
## 2.3.0 (2012-06-07)
|
2
8
|
|
3
9
|
* Improvement: [#3](https://github.com/rubiii/wasabi/pull/3) adds object inheritance.
|
data/lib/wasabi.rb
CHANGED
data/lib/wasabi/document.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "nokogiri"
|
2
|
+
require "wasabi/resolver"
|
2
3
|
require "wasabi/parser"
|
3
4
|
|
4
5
|
module Wasabi
|
@@ -24,12 +25,9 @@ module Wasabi
|
|
24
25
|
self.document = document
|
25
26
|
end
|
26
27
|
|
27
|
-
attr_accessor :document
|
28
|
+
attr_accessor :document, :request, :xml
|
28
29
|
|
29
|
-
|
30
|
-
def document?
|
31
|
-
!!document
|
32
|
-
end
|
30
|
+
alias_method :document?, :document
|
33
31
|
|
34
32
|
# Returns the SOAP endpoint.
|
35
33
|
def endpoint
|
@@ -49,7 +47,7 @@ module Wasabi
|
|
49
47
|
|
50
48
|
# Returns the value of elementFormDefault.
|
51
49
|
def element_form_default
|
52
|
-
@element_form_default ||=
|
50
|
+
@element_form_default ||= document ? parser.element_form_default : :unqualified
|
53
51
|
end
|
54
52
|
|
55
53
|
# Sets the elementFormDefault value.
|
@@ -84,7 +82,7 @@ module Wasabi
|
|
84
82
|
parser.types.each do |type, info|
|
85
83
|
namespaces << [[type], info[:namespace]]
|
86
84
|
(info.keys - [:namespace]).each { |field| namespaces << [[type, field], info[:namespace]] }
|
87
|
-
end if document
|
85
|
+
end if document
|
88
86
|
namespaces
|
89
87
|
end
|
90
88
|
end
|
@@ -98,7 +96,7 @@ module Wasabi
|
|
98
96
|
tag, namespace = field_type.split(":").reverse
|
99
97
|
result << [[type, field], tag] if user_defined(namespace)
|
100
98
|
end
|
101
|
-
end if document
|
99
|
+
end if document
|
102
100
|
result
|
103
101
|
end
|
104
102
|
end
|
@@ -112,12 +110,7 @@ module Wasabi
|
|
112
110
|
# Returns the raw WSDL document.
|
113
111
|
# Can be used as a hook to extend the library.
|
114
112
|
def xml
|
115
|
-
@xml ||= document
|
116
|
-
end
|
117
|
-
|
118
|
-
# Returns whether there is a WSDL document to parse.
|
119
|
-
def xml?
|
120
|
-
xml.kind_of?(String)
|
113
|
+
@xml ||= Resolver.new(document, request).xml
|
121
114
|
end
|
122
115
|
|
123
116
|
# Parses the WSDL document and returns the <tt>Wasabi::Parser</tt>.
|
@@ -129,7 +122,7 @@ module Wasabi
|
|
129
122
|
|
130
123
|
# Raises an error if the WSDL document is missing.
|
131
124
|
def guard_parse
|
132
|
-
return true if
|
125
|
+
return true if document
|
133
126
|
raise ArgumentError, "Wasabi needs a WSDL document"
|
134
127
|
end
|
135
128
|
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "httpi"
|
2
|
+
|
3
|
+
module Wasabi
|
4
|
+
|
5
|
+
# = Wasabi::Resolver
|
6
|
+
#
|
7
|
+
# Resolves local and remote WSDL documents.
|
8
|
+
class Resolver
|
9
|
+
|
10
|
+
class HTTPError < StandardError; end
|
11
|
+
|
12
|
+
def initialize(document, request = nil)
|
13
|
+
@document = document
|
14
|
+
@request = request
|
15
|
+
end
|
16
|
+
|
17
|
+
def xml
|
18
|
+
raise ArgumentError, "Wasabi is missing a document to resolve" unless @document
|
19
|
+
|
20
|
+
case @document
|
21
|
+
when /^http[s]?:/ then from_remote
|
22
|
+
when /^</ then @document
|
23
|
+
else from_fs
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def from_remote
|
30
|
+
response = HTTPI.get(request)
|
31
|
+
raise HTTPError.new(response) if response.error?
|
32
|
+
response.body
|
33
|
+
end
|
34
|
+
|
35
|
+
def request
|
36
|
+
@request ||= HTTPI::Request.new
|
37
|
+
@request.url = @document
|
38
|
+
@request
|
39
|
+
end
|
40
|
+
|
41
|
+
def from_fs
|
42
|
+
File.read(@document)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
data/lib/wasabi/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/support/fixture.rb
CHANGED
@@ -1,20 +1,42 @@
|
|
1
|
-
module
|
1
|
+
module SpecSupport
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
class Fixture
|
4
|
+
def self.[](name)
|
5
|
+
fixtures[name]
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def self.[]=(name, value)
|
9
|
+
fixtures[name] = value
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.fixtures
|
13
|
+
@fixtures ||= {}
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(file, ext = :wsdl)
|
17
|
+
self.file = file
|
18
|
+
self.ext = ext
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_accessor :file, :ext
|
22
|
+
|
23
|
+
def filename
|
24
|
+
"#{file}.#{ext}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def path
|
28
|
+
File.expand_path("spec/fixtures/#{filename}")
|
29
|
+
end
|
10
30
|
|
11
|
-
|
12
|
-
|
31
|
+
def read
|
32
|
+
Fixture[filename] ||= File.read(path)
|
33
|
+
end
|
13
34
|
end
|
14
35
|
|
15
|
-
|
16
|
-
|
17
|
-
|
36
|
+
module Methods
|
37
|
+
def fixture(*args)
|
38
|
+
Fixture.new(*args)
|
39
|
+
end
|
18
40
|
end
|
19
41
|
|
20
42
|
end
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe Wasabi::Document do
|
4
4
|
context "with: authentication.wsdl" do
|
5
5
|
|
6
|
-
subject { Wasabi::Document.new fixture(:authentication) }
|
6
|
+
subject { Wasabi::Document.new fixture(:authentication).read }
|
7
7
|
|
8
8
|
its(:namespace) { should == "http://v1_0.ws.auth.order.example.com/" }
|
9
9
|
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe Wasabi::Document do
|
4
4
|
context "with: geotrust.wsdl" do
|
5
5
|
|
6
|
-
subject { Wasabi::Document.new fixture(:geotrust) }
|
6
|
+
subject { Wasabi::Document.new fixture(:geotrust).read }
|
7
7
|
|
8
8
|
its(:namespace) { should == "http://api.geotrust.com/webtrust/query" }
|
9
9
|
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe Wasabi::Document do
|
4
4
|
context "with: inherited.xml" do
|
5
5
|
|
6
|
-
subject { Wasabi::Document.new fixture(:inherited) }
|
6
|
+
subject { Wasabi::Document.new fixture(:inherited).read }
|
7
7
|
|
8
8
|
its(:type_definitions) do
|
9
9
|
should include([["Account", "Id"], "ID"])
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe Wasabi::Document do
|
4
4
|
context "with: multiple_namespaces.wsdl" do
|
5
5
|
|
6
|
-
subject { Wasabi::Document.new fixture(:multiple_namespaces) }
|
6
|
+
subject { Wasabi::Document.new fixture(:multiple_namespaces).read }
|
7
7
|
|
8
8
|
its(:namespace) { should == "http://example.com/actions" }
|
9
9
|
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe Wasabi::Document do
|
4
4
|
context "with: namespaced_actions.wsdl" do
|
5
5
|
|
6
|
-
subject { Wasabi::Document.new fixture(:namespaced_actions) }
|
6
|
+
subject { Wasabi::Document.new fixture(:namespaced_actions).read }
|
7
7
|
|
8
8
|
its(:namespace) { should == "http://api.example.com/api/" }
|
9
9
|
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe Wasabi::Document do
|
4
4
|
context "with: no_namespace.wsdl" do
|
5
5
|
|
6
|
-
subject { Wasabi::Document.new fixture(:no_namespace) }
|
6
|
+
subject { Wasabi::Document.new fixture(:no_namespace).read }
|
7
7
|
|
8
8
|
its(:namespace) { should == "urn:ActionWebService" }
|
9
9
|
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe Wasabi::Document do
|
4
4
|
context "with: soap12.wsdl" do
|
5
5
|
|
6
|
-
subject { Wasabi::Document.new fixture(:soap12) }
|
6
|
+
subject { Wasabi::Document.new fixture(:soap12).read }
|
7
7
|
|
8
8
|
its(:endpoint) { should == URI("http://blogsite.example.com/endpoint12") }
|
9
9
|
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe Wasabi::Document do
|
4
4
|
context "with: two_bindings.wsdl" do
|
5
5
|
|
6
|
-
subject { Wasabi::Document.new fixture(:two_bindings) }
|
6
|
+
subject { Wasabi::Document.new fixture(:two_bindings).read }
|
7
7
|
|
8
8
|
its(:element_form_default) { should == :unqualified }
|
9
9
|
|
@@ -2,7 +2,26 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Wasabi::Document do
|
4
4
|
|
5
|
-
subject { Wasabi::Document.new }
|
5
|
+
subject { Wasabi::Document.new fixture(:authentication).read }
|
6
|
+
|
7
|
+
describe ".new" do
|
8
|
+
it "accepts a URL" do
|
9
|
+
HTTPI.expects(:get).returns(HTTPI::Response.new(200, {}, "wsdl"))
|
10
|
+
|
11
|
+
document = Wasabi::Document.new("http://example.com?wsdl")
|
12
|
+
document.xml.should == "wsdl"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "accepts a path" do
|
16
|
+
document = Wasabi::Document.new fixture(:authentication).path
|
17
|
+
document.xml.should == fixture(:authentication).read
|
18
|
+
end
|
19
|
+
|
20
|
+
it "accepts raw XML" do
|
21
|
+
document = Wasabi::Document.new fixture(:authentication).read
|
22
|
+
document.xml.should == fixture(:authentication).read
|
23
|
+
end
|
24
|
+
end
|
6
25
|
|
7
26
|
describe ".validate_element_form_default!" do
|
8
27
|
[:unqualified, :qualified].each do |value|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Wasabi::Resolver do
|
4
|
+
|
5
|
+
describe "#xml" do
|
6
|
+
it "resolves remote documents" do
|
7
|
+
HTTPI.expects(:get).returns(HTTPI::Response.new(200, {}, "wsdl"))
|
8
|
+
xml = Wasabi::Resolver.new("http://example.com?wsdl").xml
|
9
|
+
xml.should == "wsdl"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "resolves remote documents" do
|
13
|
+
xml = Wasabi::Resolver.new(fixture(:authentication).path).xml
|
14
|
+
xml.should == fixture(:authentication).read
|
15
|
+
end
|
16
|
+
|
17
|
+
it "simply returns raw XML" do
|
18
|
+
xml = Wasabi::Resolver.new("<xml/>").xml
|
19
|
+
xml.should == "<xml/>"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/spec/wasabi/wasabi_spec.rb
CHANGED
data/wasabi.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wasabi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
version: 2.
|
10
|
+
version: 2.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Harrington
|
@@ -15,10 +15,25 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-06-
|
18
|
+
date: 2012-06-08 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 15
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 0
|
30
|
+
version: "1.0"
|
31
|
+
name: httpi
|
32
|
+
type: :runtime
|
33
|
+
prerelease: false
|
34
|
+
requirement: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
22
37
|
none: false
|
23
38
|
requirements:
|
24
39
|
- - ">="
|
@@ -32,9 +47,9 @@ dependencies:
|
|
32
47
|
name: nokogiri
|
33
48
|
type: :runtime
|
34
49
|
prerelease: false
|
35
|
-
requirement: *
|
50
|
+
requirement: *id002
|
36
51
|
- !ruby/object:Gem::Dependency
|
37
|
-
version_requirements: &
|
52
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
38
53
|
none: false
|
39
54
|
requirements:
|
40
55
|
- - ~>
|
@@ -47,9 +62,9 @@ dependencies:
|
|
47
62
|
name: rake
|
48
63
|
type: :development
|
49
64
|
prerelease: false
|
50
|
-
requirement: *
|
65
|
+
requirement: *id003
|
51
66
|
- !ruby/object:Gem::Dependency
|
52
|
-
version_requirements: &
|
67
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
53
68
|
none: false
|
54
69
|
requirements:
|
55
70
|
- - ~>
|
@@ -62,9 +77,9 @@ dependencies:
|
|
62
77
|
name: rspec
|
63
78
|
type: :development
|
64
79
|
prerelease: false
|
65
|
-
requirement: *
|
80
|
+
requirement: *id004
|
66
81
|
- !ruby/object:Gem::Dependency
|
67
|
-
version_requirements: &
|
82
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
68
83
|
none: false
|
69
84
|
requirements:
|
70
85
|
- - ~>
|
@@ -77,7 +92,7 @@ dependencies:
|
|
77
92
|
name: mocha
|
78
93
|
type: :development
|
79
94
|
prerelease: false
|
80
|
-
requirement: *
|
95
|
+
requirement: *id005
|
81
96
|
description: A simple WSDL parser
|
82
97
|
email:
|
83
98
|
- me@rubiii.com
|
@@ -101,6 +116,7 @@ files:
|
|
101
116
|
- lib/wasabi/core_ext/string.rb
|
102
117
|
- lib/wasabi/document.rb
|
103
118
|
- lib/wasabi/parser.rb
|
119
|
+
- lib/wasabi/resolver.rb
|
104
120
|
- lib/wasabi/version.rb
|
105
121
|
- lib/wasabi/xpath_helper.rb
|
106
122
|
- spec/fixtures/authentication.wsdl
|
@@ -131,6 +147,7 @@ files:
|
|
131
147
|
- spec/wasabi/parser/no_namespace_spec.rb
|
132
148
|
- spec/wasabi/parser/no_target_namespace_spec.rb
|
133
149
|
- spec/wasabi/parser/symbolic_endpoint_spec.rb
|
150
|
+
- spec/wasabi/resolver_spec.rb
|
134
151
|
- spec/wasabi/wasabi_spec.rb
|
135
152
|
- wasabi.gemspec
|
136
153
|
homepage: https://github.com/rubiii/wasabi
|
@@ -195,4 +212,5 @@ test_files:
|
|
195
212
|
- spec/wasabi/parser/no_namespace_spec.rb
|
196
213
|
- spec/wasabi/parser/no_target_namespace_spec.rb
|
197
214
|
- spec/wasabi/parser/symbolic_endpoint_spec.rb
|
215
|
+
- spec/wasabi/resolver_spec.rb
|
198
216
|
- spec/wasabi/wasabi_spec.rb
|