kaiwren-wrest 0.0.6 → 0.0.8
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/README.rdoc +83 -31
- data/Rakefile +29 -13
- data/VERSION.yml +1 -1
- data/examples/delicious.rb +58 -0
- data/examples/wow_realm_status.rb +57 -0
- data/lib/wrest.rb +11 -2
- data/lib/wrest/components.rb +1 -2
- data/lib/wrest/components/attributes_container.rb +34 -74
- data/lib/wrest/components/attributes_container/typecaster.rb +121 -0
- data/lib/wrest/components/mutators.rb +18 -1
- data/lib/wrest/components/mutators/base.rb +52 -39
- data/lib/wrest/components/mutators/camel_to_snake_case.rb +7 -5
- data/lib/wrest/components/mutators/xml_mini_type_caster.rb +43 -0
- data/lib/wrest/components/mutators/xml_simple_type_caster.rb +22 -20
- data/lib/wrest/components/translators.rb +20 -17
- data/lib/wrest/components/translators/content_types.rb +2 -2
- data/lib/wrest/components/translators/json.rb +11 -8
- data/lib/wrest/components/translators/xml.rb +9 -12
- data/lib/wrest/core_ext/hash/conversions.rb +1 -1
- data/lib/wrest/core_ext/string/conversions.rb +2 -2
- data/lib/wrest/http.rb +24 -0
- data/lib/wrest/http/delete.rb +23 -0
- data/lib/wrest/http/get.rb +23 -0
- data/lib/wrest/http/options.rb +23 -0
- data/lib/wrest/http/post.rb +23 -0
- data/lib/wrest/http/put.rb +23 -0
- data/lib/wrest/http/request.rb +48 -0
- data/lib/wrest/http/response.rb +44 -0
- data/lib/wrest/resource/base.rb +52 -25
- data/lib/wrest/resource/state.rb +6 -0
- data/lib/wrest/uri.rb +85 -29
- data/lib/wrest/uri_template.rb +18 -1
- data/lib/wrest/version.rb +1 -1
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +8 -1
- data/spec/wrest/components/attributes_container/typecaster_spec.rb +63 -0
- data/spec/wrest/components/attributes_container_spec.rb +17 -61
- data/spec/wrest/components/mutators/base_spec.rb +5 -1
- data/spec/wrest/components/mutators/xml_mini_type_caster_spec.rb +75 -0
- data/spec/wrest/components/mutators_spec.rb +21 -0
- data/spec/wrest/components/translators/xml_spec.rb +1 -1
- data/spec/wrest/components/translators_spec.rb +9 -0
- data/spec/wrest/core_ext/string/conversions_spec.rb +9 -0
- data/spec/wrest/http/request_spec.rb +22 -0
- data/spec/wrest/{response_spec.rb → http/response_spec.rb} +4 -4
- data/spec/wrest/resource/base_spec.rb +126 -11
- data/spec/wrest/uri_spec.rb +124 -20
- data/spec/wrest/uri_template_spec.rb +11 -1
- metadata +33 -20
- data/lib/wrest/components/typecast_helpers.rb +0 -41
- data/lib/wrest/response.rb +0 -38
@@ -1,41 +0,0 @@
|
|
1
|
-
module Wrest::Components #:nodoc:
|
2
|
-
# Provides helper methods which build lambdas
|
3
|
-
# to cast strings to specific types.
|
4
|
-
module TypecastHelpers
|
5
|
-
def as_base64Binary
|
6
|
-
ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING['base64Binary']
|
7
|
-
end
|
8
|
-
|
9
|
-
def as_boolean
|
10
|
-
ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING['boolean']
|
11
|
-
end
|
12
|
-
|
13
|
-
def as_decimal
|
14
|
-
ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING['decimal']
|
15
|
-
end
|
16
|
-
|
17
|
-
def as_date
|
18
|
-
ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING['date']
|
19
|
-
end
|
20
|
-
|
21
|
-
def as_datetime
|
22
|
-
ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING['datetime']
|
23
|
-
end
|
24
|
-
|
25
|
-
def as_float
|
26
|
-
ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING['float']
|
27
|
-
end
|
28
|
-
|
29
|
-
def as_integer
|
30
|
-
ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING['integer']
|
31
|
-
end
|
32
|
-
|
33
|
-
def as_symbol
|
34
|
-
ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING['symbol']
|
35
|
-
end
|
36
|
-
|
37
|
-
def as_yaml
|
38
|
-
ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING['yaml']
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/lib/wrest/response.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# Copyright 2009 Sidu Ponnappa
|
2
|
-
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
6
|
-
# Unless required by applicable law or agreed to in writing, software distributed under the License
|
7
|
-
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
8
|
-
# See the License for the specific language governing permissions and limitations under the License.
|
9
|
-
|
10
|
-
module Wrest #:nodoc:
|
11
|
-
# Decorates a response providing support for deserialisation.
|
12
|
-
#
|
13
|
-
# The following methods are also available (unlisted by rdoc because they're forwarded):
|
14
|
-
#
|
15
|
-
# <tt>:@http_response, :code, :message, :body, :http_version,
|
16
|
-
# :[], :content_length, :content_type, :each_header, :each_name, :each_value, :fetch,
|
17
|
-
# :get_fields, :key?, :type_params</tt>
|
18
|
-
#
|
19
|
-
# They behave exactly like their Net::HTTPResponse equivalents.
|
20
|
-
class Response
|
21
|
-
extend Forwardable
|
22
|
-
def_delegators :@http_response, :code, :message, :body, :http_version,
|
23
|
-
:[], :content_length, :content_type, :each_header, :each_name, :each_value, :fetch,
|
24
|
-
:get_fields, :key?, :type_params
|
25
|
-
|
26
|
-
def initialize(http_response)
|
27
|
-
@http_response = http_response
|
28
|
-
end
|
29
|
-
|
30
|
-
def deserialise
|
31
|
-
deserialise_using(Wrest::Components::Translators.lookup(@http_response.content_type))
|
32
|
-
end
|
33
|
-
|
34
|
-
def deserialise_using(translator)
|
35
|
-
translator.deserialise(@http_response)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|