wrest 1.0.0.beta2 → 1.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/CHANGELOG +9 -1
  2. data/README.rdoc +2 -2
  3. data/lib/wrest/curl.rb +2 -2
  4. data/lib/wrest/multipart.rb +3 -3
  5. data/lib/wrest/native/get.rb +0 -1
  6. data/lib/wrest/native/request.rb +5 -1
  7. data/lib/wrest/uri.rb +20 -11
  8. data/lib/wrest/uri_template.rb +9 -0
  9. data/lib/wrest/version.rb +1 -1
  10. data/lib/wrest.rb +2 -2
  11. metadata +74 -97
  12. data/lib/wrest/components/container/alias_accessors.rbc +0 -905
  13. data/lib/wrest/components/container/typecaster.rbc +0 -1985
  14. data/lib/wrest/components/container.rbc +0 -2466
  15. data/lib/wrest/components/mutators/base.rbc +0 -702
  16. data/lib/wrest/components/mutators/camel_to_snake_case.rbc +0 -360
  17. data/lib/wrest/components/mutators/xml_mini_type_caster.rbc +0 -679
  18. data/lib/wrest/components/mutators/xml_simple_type_caster.rbc +0 -559
  19. data/lib/wrest/components/mutators.rbc +0 -650
  20. data/lib/wrest/components/translators/content_types.rbc +0 -339
  21. data/lib/wrest/components/translators/json.rbc +0 -462
  22. data/lib/wrest/components/translators/xml.rbc +0 -457
  23. data/lib/wrest/components/translators.rbc +0 -517
  24. data/lib/wrest/components.rbc +0 -217
  25. data/lib/wrest/core_ext/hash/conversions.rbc +0 -501
  26. data/lib/wrest/core_ext/hash.rbc +0 -182
  27. data/lib/wrest/core_ext/string/conversions.rbc +0 -471
  28. data/lib/wrest/core_ext/string.rbc +0 -182
  29. data/lib/wrest/curl.rbc +0 -704
  30. data/lib/wrest/exceptions.rbc +0 -312
  31. data/lib/wrest/http_shared/headers.rbc +0 -353
  32. data/lib/wrest/http_shared/standard_headers.rbc +0 -336
  33. data/lib/wrest/http_shared/standard_tokens.rbc +0 -316
  34. data/lib/wrest/http_shared.rbc +0 -279
  35. data/lib/wrest/native/connection_factory.rbc +0 -445
  36. data/lib/wrest/native/delete.rbc +0 -371
  37. data/lib/wrest/native/get.rbc +0 -855
  38. data/lib/wrest/native/options.rbc +0 -347
  39. data/lib/wrest/native/post.rbc +0 -388
  40. data/lib/wrest/native/put.rbc +0 -388
  41. data/lib/wrest/native/redirection.rbc +0 -520
  42. data/lib/wrest/native/request.rbc +0 -1675
  43. data/lib/wrest/native/response.rbc +0 -2150
  44. data/lib/wrest/native/session.rbc +0 -1372
  45. data/lib/wrest/native.rbc +0 -513
  46. data/lib/wrest/resource/base.rbc +0 -2115
  47. data/lib/wrest/resource.rbc +0 -163
  48. data/lib/wrest/uri.rbc +0 -2599
  49. data/lib/wrest/uri_template.rbc +0 -505
  50. data/lib/wrest/version.rbc +0 -372
  51. data/lib/wrest.rbc +0 -1900
data/CHANGELOG CHANGED
@@ -18,6 +18,14 @@ Features under a numbered section are complete and available in the Wrest gem.
18
18
 
19
19
  == Current
20
20
 
21
+ == 1.0.0.beta3
22
+ * GH#13 Works for get and delete with parameters appended to the uri string and
23
+ with ? and no parameters appended to the uri string
24
+ * GH#26 'http://localhost'.to_uri['foo/bar'] fails
25
+ * GH#11 Handle gem dependencies using bundler
26
+ * GH#22 Converts Uri to UriTemplate
27
+ * GH#23 Supports extension of UriTemplate via #[]
28
+
21
29
  == 1.0.0.beta2
22
30
  * GH#2 Make Components::Containers hash store a HashWithIndifferentAccess
23
31
  * GH#6 Net::HTTP based calls to Twitter public APIs fail
@@ -56,4 +64,4 @@ Features under a numbered section are complete and available in the Wrest gem.
56
64
  == 0.0.8
57
65
  * Added URI extension using the [] method (see examples/delicious.rb)
58
66
  * Refactored out Request as the first step to adding Response caching
59
-
67
+
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = Wrest 1.0.0.beta2
1
+ = Wrest 1.0.0.beta3
2
2
 
3
3
  (c) Copyright 2009-2010 {Sidu Ponnappa}[http://blog.sidu.in]. All Rights Reserved.
4
4
 
@@ -7,7 +7,7 @@ Wrest is a ruby REST/HTTP client library which
7
7
  * Allows allows you to quickly build object oriented wrappers around any web service
8
8
  * Designed to be used as a library, not just a command line REST client (fewer class/static methods, more object oriented)
9
9
  * Is spec driven, strongly favours immutable objects and avoids class methods and setters making it better suited for use as a library, especially in multi-threaded environments
10
- * Runs on Ruby 1.8, Ruby 1.9.2 and JRuby with Rubinius, MacRuby and IronRuby support on the way
10
+ * Runs on Ruby 1.8, Ruby 1.9.2, JRuby and Rubinius with MacRuby and IronRuby support on the way
11
11
  * Provides convenient HTTP wrappers, redirect handling, serialisation and deserialisation with response caching in the works
12
12
  * Supports using either Net::HTTP or libcurl as the underlying HTTP library
13
13
 
data/lib/wrest/curl.rb CHANGED
@@ -8,9 +8,9 @@
8
8
  # See the License for the specific language governing permissions and limitations under the License.
9
9
 
10
10
  begin
11
- gem 'patron', '>=0.4.4'
11
+ gem 'patron', '~> 0.4.9'
12
12
  rescue Gem::LoadError => e
13
- Wrest.logger.debug "Patron >= 0.4.4 not found. Patron is necessary to use libcurl. To install Patron run `sudo gem install patron` (patron is not available on JRuby, but you shouldn't need it anyway)."
13
+ Wrest.logger.debug "Patron ~> 0.4.9 not found. Patron is necessary to use libcurl. To install Patron run `sudo gem install patron` (patron is not available on JRuby, but you shouldn't need it anyway)."
14
14
  raise e
15
15
  end
16
16
  require 'patron'
@@ -8,9 +8,9 @@
8
8
  # See the License for the specific language governing permissions and limitations under the License.
9
9
 
10
10
  begin
11
- gem 'multipart-post', '>= 1.0'
11
+ gem 'multipart-post', '~> 1.0'
12
12
  rescue Gem::LoadError => e
13
- Wrest.logger.debug "Multipart Post >= 1.0 not found. Multipart Post is necessary to be able to post multipart. To install Multipart Post run 'sudo gem install multipart-post'"
13
+ Wrest.logger.debug "Multipart Post ~> 1.0 not found. Multipart Post is necessary to be able to post multipart. To install Multipart Post run 'sudo gem install multipart-post'"
14
14
  raise e
15
15
  end
16
16
 
@@ -28,7 +28,7 @@ module Wrest
28
28
  # The methods in this module are mixed into Wrest::Uri.
29
29
  module Multipart
30
30
  # Makes a multipart/form-data encoded POST request to this URI. This is a convenience API
31
- # that mimics a multipart form being posted; some allegly RESTful APIs like FCBK require
31
+ # that mimics a multipart form being posted; some allegedly RESTful APIs like FCBK require
32
32
  # this for file uploads.
33
33
  #
34
34
  # File.open('/path/to/image.jpg') do |file|
@@ -1,5 +1,4 @@
1
1
  # Copyright 2009 Sidu Ponnappa
2
-
3
2
  # Licensed under the Apache License, Version 2.0 (the "License");
4
3
  # you may not use this file except in compliance with the License.
5
4
  # You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -84,7 +84,11 @@ module Wrest::Native
84
84
  end
85
85
 
86
86
  def build_request(request_klass, uri, parameters, headers)
87
- request_klass.new(parameters.empty? ? uri.full_path : "#{uri.full_path}?#{parameters.to_query}", headers)
87
+ if(!uri.query.empty?)
88
+ request_klass.new(parameters.empty? ? "#{uri.uri_path}?#{uri.query}" : "#{uri.uri_path}?#{uri.query}&#{parameters.to_query}", headers)
89
+ else
90
+ request_klass.new(parameters.empty? ? "#{uri.uri_path}" : "#{uri.uri_path}?#{parameters.to_query}", headers)
91
+ end
88
92
  end
89
93
 
90
94
  def do_request
data/lib/wrest/uri.rb CHANGED
@@ -22,17 +22,26 @@ module Wrest #:nodoc:
22
22
  #
23
23
  # You can find examples that use real APIs (like delicious) under the wrest/examples directory.
24
24
  class Uri
25
- attr_reader :uri, :username, :password, :uri_string
25
+ attr_reader :uri, :username, :password, :uri_string, :uri_path, :query
26
26
 
27
27
  # See Wrest::Http::Request for the available options and their default values.
28
28
  def initialize(uri_string, options = {})
29
- @options = options
30
- @uri_string = uri_string.clone
31
- @uri = URI.parse(uri_string)
32
- @username = (@options[:username] ||= @uri.user)
33
- @password = (@options[:password] ||= @uri.password)
34
- end
29
+ @options = options
30
+ @uri_string = uri_string.to_s
31
+ @uri = URI.parse(@uri_string)
32
+ uri_scheme = URI.split(@uri_string)
33
+ @uri_path = uri_scheme[-4].split('?').first || ''
34
+ @uri_path = (@uri_path.empty? ? '/' : @uri_path)
35
+ @query = uri_scheme[-2] || ''
36
+ @username = (@options[:username] ||= @uri.user)
37
+ @password = (@options[:password] ||= @uri.password)
38
+ end
35
39
 
40
+ def to_template(pattern)
41
+ template_pattern = URI.join(uri_string,pattern).to_s
42
+ UriTemplate.new(template_pattern)
43
+ end
44
+
36
45
  # Build a new Wrest::Uri by appending _path_ to
37
46
  # the current uri. If the original Wrest::Uri
38
47
  # has a username and password, that will be
@@ -49,7 +58,7 @@ module Wrest #:nodoc:
49
58
  # uri = "https://localhost:3000/v1".to_uri(:username => 'foo', :password => 'bar')
50
59
  # uri['/oogas/1', {:username => 'meh', :password => 'baz'}].get
51
60
  def [](path, options = nil)
52
- Uri.new(@uri_string+path, options || @options)
61
+ Uri.new(URI.join(uri_string, path), options || @options)
53
62
  end
54
63
 
55
64
  # Clones a Uri, building a new instance with exactly the same uri string.
@@ -130,10 +139,10 @@ module Wrest #:nodoc:
130
139
  Http::Options.new(self, @options).invoke
131
140
  end
132
141
 
133
- def https?
142
+ def https?
134
143
  @uri.is_a?(URI::HTTPS)
135
144
  end
136
-
145
+
137
146
  # Provides the full path of a request.
138
147
  # For example, for
139
148
  # http://localhost:3000/demons/1/chi?sort=true
@@ -142,7 +151,7 @@ module Wrest #:nodoc:
142
151
  def full_path
143
152
  uri.request_uri
144
153
  end
145
-
154
+
146
155
  def protocol
147
156
  uri.scheme
148
157
  end
@@ -45,5 +45,14 @@ module Wrest
45
45
  uri_string.gsub(":#{key.to_s}", value.to_s)
46
46
  end.to_uri
47
47
  end
48
+
49
+ def [](path)
50
+ UriTemplate.new(URI.join(uri_pattern,path).to_s)
51
+ end
52
+
53
+ def ==(other)
54
+ return false if other.class != self.class
55
+ return other.uri_pattern == self.uri_pattern
56
+ end
48
57
  end
49
58
  end
data/lib/wrest/version.rb CHANGED
@@ -13,7 +13,7 @@ module Wrest
13
13
  MAJOR = 1
14
14
  MINOR = 0
15
15
  TINY = 0
16
- BUILD = 'beta2'
16
+ BUILD = 'beta3'
17
17
 
18
18
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
19
19
 
data/lib/wrest.rb CHANGED
@@ -57,7 +57,7 @@ begin
57
57
  ActiveSupport::XmlMini.backend='LibXML'
58
58
  rescue Gem::LoadError
59
59
  begin
60
- gem 'nokogiri', '>= 1.3.3'
60
+ gem 'nokogiri', '~> 1.4.3.1'
61
61
  ActiveSupport::XmlMini.backend='Nokogiri'
62
62
  rescue Gem::LoadError
63
63
  unless RUBY_PLATFORM =~ /java/
@@ -66,7 +66,7 @@ rescue Gem::LoadError
66
66
  Wrest.logger.debug "Warning: Nokogiri >= 1.3.3 not found, falling back to #{ActiveSupport::XmlMini.backend} (which is probably significantly slower). To install Nokogiri run `(sudo) (jruby -S) gem install nokogiri`"
67
67
  if RUBY_PLATFORM =~ /java/
68
68
  begin
69
- gem 'jrexml', '>= 0.5.3'
69
+ gem 'jrexml', '~> 0.5.3'
70
70
  require 'jrexml'
71
71
  Wrest.logger.debug "Detected JRuby, JREXML loaded."
72
72
  rescue Gem::LoadError
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wrest
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1848230054
4
+ hash: 299253595
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 0
10
- - beta2
11
- version: 1.0.0.beta2
10
+ - beta3
11
+ version: 1.0.0.beta3
12
12
  platform: ruby
13
13
  authors:
14
14
  - Sidu Ponnappa
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-08-31 00:00:00 +05:30
20
+ date: 2010-09-15 00:00:00 +05:30
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -26,15 +26,16 @@ dependencies:
26
26
  requirement: &id001 !ruby/object:Gem::Requirement
27
27
  none: false
28
28
  requirements:
29
- - - "="
29
+ - - ~>
30
30
  - !ruby/object:Gem::Version
31
- hash: -1967355497
31
+ hash: 62196431
32
32
  segments:
33
33
  - 2
34
34
  - 0
35
35
  - 0
36
- - beta19
37
- version: 2.0.0.beta19
36
+ - beta
37
+ - 22
38
+ version: 2.0.0.beta.22
38
39
  type: :development
39
40
  version_requirements: *id001
40
41
  - !ruby/object:Gem::Dependency
@@ -43,7 +44,7 @@ dependencies:
43
44
  requirement: &id002 !ruby/object:Gem::Requirement
44
45
  none: false
45
46
  requirements:
46
- - - ">="
47
+ - - ~>
47
48
  - !ruby/object:Gem::Version
48
49
  hash: 7
49
50
  segments:
@@ -54,12 +55,28 @@ dependencies:
54
55
  type: :runtime
55
56
  version_requirements: *id002
56
57
  - !ruby/object:Gem::Dependency
57
- name: json
58
+ name: builder
58
59
  prerelease: false
59
60
  requirement: &id003 !ruby/object:Gem::Requirement
60
61
  none: false
61
62
  requirements:
62
- - - ">="
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ hash: 15
66
+ segments:
67
+ - 2
68
+ - 1
69
+ - 2
70
+ version: 2.1.2
71
+ type: :runtime
72
+ version_requirements: *id003
73
+ - !ruby/object:Gem::Dependency
74
+ name: json
75
+ prerelease: false
76
+ requirement: &id004 !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ~>
63
80
  - !ruby/object:Gem::Version
64
81
  hash: 11
65
82
  segments:
@@ -68,7 +85,7 @@ dependencies:
68
85
  - 6
69
86
  version: 1.4.6
70
87
  type: :runtime
71
- version_requirements: *id003
88
+ version_requirements: *id004
72
89
  description: Wrest is a HTTP and REST client library which allows you to quickly build well encapsulated, object oriented wrappers around any web service.
73
90
  email:
74
91
  - sidu@c42.in
@@ -79,103 +96,63 @@ extensions: []
79
96
  extra_rdoc_files:
80
97
  - README.rdoc
81
98
  files:
82
- - bin/wrest
83
99
  - bin/wrest_shell.rb
84
- - lib/wrest/components/container/alias_accessors.rb
85
- - lib/wrest/components/container/alias_accessors.rbc
86
- - lib/wrest/components/container/typecaster.rb
87
- - lib/wrest/components/container/typecaster.rbc
88
- - lib/wrest/components/container.rb
89
- - lib/wrest/components/container.rbc
90
- - lib/wrest/components/mutators/base.rb
91
- - lib/wrest/components/mutators/base.rbc
92
- - lib/wrest/components/mutators/camel_to_snake_case.rb
93
- - lib/wrest/components/mutators/camel_to_snake_case.rbc
94
- - lib/wrest/components/mutators/xml_mini_type_caster.rb
95
- - lib/wrest/components/mutators/xml_mini_type_caster.rbc
96
- - lib/wrest/components/mutators/xml_simple_type_caster.rb
97
- - lib/wrest/components/mutators/xml_simple_type_caster.rbc
98
- - lib/wrest/components/mutators.rb
99
- - lib/wrest/components/mutators.rbc
100
- - lib/wrest/components/translators/content_types.rb
101
- - lib/wrest/components/translators/content_types.rbc
102
- - lib/wrest/components/translators/json.rb
103
- - lib/wrest/components/translators/json.rbc
104
- - lib/wrest/components/translators/xml.rb
105
- - lib/wrest/components/translators/xml.rbc
106
- - lib/wrest/components/translators.rb
107
- - lib/wrest/components/translators.rbc
108
- - lib/wrest/components.rb
109
- - lib/wrest/components.rbc
100
+ - bin/wrest
101
+ - lib/wrest.rb
102
+ - lib/wrest/uri_template.rb
103
+ - lib/wrest/version.rb
104
+ - lib/wrest/resource/state.rb
105
+ - lib/wrest/resource/base.rb
106
+ - lib/wrest/resource/collection.rb
107
+ - lib/wrest/test.rb
110
108
  - lib/wrest/core_ext/hash/conversions.rb
111
- - lib/wrest/core_ext/hash/conversions.rbc
112
109
  - lib/wrest/core_ext/hash.rb
113
- - lib/wrest/core_ext/hash.rbc
114
110
  - lib/wrest/core_ext/string/conversions.rb
115
- - lib/wrest/core_ext/string/conversions.rbc
116
111
  - lib/wrest/core_ext/string.rb
117
- - lib/wrest/core_ext/string.rbc
118
- - lib/wrest/curl/delete.rb
119
- - lib/wrest/curl/get.rb
120
- - lib/wrest/curl/options.rb
121
- - lib/wrest/curl/post.rb
122
- - lib/wrest/curl/put.rb
123
- - lib/wrest/curl/request.rb
124
- - lib/wrest/curl/response.rb
125
- - lib/wrest/curl/session.rb
126
112
  - lib/wrest/curl.rb
127
- - lib/wrest/curl.rbc
128
- - lib/wrest/exceptions.rb
129
- - lib/wrest/exceptions.rbc
130
- - lib/wrest/http_shared/headers.rb
131
- - lib/wrest/http_shared/headers.rbc
132
- - lib/wrest/http_shared/standard_headers.rb
133
- - lib/wrest/http_shared/standard_headers.rbc
134
- - lib/wrest/http_shared/standard_tokens.rb
135
- - lib/wrest/http_shared/standard_tokens.rbc
113
+ - lib/wrest/native.rb
136
114
  - lib/wrest/http_shared.rb
137
- - lib/wrest/http_shared.rbc
138
- - lib/wrest/multipart.rb
139
- - lib/wrest/native/connection_factory.rb
140
- - lib/wrest/native/connection_factory.rbc
141
- - lib/wrest/native/delete.rb
142
- - lib/wrest/native/delete.rbc
143
- - lib/wrest/native/get.rb
144
- - lib/wrest/native/get.rbc
115
+ - lib/wrest/native/session.rb
116
+ - lib/wrest/native/redirection.rb
117
+ - lib/wrest/native/response.rb
145
118
  - lib/wrest/native/options.rb
146
- - lib/wrest/native/options.rbc
119
+ - lib/wrest/native/get.rb
120
+ - lib/wrest/native/connection_factory.rb
121
+ - lib/wrest/native/request.rb
147
122
  - lib/wrest/native/post.rb
148
- - lib/wrest/native/post.rbc
149
- - lib/wrest/native/post_multipart.rb
150
- - lib/wrest/native/put.rb
151
- - lib/wrest/native/put.rbc
152
123
  - lib/wrest/native/put_multipart.rb
153
- - lib/wrest/native/redirection.rb
154
- - lib/wrest/native/redirection.rbc
155
- - lib/wrest/native/request.rb
156
- - lib/wrest/native/request.rbc
157
- - lib/wrest/native/response.rb
158
- - lib/wrest/native/response.rbc
159
- - lib/wrest/native/session.rb
160
- - lib/wrest/native/session.rbc
161
- - lib/wrest/native.rb
162
- - lib/wrest/native.rbc
163
- - lib/wrest/resource/base.rb
164
- - lib/wrest/resource/base.rbc
165
- - lib/wrest/resource/collection.rb
166
- - lib/wrest/resource/state.rb
124
+ - lib/wrest/native/put.rb
125
+ - lib/wrest/native/delete.rb
126
+ - lib/wrest/native/post_multipart.rb
127
+ - lib/wrest/uri.rb
128
+ - lib/wrest/components.rb
129
+ - lib/wrest/curl/session.rb
130
+ - lib/wrest/curl/response.rb
131
+ - lib/wrest/curl/options.rb
132
+ - lib/wrest/curl/get.rb
133
+ - lib/wrest/curl/request.rb
134
+ - lib/wrest/curl/post.rb
135
+ - lib/wrest/curl/put.rb
136
+ - lib/wrest/curl/delete.rb
137
+ - lib/wrest/exceptions.rb
138
+ - lib/wrest/components/translators/json.rb
139
+ - lib/wrest/components/translators/xml.rb
140
+ - lib/wrest/components/translators/content_types.rb
141
+ - lib/wrest/components/mutators.rb
142
+ - lib/wrest/components/translators.rb
143
+ - lib/wrest/components/container.rb
144
+ - lib/wrest/components/container/alias_accessors.rb
145
+ - lib/wrest/components/container/typecaster.rb
146
+ - lib/wrest/components/mutators/camel_to_snake_case.rb
147
+ - lib/wrest/components/mutators/xml_mini_type_caster.rb
148
+ - lib/wrest/components/mutators/base.rb
149
+ - lib/wrest/components/mutators/xml_simple_type_caster.rb
150
+ - lib/wrest/http_shared/standard_tokens.rb
151
+ - lib/wrest/http_shared/standard_headers.rb
152
+ - lib/wrest/http_shared/headers.rb
167
153
  - lib/wrest/resource.rb
168
- - lib/wrest/resource.rbc
169
154
  - lib/wrest/test/request_patches.rb
170
- - lib/wrest/test.rb
171
- - lib/wrest/uri.rb
172
- - lib/wrest/uri.rbc
173
- - lib/wrest/uri_template.rb
174
- - lib/wrest/uri_template.rbc
175
- - lib/wrest/version.rb
176
- - lib/wrest/version.rbc
177
- - lib/wrest.rb
178
- - lib/wrest.rbc
155
+ - lib/wrest/multipart.rb
179
156
  - README.rdoc
180
157
  - CHANGELOG
181
158
  - LICENCE