savon 0.9.11 → 0.9.14

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.
@@ -1,3 +1,24 @@
1
+ ## 0.9.14 (2012-06-07)
2
+
3
+ * Fix: [#292](https://github.com/rubiii/savon/issues/292) again
4
+
5
+ ## 0.9.13 (2012-06-07)
6
+
7
+ * Fix: [#292](https://github.com/rubiii/savon/issues/292)
8
+
9
+ ## 0.9.12 (2012-06-07)
10
+
11
+ * Re-added the log method setters to the new config object for backwards compatibility.
12
+ You should be able to configure the logger as you used to do.
13
+
14
+ ``` ruby
15
+ Savon.configure do |config|
16
+ config.log = false # disable logging
17
+ config.log_level = :info # changing the log level
18
+ config.logger = Rails.logger # using the Rails logger
19
+ end
20
+ ```
21
+
1
22
  ## 0.9.11 (2012-06-06)
2
23
 
3
24
  * Feature: [#264](https://github.com/rubiii/savon/pull/264) - Thanks to @hoverlover, Savon and Akami now support
@@ -91,7 +91,7 @@ module Savon
91
91
  response
92
92
  end
93
93
 
94
- private
94
+ private
95
95
 
96
96
  # Writer for the <tt>Savon::SOAP::XML</tt> object.
97
97
  attr_writer :soap
@@ -1,25 +1,44 @@
1
1
  require "savon/logger"
2
+ require "savon/null_logger"
2
3
  require "savon/hooks/group"
3
4
  require "savon/soap"
4
5
 
5
6
  module Savon
6
- Config = Struct.new(:logger, :pretty_print_xml, :raise_errors, :soap_version, :env_namespace, :soap_header) do
7
+ Config = Struct.new(:_logger, :pretty_print_xml, :raise_errors, :soap_version, :env_namespace, :soap_header) do
7
8
 
8
9
  def self.default
9
10
  config = new
10
- config.logger = Logger.new
11
+ config._logger = Logger.new
11
12
  config.raise_errors = true
12
- config.soap_version = SOAP::DefaultVersion
13
+ config.soap_version = SOAP::DEFAULT_VERSION
13
14
  config
14
15
  end
15
16
 
17
+ alias_method :logger, :_logger
18
+
19
+ def logger=(logger)
20
+ _logger.subject = logger
21
+ end
22
+
23
+ def log_level=(level)
24
+ _logger.level = level
25
+ end
26
+
27
+ def log=(log)
28
+ if log == true
29
+ self._logger = Logger.new
30
+ else
31
+ self._logger = NullLogger.new
32
+ end
33
+ end
34
+
16
35
  def hooks
17
36
  @hooks ||= Hooks::Group.new
18
37
  end
19
38
 
20
39
  def clone
21
40
  config = super
22
- config.logger = config.logger.clone
41
+ config._logger = config._logger.clone
23
42
  config
24
43
  end
25
44
 
@@ -15,10 +15,6 @@ module Savon
15
15
  log_raw LogMessage.new(message, filter, options).to_s
16
16
  end
17
17
 
18
- def log_raw(message)
19
- subject.send(level, message)
20
- end
21
-
22
18
  attr_writer :subject, :level, :filter
23
19
 
24
20
  def subject
@@ -33,5 +29,11 @@ module Savon
33
29
  @filter ||= []
34
30
  end
35
31
 
32
+ private
33
+
34
+ def log_raw(message)
35
+ subject.send(level, message)
36
+ end
37
+
36
38
  end
37
39
  end
@@ -24,7 +24,7 @@ module Savon
24
24
  end
25
25
  end
26
26
 
27
- private
27
+ private
28
28
 
29
29
  # Defines a class-level SOAP action method.
30
30
  def define_class_action(action)
@@ -0,0 +1,10 @@
1
+ require "savon/logger"
2
+
3
+ module Savon
4
+ class NullLogger < Logger
5
+
6
+ def log(*)
7
+ end
8
+
9
+ end
10
+ end
@@ -6,13 +6,13 @@ module Savon
6
6
  module SOAP
7
7
 
8
8
  # Default SOAP version.
9
- DefaultVersion = 1
9
+ DEFAULT_VERSION = 1
10
10
 
11
11
  # Supported SOAP versions.
12
- Versions = 1..2
12
+ VERSIONS = 1..2
13
13
 
14
14
  # SOAP namespaces by SOAP version.
15
- Namespace = {
15
+ NAMESPACE = {
16
16
  1 => "http://schemas.xmlsoap.org/soap/envelope/",
17
17
  2 => "http://www.w3.org/2003/05/soap-envelope"
18
18
  }
@@ -33,7 +33,7 @@ module Savon
33
33
  @hash ||= Nori.parse(http.body)[:envelope][:body]
34
34
  end
35
35
 
36
- private
36
+ private
37
37
 
38
38
  # Returns whether the response contains a SOAP 1.1 fault.
39
39
  def soap1_fault?
@@ -2,10 +2,12 @@ require "savon/error"
2
2
 
3
3
  module Savon
4
4
  module SOAP
5
+
5
6
  # = Savon::SOAP::InvalidResponseError
6
7
  #
7
8
  # Represents an error when the response was not a valid SOAP envelope.
8
9
  class InvalidResponseError < Error
9
10
  end
11
+
10
12
  end
11
13
  end
@@ -10,7 +10,7 @@ module Savon
10
10
  class Request
11
11
 
12
12
  # Content-Types by SOAP version.
13
- ContentType = { 1 => "text/xml;charset=UTF-8", 2 => "application/soap+xml;charset=UTF-8" }
13
+ CONTENT_TYPE = { 1 => "text/xml;charset=UTF-8", 2 => "application/soap+xml;charset=UTF-8" }
14
14
 
15
15
  # Expects an <tt>HTTPI::Request</tt> and a <tt>Savon::SOAP::XML</tt> object
16
16
  # to execute a SOAP request and returns the response.
@@ -36,7 +36,7 @@ module Savon
36
36
  end
37
37
  end
38
38
 
39
- private
39
+ private
40
40
 
41
41
  # Configures a given +http+ from the +soap+ object.
42
42
  def configure(http)
@@ -55,7 +55,7 @@ module Savon
55
55
  http.body = soap.to_xml
56
56
  end
57
57
 
58
- http.headers["Content-Type"] = ContentType[soap.version]
58
+ http.headers["Content-Type"] = CONTENT_TYPE[soap.version]
59
59
  http.headers["Content-Length"] = soap.to_xml.bytesize.to_s
60
60
  http
61
61
  end
@@ -101,7 +101,7 @@ module Savon
101
101
  doc.xpath(path, namespaces || xml_namespaces)
102
102
  end
103
103
 
104
- private
104
+ private
105
105
 
106
106
  def raise_errors
107
107
  raise soap_fault if soap_fault?
@@ -20,7 +20,7 @@ module Savon
20
20
  class XML
21
21
 
22
22
  # XML Schema Type namespaces.
23
- SchemaTypes = {
23
+ SCHEMA_TYPES = {
24
24
  "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema",
25
25
  "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance"
26
26
  }
@@ -40,7 +40,7 @@ module Savon
40
40
 
41
41
  # Sets the SOAP +version+.
42
42
  def version=(version)
43
- raise ArgumentError, "Invalid SOAP version: #{version}" unless SOAP::Versions.include? version
43
+ raise ArgumentError, "Invalid SOAP version: #{version}" unless SOAP::VERSIONS.include? version
44
44
  @version = version
45
45
  end
46
46
 
@@ -73,7 +73,7 @@ module Savon
73
73
  @namespaces ||= begin
74
74
  key = ["xmlns"]
75
75
  key << env_namespace if env_namespace && env_namespace != ""
76
- { key.join(":") => SOAP::Namespace[version] }
76
+ { key.join(":") => SOAP::NAMESPACE[version] }
77
77
  end
78
78
  end
79
79
 
@@ -175,7 +175,7 @@ module Savon
175
175
  end
176
176
  end
177
177
 
178
- private
178
+ private
179
179
 
180
180
  # Returns a new <tt>Builder::XmlMarkup</tt> object.
181
181
  def builder(directive_tag = :xml, attrs = { :encoding => encoding })
@@ -196,7 +196,7 @@ module Savon
196
196
 
197
197
  # Returns the complete Hash of namespaces.
198
198
  def complete_namespaces
199
- defaults = SchemaTypes.dup
199
+ defaults = SCHEMA_TYPES.dup
200
200
  defaults["xmlns:#{namespace_identifier}"] = namespace if namespace
201
201
  defaults.merge namespaces
202
202
  end
@@ -1,5 +1,5 @@
1
1
  module Savon
2
2
 
3
- Version = "0.9.11"
3
+ VERSION = "0.9.14"
4
4
 
5
5
  end
@@ -18,7 +18,7 @@ module Savon
18
18
  # Sets the <tt>HTTPI::Request</tt> for remote WSDL documents.
19
19
  attr_writer :request
20
20
 
21
- private
21
+ private
22
22
 
23
23
  # Sets up and returns the <tt>HTTPI::Request</tt>.
24
24
  def request
@@ -30,7 +30,7 @@ module Savon
30
30
  # Resolves and returns the raw WSDL document.
31
31
  def resolve_document
32
32
  case document
33
- when /^http[s]?:/ then
33
+ when /^http[s]?:/ then
34
34
  response = HTTPI.get(request)
35
35
  if response.error?
36
36
  raise Savon::HTTP::Error.new(response)
@@ -6,7 +6,7 @@ require "savon/version"
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "savon"
9
- s.version = Savon::Version
9
+ s.version = Savon::VERSION
10
10
  s.authors = "Daniel Harrington"
11
11
  s.email = "me@rubiii.com"
12
12
  s.homepage = "http://savonrb.com"
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
 
18
18
  s.add_dependency "builder", ">= 2.1.2"
19
19
  s.add_dependency "nori", "~> 1.1"
20
- s.add_dependency "httpi", "~> 0.9"
20
+ s.add_dependency "httpi", "~> 1.0"
21
21
  s.add_dependency "wasabi", "~> 2.2"
22
22
  s.add_dependency "akami", "~> 1.1"
23
23
  s.add_dependency "gyoku", ">= 0.4.0"
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe "Integration" do
4
+
5
+ it "returns the result in a CDATA tag" do
6
+ client = Savon.client("http://www.webservicex.net/stockquote.asmx?WSDL")
7
+ response = client.request(:get_quote, :body => { :symbol => "AAPL" })
8
+
9
+ cdata = response[:get_quote_response][:get_quote_result]
10
+ result = Nori.parse(cdata)
11
+ result[:stock_quotes][:stock][:symbol].should == "AAPL"
12
+ end
13
+
14
+ it "passes Strings as they are" do
15
+ client = Savon.client("http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx?wsdl")
16
+ response = client.request(:verify_email, :body => { :email => "soap@example.com", "LicenseKey" => "?" })
17
+
18
+ response_text = response[:verify_email_response][:verify_email_result][:response_text]
19
+ response_text.should == "Email Domain Not Found"
20
+ end
21
+
22
+ end
@@ -246,7 +246,7 @@ describe Savon::Client do
246
246
  HTTPI.stubs(:post).returns(new_response(:headers => { "Set-Cookie" => "second-cookie=oatmeal; Path=/; HttpOnly" }))
247
247
  client.request :nibble
248
248
 
249
- client.http.headers["Cookie"].should == "some-cookie=choc-chip;second-cookie=oatmeal"
249
+ client.http.headers["Cookie"].split(";").should include("some-cookie=choc-chip", "second-cookie=oatmeal")
250
250
  end
251
251
 
252
252
  end
@@ -2,19 +2,37 @@ require "spec_helper"
2
2
 
3
3
  describe Savon::Config do
4
4
 
5
- describe "#clone" do
6
- subject do
7
- config = Savon::Config.new
8
- config.logger = Savon::Logger.new
9
- config
10
- end
5
+ let(:config) {
6
+ config = Savon::Config.new
7
+ config._logger = Savon::Logger.new
8
+ config
9
+ }
11
10
 
11
+ describe "#clone" do
12
12
  it "clones the logger" do
13
- logger = subject.logger
14
- clone = subject.clone
13
+ logger = config.logger
14
+ clone = config.clone
15
15
 
16
16
  logger.should_not equal(clone.logger)
17
17
  end
18
18
  end
19
19
 
20
+ it "allows to change the logger" do
21
+ logger = Logger.new("/dev/null")
22
+ config.logger = logger
23
+ config._logger.subject.should equal(logger)
24
+ end
25
+
26
+ it "allows to change the log level" do
27
+ config.log_level = :info
28
+ config._logger.level.should == :info
29
+ end
30
+
31
+ it "allows to enable/disable logging" do
32
+ config.log = false
33
+ config._logger.should be_a(Savon::NullLogger)
34
+ config.log = true
35
+ config._logger.should be_a(Savon::Logger)
36
+ end
37
+
20
38
  end
@@ -7,7 +7,6 @@ describe Savon::Model do
7
7
  end
8
8
 
9
9
  describe ":model_soap_response hook" do
10
-
11
10
  before(:all) do
12
11
  model.actions :get_user, "GetAllUsers"
13
12
  end
@@ -24,75 +23,57 @@ describe Savon::Model do
24
23
  model.client.stubs(:request).returns("world") #
25
24
  model.get_user.should == "hello world"
26
25
  end
27
-
28
26
  end
29
27
 
30
28
  describe ".client" do
31
-
32
- it "passes a given block to a new Savon::Client"
33
-
34
29
  it "memoizes the Savon::Client" do
35
30
  model.client.should equal(model.client)
36
31
  end
37
-
38
32
  end
39
33
 
40
34
  describe ".config" do
41
-
42
35
  it "memoizes a clone of the global config" do
43
36
  model.config.should be_a(Savon::Config)
44
37
  model.config.should_not equal(Savon.config)
45
38
  end
46
-
47
39
  end
48
40
 
49
41
  describe ".endpoint" do
50
-
51
42
  it "sets the SOAP endpoint" do
52
43
  model.endpoint "http://example.com"
53
44
  model.client.wsdl.endpoint.should == "http://example.com"
54
45
  end
55
-
56
46
  end
57
47
 
58
48
  describe ".namespace" do
59
-
60
49
  it "sets the target namespace" do
61
50
  model.namespace "http://v1.example.com"
62
51
  model.client.wsdl.namespace.should == "http://v1.example.com"
63
52
  end
64
-
65
53
  end
66
54
 
67
55
  describe ".document" do
68
-
69
56
  it "sets the WSDL document" do
70
57
  model.document "http://example.com/?wsdl"
71
58
  model.client.wsdl.document.should == "http://example.com/?wsdl"
72
59
  end
73
-
74
60
  end
75
61
 
76
62
  describe ".headers" do
77
-
78
63
  it "sets the HTTP headers" do
79
64
  model.headers("Accept-Charset" => "utf-8")
80
65
  model.client.http.headers.should == { "Accept-Charset" => "utf-8" }
81
66
  end
82
-
83
67
  end
84
68
 
85
69
  describe ".basic_auth" do
86
-
87
70
  it "sets HTTP Basic auth credentials" do
88
71
  model.basic_auth "login", "password"
89
72
  model.client.http.auth.basic.should == ["login", "password"]
90
73
  end
91
-
92
74
  end
93
75
 
94
76
  describe ".wsse_auth" do
95
-
96
77
  it "sets WSSE auth credentials" do
97
78
  model.wsse_auth "login", "password", :digest
98
79
 
@@ -100,11 +81,9 @@ describe Savon::Model do
100
81
  model.client.wsse.password.should == "password"
101
82
  model.client.wsse.should be_digest
102
83
  end
103
-
104
84
  end
105
85
 
106
86
  describe ".actions" do
107
-
108
87
  before(:all) do
109
88
  model.actions :get_user, "GetAllUsers"
110
89
  end
@@ -118,7 +97,6 @@ describe Savon::Model do
118
97
  end
119
98
 
120
99
  context "(class-level)" do
121
-
122
100
  it "executes SOAP requests with a given body" do
123
101
  model.client.expects(:request).with(:wsdl, :get_user, :body => { :id => 1 })
124
102
  model.get_user :id => 1
@@ -131,28 +109,21 @@ describe Savon::Model do
131
109
  end
132
110
 
133
111
  context "(instance-level)" do
134
-
135
112
  it "delegates to the corresponding class method" do
136
113
  model.expects(:get_all_users).with(:active => true)
137
114
  model.new.get_all_users :active => true
138
115
  end
139
-
140
116
  end
141
-
142
117
  end
143
118
 
144
119
  describe "#client" do
145
-
146
120
  it "returns the class-level Savon::Client" do
147
121
  model.new.client.should == model.client
148
122
  end
149
-
150
123
  end
151
124
 
152
125
  describe "overwriting action methods" do
153
-
154
126
  context "(class-level)" do
155
-
156
127
  let(:supermodel) do
157
128
  supermodel = model.dup
158
129
  supermodel.actions :get_user
@@ -171,11 +142,9 @@ describe Savon::Model do
171
142
 
172
143
  supermodel.get_user :id => 1
173
144
  end
174
-
175
145
  end
176
146
 
177
147
  context "(instance-level)" do
178
-
179
148
  let(:supermodel) do
180
149
  supermodel = model.dup
181
150
  supermodel.actions :get_user
@@ -195,9 +164,7 @@ describe Savon::Model do
195
164
 
196
165
  supermodel.get_user :id => 1
197
166
  end
198
-
199
167
  end
200
-
201
168
  end
202
169
 
203
170
  end
@@ -19,7 +19,7 @@ describe Savon::SOAP::Request do
19
19
  end
20
20
 
21
21
  it "contains the content type for each supported SOAP version" do
22
- content_type = Savon::SOAP::Request::ContentType
22
+ content_type = Savon::SOAP::Request::CONTENT_TYPE
23
23
  content_type[1].should == "text/xml;charset=UTF-8"
24
24
  content_type[2].should == "application/soap+xml;charset=UTF-8"
25
25
  end
@@ -42,12 +42,12 @@ describe Savon::SOAP::Request do
42
42
  end
43
43
 
44
44
  it "sets the Content-Type header for SOAP 1.1" do
45
- soap_request.http.headers["Content-Type"].should == Savon::SOAP::Request::ContentType[1]
45
+ soap_request.http.headers["Content-Type"].should == Savon::SOAP::Request::CONTENT_TYPE[1]
46
46
  end
47
47
 
48
48
  it "sets the Content-Type header for SOAP 1.2" do
49
49
  soap_xml.version = 2
50
- soap_request.http.headers["Content-Type"].should == Savon::SOAP::Request::ContentType[2]
50
+ soap_request.http.headers["Content-Type"].should == Savon::SOAP::Request::CONTENT_TYPE[2]
51
51
  end
52
52
 
53
53
  it "sets the Content-Length header" do
@@ -3,14 +3,14 @@ require "spec_helper"
3
3
  describe Savon::SOAP do
4
4
 
5
5
  it "should contain the SOAP namespace for each supported SOAP version" do
6
- Savon::SOAP::Versions.each do |soap_version|
7
- Savon::SOAP::Namespace[soap_version].should be_a(String)
8
- Savon::SOAP::Namespace[soap_version].should_not be_empty
6
+ Savon::SOAP::VERSIONS.each do |soap_version|
7
+ Savon::SOAP::NAMESPACE[soap_version].should be_a(String)
8
+ Savon::SOAP::NAMESPACE[soap_version].should_not be_empty
9
9
  end
10
10
  end
11
11
 
12
12
  it "should contain a Rage of supported SOAP versions" do
13
- Savon::SOAP::Versions.should == (1..2)
13
+ Savon::SOAP::VERSIONS.should == (1..2)
14
14
  end
15
15
 
16
16
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: savon
3
3
  version: !ruby/object:Gem::Version
4
- hash: 45
4
+ hash: 39
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 11
10
- version: 0.9.11
9
+ - 14
10
+ version: 0.9.14
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Harrington
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-06-06 00:00:00 Z
18
+ date: 2012-06-07 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -54,11 +54,11 @@ dependencies:
54
54
  requirements:
55
55
  - - ~>
56
56
  - !ruby/object:Gem::Version
57
- hash: 25
57
+ hash: 15
58
58
  segments:
59
+ - 1
59
60
  - 0
60
- - 9
61
- version: "0.9"
61
+ version: "1.0"
62
62
  name: httpi
63
63
  type: :runtime
64
64
  prerelease: false
@@ -214,6 +214,7 @@ files:
214
214
  - lib/savon/log_message.rb
215
215
  - lib/savon/logger.rb
216
216
  - lib/savon/model.rb
217
+ - lib/savon/null_logger.rb
217
218
  - lib/savon/soap.rb
218
219
  - lib/savon/soap/fault.rb
219
220
  - lib/savon/soap/invalid_response_error.rb
@@ -237,7 +238,7 @@ files:
237
238
  - spec/fixtures/wsdl/multiple_namespaces.xml
238
239
  - spec/fixtures/wsdl/multiple_types.xml
239
240
  - spec/fixtures/wsdl/taxcloud.xml
240
- - spec/integration/stockquote_spec.rb
241
+ - spec/integration/request_spec.rb
241
242
  - spec/savon/client_spec.rb
242
243
  - spec/savon/config_spec.rb
243
244
  - spec/savon/core_ext/string_spec.rb
@@ -1,14 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "webservicex/stockquote" do
4
-
5
- it "returns the result in a CDATA tag" do
6
- client = Savon.client("http://www.webservicex.net/stockquote.asmx?WSDL")
7
- response = client.request(:get_quote, :body => { :symbol => "AAPL" })
8
-
9
- cdata = response[:get_quote_response][:get_quote_result]
10
- result = Nori.parse(cdata)
11
- result[:stock_quotes][:stock][:symbol].should == "AAPL"
12
- end
13
-
14
- end