rapuncel 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,11 +18,10 @@ module Rapuncel
18
18
 
19
19
  def initialize configuration = {}
20
20
 
21
- @host = configuration[:host] || 'localhost'
22
- @port = configuration[:port] || '8080'
23
- @path = configuration[:path] || '/'
24
- @headers = configuration[:headers] || {}
25
-
21
+ self.host = configuration[:host] || 'localhost'
22
+ self.port = configuration[:port] || '8080'
23
+ self.path = configuration[:path] || '/'
24
+ self.headers = configuration[:headers] || {}
26
25
 
27
26
  if ssl = configuration[:ssl]
28
27
  @ssl = true
@@ -33,6 +32,18 @@ module Rapuncel
33
32
  def url
34
33
  "http://#{host}:#{port}#{path}"
35
34
  end
35
+
36
+ def host= value
37
+ @host = value.to_s.sub /^http\:\/\//, ''
38
+ end
39
+
40
+ def path= value
41
+ unless value =~ /^\//
42
+ value = "/" + value
43
+ end
44
+
45
+ @path = value
46
+ end
36
47
 
37
48
  def headers
38
49
  @headers.merge :Accept => 'text/xml', :'content-type' => 'text/xml'
@@ -2,7 +2,7 @@ require 'rapuncel/request'
2
2
 
3
3
  module Rapuncel
4
4
  class Proxy
5
- PROXY_METHODS = %w(tap inspect clone freeze dup class initialize).freeze
5
+ PROXY_METHODS = %w(tap inspect clone freeze dup class initialize to_s).freeze
6
6
  LOCKED_METHODS = %w(method_missing).freeze
7
7
  LOCKED_PATTERN = /(\A__|\?\Z|!\Z)/.freeze
8
8
 
@@ -40,6 +40,8 @@ module Rapuncel
40
40
  PROXY_METHODS.each do |name|
41
41
  alias_method "__#{name}__", name
42
42
  end
43
+
44
+ alias_method "__inspect__", "__to_s__"
43
45
 
44
46
  instance_methods.each do |name|
45
47
  unless LOCKED_METHODS.include?(name) || LOCKED_PATTERN.match(name)
Binary file
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rapuncel"
3
- s.version = "0.0.3"
3
+ s.version = "0.0.4"
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'
@@ -9,18 +9,19 @@ class ArrayTest < ActiveSupport::TestCase
9
9
  assert_select xml, '/array/data/value', 10
10
10
  end
11
11
 
12
- def test_array arr
13
- xml = arr.to_xml_rpc
14
12
 
15
- xml_node = Nokogiri::XML(xml).children.first
16
13
 
17
- reparsed = Array.from_xml_rpc xml_node
14
+ test "An array, converted to xml and parsed back should be itself" do
15
+ def test_array_conversion arr
16
+ xml = arr.to_xml_rpc
18
17
 
19
- reparsed
20
- end
18
+ xml_node = Nokogiri::XML(xml).children.first
21
19
 
20
+ reparsed = Array.from_xml_rpc xml_node
22
21
 
23
- test "An array, converted to xml and parsed back should be itself" do
22
+ reparsed
23
+ end
24
+
24
25
  arr1 = (1..10).to_a
25
26
  arr2 = arr1.map &:to_s
26
27
 
@@ -28,10 +29,10 @@ class ArrayTest < ActiveSupport::TestCase
28
29
 
29
30
  arr4 = ["hello", arr3]
30
31
 
31
- reparsed1 = test_array arr1
32
- reparsed2 = test_array arr2
33
- reparsed3 = test_array arr3
34
- reparsed4 = test_array arr4
32
+ reparsed1 = test_array_conversion arr1
33
+ reparsed2 = test_array_conversion arr2
34
+ reparsed3 = test_array_conversion arr3
35
+ reparsed4 = test_array_conversion arr4
35
36
 
36
37
  [reparsed1, reparsed2, reparsed3, reparsed4].zip([arr1, arr2, arr3, arr4]).each do |b|
37
38
  assert_equal *b
@@ -6,6 +6,18 @@ class ConnectionTest < ActiveSupport::TestCase
6
6
  assert_kind_of Rapuncel::AuthConnection, Rapuncel::Connection.build(:user => '')
7
7
  assert_kind_of Rapuncel::AuthConnection, Rapuncel::Connection.build(:password => '')
8
8
  end
9
+
10
+ test "Connection should not choke on extra 'http://' in @host" do
11
+ connection = Rapuncel::Connection.build :host => "http://example.org"
12
+
13
+ assert_equal "example.org", connection.host
14
+ end
15
+
16
+ test "Connection should accept path beginning with or without /" do
17
+ connection = Rapuncel::Connection.build :host => "http://example.org", :path => "abcd"
18
+
19
+ assert_equal "/abcd", connection.path
20
+ end
9
21
 
10
22
  test "Connection.new should return an ApiKeyAuthConnection if api_key is set" do
11
23
  assert_kind_of Rapuncel::ApiKeyAuthConnection, Rapuncel::Connection.build(:api_key => 'xyz')
@@ -47,6 +47,6 @@ class ProxyTest < ActiveSupport::TestCase
47
47
 
48
48
  p.foobar
49
49
 
50
- assert Rapuncel::Proxy.instance_methods.include?('foobar')
50
+ assert (Rapuncel::Proxy.instance_methods.include?('foobar') || Rapuncel::Proxy.instance_methods.include?(:foobar))
51
51
  end
52
52
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapuncel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Eickenberg
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-04-29 00:00:00 +02:00
19
+ date: 2011-05-24 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -93,6 +93,7 @@ files:
93
93
  - lib/rapuncel.rb
94
94
  - MIT-LICENSE
95
95
  - Rakefile
96
+ - rapuncel-0.0.3.gem
96
97
  - rapuncel.gemspec
97
98
  - README.md
98
99
  - test/functional/client_test.rb