wrest 1.0.0.beta6-universal-java-1.6 → 1.0.0-universal-java-1.6
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/CHANGELOG +9 -0
- data/README.rdoc +31 -4
- data/bin/wrest_shell.rb +2 -2
- data/lib/wrest.rb +3 -0
- data/lib/wrest/components/translators/json.rb +1 -1
- data/lib/wrest/components/translators/xml.rb +1 -40
- data/lib/wrest/curl/request.rb +3 -3
- data/lib/wrest/curl/session.rb +1 -1
- data/lib/wrest/exceptions.rb +1 -1
- data/lib/wrest/native/connection_factory.rb +6 -5
- data/lib/wrest/native/redirection.rb +1 -1
- data/lib/wrest/native/request.rb +10 -3
- data/lib/wrest/native/session.rb +1 -1
- data/lib/wrest/uri.rb +6 -6
- data/lib/wrest/version.rb +1 -1
- data/lib/wrest/xml_mini.rb +10 -0
- data/lib/wrest/xml_mini/jdom.rb +6 -0
- data/lib/wrest/xml_mini/jdom/xpath_filter.rb +17 -0
- data/lib/wrest/xml_mini/libxml.rb +8 -0
- data/lib/wrest/xml_mini/libxml/xpath_filter.rb +12 -0
- data/lib/wrest/xml_mini/nokogiri.rb +7 -0
- data/lib/wrest/xml_mini/nokogiri/xpath_filter.rb +15 -0
- data/lib/wrest/xml_mini/rexml.rb +8 -0
- data/lib/wrest/xml_mini/rexml/xpath_filter.rb +15 -0
- metadata +55 -54
data/CHANGELOG
CHANGED
|
@@ -17,6 +17,15 @@ Features under a numbered section are complete and available in the Wrest gem.
|
|
|
17
17
|
* Ensure Components::Container is ActiveModel compliant
|
|
18
18
|
|
|
19
19
|
== Current
|
|
20
|
+
* GH#56 Detailed Net::HTTP debug output option added to Wrest::Native:Request.
|
|
21
|
+
* GH#60 Wrest debug log arrow direction changed to be consistent with Net::HTPP debug log
|
|
22
|
+
* GH#59 follow_redirects_limit is off by one
|
|
23
|
+
* GH#24 Add support for xpath based filtering of xml response bodies to the response chain
|
|
24
|
+
* GH#46 Response.deserialise for Json responses
|
|
25
|
+
* GH#52 Wrest console (bin/wrest) fails on 1.9.2
|
|
26
|
+
|
|
27
|
+
== 1.0.0.beta7
|
|
28
|
+
* GH#46 Response.deserialise for Json responses
|
|
20
29
|
|
|
21
30
|
== 1.0.0.beta6
|
|
22
31
|
* GH#35 Wrest::UriTemplate extensions swallow existing path
|
data/README.rdoc
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
= Wrest 1.0.0
|
|
1
|
+
= Wrest 1.0.0
|
|
2
2
|
|
|
3
3
|
(c) Copyright 2009-2010 {Sidu Ponnappa}[http://blog.sidu.in]. All Rights Reserved.
|
|
4
4
|
|
|
@@ -34,6 +34,17 @@ For Facebook, Twitter, Delicious, GitHub and other API examples, see http://gith
|
|
|
34
34
|
'http://google.com'.to_uri(:follow_redirects => false).get
|
|
35
35
|
|
|
36
36
|
'http://google.com'.to_uri(:follow_redirects_limit => 1).get
|
|
37
|
+
|
|
38
|
+
:follow_redirects_limit defaults to 5 if not specified.
|
|
39
|
+
|
|
40
|
+
* Deserialise with XPath filtering
|
|
41
|
+
|
|
42
|
+
ActiveSupport::XmlMini.backend = 'REXML'
|
|
43
|
+
|
|
44
|
+
'http://twitter.com/statuses/public_timeline.xml'.to_uri.get.deserialise(
|
|
45
|
+
:xpath => '//user/name/text()'
|
|
46
|
+
)
|
|
47
|
+
|
|
37
48
|
* More complex request with parameters and a custom deserialiser
|
|
38
49
|
|
|
39
50
|
'http://search.yahooapis.com/NewsSearchService/V1/newsSearch'.to_uri.get(
|
|
@@ -135,7 +146,7 @@ Features that are planned, in progress or already implemented are documented in
|
|
|
135
146
|
|
|
136
147
|
The source is available at git://github.com/kaiwren/wrest.git
|
|
137
148
|
|
|
138
|
-
To install the Wrest gem, do <tt>(sudo) gem install wrest
|
|
149
|
+
To install the Wrest gem, do <tt>(sudo) gem install wrest</tt>.
|
|
139
150
|
|
|
140
151
|
Wrest is currently available as a gem for for Ruby and JRuby.
|
|
141
152
|
|
|
@@ -144,7 +155,21 @@ Wrest is currently available as a gem for for Ruby and JRuby.
|
|
|
144
155
|
You can launch the interactive Wrest shell by running bin/wrest if you have the source or invoking <tt>wrest</tt> from your prompt if you've installed the gem.
|
|
145
156
|
$ wrest
|
|
146
157
|
>> y 'http://twitter.com/statuses/public_timeline.json'.to_uri(:timeout => 5).get.deserialise
|
|
147
|
-
|
|
158
|
+
|
|
159
|
+
=== Testing
|
|
160
|
+
|
|
161
|
+
Start the Sinatra test server for functional test.
|
|
162
|
+
rake -f spec/sample_app/Rakefile
|
|
163
|
+
|
|
164
|
+
Run the tests in a different terminal:
|
|
165
|
+
|
|
166
|
+
# Run the normal test suite.
|
|
167
|
+
rake
|
|
168
|
+
|
|
169
|
+
# Runs the functional test suite.
|
|
170
|
+
rake rspec:functional
|
|
171
|
+
|
|
172
|
+
|
|
148
173
|
== Contributors
|
|
149
174
|
|
|
150
175
|
* Sidu Ponnappa : {kaiwren}[http://github.com/kaiwren]
|
|
@@ -153,4 +178,6 @@ You can launch the interactive Wrest shell by running bin/wrest if you have the
|
|
|
153
178
|
* Srushti : {srushti}[http://github.com/srushti]
|
|
154
179
|
* Preethi Ramdev : {preethiramdev}[http://github.com/preethiramdev]
|
|
155
180
|
* Nikhil Vallishayee : {nikhilvallishayee}[http://github.com/nikhilvallishayee]
|
|
156
|
-
* Jacques Crocker : {railsjedi}[http://github.com/railsjedi]
|
|
181
|
+
* Jacques Crocker : {railsjedi}[http://github.com/railsjedi]
|
|
182
|
+
* Jasim A Basheer: {jasim}[http://github.com/jasim]
|
|
183
|
+
|
data/bin/wrest_shell.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
puts "Ruby #{RUBY_VERSION}, #{RUBY_RELEASE_DATE}, #{RUBY_PLATFORM}"
|
|
2
2
|
|
|
3
|
-
entry_point = "#{File.dirname(__FILE__)}/../lib/wrest.rb"
|
|
4
|
-
version = "#{File.dirname(__FILE__)}/../lib/wrest/version"
|
|
3
|
+
entry_point = File.expand_path "#{File.dirname(__FILE__)}/../lib/wrest.rb"
|
|
4
|
+
version = File.expand_path "#{File.dirname(__FILE__)}/../lib/wrest/version.rb"
|
|
5
5
|
|
|
6
6
|
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
|
7
7
|
|
data/lib/wrest.rb
CHANGED
|
@@ -83,6 +83,9 @@ ActiveSupport::JSON.backend = "JSONGem"
|
|
|
83
83
|
|
|
84
84
|
require "#{Wrest::Root}/wrest/core_ext/string"
|
|
85
85
|
|
|
86
|
+
# Load XmlMini Extensions
|
|
87
|
+
require "#{Wrest::Root}/wrest/xml_mini"
|
|
88
|
+
|
|
86
89
|
# Load Wrest Core
|
|
87
90
|
require "#{Wrest::Root}/wrest/version"
|
|
88
91
|
require "#{Wrest::Root}/wrest/http_shared"
|
|
@@ -6,18 +6,6 @@
|
|
|
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
|
-
# 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
|
|
21
9
|
module Wrest
|
|
22
10
|
module Components::Translators
|
|
23
11
|
module Xml
|
|
@@ -25,7 +13,7 @@ module Wrest
|
|
|
25
13
|
|
|
26
14
|
def deserialise(response,options={})
|
|
27
15
|
if(!options[:xpath].nil?)
|
|
28
|
-
|
|
16
|
+
ActiveSupport::XmlMini.filter(response.body,options[:xpath])
|
|
29
17
|
else
|
|
30
18
|
Hash.from_xml(response.body)
|
|
31
19
|
end
|
|
@@ -34,33 +22,6 @@ module Wrest
|
|
|
34
22
|
def serialise(hash, options = {})
|
|
35
23
|
hash.to_xml(options)
|
|
36
24
|
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
|
-
|
|
64
25
|
end
|
|
65
26
|
end
|
|
66
27
|
end
|
data/lib/wrest/curl/request.rb
CHANGED
|
@@ -59,7 +59,7 @@ module Wrest
|
|
|
59
59
|
@http_request.timeout = @timeout
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
# Makes a request and returns a Wrest::
|
|
62
|
+
# Makes a request and returns a Wrest::Native::Response.
|
|
63
63
|
# Data about the request is and logged to Wrest.logger
|
|
64
64
|
# The log entry contains the following information:
|
|
65
65
|
#
|
|
@@ -84,9 +84,9 @@ module Wrest
|
|
|
84
84
|
|
|
85
85
|
prefix = "#{http_request.action.to_s.upcase} #{http_request.hash} #{connection.hash}"
|
|
86
86
|
|
|
87
|
-
Wrest.logger.debug "
|
|
87
|
+
Wrest.logger.debug "<- (#{prefix}) #{http_request.url}"
|
|
88
88
|
time = Benchmark.realtime { response = Wrest::Curl::Response.new(connection.handle_request(http_request))}
|
|
89
|
-
Wrest.logger.debug "
|
|
89
|
+
Wrest.logger.debug "-> (#{prefix}) %s (%d bytes %.2fs)" % [response.message, response.body ? response.body.length : 0, time]
|
|
90
90
|
|
|
91
91
|
response
|
|
92
92
|
rescue Patron::TimeoutError => e
|
data/lib/wrest/curl/session.rb
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
module Wrest::Curl
|
|
11
11
|
# This class is a wrapper for a keep-alive HTTP connection. It simply passes the
|
|
12
|
-
# same connection instance as an option to all Wrest::
|
|
12
|
+
# same connection instance as an option to all Wrest::Native::Request instances created using it.
|
|
13
13
|
#
|
|
14
14
|
# If at any point the server closes an existing connection during a Session by returning a
|
|
15
15
|
# Connection: Close header the current connection is destroyed and a fresh one created for the next
|
data/lib/wrest/exceptions.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Wrest
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
# Raised when a request auto redirects more times than are allowed
|
|
14
|
-
# by its follow_redirects_limit. See Wrest::
|
|
14
|
+
# by its follow_redirects_limit. See Wrest::Native::Redirection.
|
|
15
15
|
class AutoRedirectLimitExceeded < StandardError
|
|
16
16
|
end
|
|
17
17
|
|
|
@@ -9,15 +9,16 @@
|
|
|
9
9
|
|
|
10
10
|
module Wrest::Native
|
|
11
11
|
module ConnectionFactory
|
|
12
|
-
def create_connection(
|
|
13
|
-
timeout ||= 60
|
|
12
|
+
def create_connection(options = {:timeout => 60, :verify_mode => 'VERIFY_PEER'})
|
|
13
|
+
options[:timeout] ||= 60
|
|
14
14
|
connection = Net::HTTP.new(self.host, self.port)
|
|
15
|
-
connection.read_timeout = timeout
|
|
15
|
+
connection.read_timeout = options[:timeout]
|
|
16
16
|
if self.https?
|
|
17
17
|
connection.use_ssl = true
|
|
18
|
-
connection.verify_mode = OpenSSL::SSL::
|
|
18
|
+
connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
|
19
|
+
connection.verify_mode = OpenSSL::SSL::VERIFY_NONE if options[:verify_mode] == 'VERIFY_NONE'
|
|
19
20
|
end
|
|
20
21
|
connection
|
|
21
22
|
end
|
|
22
23
|
end
|
|
23
|
-
end
|
|
24
|
+
end
|
|
@@ -28,7 +28,7 @@ module Wrest #:nodoc:
|
|
|
28
28
|
target = self['location']
|
|
29
29
|
redirect_request_options = redirect_request_options.clone
|
|
30
30
|
|
|
31
|
-
raise Wrest::Exceptions::AutoRedirectLimitExceeded if (redirect_request_options[:follow_redirects_count] += 1)
|
|
31
|
+
raise Wrest::Exceptions::AutoRedirectLimitExceeded if (redirect_request_options[:follow_redirects_count] += 1) > redirect_request_options[:follow_redirects_limit]
|
|
32
32
|
|
|
33
33
|
Wrest.logger.debug "--| Redirecting to #{target}"
|
|
34
34
|
Wrest::Uri.new(target, redirect_request_options).get
|
data/lib/wrest/native/request.rb
CHANGED
|
@@ -32,6 +32,10 @@ module Wrest::Native
|
|
|
32
32
|
# :connection => The HTTP Connection object to use. This is how a keep-alive connection can be
|
|
33
33
|
# used for multiple requests.
|
|
34
34
|
# :cache_store => The object which should be used as cache store for cacheable responses
|
|
35
|
+
# :detailed_http_logging => nil/$stdout/$stderr or File/Logger/IO object. Defaults to nil (recommended).
|
|
36
|
+
#
|
|
37
|
+
# *WARNING* : detailed_http_logging causes serious security hole. Never use it in production code.
|
|
38
|
+
#
|
|
35
39
|
def initialize(wrest_uri, http_request_klass, parameters = {}, body = nil, headers = {}, options = {})
|
|
36
40
|
@uri = wrest_uri
|
|
37
41
|
@headers = headers.stringify_keys
|
|
@@ -47,6 +51,7 @@ module Wrest::Native
|
|
|
47
51
|
@connection = @options[:connection]
|
|
48
52
|
@http_request = self.build_request(http_request_klass, @uri, @parameters, @headers)
|
|
49
53
|
@cache_store = options[:cache_store]
|
|
54
|
+
@detailed_http_logging = options[:detailed_http_logging]
|
|
50
55
|
end
|
|
51
56
|
|
|
52
57
|
# Makes a request and returns a Wrest::Native::Response.
|
|
@@ -69,14 +74,16 @@ module Wrest::Native
|
|
|
69
74
|
def invoke
|
|
70
75
|
response = nil
|
|
71
76
|
|
|
72
|
-
@connection ||= @uri.create_connection(timeout)
|
|
77
|
+
@connection ||= @uri.create_connection({:timeout => timeout})
|
|
78
|
+
@connection.set_debug_output @detailed_http_logging
|
|
79
|
+
|
|
73
80
|
http_request.basic_auth username, password unless username.nil? || password.nil?
|
|
74
81
|
|
|
75
82
|
prefix = "#{http_request.method} #{http_request.hash} #{@connection.hash}"
|
|
76
83
|
|
|
77
|
-
Wrest.logger.debug "
|
|
84
|
+
Wrest.logger.debug "<- (#{prefix}) #{@uri.protocol}://#{@uri.host}:#{@uri.port}#{@http_request.path}"
|
|
78
85
|
time = Benchmark.realtime { response = Wrest::Native::Response.new( do_request ) }
|
|
79
|
-
Wrest.logger.debug "
|
|
86
|
+
Wrest.logger.debug "-> (#{prefix}) %d %s (%d bytes %.2fs)" % [response.code, response.message, response.body ? response.body.length : 0, time]
|
|
80
87
|
|
|
81
88
|
@follow_redirects ? response.follow(@options) : response
|
|
82
89
|
rescue Timeout::Error => e
|
data/lib/wrest/native/session.rb
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
module Wrest::Native
|
|
11
11
|
# This class is a wrapper for a keep-alive HTTP connection. It simply passes the
|
|
12
|
-
# same connection instance as an option to all Wrest::
|
|
12
|
+
# same connection instance as an option to all Wrest::Native::Request instances created using it.
|
|
13
13
|
#
|
|
14
14
|
# If at any point the server closes an existing connection during a Session by returning a
|
|
15
15
|
# Connection: Close header the current connection is destroyed and a fresh one created for the next
|
data/lib/wrest/uri.rb
CHANGED
|
@@ -24,7 +24,7 @@ module Wrest #:nodoc:
|
|
|
24
24
|
class Uri
|
|
25
25
|
attr_reader :uri, :username, :password, :uri_string, :uri_path, :query
|
|
26
26
|
|
|
27
|
-
# See Wrest::
|
|
27
|
+
# See Wrest::Native::Request for the available options and their default values.
|
|
28
28
|
def initialize(uri_string, options = {})
|
|
29
29
|
@options = options
|
|
30
30
|
@uri_string = uri_string.to_s
|
|
@@ -88,7 +88,7 @@ module Wrest #:nodoc:
|
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
# Make a GET request to this URI. This is a convenience API
|
|
91
|
-
# that creates a Wrest::
|
|
91
|
+
# that creates a Wrest::Native::Get, executes it and returns a Wrest::Native::Response.
|
|
92
92
|
#
|
|
93
93
|
# Remember to escape all parameter strings if necessary, using URI.escape
|
|
94
94
|
def get(parameters = {}, headers = {})
|
|
@@ -96,7 +96,7 @@ module Wrest #:nodoc:
|
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
# Make a PUT request to this URI. This is a convenience API
|
|
99
|
-
# that creates a Wrest::
|
|
99
|
+
# that creates a Wrest::Native::Put, executes it and returns a Wrest::Native::Response.
|
|
100
100
|
#
|
|
101
101
|
# Remember to escape all parameter strings if necessary, using URI.escape
|
|
102
102
|
def put(body = '', headers = {}, parameters = {})
|
|
@@ -104,7 +104,7 @@ module Wrest #:nodoc:
|
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
# Makes a POST request to this URI. This is a convenience API
|
|
107
|
-
# that creates a Wrest::
|
|
107
|
+
# that creates a Wrest::Native::Post, executes it and returns a Wrest::Native::Response.
|
|
108
108
|
# Note that sending an empty body will blow up if you're using libcurl.
|
|
109
109
|
#
|
|
110
110
|
# Remember to escape all parameter strings if necessary, using URI.escape
|
|
@@ -126,7 +126,7 @@ module Wrest #:nodoc:
|
|
|
126
126
|
end
|
|
127
127
|
|
|
128
128
|
# Makes a DELETE request to this URI. This is a convenience API
|
|
129
|
-
# that creates a Wrest::
|
|
129
|
+
# that creates a Wrest::Native::Delete, executes it and returns a Wrest::Native::Response.
|
|
130
130
|
#
|
|
131
131
|
# Remember to escape all parameter strings if necessary, using URI.escape
|
|
132
132
|
def delete(parameters = {}, headers = {})
|
|
@@ -134,7 +134,7 @@ module Wrest #:nodoc:
|
|
|
134
134
|
end
|
|
135
135
|
|
|
136
136
|
# Makes an OPTIONS request to this URI. This is a convenience API
|
|
137
|
-
# that creates a Wrest::
|
|
137
|
+
# that creates a Wrest::Native::Options, executes it and returns the Wrest::Native::Response.
|
|
138
138
|
def options
|
|
139
139
|
Http::Options.new(self, @options).invoke
|
|
140
140
|
end
|
data/lib/wrest/version.rb
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
raise "JRuby is required to use the JDOM backend for XmlMini" unless RUBY_PLATFORM =~ /java/
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
module XmlMini
|
|
7
|
+
module JDOM
|
|
8
|
+
module XPathFilter
|
|
9
|
+
#Enables filtering of an xml response using a specified xpath
|
|
10
|
+
#Returns an array of elements matching the xpath
|
|
11
|
+
def filter(xml_body,xpath)
|
|
12
|
+
raise NotImplementedError, "'filter' method is not implemented if JDOM backend is being used"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module XmlMini
|
|
2
|
+
module LibXML
|
|
3
|
+
module XPathFilter
|
|
4
|
+
#Enables filtering of an xml response using a specified xpath
|
|
5
|
+
#Returns an array of elements matching the xpath
|
|
6
|
+
def filter(xml_body,xpath)
|
|
7
|
+
doc = ::LibXML::XML::Document.string(xml_body)
|
|
8
|
+
doc.find(xpath).to_a
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module XmlMini
|
|
2
|
+
module Nokogiri
|
|
3
|
+
module XPathFilter
|
|
4
|
+
#Enables filtering of an xml response using a specified xpath
|
|
5
|
+
#Returns all elements that match the xpath
|
|
6
|
+
def filter(xml_body,xpath)
|
|
7
|
+
doc = ::Nokogiri::XML(xml_body)
|
|
8
|
+
doc.xpath(xpath).to_a
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module XmlMini
|
|
2
|
+
module Rexml
|
|
3
|
+
module XPathFilter
|
|
4
|
+
#Enables filtering of an xml response using a specified xpath
|
|
5
|
+
#Returns an array of elements matching the xpath
|
|
6
|
+
def filter(xml_body,xpath)
|
|
7
|
+
doc = REXML::Document.new(xml_body)
|
|
8
|
+
REXML::XPath.each(doc,xpath).to_a
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
metadata
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wrest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
prerelease:
|
|
4
|
+
prerelease: false
|
|
5
5
|
segments:
|
|
6
6
|
- 1
|
|
7
7
|
- 0
|
|
8
8
|
- 0
|
|
9
|
-
|
|
10
|
-
version: 1.0.0.beta6
|
|
9
|
+
version: 1.0.0
|
|
11
10
|
platform: universal-java-1.6
|
|
12
11
|
authors:
|
|
13
12
|
- Sidu Ponnappa
|
|
@@ -16,14 +15,13 @@ autorequire:
|
|
|
16
15
|
bindir: bin
|
|
17
16
|
cert_chain: []
|
|
18
17
|
|
|
19
|
-
date: 2010-
|
|
18
|
+
date: 2010-12-24 00:00:00 +05:30
|
|
20
19
|
default_executable:
|
|
21
20
|
dependencies:
|
|
22
21
|
- !ruby/object:Gem::Dependency
|
|
23
22
|
name: rspec
|
|
24
23
|
prerelease: false
|
|
25
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
|
26
|
-
none: false
|
|
27
25
|
requirements:
|
|
28
26
|
- - ~>
|
|
29
27
|
- !ruby/object:Gem::Version
|
|
@@ -40,7 +38,6 @@ dependencies:
|
|
|
40
38
|
name: activesupport
|
|
41
39
|
prerelease: false
|
|
42
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
|
43
|
-
none: false
|
|
44
41
|
requirements:
|
|
45
42
|
- - ~>
|
|
46
43
|
- !ruby/object:Gem::Version
|
|
@@ -55,7 +52,6 @@ dependencies:
|
|
|
55
52
|
name: builder
|
|
56
53
|
prerelease: false
|
|
57
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
|
58
|
-
none: false
|
|
59
55
|
requirements:
|
|
60
56
|
- - ~>
|
|
61
57
|
- !ruby/object:Gem::Version
|
|
@@ -70,7 +66,6 @@ dependencies:
|
|
|
70
66
|
name: json-jruby
|
|
71
67
|
prerelease: false
|
|
72
68
|
requirement: &id004 !ruby/object:Gem::Requirement
|
|
73
|
-
none: false
|
|
74
69
|
requirements:
|
|
75
70
|
- - ~>
|
|
76
71
|
- !ruby/object:Gem::Version
|
|
@@ -86,7 +81,6 @@ dependencies:
|
|
|
86
81
|
name: nokogiri
|
|
87
82
|
prerelease: false
|
|
88
83
|
requirement: &id005 !ruby/object:Gem::Requirement
|
|
89
|
-
none: false
|
|
90
84
|
requirements:
|
|
91
85
|
- - ~>
|
|
92
86
|
- !ruby/object:Gem::Version
|
|
@@ -112,60 +106,69 @@ files:
|
|
|
112
106
|
- bin/wrest
|
|
113
107
|
- lib/wrest_no_ext.rb
|
|
114
108
|
- lib/wrest.rb
|
|
115
|
-
- lib/wrest/uri_template.rb
|
|
116
|
-
- lib/wrest/version.rb
|
|
117
|
-
- lib/wrest/test.rb
|
|
118
|
-
- lib/wrest/curl.rb
|
|
119
|
-
- lib/wrest/native.rb
|
|
120
109
|
- lib/wrest/http_shared.rb
|
|
121
|
-
- lib/wrest/
|
|
122
|
-
- lib/wrest/
|
|
110
|
+
- lib/wrest/native.rb
|
|
111
|
+
- lib/wrest/multipart.rb
|
|
112
|
+
- lib/wrest/xml_mini.rb
|
|
123
113
|
- lib/wrest/exceptions.rb
|
|
114
|
+
- lib/wrest/curl.rb
|
|
124
115
|
- lib/wrest/resource.rb
|
|
125
|
-
- lib/wrest/
|
|
126
|
-
- lib/wrest/
|
|
127
|
-
- lib/wrest/
|
|
128
|
-
- lib/wrest/
|
|
129
|
-
- lib/wrest/
|
|
130
|
-
- lib/wrest/
|
|
131
|
-
- lib/wrest/
|
|
132
|
-
- lib/wrest/
|
|
133
|
-
- lib/wrest/
|
|
134
|
-
- lib/wrest/
|
|
135
|
-
- lib/wrest/
|
|
136
|
-
- lib/wrest/
|
|
137
|
-
- lib/wrest/
|
|
138
|
-
- lib/wrest/
|
|
116
|
+
- lib/wrest/test.rb
|
|
117
|
+
- lib/wrest/uri_template.rb
|
|
118
|
+
- lib/wrest/uri.rb
|
|
119
|
+
- lib/wrest/components.rb
|
|
120
|
+
- lib/wrest/version.rb
|
|
121
|
+
- lib/wrest/components/translators.rb
|
|
122
|
+
- lib/wrest/components/container.rb
|
|
123
|
+
- lib/wrest/components/mutators.rb
|
|
124
|
+
- lib/wrest/components/mutators/xml_mini_type_caster.rb
|
|
125
|
+
- lib/wrest/components/mutators/base.rb
|
|
126
|
+
- lib/wrest/components/mutators/camel_to_snake_case.rb
|
|
127
|
+
- lib/wrest/components/mutators/xml_simple_type_caster.rb
|
|
128
|
+
- lib/wrest/components/translators/xml.rb
|
|
129
|
+
- lib/wrest/components/translators/content_types.rb
|
|
130
|
+
- lib/wrest/components/translators/json.rb
|
|
131
|
+
- lib/wrest/components/container/typecaster.rb
|
|
132
|
+
- lib/wrest/components/container/alias_accessors.rb
|
|
139
133
|
- lib/wrest/native/request.rb
|
|
140
|
-
- lib/wrest/native/
|
|
134
|
+
- lib/wrest/native/connection_factory.rb
|
|
141
135
|
- lib/wrest/native/put_multipart.rb
|
|
142
|
-
- lib/wrest/native/put.rb
|
|
143
136
|
- lib/wrest/native/delete.rb
|
|
137
|
+
- lib/wrest/native/response.rb
|
|
138
|
+
- lib/wrest/native/get.rb
|
|
144
139
|
- lib/wrest/native/post_multipart.rb
|
|
145
|
-
- lib/wrest/
|
|
140
|
+
- lib/wrest/native/put.rb
|
|
141
|
+
- lib/wrest/native/options.rb
|
|
142
|
+
- lib/wrest/native/session.rb
|
|
143
|
+
- lib/wrest/native/post.rb
|
|
144
|
+
- lib/wrest/native/redirection.rb
|
|
145
|
+
- lib/wrest/core_ext/hash.rb
|
|
146
|
+
- lib/wrest/core_ext/string.rb
|
|
147
|
+
- lib/wrest/core_ext/string/conversions.rb
|
|
148
|
+
- lib/wrest/core_ext/hash/conversions.rb
|
|
149
|
+
- lib/wrest/curl/request.rb
|
|
150
|
+
- lib/wrest/curl/delete.rb
|
|
146
151
|
- lib/wrest/curl/response.rb
|
|
147
|
-
- lib/wrest/curl/options.rb
|
|
148
152
|
- lib/wrest/curl/get.rb
|
|
149
|
-
- lib/wrest/curl/request.rb
|
|
150
|
-
- lib/wrest/curl/post.rb
|
|
151
153
|
- lib/wrest/curl/put.rb
|
|
152
|
-
- lib/wrest/curl/
|
|
153
|
-
- lib/wrest/
|
|
154
|
-
- lib/wrest/
|
|
155
|
-
- lib/wrest/
|
|
156
|
-
- lib/wrest/
|
|
157
|
-
- lib/wrest/
|
|
158
|
-
- lib/wrest/
|
|
159
|
-
- lib/wrest/
|
|
160
|
-
- lib/wrest/
|
|
161
|
-
- lib/wrest/
|
|
162
|
-
- lib/wrest/
|
|
163
|
-
- lib/wrest/
|
|
164
|
-
- lib/wrest/
|
|
165
|
-
- lib/wrest/
|
|
154
|
+
- lib/wrest/curl/options.rb
|
|
155
|
+
- lib/wrest/curl/session.rb
|
|
156
|
+
- lib/wrest/curl/post.rb
|
|
157
|
+
- lib/wrest/resource/base.rb
|
|
158
|
+
- lib/wrest/resource/collection.rb
|
|
159
|
+
- lib/wrest/resource/state.rb
|
|
160
|
+
- lib/wrest/xml_mini/libxml.rb
|
|
161
|
+
- lib/wrest/xml_mini/jdom.rb
|
|
162
|
+
- lib/wrest/xml_mini/nokogiri.rb
|
|
163
|
+
- lib/wrest/xml_mini/rexml.rb
|
|
164
|
+
- lib/wrest/xml_mini/rexml/xpath_filter.rb
|
|
165
|
+
- lib/wrest/xml_mini/libxml/xpath_filter.rb
|
|
166
|
+
- lib/wrest/xml_mini/jdom/xpath_filter.rb
|
|
167
|
+
- lib/wrest/xml_mini/nokogiri/xpath_filter.rb
|
|
168
|
+
- lib/wrest/test/request_patches.rb
|
|
166
169
|
- lib/wrest/http_shared/standard_headers.rb
|
|
170
|
+
- lib/wrest/http_shared/standard_tokens.rb
|
|
167
171
|
- lib/wrest/http_shared/headers.rb
|
|
168
|
-
- lib/wrest/test/request_patches.rb
|
|
169
172
|
- README.rdoc
|
|
170
173
|
- CHANGELOG
|
|
171
174
|
- LICENCE
|
|
@@ -179,7 +182,6 @@ rdoc_options:
|
|
|
179
182
|
require_paths:
|
|
180
183
|
- lib
|
|
181
184
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
182
|
-
none: false
|
|
183
185
|
requirements:
|
|
184
186
|
- - ">="
|
|
185
187
|
- !ruby/object:Gem::Version
|
|
@@ -187,7 +189,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
187
189
|
- 0
|
|
188
190
|
version: "0"
|
|
189
191
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
|
-
none: false
|
|
191
192
|
requirements:
|
|
192
193
|
- - ">="
|
|
193
194
|
- !ruby/object:Gem::Version
|
|
@@ -200,7 +201,7 @@ requirements:
|
|
|
200
201
|
- To use multipart post, install the 'multipart-post' gem.
|
|
201
202
|
- To use curl as the http engine, install the 'patron' gem. This feature is not available (and should be unneccessary) on jruby.
|
|
202
203
|
rubyforge_project: wrest
|
|
203
|
-
rubygems_version: 1.3.
|
|
204
|
+
rubygems_version: 1.3.6
|
|
204
205
|
signing_key:
|
|
205
206
|
specification_version: 3
|
|
206
207
|
summary: Wrest is an elegant, object oriented HTTP client library for 1.8, 1.9, JRuby and Rubinius.
|