savon-xaop 0.7.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/CHANGELOG +124 -0
  2. data/README.textile +75 -0
  3. data/Rakefile +45 -0
  4. data/lib/savon/client.rb +84 -0
  5. data/lib/savon/core_ext/datetime.rb +8 -0
  6. data/lib/savon/core_ext/hash.rb +78 -0
  7. data/lib/savon/core_ext/net_http.rb +20 -0
  8. data/lib/savon/core_ext/object.rb +21 -0
  9. data/lib/savon/core_ext/string.rb +47 -0
  10. data/lib/savon/core_ext/symbol.rb +8 -0
  11. data/lib/savon/core_ext/uri.rb +10 -0
  12. data/lib/savon/core_ext.rb +3 -0
  13. data/lib/savon/request.rb +160 -0
  14. data/lib/savon/response.rb +108 -0
  15. data/lib/savon/soap.rb +176 -0
  16. data/lib/savon/wsdl.rb +122 -0
  17. data/lib/savon/wsse.rb +136 -0
  18. data/lib/savon.rb +34 -0
  19. data/spec/basic_spec_helper.rb +12 -0
  20. data/spec/endpoint_helper.rb +22 -0
  21. data/spec/fixtures/response/response_fixture.rb +36 -0
  22. data/spec/fixtures/response/xml/authentication.xml +14 -0
  23. data/spec/fixtures/response/xml/multi_ref.xml +39 -0
  24. data/spec/fixtures/response/xml/soap_fault.xml +8 -0
  25. data/spec/fixtures/response/xml/soap_fault12.xml +18 -0
  26. data/spec/fixtures/wsdl/wsdl_fixture.rb +37 -0
  27. data/spec/fixtures/wsdl/xml/authentication.xml +63 -0
  28. data/spec/fixtures/wsdl/xml/namespaced_actions.xml +307 -0
  29. data/spec/fixtures/wsdl/xml/no_namespace.xml +115 -0
  30. data/spec/http_stubs.rb +23 -0
  31. data/spec/integration/http_basic_auth_spec.rb +16 -0
  32. data/spec/integration/server.rb +51 -0
  33. data/spec/savon/client_spec.rb +77 -0
  34. data/spec/savon/core_ext/datetime_spec.rb +12 -0
  35. data/spec/savon/core_ext/hash_spec.rb +138 -0
  36. data/spec/savon/core_ext/net_http_spec.rb +38 -0
  37. data/spec/savon/core_ext/object_spec.rb +40 -0
  38. data/spec/savon/core_ext/string_spec.rb +68 -0
  39. data/spec/savon/core_ext/symbol_spec.rb +11 -0
  40. data/spec/savon/core_ext/uri_spec.rb +15 -0
  41. data/spec/savon/request_spec.rb +89 -0
  42. data/spec/savon/response_spec.rb +137 -0
  43. data/spec/savon/savon_spec.rb +23 -0
  44. data/spec/savon/soap_spec.rb +171 -0
  45. data/spec/savon/wsdl_spec.rb +84 -0
  46. data/spec/savon/wsse_spec.rb +132 -0
  47. data/spec/spec_helper.rb +5 -0
  48. metadata +175 -0
data/CHANGELOG ADDED
@@ -0,0 +1,124 @@
1
+ == 0.7.2 (2010-01-17)
2
+ * Exposed the Net::HTTP response (added by Kevin Ingolfsland). Use the "http" accessor (response.http) on your
3
+ Savon::Response to access the Net::HTTP response object.
4
+ * Fix for Github issue #21 (savon is stripping ?SOAP off the end of WSDL locations).
5
+ * Fix for Github issue #22 (REXML::ParseException parsing 401 Unauthorized response body).
6
+ * Fix for Github issue #19 (Unable to set attribute in name-spaced WSSE password element).
7
+ * Added support for global header and namespaces. See Github issue #9 (Setting headers and namespaces).
8
+
9
+ == 0.7.1 (2010-01-10)
10
+ * The Hash of HTTP headers for SOAP calls is now public via Savon::Request#headers.
11
+ Patch for: http://github.com/rubiii/savon/issues/#issue/8
12
+
13
+ == 0.7.0 (2010-01-09)
14
+ This version comes with several changes to the public API!
15
+ Pay attention to the following list and read the updated Wiki: http://wiki.github.com/rubiii/savon
16
+
17
+ * Changed how Savon::WSDL can be disabled. Instead of disabling the WSDL globally/per request via two
18
+ different methods, you now simply append an exclamation mark (!) to your SOAP call: client.get_all_users!
19
+ Make sure you know what you're doing because when the WSDL is disabled, Savon does not know about which
20
+ SOAP actions are valid and just dispatches everything.
21
+ * The Net::HTTP object used by Savon::Request to retrieve WSDL documents and execute SOAP calls is now public.
22
+ While this makes the library even more flexible, it also comes with two major changes:
23
+ * SSL client authentication needs to be defined directly on the Net::HTTP object:
24
+ client.request.http.client_cert = ...
25
+ I added a shortcut method for setting all options through a Hash similar to the previous implementation:
26
+ client.request.http.ssl_client_auth :client_cert => ...
27
+ * Open and read timeouts also need to be set on the Net::HTTP object:
28
+ client.request.http.open_timeout = 30
29
+ client.request.http.read_timeout = 30
30
+ * Please refer to the Net::HTTP documentation for more details:
31
+ http://www.ruby-doc.org/stdlib/libdoc/net/http/rdoc/index.html
32
+ * Thanks to JulianMorrison, Savon now supports HTTP basic authentication:
33
+ client.request.http.basic_auth "username", "password"
34
+ * Julian also added a way to explicitly specify the order of Hash keys and values, so you should now be able
35
+ to work with services requiring a specific order of input parameters while still using Hash input.
36
+ For example: client.find_user { |soap| soap.body = { :name => "Lucy", :id => 666, :@inorder => [:id, :name] } }
37
+ * Savon::Response#to_hash now returns the content inside of "soap:Body" instead of trying to go one level
38
+ deeper and return it's content. The previous implementation only worked when the "soap:Body" element
39
+ contained a single child. See: http://github.com/rubiii/savon/issues#issue/17
40
+ * Added Savon::SOAP#namespace as a shortcut for setting the "xmlns:wsdl" namespace.
41
+ Usage example: soap.namespace = "http://example.com"
42
+
43
+ == 0.6.8 (2010-01-01)
44
+ * Improved specifications for various kinds of WSDL documents.
45
+ * Added support for SOAP endpoints which are different than the WSDL endpoint of a service.
46
+ * Changed how SOAP actions and inputs are retrieved from the WSDL documents. This might break a few existing
47
+ implementations, but makes Savon work well with even more services. If this change breaks your implementation,
48
+ please take a look at the +action+ and +input+ methods of the Savon::SOAP object.
49
+ One specific problem I know of is working with the createsend WSDL and its namespaced actions.
50
+ To make it work, call the SOAP action without namespace and specify the input manually:
51
+ client.get_api_key { |soap| soap.input = "User.GetApiKey" }
52
+
53
+ == 0.6.7 (2009-12-18)
54
+ * Implemented support for a proxy server. The proxy URI can be set through an optional Hash of options passed
55
+ to instantiating Savon::Client (Dave Woodward <dave@futuremint.com>)
56
+ * Implemented support for SSL client authentication. Settings can be set through an optional Hash of arguments
57
+ passed to instantiating Savon::Client (colonhyphenp)
58
+ * Patch for issue #10 (Problem with operation tags without a namespace).
59
+
60
+ == 0.6.6 (2009-12-14)
61
+ * Default to use the name of the SOAP action (the method called in a client) in lowerCamelCase for SOAP action
62
+ and input when Savon::WSDL is disabled. You still need to specify soap.action and maybe soap.input in case
63
+ your SOAP actions are named any different.
64
+
65
+ == 0.6.5 (2009-12-13)
66
+ * Added an open_timeout method to Savon::Request.
67
+
68
+ == 0.6.4 (2009-12-13)
69
+ * Refactored specs to be less unit-like.
70
+ * Added a getter for the Savon::Request to Savon::Client and a read_timeout setter for HTTP requests.
71
+ * wsdl.soap_actions now returns an Array of SOAP actions. For the previous "mapping" please use wsdl.operations.
72
+ * Replaced WSDL document with stream parsing.
73
+
74
+ Benchmarks (1000 SOAP calls):
75
+
76
+ user system total real
77
+ 0.6.4 72.180000 8.280000 80.460000 (750.799011)
78
+ 0.6.3 192.900000 19.630000 212.530000 (914.031865)
79
+
80
+ == 0.6.3 (2009-12-11)
81
+ * Removing 2 ruby deprecation warnings for parenthesized arguments. (Dave Woodward <dave@futuremint.com>)
82
+ * Added global and per request options for disabling Savon::WSDL.
83
+
84
+ Benchmarks (1000 SOAP calls):
85
+
86
+ user system total real
87
+ WSDL 192.900000 19.630000 212.530000 (914.031865)
88
+ disabled WSDL 5.680000 1.340000 7.020000 (298.265318)
89
+
90
+ * Improved XPath expressions for parsing the WSDL document.
91
+
92
+ Benchmarks (1000 SOAP calls):
93
+
94
+ user system total real
95
+ 0.6.3 192.900000 19.630000 212.530000 (914.031865)
96
+ 0.6.2 574.720000 78.380000 653.100000 (1387.778539)
97
+
98
+ == 0.6.2 (2009-12-06)
99
+ * Added support for changing the name of the SOAP input node.
100
+ * Added a CHANGELOG.
101
+
102
+ == 0.6.1 (2009-12-06)
103
+ * Fixed a problem with WSSE credentials, where every request contained a WSSE authentication header.
104
+
105
+ == 0.6.0 (2009-12-06)
106
+ * method_missing now yields the SOAP and WSSE objects to a given block.
107
+ * The response_process (which previously was a block passed to method_missing) was replaced by Savon::Response.
108
+ * Improved SOAP action handling (another problem that came up with issue #1).
109
+
110
+ == 0.5.3 (2009-11-30)
111
+ * Patch for issue #2 (NoMethodError: undefined method `invalid!' for Savon::WSDL)
112
+
113
+ == 0.5.2 (2009-11-30)
114
+ * Patch for issue #1 (Calls fail if api methods have periods in them)
115
+
116
+ == 0.5.1 (2009-11-29)
117
+ * Optimized default response process.
118
+ * Added WSSE settings via defaults.
119
+ * Added SOAP fault and HTTP error handling.
120
+ * Improved documentation
121
+ * Added specs
122
+
123
+ == 0.5.0 (2009-11-29)
124
+ * Complete rewrite.
data/README.textile ADDED
@@ -0,0 +1,75 @@
1
+ h1. Savon
2
+
3
+ h4. Heavy metal Ruby SOAP client library
4
+
5
+ p. "RDoc":http://rdoc.info/projects/rubiii/savon | "Wiki":http://wiki.github.com/rubiii/savon | "ToDo":http://rubiii.tadalist.com/lists/1459816/public | "Metrics":http://getcaliper.com/caliper/project?repo=git://github.com/rubiii/savon.git
6
+
7
+ h2. Warning
8
+
9
+ p. Savon 0.7.0 comes with several changes to the public API. Pay attention to the CHANGELOG and the updated Wiki.
10
+
11
+ h2. Installation
12
+
13
+ bc. $ gem install savon
14
+
15
+ p. Savon expects you to be familiar with SOAP, WSDL and tools like soapUI.
16
+
17
+ h2. Instantiate a client
18
+
19
+ p. Instantiate Savon::Client, passing in the WSDL of your service.
20
+
21
+ bc. client = Savon::Client.new "http://example.com/UserService?wsdl"
22
+
23
+ p. More information: "Client":http://wiki.github.com/rubiii/savon/client
24
+
25
+ h2. Calling a SOAP action
26
+
27
+ p. Assuming your service applies to the defaults, you can now call any available SOAP action.
28
+
29
+ bc. response = client.get_all_users
30
+
31
+ p. Savon lets you call SOAP actions using snake_case, because even though they will propably be written in lowerCamelCase or CamelCase, it just feels much more natural.
32
+
33
+ h2. The WSDL object
34
+
35
+ p. Savon::WSDL represents the WSDL of your service, including information like the namespace URI and available SOAP actions.
36
+
37
+ bc. client.wsdl.soap_actions
38
+ => [:get_all_users, :get_user_by_id, :user_magic]
39
+
40
+ p. More information: "WSDL":http://wiki.github.com/rubiii/savon/wsdl
41
+
42
+ h2. The SOAP object
43
+
44
+ p. Savon::SOAP represents the SOAP request. Pass a block to your SOAP call and the SOAP object is passed to it as the first argument. The object allows setting the SOAP version, header, body and namespaces per request.
45
+
46
+ bc. response = client.get_user_by_id { |soap| soap.body = { :id => 666 } }
47
+
48
+ p. More information: "SOAP":http://wiki.github.com/rubiii/savon/soap
49
+
50
+ h2. The WSSE object
51
+
52
+ p. Savon::WSSE represents WSSE authentication. Pass a block to your SOAP call and the WSSE object is passed to it as the second argument. The object allows setting the WSSE username, password and whether to use digest authentication.
53
+
54
+ bc. response = client.get_user_by_id do |soap, wsse|
55
+ wsse.username = "gorilla"
56
+ wsse.password = "secret"
57
+ soap.body = { :id => 666 }
58
+ end
59
+
60
+ p. More information: "WSSE":http://wiki.github.com/rubiii/savon/wsse
61
+
62
+ h2. The Response object
63
+
64
+ p. Savon::Response represents the HTTP and SOAP response. It contains and raises errors in case of an HTTP error or SOAP fault (unless disabled). Also you can get the response as XML (for parsing it with an XML library) or translated into a Hash.
65
+ More information: "Response":http://wiki.github.com/rubiii/savon/response
66
+
67
+ h2. HTTP errors and SOAP faults
68
+
69
+ p. Savon raises a Savon::SOAPFault in case of a SOAP fault and a Savon::HTTPError in case of an HTTP error.
70
+ More information: "Errors":http://wiki.github.com/rubiii/savon/errors
71
+
72
+ h2. Logging
73
+
74
+ p. Savon logs each request and response to STDOUT. But there are a couple of options to change the default behavior.
75
+ More information: "Logging":http://wiki.github.com/rubiii/savon/logging
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ require "rake"
2
+ require "spec/rake/spectask"
3
+ require "spec/rake/verify_rcov"
4
+ require "rake/rdoctask"
5
+
6
+ task :default => :spec_verify
7
+
8
+ Spec::Rake::SpecTask.new do |spec|
9
+ spec.spec_files = FileList["spec/{savon}/**/*_spec.rb"]
10
+ spec.spec_opts << "--color"
11
+ spec.libs += ["lib", "spec"]
12
+ spec.rcov = true
13
+ spec.rcov_dir = "rcov"
14
+ end
15
+
16
+ RCov::VerifyTask.new(:spec_verify => :spec) do |verify|
17
+ verify.threshold = 100.0
18
+ verify.index_html = "rcov/index.html"
19
+ end
20
+
21
+ desc "Run integration specs using WEBrick"
22
+ task :spec_integration do
23
+ pid = fork { exec "ruby spec/integration/server.rb" }
24
+ sleep 10 # wait until the server is actually ready
25
+ begin
26
+ task(:run_integration_spec).invoke
27
+ ensure
28
+ Process.kill "TERM", pid
29
+ Process.wait pid
30
+ end
31
+ end
32
+
33
+ desc "" # make this task invisible for "rake -T"
34
+ Spec::Rake::SpecTask.new(:run_integration_spec) do |spec|
35
+ spec.spec_files = FileList["spec/{integration}/**/*_spec.rb"]
36
+ spec.spec_opts << "--color"
37
+ spec.libs += ["lib", "spec"]
38
+ end
39
+
40
+ Rake::RDocTask.new do |rdoc|
41
+ rdoc.title = "Savon"
42
+ rdoc.rdoc_dir = "rdoc"
43
+ rdoc.rdoc_files.include("lib/**/*.rb")
44
+ rdoc.options = ["--line-numbers", "--inline-source"]
45
+ end
@@ -0,0 +1,84 @@
1
+ module Savon
2
+
3
+ # == Savon::Client
4
+ #
5
+ # Heavy metal Ruby SOAP client library. Minimizes the overhead of working
6
+ # with SOAP services and XML.
7
+ class Client
8
+
9
+ # Expects a SOAP +endpoint+ String. Also accepts an optional Hash of
10
+ # +options+ for specifying a proxy server and SSL client authentication.
11
+ def initialize(endpoint, options = {})
12
+ @request = Request.new endpoint, options
13
+ @wsdl = WSDL.new @request
14
+ end
15
+
16
+ # Returns the Savon::WSDL.
17
+ attr_reader :wsdl
18
+
19
+ # Returns the Savon::Request.
20
+ attr_reader :request
21
+
22
+ # Returns +true+ for available methods and SOAP actions.
23
+ def respond_to?(method)
24
+ return true if @wsdl.respond_to? method
25
+ super
26
+ end
27
+
28
+ private
29
+
30
+ # Dispatches requests to SOAP actions matching a given +method+ name.
31
+ def method_missing(method, *args, &block) #:doc:
32
+ soap_call = soap_call_from method.to_s
33
+ super if @wsdl.enabled? && !@wsdl.respond_to?(soap_call)
34
+
35
+ setup_objects operation_from(soap_call), &block
36
+ Response.new @request.soap(@soap)
37
+ end
38
+
39
+ # Sets whether to use Savon::WSDL by a given +method+ name and
40
+ # removes exclamation marks from the given +method+ name.
41
+ def soap_call_from(method)
42
+ if method[-1, 1] == "!"
43
+ @wsdl.enabled = false
44
+ method[0, method.length-1].to_sym
45
+ else
46
+ @wsdl.enabled = true
47
+ method.to_sym
48
+ end
49
+ end
50
+
51
+ # Returns a SOAP operation Hash containing the SOAP action and input
52
+ # for a given +soap_call+.
53
+ def operation_from(soap_call)
54
+ return @wsdl.operations[soap_call] if @wsdl.enabled?
55
+ { :action => soap_call.to_soap_key, :input => soap_call.to_soap_key }
56
+ end
57
+
58
+ # Returns the SOAP endpoint.
59
+ def soap_endpoint
60
+ @wsdl.enabled? ? @wsdl.soap_endpoint : @request.endpoint
61
+ end
62
+
63
+ # Expects a SOAP operation Hash and sets up Savon::SOAP and Savon::WSSE.
64
+ # Yields them to a given +block+ in case one was given.
65
+ def setup_objects(operation, &block)
66
+ @soap, @wsse = SOAP.new, WSSE.new
67
+ @soap.action, @soap.input, @soap.endpoint = operation[:action], operation[:input], soap_endpoint
68
+
69
+ yield_objects &block if block
70
+
71
+ @soap.namespaces["xmlns:wsdl"] ||= @wsdl.namespace_uri if @wsdl.enabled?
72
+ @soap.wsse = @wsse
73
+ end
74
+
75
+ # Yields Savon::SOAP and Savon::WSSE to a given +block+.
76
+ def yield_objects(&block)
77
+ case block.arity
78
+ when 1 then yield @soap
79
+ when 2 then yield @soap, @wsse
80
+ end
81
+ end
82
+
83
+ end
84
+ end
@@ -0,0 +1,8 @@
1
+ class DateTime
2
+
3
+ # Returns the DateTime as an xs:dateTime formatted String.
4
+ def to_soap_value
5
+ strftime Savon::SOAPDateTimeFormat
6
+ end
7
+
8
+ end
@@ -0,0 +1,78 @@
1
+ class Hash
2
+
3
+ # Error message for missing :@inorder elements.
4
+ InOrderMissing = "Missing elements in :@inorder %s"
5
+
6
+ # Error message for spurious :@inorder elements.
7
+ InOrderSpurious = "Spurious elements in :@inorder %s"
8
+
9
+ # Returns the values from the 'soap:Body' element or an empty Hash
10
+ # in case the node could not be found.
11
+ def find_soap_body
12
+ envelope = self[self.keys.first] || {}
13
+ body_key = envelope.keys.find { |key| /.+:Body/ =~ key } rescue nil
14
+ body_key ? envelope[body_key].map_soap_response : {}
15
+ end
16
+
17
+ # Returns the Hash translated into SOAP request compatible XML.
18
+ #
19
+ # To control the order of output, add a key of :@inorder with
20
+ # the value being an Array listing keys in order.
21
+ #
22
+ # === Examples
23
+ #
24
+ # { :find_user => { :id => 666 } }.to_soap_xml
25
+ # => "<findUser><id>666</id></findUser>"
26
+ #
27
+ # { :find_user => { :name => "Lucy", :id => 666, :@inorder => [:id, :name] } }.to_soap_xml
28
+ # => "<findUser><id>666</id><name>Lucy</name></findUser>"
29
+ def to_soap_xml
30
+ @soap_xml = Builder::XmlMarkup.new
31
+ inorder(self).each { |key| nested_data_to_soap_xml key, self[key] }
32
+ @soap_xml.target!
33
+ end
34
+
35
+ # Maps keys and values of a Hash created from SOAP response XML to
36
+ # more convenient Ruby Objects.
37
+ def map_soap_response
38
+ inject({}) do |hash, (key, value)|
39
+ key = key.strip_namespace.snakecase.to_sym
40
+
41
+ value = case value
42
+ when Hash then value["xsi:nil"] ? nil : value.map_soap_response
43
+ when Array then value.map { |a_value| a_value.map_soap_response rescue a_value }
44
+ when String then value.map_soap_response
45
+ end
46
+ hash.merge key => value
47
+ end
48
+ end
49
+
50
+ private
51
+
52
+ # Expects a Hash +key+ and +value+ and recursively creates an XML structure
53
+ # representing the Hash content.
54
+ def nested_data_to_soap_xml(key, value)
55
+ case value
56
+ when Array
57
+ value.map { |subitem| nested_data_to_soap_xml key, subitem }
58
+ when Hash
59
+ @soap_xml.tag!(key.to_soap_key) do
60
+ inorder(value).each { |subkey| nested_data_to_soap_xml subkey, value[subkey] }
61
+ end
62
+ else
63
+ @soap_xml.tag!(key.to_soap_key) { @soap_xml << value.to_soap_value }
64
+ end
65
+ end
66
+
67
+ # Takes a +hash+, removes the :@inorder marker and returns its keys.
68
+ # Raises an error in case an :@inorder Array does not match the Hash keys.
69
+ def inorder(hash)
70
+ inorder = hash.delete :@inorder
71
+ hash_keys = hash.keys
72
+ inorder = hash_keys unless inorder.kind_of? Array
73
+ raise InOrderMissing % (hash_keys - inorder).inspect unless (hash_keys - inorder).empty?
74
+ raise InOrderSpurious % (inorder - hash_keys).inspect unless (inorder - hash_keys).empty?
75
+ inorder
76
+ end
77
+
78
+ end
@@ -0,0 +1,20 @@
1
+ module Net
2
+ class HTTP
3
+
4
+ # Sets the endpoint +address+ and +port+.
5
+ def endpoint(address, port)
6
+ @address, @port = address, port
7
+ end
8
+
9
+ # Convenience method for setting SSL client authentication
10
+ # through a Hash of +options+.
11
+ def ssl_client_auth(options)
12
+ self.use_ssl = true
13
+ self.cert = options[:cert] if options[:cert]
14
+ self.key = options[:key] if options[:key]
15
+ self.ca_file = options[:ca_file] if options[:ca_file]
16
+ self.verify_mode = options[:verify_mode] if options[:verify_mode]
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ class Object
2
+
3
+ # Returns +true+ if the Object is false, empty, or a whitespace string.
4
+ # For example, "", false, nil, [], and {} are blank.
5
+ # Implementation from ActiveSupport.
6
+ def blank?
7
+ respond_to?(:empty?) ? empty? : !self
8
+ end unless defined? blank?
9
+
10
+ # Returns the Object as a SOAP request compliant key.
11
+ def to_soap_key
12
+ to_s
13
+ end
14
+
15
+ # Returns the Object as a SOAP request compliant value.
16
+ def to_soap_value
17
+ return to_s unless respond_to? :to_datetime
18
+ to_datetime.to_soap_value
19
+ end
20
+
21
+ end
@@ -0,0 +1,47 @@
1
+ class String
2
+
3
+ # Returns a random String of a given +length+.
4
+ def self.random(length = 100)
5
+ (0...length).map { ("a".."z").to_a[rand(26)] }.join
6
+ end
7
+
8
+ # Returns the String in snake_case.
9
+ def snakecase
10
+ str = dup
11
+ str.gsub! /::/, '/'
12
+ str.gsub! /([A-Z]+)([A-Z][a-z])/, '\1_\2'
13
+ str.gsub! /([a-z\d])([A-Z])/, '\1_\2'
14
+ str.tr! ".", "_"
15
+ str.tr! "-", "_"
16
+ str.downcase!
17
+ str
18
+ end
19
+
20
+ # Returns the String in lowerCamelCase.
21
+ def lower_camelcase
22
+ str = dup
23
+ str.gsub!(/\/(.?)/) { "::#{$1.upcase}" }
24
+ str.gsub!(/(?:_+|-+)([a-z])/) { $1.upcase }
25
+ str.gsub!(/(\A|\s)([A-Z])/) { $1 + $2.downcase }
26
+ str
27
+ end
28
+
29
+ # Returns the String without namespace.
30
+ def strip_namespace
31
+ gsub /(.+:)(.+)/, '\2'
32
+ end
33
+
34
+ # Translates SOAP response values to more convenient Ruby Objects.
35
+ def map_soap_response
36
+ return DateTime.parse( self ) if Savon::SOAPDateTimeRegexp === self
37
+ return true if self.strip.downcase == "true"
38
+ return false if self.strip.downcase == "false"
39
+ self
40
+ end
41
+
42
+ # Returns the String as a SOAP request compliant value.
43
+ def to_soap_value
44
+ to_s
45
+ end
46
+
47
+ end
@@ -0,0 +1,8 @@
1
+ class Symbol
2
+
3
+ # Returns the Symbol as a lowerCamelCase String.
4
+ def to_soap_key
5
+ to_s.lower_camelcase
6
+ end
7
+
8
+ end
@@ -0,0 +1,10 @@
1
+ module URI
2
+ class HTTP
3
+
4
+ # Returns whether the URI hints to SSL.
5
+ def ssl?
6
+ /^https/ === @scheme
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ %w(object string symbol datetime hash uri net_http).each do |file|
2
+ require File.dirname(__FILE__) + "/core_ext/#{file}"
3
+ end