savon_model 0.2.0 → 0.3.0

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.
data/Gemfile CHANGED
@@ -1,3 +1,2 @@
1
- source "http://gems.blau.de"
2
1
  source :rubygems
3
2
  gemspec
data/lib/savon/model.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require "savon"
2
- require "savon/ext/response"
3
2
 
4
3
  module Savon
5
4
 
@@ -8,19 +7,7 @@ module Savon
8
7
  # Model for SOAP service oriented applications.
9
8
  module Model
10
9
 
11
- VERSION = "0.2.0"
12
-
13
- class << self
14
-
15
- # Returns the response pattern to apply.
16
- def response_pattern
17
- @response_pattern ||= []
18
- end
19
-
20
- # Sets the response pattern. This is required to be an Array of Regexps or Symbols.
21
- attr_writer :response_pattern
22
-
23
- end
10
+ VERSION = "0.3.0"
24
11
 
25
12
  module ClassMethods
26
13
 
data/savon_model.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = s.name
16
16
 
17
- s.add_development_dependency "savon", "~> 0.8.0.beta.1"
17
+ s.add_development_dependency "savon", "~> 0.8.0.beta.2"
18
18
 
19
19
  s.add_development_dependency "rspec", "~> 2.0.0"
20
20
  s.add_development_dependency "mocha", "~> 0.9.8"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: savon_model
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Harrington
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-30 00:00:00 +02:00
18
+ date: 2010-11-05 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,14 +26,14 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 62196257
29
+ hash: 62196263
30
30
  segments:
31
31
  - 0
32
32
  - 8
33
33
  - 0
34
34
  - beta
35
- - 1
36
- version: 0.8.0.beta.1
35
+ - 2
36
+ version: 0.8.0.beta.2
37
37
  type: :development
38
38
  version_requirements: *id001
39
39
  - !ruby/object:Gem::Dependency
@@ -85,13 +85,9 @@ files:
85
85
  - README.md
86
86
  - Rakefile
87
87
  - autotest/discover.rb
88
- - lib/savon/ext/response.rb
89
88
  - lib/savon/model.rb
90
89
  - lib/savon_model.rb
91
90
  - savon_model.gemspec
92
- - spec/fixtures/authentication.xml
93
- - spec/fixtures/users.xml
94
- - spec/savon/ext/response_spec.rb
95
91
  - spec/savon/model_spec.rb
96
92
  - spec/spec_helper.rb
97
93
  has_rdoc: true
@@ -1,42 +0,0 @@
1
- require "savon"
2
- require "savon/model"
3
-
4
- module Savon
5
- module SOAP
6
- class Response
7
-
8
- # Returns the original result of <tt>Savon::SOAP::Response#to_hash</tt>.
9
- def new_hash
10
- @new_hash ||= response_pattern original_hash
11
- end
12
-
13
- alias_method :original_hash, :to_hash
14
- alias_method :to_hash, :new_hash
15
-
16
- # Returns the response Hash as an Array.
17
- def to_array
18
- @array ||= begin
19
- array = to_hash.kind_of?(Array) ? to_hash : [to_hash]
20
- array.compact
21
- end
22
- end
23
-
24
- private
25
-
26
- def response_pattern(hash)
27
- return hash if Model.response_pattern.blank?
28
-
29
- Model.response_pattern.inject(hash) do |memo, pattern|
30
- key = case pattern
31
- when Regexp then memo.keys.find { |key| key.to_s =~ pattern }
32
- else memo.keys.find { |key| key.to_s == pattern.to_s }
33
- end
34
-
35
- return unless key
36
- memo[key]
37
- end
38
- end
39
-
40
- end
41
- end
42
- end
@@ -1,14 +0,0 @@
1
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
2
- <soap:Body>
3
- <ns2:authenticateResponse xmlns:ns2="http://v1_0.ws.user.example.com">
4
- <return>
5
- <authenticationValue>
6
- <token>a68d1d6379b62ff339a0e0c69ed4d9cf</token>
7
- <tokenHash>AAAJxA;cIedoT;mY10ExZwG6JuKgp2OYKxow==</tokenHash>
8
- <client>radclient</client>
9
- </authenticationValue>
10
- <success>true</success>
11
- </return>
12
- </ns2:authenticateResponse>
13
- </soap:Body>
14
- </soap:Envelope>
@@ -1,18 +0,0 @@
1
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
2
- <soap:Body>
3
- <ns2:getAllUsersResponse xmlns:ns2="http://v1_0.ws.user.example.com">
4
- <return>
5
- <id>1</id>
6
- <name>Thilko</name>
7
- </return>
8
- <return>
9
- <id>2</id>
10
- <name>Peter</name>
11
- </return>
12
- <return>
13
- <id>3</id>
14
- <name>Alex</name>
15
- </return>
16
- </ns2:getAllUsersResponse>
17
- </soap:Body>
18
- </soap:Envelope>
@@ -1,76 +0,0 @@
1
- require "spec_helper"
2
- require "savon/ext/response"
3
-
4
- describe Savon::SOAP::Response do
5
- let(:response) { Savon::SOAP::Response.new http_response(:authentication) }
6
- let(:users_response) { Savon::SOAP::Response.new http_response(:users) }
7
-
8
- describe "#original_hash" do
9
- it "should return the original Hash" do
10
- response.original_hash[:authenticate_response].should be_a(Hash)
11
- end
12
- end
13
-
14
- describe "#to_hash" do
15
- it "should memoize the result" do
16
- response.to_hash.should equal(response.to_hash)
17
- end
18
-
19
- context "without response pattern" do
20
- it "should return the original Hash" do
21
- response.to_hash[:authenticate_response].should be_a(Hash)
22
- end
23
- end
24
-
25
- context "with response pattern" do
26
- around do |example|
27
- Savon::Model.response_pattern = [/.+_response/, :return]
28
- example.run
29
- Savon::Model.response_pattern = nil
30
- end
31
-
32
- it "should apply the response pattern" do
33
- response.to_hash[:success].should be_true
34
- end
35
- end
36
-
37
- context "with unmatched response pattern" do
38
- around do |example|
39
- Savon::Model.response_pattern = [:unmatched, :pattern]
40
- example.run
41
- Savon::Model.response_pattern = nil
42
- end
43
-
44
- it "should apply the response pattern" do
45
- response.to_hash.should be_nil
46
- end
47
- end
48
- end
49
-
50
- describe "#to_array" do
51
- around do |example|
52
- Savon::Model.response_pattern = [/.+_response/, :return]
53
- example.run
54
- Savon::Model.response_pattern = nil
55
- end
56
-
57
- it "should return an Array for a single response element" do
58
- response.to_array.should be_an(Array)
59
- response.to_array.first[:success].should be_true
60
- end
61
-
62
- it "should memoize the result" do
63
- response.to_array.should equal(response.to_array)
64
- end
65
-
66
- it "should return an Array for multiple response element" do
67
- users_response.to_array.should be_an(Array)
68
- users_response.to_array.should have(3).items
69
- end
70
- end
71
-
72
- def http_response(fixture)
73
- HTTPI::Response.new 200, {}, File.read("spec/fixtures/#{fixture}.xml")
74
- end
75
-
76
- end