smacks-apricoteatsgorilla 0.3.2 → 0.3.3

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.
Files changed (3) hide show
  1. data/README.rdoc +26 -7
  2. data/lib/apricoteatsgorilla.rb +5 -6
  3. metadata +3 -3
data/README.rdoc CHANGED
@@ -14,19 +14,34 @@ uses Hpricot instead of REXML and doesn't follow the BadgerFish convention.
14
14
 
15
15
  Hpricot 0.6.164 (also available for JRuby)
16
16
 
17
- == Translating an XML String into a Ruby Hash
17
+ == How to use
18
18
 
19
- xml = "<apricot><eats>Gorilla</eats></apricot>"
20
- ApricotEatsGorilla[xml]
21
- # => { :eats => "Gorilla" }
19
+ === xml_to_hash(xml, root_node = nil)
22
20
 
23
- == Translating a Ruby Hash into an XML String
21
+ xml = '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
22
+ <soap:Body>
23
+ <ns2:authenticateResponse xmlns:ns2="http://v1_0.ws.example.com/">
24
+ <return>
25
+ <authValue>
26
+ <token>secret</token>
27
+ <client>example</client>
28
+ </authValue>
29
+ </return>
30
+ </ns2:authenticateResponse>
31
+ </soap:Body>
32
+ </soap:Envelope>'
33
+
34
+ ApricotEatsGorilla[xml, "//return"]
35
+ # => { :auth_value => { :token => "secret", :client => "example" } }
36
+
37
+ === hash_to_xml(hash)
24
38
 
25
39
  hash = { :apricot => { :eats => "Gorilla" } }
40
+
26
41
  ApricotEatsGorilla[hash]
27
42
  # => "<apricot><eats>Gorilla</eats></apricot>"
28
43
 
29
- == Creating a SOAP request envelope
44
+ === soap_envelope(namespaces = {})
30
45
 
31
46
  ApricotEatsGorilla.soap_envelope { "<authenticate>me</authenticate>" }
32
47
 
@@ -34,4 +49,8 @@ uses Hpricot instead of REXML and doesn't follow the BadgerFish convention.
34
49
  # => <env:Body>
35
50
  # => <authenticate>me</authenticate>
36
51
  # => </env:Body>
37
- # => </env:Envelope>'
52
+ # => </env:Envelope>'
53
+
54
+ == More examples
55
+
56
+ Please take a look at the tests for some more examples.
@@ -7,19 +7,19 @@ require "hpricot"
7
7
  # be used to build a SOAP request envelope. It is based on CobraVsMongoose but
8
8
  # uses Hpricot instead of REXML and doesn't follow the BadgerFish convention.
9
9
  #
10
- # == Translating an XML String into a Ruby Hash
10
+ # === Translating an XML String into a Ruby Hash
11
11
  #
12
12
  # xml = "<apricot><eats>Gorilla</eats></apricot>"
13
13
  # ApricotEatsGorilla[xml]
14
14
  # # => { :eats => "Gorilla" }
15
15
  #
16
- # == Translating a Ruby Hash into an XML String
16
+ # === Translating a Ruby Hash into an XML String
17
17
  #
18
18
  # hash = { :apricot => { :eats => "Gorilla" } }
19
19
  # ApricotEatsGorilla[hash]
20
20
  # # => "<apricot><eats>Gorilla</eats></apricot>"
21
21
  #
22
- # == Creating a SOAP request envelope
22
+ # === Creating a SOAP request envelope
23
23
  #
24
24
  # ApricotEatsGorilla.soap_envelope { "<authenticate>me</authenticate>" }
25
25
  #
@@ -156,8 +156,7 @@ class ApricotEatsGorilla
156
156
  key, value = child.name, xml_node_to_hash(child)
157
157
  end
158
158
 
159
- key = remove_namespace(key)
160
- key = to_snake_case(key).intern
159
+ key = to_snake_case(remove_namespace(key)).intern
161
160
  current = this_node[key]
162
161
  case current
163
162
  when Array
@@ -165,7 +164,7 @@ class ApricotEatsGorilla
165
164
  when nil
166
165
  this_node[key] = value
167
166
  else
168
- this_node[key] = [current.dup, value]
167
+ this_node[key] = [current, value]
169
168
  end
170
169
  end
171
170
  this_node
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smacks-apricoteatsgorilla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Harrington
@@ -53,8 +53,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  - !ruby/object:Gem::Version
54
54
  version: "0"
55
55
  version:
56
- requirements: []
57
-
56
+ requirements:
57
+ - shoulda for testing
58
58
  rubyforge_project:
59
59
  rubygems_version: 1.2.0
60
60
  signing_key: