README.rdoc in smacks-apricoteatsgorilla-0.4.1 vs README.rdoc in smacks-apricoteatsgorilla-0.4.2
- old
+ new
@@ -1,12 +1,12 @@
= Apricot eats Gorilla
Apricot eats Gorilla is a SOAP communication helper.
-It translates between SOAP response messages (XML) and Ruby Hashes and may
-be used to build a SOAP request envelope. It is based on CobraVsMongoose but
-uses Hpricot instead of REXML and doesn't follow the BadgerFish convention.
+It translates between SOAP messages (XML) and Ruby Hashes while offering some
+helpful methods for working with SOAP webservices. Apricot eats Gorilla was
+initially based on CobraVsMongoose but uses Hpricot instead of REXML.
== Install
$ gem install smacks-apricoteatsgorilla -s http://gems.github.com
@@ -16,10 +16,16 @@
== How to use
=== xml_to_hash(xml, root_node = nil)
+Converts a given XML String into a Ruby Hash. Starts parsing at root node by
+default. The optional root_node parameter can be used to specify a custom root
+node to start parsing at using an XPath expression (Hpricot search). The root
+node itself won't be included in the Hash. Converts tag names from CamelCase/
+lowerCamelCase to snake_case and into Symbols by default.
+
xml = '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:authenticateResponse xmlns:ns2="http://v1_0.ws.example.com/">
<return>
<authValue>
@@ -34,23 +40,58 @@
ApricotEatsGorilla[xml, "//return"]
# => { :auth_value => { :token => "secret", :client => "example" } }
=== hash_to_xml(hash)
- hash = { :apricot => { :eats => "Gorilla" } }
+Converts a given Ruby Hash into an XML String. Converts Hash keys from snake_case
+to lowerCamelCase by default.
+ hash = { :apricot => { :eats => { :lots_of => "Gorillas" } } }
+
ApricotEatsGorilla[hash]
- # => "<apricot><eats>Gorilla</eats></apricot>"
+ # => "<apricot><eats><lotsOf>Gorillas</lotsOf></eats></apricot>"
=== soap_envelope(namespaces = {})
+Builds a SOAP request envelope and includes the content from a given block
+into the envelope body. Accepts a Hash (namespace => namespace_uri) of additional
+namespaces to set.
+
ApricotEatsGorilla.soap_envelope { "<authenticate>me</authenticate>" }
# => '<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
# => <env:Body>
# => <authenticate>me</authenticate>
# => </env:Body>
# => </env:Envelope>'
-== More examples
+== Changing defaults
-Please take a look at the tests for some more examples.
+There are several options for changing the default behavior. Options can be
+set using a setup block or by setting one option at a time.
+
+ ApricotEatsGorilla.setup do |s|
+ s.disable_tag_names_to_lower_camel_case = true
+ s.disable_hash_keys_to_snake_case = true
+ s.disable_hash_keys_to_symbol = true
+ end
+
+=== Disable conversion of tag names to lowerCamelCase
+
+By default XML tags created by hash_to_xml are converted from snake_case to
+lowerCamelCase. Disable by setting disable_tag_names_to_lower_camel_case to true.
+
+ ApricotEatsGorilla.disable_tag_names_to_lower_camel_case = true
+
+=== Disable conversion of Hash keys to snake_case
+
+By default Hash keys created by xml_to_hash are converted from lowerCamelCase/
+CamelCase to snake_case. Disable by setting disable_hash_keys_to_snake_case to true.
+
+ ApricotEatsGorilla.disable_hash_keys_to_snake_case = true
+
+=== Disable conversion of Hash keys to Symbols
+
+By default Hash keys created by xml_to_hash are converted to Symbols.
+Disable by setting disable_hash_keys_to_symbol to true.
+
+ ApricotEatsGorilla.disable_hash_keys_to_symbol = true
\ No newline at end of file