wrest 1.0.0.beta5-universal-java-1.6 → 1.0.0.beta6-universal-java-1.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -18,6 +18,10 @@ Features under a numbered section are complete and available in the Wrest gem.
18
18
 
19
19
  == Current
20
20
 
21
+ == 1.0.0.beta6
22
+ * GH#35 Wrest::UriTemplate extensions swallow existing path
23
+ * GH#41 Make Hash core_ext opt out
24
+
21
25
  == 1.0.0.beta5
22
26
  * GH#30 Replace rails app in spec/sample_rails_app with a lighter sinatra app
23
27
  * GH#37 Allow opting out of Adding to_uri to string
@@ -1,4 +1,4 @@
1
- = Wrest 1.0.0.beta4
1
+ = Wrest 1.0.0.beta5
2
2
 
3
3
  (c) Copyright 2009-2010 {Sidu Ponnappa}[http://blog.sidu.in]. All Rights Reserved.
4
4
 
@@ -147,10 +147,10 @@ You can launch the interactive Wrest shell by running bin/wrest if you have the
147
147
 
148
148
  == Contributors
149
149
 
150
- * Sidu Ponnappa : {kaiwren}[http://github.com/kaiwren]
151
- * Niranjan Paranjape : {achamian}[http://github.com/achamian]
152
- * Aakash Dharmadhkari : {aakashd}[http://github.com/aakashd]
153
- * Srushti : {srushti}[http://github.com/srushti]
154
- * Preethi Ramdev : {preethiramdev}[http://github.com/preethiramdev]
155
- * Nikhil Vallishayee : {preethiramdev}[http://github.com/preethiramdev]
156
- * Jacques Crocker: {railsjedi}[http://github.com/railsjedi]
150
+ * Sidu Ponnappa : {kaiwren}[http://github.com/kaiwren]
151
+ * Niranjan Paranjape : {achamian}[http://github.com/achamian]
152
+ * Aakash Dharmadhkari : {aakashd}[http://github.com/aakashd]
153
+ * Srushti : {srushti}[http://github.com/srushti]
154
+ * Preethi Ramdev : {preethiramdev}[http://github.com/preethiramdev]
155
+ * Nikhil Vallishayee : {nikhilvallishayee}[http://github.com/nikhilvallishayee]
156
+ * Jacques Crocker : {railsjedi}[http://github.com/railsjedi]
@@ -80,7 +80,8 @@ RUBY_PLATFORM =~ /java/ ? gem('json-jruby', '>= 1.4.2') : gem('json', '>= 1.4.2'
80
80
  ActiveSupport::JSON.backend = "JSONGem"
81
81
 
82
82
 
83
- Dir["#{File.expand_path(File.dirname(__FILE__))}/wrest/core_ext/*.rb"].each { |file| require file }
83
+
84
+ require "#{Wrest::Root}/wrest/core_ext/string"
84
85
 
85
86
  # Load Wrest Core
86
87
  require "#{Wrest::Root}/wrest/version"
@@ -16,5 +16,4 @@ module Wrest
16
16
  end
17
17
 
18
18
  require "#{Wrest::Root}/wrest/components/container"
19
- require "#{Wrest::Root}/wrest/components/mutators"
20
- require "#{Wrest::Root}/wrest/components/translators"
19
+ require "#{Wrest::Root}/wrest/components/translators"
@@ -32,8 +32,9 @@ module Wrest
32
32
  end
33
33
  end
34
34
  end
35
-
35
+ require "#{Wrest::Root}/wrest/core_ext/hash"
36
36
  require "#{Wrest::Root}/wrest/components/mutators/base"
37
37
  require "#{Wrest::Root}/wrest/components/mutators/xml_simple_type_caster"
38
38
  require "#{Wrest::Root}/wrest/components/mutators/xml_mini_type_caster"
39
- require "#{Wrest::Root}/wrest/components/mutators/camel_to_snake_case"
39
+ require "#{Wrest::Root}/wrest/components/mutators/camel_to_snake_case"
40
+
@@ -6,19 +6,61 @@
6
6
  # Unless required by applicable law or agreed to in writing, software distributed under the License
7
7
  # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8
8
  # See the License for the specific language governing permissions and limitations under the License.
9
-
9
+ # require 'jruby'
10
+ # include Java
11
+ #
12
+ # java_import javax.xml.parsers.DocumentBuilder
13
+ # java_import javax.xml.parsers.DocumentBuilderFactory
14
+ # java_import java.io.StringReader
15
+ # java_import org.xml.sax.InputSource
16
+ # java_import javax.xml.xpath.XPath
17
+ # java_import javax.xml.xpath.XPathFactory
18
+ # java_import javax.xml.xpath.XPathConstants
19
+ # java_import javax.xml.xpath.XPathExpression
20
+ # #java_import Java::org.jdom.input.SAXBuilder
10
21
  module Wrest
11
22
  module Components::Translators
12
23
  module Xml
13
24
  extend self
14
25
 
15
- def deserialise(response)
16
- Hash.from_xml(response.body)
26
+ def deserialise(response,options={})
27
+ if(!options[:xpath].nil?)
28
+ Hash.from_xml(filter(response,options[:xpath]))
29
+ else
30
+ Hash.from_xml(response.body)
31
+ end
17
32
  end
18
33
 
19
34
  def serialise(hash, options = {})
20
35
  hash.to_xml(options)
21
36
  end
37
+
38
+ def filter(response,xpath)
39
+ filter_rexml(response,xpath)
40
+ end
41
+
42
+ def filter_rexml(response,xpath)
43
+ doc = REXML::Document.new(response.body)
44
+ REXML::XPath.first(doc,xpath).to_s
45
+ end
46
+
47
+
48
+ # def filter_jdom(response,xpath)
49
+ # # string_reader = StringReader.new(response.body)
50
+ # input_source = InputSource.new(string_reader)
51
+ # #p input_source.to_s
52
+ # doc = DocumentBuilderFactory.new_instance.new_document_builder.parse(input_source)
53
+ # #doc = SAXBuilder.new.build(string_reader)
54
+ # p doc
55
+ # p doc.toString
56
+ # #xpath_instance = XPathFactory.new_instance.newXPath
57
+ # #expr = xpath_instance.compile(xpath)
58
+ # #p expr.to_s
59
+ # #result = expr.evaluate(doc)
60
+
61
+ # #puts result
62
+ # end
63
+
22
64
  end
23
65
  end
24
66
  end
@@ -2,4 +2,4 @@ require "#{Wrest::Root}/wrest/core_ext/hash/conversions"
2
2
 
3
3
  class Hash #:nodoc:
4
4
  include Wrest::CoreExt::Hash::Conversions
5
- end
5
+ end
@@ -30,12 +30,12 @@ module Wrest #:nodoc:
30
30
  initialize_http_header
31
31
  end
32
32
 
33
- def deserialise
34
- deserialise_using(Wrest::Components::Translators.lookup(content_type))
33
+ def deserialise(options = {})
34
+ deserialise_using(Wrest::Components::Translators.lookup(content_type),options)
35
35
  end
36
36
 
37
- def deserialise_using(translator)
38
- translator.deserialise(@http_response)
37
+ def deserialise_using(translator,options={})
38
+ translator.deserialise(@http_response,options)
39
39
  end
40
40
 
41
41
  def code
@@ -68,4 +68,4 @@ module Wrest #:nodoc:
68
68
  end
69
69
  end
70
70
  end
71
- end
71
+ end
@@ -6,7 +6,7 @@
6
6
  # Unless required by applicable law or agreed to in writing, software distributed under the License
7
7
  # is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
8
8
  # See the License for the specific language governing permissions and limitations under the License.
9
-
9
+ require "rexml/document"
10
10
  module Wrest #:nodoc:
11
11
  module Native #:nodoc:
12
12
  # Decorates a response providing support for deserialisation.
@@ -40,12 +40,13 @@ module Wrest #:nodoc:
40
40
  @http_response = http_response
41
41
  end
42
42
 
43
- def deserialise
44
- deserialise_using(Wrest::Components::Translators.lookup(@http_response.content_type))
43
+
44
+ def deserialise(options = {})
45
+ deserialise_using(Wrest::Components::Translators.lookup(@http_response.content_type),options)
45
46
  end
46
47
 
47
- def deserialise_using(translator)
48
- translator.deserialise(@http_response)
48
+ def deserialise_using(translator,options = {})
49
+ translator.deserialise(@http_response,options)
49
50
  end
50
51
 
51
52
  def headers
@@ -54,7 +55,7 @@ module Wrest #:nodoc:
54
55
 
55
56
  # A null object implementation - invoking this method on
56
57
  # a response simply returns the same response unless
57
- # the response is a Redirection (code 3xx), in which case a
58
+ # the response is Redirection (code 3xx), in which case a
58
59
  # get is invoked on the url stored in the response headers
59
60
  # under the key 'location' and the new Response is returned.
60
61
  def follow(redirect_request_options = {})
@@ -47,7 +47,7 @@ module Wrest
47
47
  end
48
48
 
49
49
  def [](path)
50
- UriTemplate.new(URI.join(uri_pattern,path).to_s)
50
+ UriTemplate.new(File.join(uri_pattern, path))
51
51
  end
52
52
 
53
53
  def ==(other)
@@ -13,7 +13,7 @@ module Wrest
13
13
  MAJOR = 1
14
14
  MINOR = 0
15
15
  TINY = 0
16
- BUILD = 'beta5'
16
+ BUILD = 'beta6'
17
17
 
18
18
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
19
19
 
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 1
7
7
  - 0
8
8
  - 0
9
- - beta5
10
- version: 1.0.0.beta5
9
+ - beta6
10
+ version: 1.0.0.beta6
11
11
  platform: universal-java-1.6
12
12
  authors:
13
13
  - Sidu Ponnappa
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-09-19 00:00:00 +05:30
19
+ date: 2010-09-21 00:00:00 +05:30
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -108,63 +108,63 @@ extensions: []
108
108
  extra_rdoc_files:
109
109
  - README.rdoc
110
110
  files:
111
- - bin/wrest
112
111
  - bin/wrest_shell.rb
113
- - lib/wrest.rb
112
+ - bin/wrest
114
113
  - lib/wrest_no_ext.rb
115
- - lib/wrest/components.rb
114
+ - lib/wrest.rb
115
+ - lib/wrest/uri_template.rb
116
+ - lib/wrest/version.rb
117
+ - lib/wrest/test.rb
116
118
  - lib/wrest/curl.rb
117
- - lib/wrest/exceptions.rb
118
- - lib/wrest/http_shared.rb
119
- - lib/wrest/multipart.rb
120
119
  - lib/wrest/native.rb
121
- - lib/wrest/resource.rb
122
- - lib/wrest/test.rb
120
+ - lib/wrest/http_shared.rb
123
121
  - lib/wrest/uri.rb
124
- - lib/wrest/uri_template.rb
125
- - lib/wrest/version.rb
126
- - lib/wrest/components/container.rb
127
- - lib/wrest/components/mutators.rb
128
- - lib/wrest/components/translators.rb
129
- - lib/wrest/components/container/alias_accessors.rb
130
- - lib/wrest/components/container/typecaster.rb
131
- - lib/wrest/components/mutators/base.rb
132
- - lib/wrest/components/mutators/camel_to_snake_case.rb
133
- - lib/wrest/components/mutators/xml_mini_type_caster.rb
134
- - lib/wrest/components/mutators/xml_simple_type_caster.rb
135
- - lib/wrest/components/translators/content_types.rb
136
- - lib/wrest/components/translators/json.rb
137
- - lib/wrest/components/translators/xml.rb
122
+ - lib/wrest/components.rb
123
+ - lib/wrest/exceptions.rb
124
+ - lib/wrest/resource.rb
125
+ - lib/wrest/multipart.rb
126
+ - lib/wrest/resource/state.rb
127
+ - lib/wrest/resource/base.rb
128
+ - lib/wrest/resource/collection.rb
138
129
  - lib/wrest/core_ext/hash.rb
139
130
  - lib/wrest/core_ext/string.rb
140
131
  - lib/wrest/core_ext/hash/conversions.rb
141
132
  - lib/wrest/core_ext/string/conversions.rb
142
- - lib/wrest/curl/delete.rb
143
- - lib/wrest/curl/get.rb
133
+ - lib/wrest/native/session.rb
134
+ - lib/wrest/native/redirection.rb
135
+ - lib/wrest/native/response.rb
136
+ - lib/wrest/native/options.rb
137
+ - lib/wrest/native/get.rb
138
+ - lib/wrest/native/connection_factory.rb
139
+ - lib/wrest/native/request.rb
140
+ - lib/wrest/native/post.rb
141
+ - lib/wrest/native/put_multipart.rb
142
+ - lib/wrest/native/put.rb
143
+ - lib/wrest/native/delete.rb
144
+ - lib/wrest/native/post_multipart.rb
145
+ - lib/wrest/curl/session.rb
146
+ - lib/wrest/curl/response.rb
144
147
  - lib/wrest/curl/options.rb
148
+ - lib/wrest/curl/get.rb
149
+ - lib/wrest/curl/request.rb
145
150
  - lib/wrest/curl/post.rb
146
151
  - lib/wrest/curl/put.rb
147
- - lib/wrest/curl/request.rb
148
- - lib/wrest/curl/response.rb
149
- - lib/wrest/curl/session.rb
150
- - lib/wrest/http_shared/headers.rb
151
- - lib/wrest/http_shared/standard_headers.rb
152
+ - lib/wrest/curl/delete.rb
153
+ - lib/wrest/components/mutators.rb
154
+ - lib/wrest/components/translators.rb
155
+ - lib/wrest/components/container.rb
156
+ - lib/wrest/components/translators/json.rb
157
+ - lib/wrest/components/translators/xml.rb
158
+ - lib/wrest/components/translators/content_types.rb
159
+ - lib/wrest/components/container/alias_accessors.rb
160
+ - lib/wrest/components/container/typecaster.rb
161
+ - lib/wrest/components/mutators/camel_to_snake_case.rb
162
+ - lib/wrest/components/mutators/xml_mini_type_caster.rb
163
+ - lib/wrest/components/mutators/base.rb
164
+ - lib/wrest/components/mutators/xml_simple_type_caster.rb
152
165
  - lib/wrest/http_shared/standard_tokens.rb
153
- - lib/wrest/native/connection_factory.rb
154
- - lib/wrest/native/delete.rb
155
- - lib/wrest/native/get.rb
156
- - lib/wrest/native/options.rb
157
- - lib/wrest/native/post.rb
158
- - lib/wrest/native/post_multipart.rb
159
- - lib/wrest/native/put.rb
160
- - lib/wrest/native/put_multipart.rb
161
- - lib/wrest/native/redirection.rb
162
- - lib/wrest/native/request.rb
163
- - lib/wrest/native/response.rb
164
- - lib/wrest/native/session.rb
165
- - lib/wrest/resource/base.rb
166
- - lib/wrest/resource/collection.rb
167
- - lib/wrest/resource/state.rb
166
+ - lib/wrest/http_shared/standard_headers.rb
167
+ - lib/wrest/http_shared/headers.rb
168
168
  - lib/wrest/test/request_patches.rb
169
169
  - README.rdoc
170
170
  - CHANGELOG