README.rdoc in smacks-apricoteatsgorilla-0.4.5 vs README.rdoc in smacks-apricoteatsgorilla-0.4.6

- old
+ new

@@ -1,97 +1,52 @@ = Apricot eats Gorilla -Apricot eats Gorilla is a SOAP communication helper. +Apricot eats Gorilla is a SOAP communication helper. It translates between +SOAP messages (XML) and Ruby Hashes and comes with some additional helpers +for working with SOAP services. -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 == Dependencies hpricot 0.6.164 (also available for JRuby) -== How to use +== Translate an XML String into a Ruby Hash -=== 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> - <token>secret</token> - <client>example</client> - </authValue> + <apricot> + <eats>Gorilla</eats> + </apricot> </return> </ns2:authenticateResponse> </soap:Body> </soap:Envelope>' ApricotEatsGorilla[xml, "//return"] - # => { :auth_value => { :token => "secret", :client => "example" } } + # => { :apricot => { :eats => "Gorilla" } } -=== hash_to_xml(hash) +== Translate a Ruby Hash into an XML String -Converts a given Ruby Hash into an XML String. Converts Hash keys from snake_case -to lowerCamelCase by default. + hash = { :apricot => { :eats => "Gorilla" } } - hash = { :apricot => { :eats => { :lots_of => "Gorillas" } } } - ApricotEatsGorilla[hash] - # => "<apricot><eats><lotsOf>Gorillas</lotsOf></eats></apricot>" + # => "<apricot><eats>Gorilla</eats></apricot>" -=== soap_envelope(namespaces = {}) +== Build a SOAP request envelope -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 { "<apricot><eats>Gorilla</eats></apricot>" } - ApricotEatsGorilla.soap_envelope { "<authenticate>me</authenticate>" } - # => '<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> # => <env:Body> - # => <authenticate>me</authenticate> + # => <apricot><eats>Gorilla</eats></apricot> # => </env:Body> # => </env:Envelope>' -== Changing defaults +== Read more -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 +For more detailed information, please take a look at the +{GitHub Wiki}[http://wiki.github.com/smacks/apricoteatsgorilla]. \ No newline at end of file