wrest 2.1.9 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG +6 -0
- data/LICENCE +1 -1
- data/README.md +47 -40
- data/bin/wrest +2 -1
- data/bin/wrest_shell.rb +10 -8
- data/lib/wrest/async_request/event_machine_backend.rb +3 -1
- data/lib/wrest/async_request/thread_backend.rb +5 -2
- data/lib/wrest/async_request/thread_pool.rb +4 -2
- data/lib/wrest/async_request.rb +7 -6
- data/lib/wrest/cache_proxy.rb +39 -28
- data/lib/wrest/caching/memcached.rb +21 -18
- data/lib/wrest/caching/redis.rb +22 -22
- data/lib/wrest/caching.rb +16 -14
- data/lib/wrest/callback.rb +19 -16
- data/lib/wrest/components/container/alias_accessors.rb +51 -47
- data/lib/wrest/components/container/typecaster.rb +146 -95
- data/lib/wrest/components/container.rb +171 -152
- data/lib/wrest/components/mutators/base.rb +43 -34
- data/lib/wrest/components/mutators/camel_to_snake_case.rb +7 -3
- data/lib/wrest/components/mutators/{xml_mini_type_caster.rb → xml_type_caster.rb} +29 -16
- data/lib/wrest/components/mutators.rb +21 -19
- data/lib/wrest/components/translators/content_types.rb +20 -16
- data/lib/wrest/components/translators/json.rb +19 -16
- data/lib/wrest/components/translators/txt.rb +19 -15
- data/lib/wrest/components/translators/xml/conversions.rb +56 -0
- data/lib/wrest/components/translators/xml.rb +60 -18
- data/lib/wrest/components/translators.rb +7 -6
- data/lib/wrest/components.rb +11 -8
- data/lib/wrest/core_ext/hash/conversions.rb +10 -10
- data/lib/wrest/core_ext/hash.rb +4 -2
- data/lib/wrest/core_ext/string/conversions.rb +14 -13
- data/lib/wrest/core_ext/string.rb +5 -3
- data/lib/wrest/exceptions.rb +4 -2
- data/lib/wrest/hash_with_case_insensitive_access.rb +8 -8
- data/lib/wrest/hash_with_indifferent_access.rb +442 -0
- data/lib/wrest/http_codes.rb +20 -19
- data/lib/wrest/http_shared/headers.rb +2 -0
- data/lib/wrest/http_shared/standard_headers.rb +2 -2
- data/lib/wrest/http_shared/standard_tokens.rb +8 -6
- data/lib/wrest/http_shared.rb +5 -3
- data/lib/wrest/multipart.rb +20 -11
- data/lib/wrest/native/connection_factory.rb +15 -11
- data/lib/wrest/native/delete.rb +15 -11
- data/lib/wrest/native/get.rb +60 -55
- data/lib/wrest/native/options.rb +15 -11
- data/lib/wrest/native/patch.rb +27 -0
- data/lib/wrest/native/post.rb +15 -11
- data/lib/wrest/native/post_multipart.rb +22 -18
- data/lib/wrest/native/put.rb +16 -12
- data/lib/wrest/native/put_multipart.rb +22 -18
- data/lib/wrest/native/redirection.rb +13 -12
- data/lib/wrest/native/request.rb +144 -106
- data/lib/wrest/native/response.rb +87 -78
- data/lib/wrest/native/session.rb +49 -40
- data/lib/wrest/native.rb +14 -11
- data/lib/wrest/test/request_patches.rb +10 -3
- data/lib/wrest/test.rb +3 -1
- data/lib/wrest/uri/builders.rb +14 -12
- data/lib/wrest/uri.rb +92 -50
- data/lib/wrest/uri_template.rb +11 -7
- data/lib/wrest/utils.rb +129 -0
- data/lib/wrest/version.rb +3 -1
- data/lib/wrest.rb +31 -33
- data/lib/wrest_no_ext.rb +2 -0
- metadata +91 -56
- data/lib/wrest/components/mutators/xml_simple_type_caster.rb +0 -37
- data/lib/wrest/xml_mini/jdom/xpath_filter.rb +0 -17
- data/lib/wrest/xml_mini/jdom.rb +0 -6
- data/lib/wrest/xml_mini/libxml/xpath_filter.rb +0 -12
- data/lib/wrest/xml_mini/libxml.rb +0 -8
- data/lib/wrest/xml_mini/nokogiri/xpath_filter.rb +0 -15
- data/lib/wrest/xml_mini/nokogiri.rb +0 -7
- data/lib/wrest/xml_mini/rexml/xpath_filter.rb +0 -15
- data/lib/wrest/xml_mini/rexml.rb +0 -8
- data/lib/wrest/xml_mini.rb +0 -8
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright 2009 Sidu Ponnappa
|
2
4
|
|
3
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -7,26 +9,27 @@
|
|
7
9
|
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
8
10
|
# See the License for the specific language governing permissions and limitations under the License.
|
9
11
|
|
10
|
-
|
11
12
|
module Wrest
|
12
13
|
module Components
|
13
|
-
module Translators
|
14
|
-
|
14
|
+
module Translators
|
15
|
+
module Json
|
16
|
+
module_function
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
def deserialise(response, _options = {})
|
19
|
+
JSON.parse(response.body)
|
20
|
+
end
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
def deserialize(response, options = {})
|
23
|
+
deserialise(response, options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def serialise(hash, options = {})
|
27
|
+
hash.to_json(options)
|
28
|
+
end
|
29
|
+
|
30
|
+
def serialize(hash, options = {})
|
31
|
+
serialise(hash, options)
|
32
|
+
end
|
30
33
|
end
|
31
34
|
end
|
32
35
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright 2009 Sidu Ponnappa
|
2
4
|
|
3
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -7,24 +9,26 @@
|
|
7
9
|
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
8
10
|
# See the License for the specific language governing permissions and limitations under the License.
|
9
11
|
module Wrest
|
10
|
-
module Components
|
11
|
-
module
|
12
|
-
|
12
|
+
module Components
|
13
|
+
module Translators
|
14
|
+
module Txt
|
15
|
+
module_function
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
def deserialise(response, _options = {})
|
18
|
+
response.body
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
def deserialize(response, options = {})
|
22
|
+
deserialise(response, options)
|
23
|
+
end
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
def serialise(hash, _options = {})
|
26
|
+
hash.inspect
|
27
|
+
end
|
28
|
+
|
29
|
+
def serialize(hash, options = {})
|
30
|
+
serialise(hash, options)
|
31
|
+
end
|
28
32
|
end
|
29
33
|
end
|
30
34
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Wrest
|
4
|
+
module Components
|
5
|
+
module Translators
|
6
|
+
module Xml
|
7
|
+
module Conversions # :nodoc:
|
8
|
+
module Document # :nodoc:
|
9
|
+
def to_hash
|
10
|
+
root.to_hash
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Node # :nodoc:
|
15
|
+
CONTENT_ROOT = '__content__'
|
16
|
+
|
17
|
+
# Convert XML document to hash.
|
18
|
+
#
|
19
|
+
# hash::
|
20
|
+
# Hash to merge the converted element into.
|
21
|
+
def to_hash(hash = {})
|
22
|
+
node_hash = {}
|
23
|
+
|
24
|
+
# Insert node hash into parent hash correctly.
|
25
|
+
case hash[name]
|
26
|
+
when Array then hash[name] << node_hash
|
27
|
+
when Hash then hash[name] = [hash[name], node_hash]
|
28
|
+
when nil then hash[name] = node_hash
|
29
|
+
end
|
30
|
+
|
31
|
+
# Handle child elements
|
32
|
+
children.each do |c|
|
33
|
+
if c.element?
|
34
|
+
c.to_hash(node_hash)
|
35
|
+
elsif c.text? || c.cdata?
|
36
|
+
node_hash[CONTENT_ROOT] ||= +''
|
37
|
+
node_hash[CONTENT_ROOT] << c.content
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Remove content node if it is blank and there are child tags
|
42
|
+
node_hash.delete(CONTENT_ROOT) if node_hash.length > 1 && Utils.object_blank?(node_hash[CONTENT_ROOT])
|
43
|
+
|
44
|
+
# Handle attributes
|
45
|
+
attribute_nodes.each { |a| node_hash[a.node_name] = a.value }
|
46
|
+
|
47
|
+
hash
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
Nokogiri::XML::Document.include(Conversions::Document)
|
52
|
+
Nokogiri::XML::Node.include(Conversions::Node)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright 2009 Sidu Ponnappa
|
2
4
|
|
3
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -6,29 +8,69 @@
|
|
6
8
|
# Unless required by applicable law or agreed to in writing, software distributed under the License
|
7
9
|
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
8
10
|
# See the License for the specific language governing permissions and limitations under the License.
|
11
|
+
|
12
|
+
require_relative 'xml/conversions'
|
13
|
+
|
9
14
|
module Wrest
|
10
|
-
module Components
|
11
|
-
module
|
12
|
-
|
15
|
+
module Components
|
16
|
+
module Translators
|
17
|
+
module Xml
|
18
|
+
module_function
|
13
19
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
20
|
+
def deserialise(response, options = {})
|
21
|
+
data = response.body
|
22
|
+
data = StringIO.new(data || '') unless data.respond_to?(:read)
|
23
|
+
return {} if data.eof?
|
24
|
+
|
25
|
+
if options[:xpath].nil?
|
26
|
+
parse(data)
|
27
|
+
else
|
28
|
+
search(data, options[:xpath])
|
29
|
+
end
|
19
30
|
end
|
20
|
-
end
|
21
31
|
|
22
|
-
|
23
|
-
|
24
|
-
|
32
|
+
def deserialize(response, options = {})
|
33
|
+
deserialise(response, options)
|
34
|
+
end
|
25
35
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
36
|
+
def serialise(hash, _options = {})
|
37
|
+
to_xml(hash)
|
38
|
+
end
|
39
|
+
|
40
|
+
def serialize(hash, options = {})
|
41
|
+
serialise(hash, options)
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_xml(hash, builder = nil)
|
45
|
+
builder ||= Nokogiri::XML::Builder.new
|
46
|
+
hash.each_with_object(builder) do |(key, value), inner_builder|
|
47
|
+
if value.is_a?(Hash)
|
48
|
+
inner_builder.send(key.to_s) do |child_builder|
|
49
|
+
to_xml(value, child_builder)
|
50
|
+
end
|
51
|
+
else
|
52
|
+
inner_builder.send(key.to_s, value.to_s)
|
53
|
+
end
|
54
|
+
end.to_xml
|
55
|
+
end
|
56
|
+
|
57
|
+
# Parse an XML Document string or IO into a simple hash using libxml / nokogiri.
|
58
|
+
# data::
|
59
|
+
# XML Document string or IO to parse
|
60
|
+
def parse(data)
|
61
|
+
build_nokogiri_doc(data).to_hash
|
62
|
+
end
|
63
|
+
|
64
|
+
def search(data, xpath)
|
65
|
+
build_nokogiri_doc(data).xpath(xpath)
|
66
|
+
end
|
67
|
+
|
68
|
+
def build_nokogiri_doc(data)
|
69
|
+
doc = Nokogiri::XML(data)
|
70
|
+
raise doc.errors.join("\n") if doc.errors.length.positive?
|
71
|
+
|
72
|
+
doc
|
73
|
+
end
|
32
74
|
end
|
33
75
|
end
|
34
76
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright 2009 Sidu Ponnappa
|
2
4
|
|
3
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -7,7 +9,6 @@
|
|
7
9
|
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
8
10
|
# See the License for the specific language governing permissions and limitations under the License.
|
9
11
|
|
10
|
-
|
11
12
|
module Wrest
|
12
13
|
module Components
|
13
14
|
# Contains strategies/lambdas which know how to deserialise
|
@@ -17,13 +18,13 @@ module Wrest
|
|
17
18
|
# the content type
|
18
19
|
def self.lookup(content_type)
|
19
20
|
translator = CONTENT_TYPES[content_type]
|
20
|
-
translator || (raise Wrest::Exceptions::UnsupportedContentType
|
21
|
+
translator || (raise Wrest::Exceptions::UnsupportedContentType, "Unsupported content type #{content_type}")
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
27
|
+
require 'wrest/components/translators/txt'
|
28
|
+
require 'wrest/components/translators/xml'
|
29
|
+
require 'wrest/components/translators/json'
|
30
|
+
require 'wrest/components/translators/content_types'
|
data/lib/wrest/components.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright 2009 Sidu Ponnappa
|
2
4
|
|
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.
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
# Unless required by applicable law or agreed to in writing, software distributed under the License
|
9
|
+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
9
11
|
|
10
12
|
module Wrest
|
11
13
|
# A component is a building block that can
|
@@ -15,5 +17,6 @@ module Wrest
|
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
18
|
-
require
|
19
|
-
require
|
20
|
+
require 'wrest/components/container'
|
21
|
+
require 'wrest/components/mutators'
|
22
|
+
require 'wrest/components/translators'
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright 2009 Sidu Ponnappa
|
2
4
|
|
3
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -8,37 +10,35 @@
|
|
8
10
|
# See the License for the specific language governing permissions and limitations under the License.
|
9
11
|
|
10
12
|
module Wrest
|
11
|
-
module CoreExt
|
12
|
-
module Hash
|
13
|
+
module CoreExt # :nodoc:
|
14
|
+
module Hash # :nodoc:
|
13
15
|
# Makes it easier to build other objects from a Hash
|
14
16
|
module Conversions
|
15
|
-
|
16
17
|
# This method accepts a hash mutator (found in Wrest::Compononents)
|
17
18
|
# to build a new hash map by making changes to an existing one.
|
18
19
|
#
|
19
|
-
# No, this method does not mutate the state of the hash it is invoked on,
|
20
|
+
# No, this method does not mutate the state of the hash it is invoked on,
|
20
21
|
# but rather builds a new one.
|
21
22
|
#
|
22
|
-
# Yes, the name is misleading in that respect. However, one
|
23
|
+
# Yes, the name is misleading in that respect. However, one
|
23
24
|
# hopes the absence of an exclamation mark will increase clarity.
|
24
25
|
#
|
25
26
|
# Uses include mutating the hash produced by deserialising xml
|
26
27
|
# by using the meta data in the hash to type cast values.
|
27
|
-
#
|
28
|
+
#
|
28
29
|
# Example:
|
29
30
|
# "http://search.yahooapis.com/NewsSearchService/V1/newsSearch".to_uri.get(
|
30
|
-
# :appid => 'YahooDemo',
|
31
|
+
# :appid => 'YahooDemo',
|
31
32
|
# :output => 'xml',
|
32
33
|
# :query => 'India',
|
33
34
|
# :results=> '3',
|
34
35
|
# :start => '1'
|
35
|
-
# ).deserialise.mutate_using(
|
36
|
+
# ).deserialise.mutate_using(XmlTypeCaster.new)
|
36
37
|
def mutate_using(mutator)
|
37
38
|
mutated_hash = {}
|
38
|
-
|
39
|
+
each { |tuple| mutated_hash.store(*mutator.mutate(tuple)) }
|
39
40
|
mutated_hash
|
40
41
|
end
|
41
|
-
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
data/lib/wrest/core_ext/hash.rb
CHANGED
@@ -1,19 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Copyright 2009 Sidu Ponnappa
|
2
4
|
|
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.
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
# Unless required by applicable law or agreed to in writing, software distributed under the License
|
9
|
+
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and limitations under the License.
|
9
11
|
|
10
12
|
module Wrest
|
11
|
-
module CoreExt
|
12
|
-
module String
|
13
|
+
module CoreExt # :nodoc:
|
14
|
+
module String # :nodoc:
|
13
15
|
# Makes it easier to build other objects from a String
|
14
16
|
# This module is opt-out - if you don't want the to_uri
|
15
|
-
# and to_uri_template convenience method on String, set
|
16
|
-
# the NoStringExtensions constant on the Wrest module
|
17
|
+
# and to_uri_template convenience method on String, set
|
18
|
+
# the NoStringExtensions constant on the Wrest module
|
17
19
|
# before requiring wrest.
|
18
20
|
#
|
19
21
|
# module Wrest
|
@@ -21,15 +23,14 @@ module Wrest
|
|
21
23
|
# end
|
22
24
|
# require 'wrest'
|
23
25
|
module Conversions
|
24
|
-
|
25
26
|
# A convenience method equivalent to Wrest::Uri.new(string)
|
26
27
|
def to_uri(options = {})
|
27
|
-
Wrest::Uri.new(
|
28
|
+
Wrest::Uri.new(strip, options)
|
28
29
|
end
|
29
30
|
|
30
31
|
# A convenience method equivalent to Wrest:UriTemplate.new(uri_pattern)
|
31
32
|
def to_uri_template(options = {})
|
32
|
-
Wrest::UriTemplate.new(
|
33
|
+
Wrest::UriTemplate.new(strip, options)
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
@@ -1,5 +1,7 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'wrest/core_ext/string/conversions'
|
4
|
+
|
5
|
+
class String # :nodoc:
|
4
6
|
include Wrest::CoreExt::String::Conversions unless Wrest.const_defined?('NoStringExtensions')
|
5
|
-
end
|
7
|
+
end
|
data/lib/wrest/exceptions.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Wrest
|
2
|
-
module Exceptions
|
4
|
+
module Exceptions # :nodoc:
|
3
5
|
# Raised when a base method that should be overriden
|
4
6
|
# is invoked on a subclass that has not implemented it.
|
5
7
|
class MethodNotOverridden < StandardError
|
@@ -26,7 +28,7 @@ module Wrest
|
|
26
28
|
# Raised when a request times out
|
27
29
|
class Timeout < StandardError
|
28
30
|
end
|
29
|
-
|
31
|
+
|
30
32
|
class UnsupportedHttpVerb < StandardError
|
31
33
|
end
|
32
34
|
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module Wrest
|
3
4
|
# A hash with case-insensitive key access.
|
4
5
|
#
|
5
6
|
# hash = Wrest::HashWithCaseInsensitiveAccess.new 'Abcd' => 1, 'xyz' => 2
|
@@ -7,14 +8,14 @@ module Wrest
|
|
7
8
|
# hash['abcd'] #=> 1
|
8
9
|
# hash['aBCd'] #=> 1
|
9
10
|
#
|
10
|
-
class HashWithCaseInsensitiveAccess < ::Hash
|
11
|
-
|
12
|
-
def initialize(hash={})
|
11
|
+
class HashWithCaseInsensitiveAccess < ::Hash # :nodoc:
|
12
|
+
def initialize(hash = {})
|
13
13
|
super()
|
14
14
|
hash.each do |key, value|
|
15
15
|
self[convert_key(key)] = value
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
18
19
|
def [](key)
|
19
20
|
super(convert_key(key))
|
20
21
|
end
|
@@ -44,9 +45,8 @@ module Wrest
|
|
44
45
|
|
45
46
|
protected
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
def convert_key(key)
|
49
|
+
key.is_a?(String) ? key.downcase : key
|
50
|
+
end
|
51
51
|
end
|
52
52
|
end
|