rapuncel 0.0.5 → 0.0.6.RC1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
1
  source 'http://www.rubygems.org'
2
2
  gemspec
3
+ gem 'rake', :require => false
3
4
 
@@ -1,15 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rapuncel (0.0.5.RC1)
4
+ rapuncel (0.0.6.RC1)
5
5
  activesupport (>= 3.0.0)
6
6
  nokogiri
7
7
 
8
8
  GEM
9
9
  remote: http://www.rubygems.org/
10
10
  specs:
11
- activesupport (3.0.9)
11
+ activesupport (3.1.3)
12
+ multi_json (~> 1.0)
12
13
  diff-lcs (1.1.2)
14
+ multi_json (1.0.4)
13
15
  nokogiri (1.5.0)
14
16
  rake (0.9.2)
15
17
  rspec (2.6.0)
data/README.md CHANGED
@@ -159,6 +159,7 @@ Don't use Symbols as keys for deserialized `<struct>`, but Strings.
159
159
  * HTTP-Proxy support
160
160
  * Async requests
161
161
  * XMLRPC Extensions (pluggable support)
162
+ * Apache vendor extensions
162
163
  * How do i test SSL?
163
164
 
164
165
  ## What happens if something goes wrong?
@@ -4,15 +4,26 @@ require 'rapuncel/xml_rpc/serializer'
4
4
  require 'rapuncel/xml_rpc/deserializer'
5
5
  require 'active_support/core_ext/hash/except'
6
6
  require 'active_support/inflector/methods'
7
+ require 'active_support/deprecation'
7
8
 
8
9
  module Rapuncel
9
10
  class Client
11
+ autoload :Logging, 'rapuncel/client/logging'
12
+
10
13
  attr_accessor :connection, :raise_on_fault, :raise_on_error
11
14
 
12
15
  include Adapters::NetHttpAdapter
13
16
 
14
- def proxy_for interface
15
- Proxy.new self, interface
17
+ def proxy_for interface = nil
18
+ if interface.nil?
19
+ @default_proxy ||= Proxy.new self, nil
20
+ else
21
+ @proxies ||= Hash.new do |hash, key|
22
+ hash[key] = Proxy.new self, key
23
+ end
24
+
25
+ @proxies[interface.to_s]
26
+ end
16
27
  end
17
28
 
18
29
  def proxy
@@ -33,16 +44,22 @@ module Rapuncel
33
44
  else
34
45
  [false, false]
35
46
  end
47
+
48
+ if logger = configuration[:logger]
49
+ extend Logging
50
+ initialize_logging logger, configuration[:log_level]
51
+ end
36
52
  end
37
53
 
38
54
  # Dispatch a method call and return the response as Rapuncel::Response object.
39
55
  def call name, *args
40
- execute Request.new(name, *args)
56
+ ActiveSupport::Deprecation.warn "Using #call is deprecated, please use #call_to_ruby instead.", caller
57
+ _call name, *args
41
58
  end
42
59
 
43
60
  # Dispatch a method call and return the response as parsed ruby.
44
61
  def call_to_ruby name, *args
45
- response = call name, *args
62
+ response = _call name, *args
46
63
 
47
64
  raise_on_fault && response.fault? && raise_fault(response)
48
65
  raise_on_error && response.error? && raise_error(response)
@@ -51,6 +68,10 @@ module Rapuncel
51
68
  end
52
69
 
53
70
  protected
71
+ def _call name, *args
72
+ execute Request.new(name, *args)
73
+ end
74
+
54
75
  def execute request
55
76
  xml = serializer[request]
56
77
 
@@ -0,0 +1,83 @@
1
+ require 'logger'
2
+
3
+ module Rapuncel
4
+ module Client::Logging
5
+ attr_accessor :logger
6
+
7
+ def log_level
8
+ @logger.try :level
9
+ end
10
+
11
+ def log_level= log_level
12
+ @logger && @logger.level = log_level
13
+ end
14
+
15
+ def logger= logger
16
+ @logger = case logger
17
+ when Logger
18
+ logger
19
+ when IO
20
+ Logger.new logger
21
+ when String, Symbol
22
+ Logger.new ActiveSupport::Inflector.constantize(logger.to_s.upcase)
23
+ else
24
+ Logger.new STDOUT
25
+ end
26
+ end
27
+
28
+ protected
29
+ def initialize_logging logger, log_level
30
+ self.logger = logger
31
+ if log_level
32
+ self.log_level = log_level
33
+ end
34
+
35
+ logger.info { with_log_prefix "Initialized." }
36
+ logger.debug { with_log_prefix "Using (De)Serializer: #{serialization.to_s}" }
37
+ end
38
+
39
+ def _call name, *args
40
+ if logger.debug?
41
+ logger.debug { with_log_prefix "Calling RPC Method \"#{name}\" with #{args.map(&:inspect).join(', ')}" }
42
+ else
43
+ logger.info { with_log_prefix "Calling RPC Method \"#{name}\" with #{args.length} arguments." }
44
+ end
45
+
46
+ super
47
+ end
48
+
49
+ def send_method_call xml
50
+ logger.debug { with_log_prefix "Sending XML:\n #{xml}" }
51
+
52
+ super
53
+ end
54
+
55
+ def execute request
56
+ super.tap do |response|
57
+ case
58
+ when response.success?
59
+ logger.debug { "Received XML-Response: \n #{response.body}" }
60
+ when response.fault?
61
+ level = raise_on_fault ? :error : :warn
62
+ logger.add(level) { "Received XML-Fault: \n #{response.body}" }
63
+ when response.error?
64
+ level = raise_on_error ? :error : :warn
65
+ logger.add(level) { "HTTP Error: #{response.status}\n #{response.body}" }
66
+ end
67
+ end
68
+ end
69
+
70
+ private
71
+ def log_host_config
72
+ "#{connection.host}:#{connection.port}#{connection.path}"
73
+ end
74
+
75
+ def with_log_prefix message
76
+ "#{log_prefix} #{message}"
77
+ end
78
+
79
+ def log_prefix
80
+ @log_prefix ||= "[XML-RPC@#{log_host_config}]"
81
+ end
82
+ end
83
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rapuncel"
3
- s.version = "0.0.5"
3
+ s.version = "0.0.6.RC1"
4
4
  s.date = Time.now.strftime("%Y-%m-%d")
5
5
  s.authors = ["Michael Eickenberg", "Marian Theisen"]
6
6
  s.email = 'marian@cice-online.net'
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+ require 'logger'
3
+
4
+ describe Rapuncel::Client do
5
+ let(:logger) { nil }
6
+ subject { Rapuncel::Client.new :logger => logger }
7
+
8
+ it { should_not respond_to :logger }
9
+ it { should_not respond_to :log_level }
10
+
11
+ describe "with Logging enabled" do
12
+ let(:logger) { Logger.new(STDOUT) }
13
+
14
+ it { should respond_to :logger }
15
+ it { should respond_to :log_level }
16
+ end
17
+ end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapuncel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
5
- prerelease:
4
+ version: 0.0.6.RC1
5
+ prerelease: 6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Eickenberg
@@ -10,12 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-08-16 00:00:00.000000000 +02:00
14
- default_executable:
13
+ date: 2011-12-30 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: nokogiri
18
- requirement: &70165832864660 !ruby/object:Gem::Requirement
17
+ requirement: &70109985630700 !ruby/object:Gem::Requirement
19
18
  none: false
20
19
  requirements:
21
20
  - - ! '>='
@@ -23,10 +22,10 @@ dependencies:
23
22
  version: '0'
24
23
  type: :runtime
25
24
  prerelease: false
26
- version_requirements: *70165832864660
25
+ version_requirements: *70109985630700
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: activesupport
29
- requirement: &70165832864100 !ruby/object:Gem::Requirement
28
+ requirement: &70109985630120 !ruby/object:Gem::Requirement
30
29
  none: false
31
30
  requirements:
32
31
  - - ! '>='
@@ -34,10 +33,10 @@ dependencies:
34
33
  version: 3.0.0
35
34
  type: :runtime
36
35
  prerelease: false
37
- version_requirements: *70165832864100
36
+ version_requirements: *70109985630120
38
37
  - !ruby/object:Gem::Dependency
39
38
  name: rspec
40
- requirement: &70165832863580 !ruby/object:Gem::Requirement
39
+ requirement: &70109985629600 !ruby/object:Gem::Requirement
41
40
  none: false
42
41
  requirements:
43
42
  - - ! '>='
@@ -45,10 +44,10 @@ dependencies:
45
44
  version: 2.6.0
46
45
  type: :development
47
46
  prerelease: false
48
- version_requirements: *70165832863580
47
+ version_requirements: *70109985629600
49
48
  - !ruby/object:Gem::Dependency
50
49
  name: rake
51
- requirement: &70165832863200 !ruby/object:Gem::Requirement
50
+ requirement: &70109985629220 !ruby/object:Gem::Requirement
52
51
  none: false
53
52
  requirements:
54
53
  - - ! '>='
@@ -56,7 +55,7 @@ dependencies:
56
55
  version: '0'
57
56
  type: :development
58
57
  prerelease: false
59
- version_requirements: *70165832863200
58
+ version_requirements: *70109985629220
60
59
  description: Rapuncel is a simple XML-RPC Client based on Nokogiri, thus provides
61
60
  a fast and easy way to interact with XML-RPC services.
62
61
  email: marian@cice-online.net
@@ -68,6 +67,7 @@ files:
68
67
  - Gemfile.lock
69
68
  - lib/rapuncel/adapters/net_http_adapter.rb
70
69
  - lib/rapuncel/base_64_string.rb
70
+ - lib/rapuncel/client/logging.rb
71
71
  - lib/rapuncel/client.rb
72
72
  - lib/rapuncel/connection.rb
73
73
  - lib/rapuncel/proxy.rb
@@ -78,8 +78,6 @@ files:
78
78
  - lib/rapuncel.rb
79
79
  - MIT-LICENSE
80
80
  - Rakefile
81
- - rapuncel-0.0.5.RC1.gem
82
- - rapuncel-0.0.5.RC2.gem
83
81
  - rapuncel.gemspec
84
82
  - README.md
85
83
  - spec/functional/client_spec.rb
@@ -88,6 +86,7 @@ files:
88
86
  - spec/unit/array_spec.rb
89
87
  - spec/unit/base64_spec.rb
90
88
  - spec/unit/boolean_spec.rb
89
+ - spec/unit/client_spec.rb
91
90
  - spec/unit/connection_spec.rb
92
91
  - spec/unit/custom_serialization_spec.rb
93
92
  - spec/unit/float_spec.rb
@@ -100,7 +99,6 @@ files:
100
99
  - spec/unit/response_spec.rb
101
100
  - spec/unit/string_spec.rb
102
101
  - spec/unit/time_spec.rb
103
- has_rdoc: true
104
102
  homepage: http://github.com/cice/rapuncel
105
103
  licenses: []
106
104
  post_install_message:
@@ -116,12 +114,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
114
  required_rubygems_version: !ruby/object:Gem::Requirement
117
115
  none: false
118
116
  requirements:
119
- - - ! '>='
117
+ - - ! '>'
120
118
  - !ruby/object:Gem::Version
121
- version: '0'
119
+ version: 1.3.1
122
120
  requirements: []
123
121
  rubyforge_project:
124
- rubygems_version: 1.6.2
122
+ rubygems_version: 1.8.10
125
123
  signing_key:
126
124
  specification_version: 3
127
125
  summary: Simple XML-RPC Client
Binary file
Binary file