smacks-savon 0.0.8 → 0.0.75

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -9,7 +9,7 @@ service method to receive.
9
9
 
10
10
  == Install
11
11
 
12
- $ gem install smacks-savon -s http://gems.github.com
12
+ $ gem install smacks-savon --s http://gems.github.com
13
13
 
14
14
  == Dependencies
15
15
 
data/lib/savon/service.rb CHANGED
@@ -40,9 +40,6 @@ module Savon
40
40
  # response.to_mash("//user/email")
41
41
  class Service
42
42
 
43
- # The logger to use.
44
- @@logger = nil
45
-
46
43
  # The Net::HTTP connection instance to use.
47
44
  attr_writer :http
48
45
 
@@ -61,35 +58,15 @@ module Savon
61
58
  @wsdl
62
59
  end
63
60
 
64
- # Sets the logger to use.
65
- def self.logger=(logger)
66
- @@logger = logger
67
- end
68
-
69
61
  private
70
62
 
71
63
  # Prepares and processes the SOAP request. Returns a Savon::Response object.
72
64
  def call_service
73
65
  headers = { "Content-Type" => "text/xml; charset=utf-8", "SOAPAction" => @action }
74
-
75
- ApricotEatsGorilla.setup do |s|
76
- s.nodes_to_namespace = wsdl.choice_elements
77
- s.node_namespace = "wsdl"
78
- end
79
66
  body = ApricotEatsGorilla.soap_envelope("wsdl" => wsdl.namespace_uri) do
80
- ApricotEatsGorilla["wsdl:#{@action}" => @options]
81
- end
82
-
83
- debug do |logger|
84
- logger.info "Request; #{@uri}"
85
- logger.info headers.map { |key, value| "#{key}: #{value}" }.join("\n")
86
- logger.info body
67
+ ApricotEatsGorilla["wsdl:#{@action}" => namespaced_options]
87
68
  end
88
69
  response = @http.request_post(@uri.path, body, headers)
89
- debug do |logger|
90
- logger.info "Response (Status #{response.code}):"
91
- logger.info response.body
92
- end
93
70
  Savon::Response.new(response)
94
71
  end
95
72
 
@@ -110,17 +87,26 @@ module Savon
110
87
  end
111
88
  end
112
89
 
113
- # Debug method. Outputs a given +message+ to the defined @@logger or
114
- # yields the @@logger to a +block+ in case one was given.
115
- def debug(message = nil)
116
- if @@logger
117
- if message
118
- @@logger.info(message)
119
- end
120
- if block_given?
121
- yield @@logger
90
+ # Checks if there were any choice elements found in the WSDL and namespaces
91
+ # the corresponding keys from the passed in Hash of options.
92
+ def namespaced_options
93
+ return @options if wsdl.choice_elements.empty?
94
+
95
+ options = {}
96
+ @options.each do |key, value|
97
+ key = "wsdl:#{key}" if wsdl.choice_elements.include? key.to_s
98
+
99
+ current = options[key]
100
+ case current
101
+ when Array
102
+ options[key] << value
103
+ when nil
104
+ options[key] = value
105
+ else
106
+ options[key] = [current.dup, value]
122
107
  end
123
108
  end
109
+ options
124
110
  end
125
111
 
126
112
  # Intercepts calls to SOAP service methods.
@@ -41,12 +41,4 @@ class SavonWsdlTest < Test::Unit::TestCase
41
41
  end
42
42
  end
43
43
 
44
- context "Savon::Wsdl with an invalid (non-WSDL) response" do
45
- should "raise an ArgumentError" do
46
- assert_raise ArgumentError do
47
- Savon::Wsdl.new(some_uri, http_mock("Non-WSDL response"))
48
- end
49
- end
50
- end
51
-
52
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smacks-savon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.75
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Harrington
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.3.8
33
+ version: 0.3.5
34
34
  version:
35
35
  description: Savon is a lightweight SOAP client.
36
36
  email:
@@ -46,7 +46,6 @@ files:
46
46
  - lib/savon/service.rb
47
47
  - lib/savon/wsdl.rb
48
48
  - lib/savon/response.rb
49
- - lib/savon/mash.rb
50
49
  has_rdoc: true
51
50
  homepage: http://github.com/smacks/savon
52
51
  post_install_message:
data/lib/savon/mash.rb DELETED
@@ -1,61 +0,0 @@
1
- module Savon
2
-
3
- # Savon::Mash converts a given Hash into an Object.
4
- class Mash
5
-
6
- # Loops through a given +hash+, stores each value in an instance variable
7
- # and creates getter and setter methods.
8
- #
9
- # === Parameters
10
- #
11
- # * +hash+ - The Hash to convert.
12
- def initialize(hash)
13
- hash.each do |key,value|
14
- value = Savon::Mash.new(value) if value.is_a? Hash
15
-
16
- if value.is_a? Array
17
- value = value.map do |item|
18
- if item.is_a?(Hash) then Savon::Mash.new(item) else item end
19
- end
20
- end
21
-
22
- set_instance_variable key, value
23
- define_reader key
24
- define_writer key
25
- end
26
- end
27
-
28
- private
29
-
30
- # Sets and instance variable with a given +name+ and +value+.
31
- #
32
- # === Parameters
33
- #
34
- # * +name+ - Name of the instance variable.
35
- # * +value+ - Value of the instance variable.
36
- def set_instance_variable(name, value)
37
- self.instance_variable_set("@#{name}", value)
38
- end
39
-
40
- # Defines a reader method for a given instance +variable+.
41
- #
42
- # === Parameters
43
- #
44
- # * +variable+ - Name of the instance variable.
45
- def define_reader(variable)
46
- method = proc { self.instance_variable_get("@#{variable}") }
47
- self.class.send(:define_method, variable, method)
48
- end
49
-
50
- # Defines a writer method for a given instance +variable+.
51
- #
52
- # === Parameters
53
- #
54
- # * +variable+ - Name of the instance variable.
55
- def define_writer(variable)
56
- method = proc { |value| self.instance_variable_set("@#{variable}", value) }
57
- self.class.send(:define_method, "#{variable}=", method)
58
- end
59
-
60
- end
61
- end