wrest 1.0.0.beta1 → 1.0.0.beta2
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 +14 -2
- data/LICENCE +7 -0
- data/README.rdoc +15 -69
- data/lib/wrest/components/container/alias_accessors.rb +1 -1
- data/lib/wrest/components/container/alias_accessors.rbc +905 -0
- data/lib/wrest/components/container/typecaster.rb +5 -5
- data/lib/wrest/components/container/typecaster.rbc +1985 -0
- data/lib/wrest/components/container.rb +11 -12
- data/lib/wrest/components/container.rbc +2466 -0
- data/lib/wrest/components/mutators/base.rbc +702 -0
- data/lib/wrest/components/mutators/camel_to_snake_case.rbc +360 -0
- data/lib/wrest/components/mutators/xml_mini_type_caster.rbc +679 -0
- data/lib/wrest/components/mutators/xml_simple_type_caster.rbc +559 -0
- data/lib/wrest/components/mutators.rbc +650 -0
- data/lib/wrest/components/translators/content_types.rbc +339 -0
- data/lib/wrest/components/translators/json.rbc +462 -0
- data/lib/wrest/components/translators/xml.rbc +457 -0
- data/lib/wrest/components/translators.rbc +517 -0
- data/lib/wrest/components.rbc +217 -0
- data/lib/wrest/core_ext/hash/conversions.rbc +501 -0
- data/lib/wrest/core_ext/hash.rbc +182 -0
- data/lib/wrest/core_ext/string/conversions.rbc +471 -0
- data/lib/wrest/core_ext/string.rbc +182 -0
- data/lib/wrest/curl/response.rb +8 -0
- data/lib/wrest/curl.rbc +704 -0
- data/lib/wrest/exceptions.rbc +312 -0
- data/lib/wrest/http_shared/headers.rb +0 -7
- data/lib/wrest/http_shared/headers.rbc +353 -0
- data/lib/wrest/http_shared/standard_headers.rbc +336 -0
- data/lib/wrest/http_shared/standard_tokens.rbc +316 -0
- data/lib/wrest/http_shared.rbc +279 -0
- data/lib/wrest/native/connection_factory.rbc +445 -0
- data/lib/wrest/native/delete.rbc +371 -0
- data/lib/wrest/native/get.rb +26 -0
- data/lib/wrest/native/get.rbc +855 -0
- data/lib/wrest/native/options.rbc +347 -0
- data/lib/wrest/native/post.rbc +388 -0
- data/lib/wrest/native/put.rbc +388 -0
- data/lib/wrest/native/redirection.rbc +520 -0
- data/lib/wrest/native/request.rb +4 -2
- data/lib/wrest/native/request.rbc +1675 -0
- data/lib/wrest/native/response.rb +53 -2
- data/lib/wrest/native/response.rbc +2150 -0
- data/lib/wrest/native/session.rbc +1372 -0
- data/lib/wrest/native.rbc +513 -0
- data/lib/wrest/resource/base.rbc +2115 -0
- data/lib/wrest/resource.rbc +163 -0
- data/lib/wrest/uri.rbc +2599 -0
- data/lib/wrest/uri_template.rbc +505 -0
- data/lib/wrest/version.rb +1 -1
- data/lib/wrest/version.rbc +372 -0
- data/lib/wrest.rb +1 -1
- data/lib/wrest.rbc +1900 -0
- metadata +99 -102
- data/Rakefile +0 -495
- data/VERSION.yml +0 -5
- data/bin/jwrest +0 -3
- data/examples/delicious.rb +0 -72
- data/examples/facebook.rb +0 -101
- data/examples/imgur_multipart.rb +0 -24
- data/examples/keep_alive.rb +0 -37
- data/examples/redirection.rb +0 -27
- data/examples/twitter.rb +0 -78
- data/examples/twitter_public_timeline.rb +0 -32
- data/examples/wow_realm_status.rb +0 -67
- data/init.rb +0 -0
- data/spec/custom_matchers/custom_matchers.rb +0 -2
- data/spec/rcov.opts +0 -4
- data/spec/spec.opts.disable +0 -6
- data/spec/unit/spec_helper.rb +0 -35
- data/spec/unit/wrest/components/attributes_container/alias_accessors_spec.rb +0 -49
- data/spec/unit/wrest/components/attributes_container/typecaster_spec.rb +0 -83
- data/spec/unit/wrest/components/attributes_container_spec.rb +0 -254
- data/spec/unit/wrest/components/mutators/base_spec.rb +0 -42
- data/spec/unit/wrest/components/mutators/camel_to_snake_spec.rb +0 -22
- data/spec/unit/wrest/components/mutators/xml_mini_type_caster_spec.rb +0 -75
- data/spec/unit/wrest/components/mutators/xml_simple_type_caster_spec.rb +0 -47
- data/spec/unit/wrest/components/mutators_spec.rb +0 -21
- data/spec/unit/wrest/components/translators/xml_spec.rb +0 -16
- data/spec/unit/wrest/components/translators_spec.rb +0 -18
- data/spec/unit/wrest/core_ext/hash/conversions_spec.rb +0 -22
- data/spec/unit/wrest/core_ext/string/conversions_spec.rb +0 -39
- data/spec/unit/wrest/curl/request_spec.rb +0 -19
- data/spec/unit/wrest/curl/response_spec.rb +0 -16
- data/spec/unit/wrest/http/response_spec.rb +0 -24
- data/spec/unit/wrest/native/redirection_spec.rb +0 -42
- data/spec/unit/wrest/native/request_spec.rb +0 -71
- data/spec/unit/wrest/native/response_spec.rb +0 -72
- data/spec/unit/wrest/native/session_spec.rb +0 -74
- data/spec/unit/wrest/resource/base_spec.rb +0 -274
- data/spec/unit/wrest/uri_spec.rb +0 -273
- data/spec/unit/wrest/uri_template_spec.rb +0 -38
- data/wrest.gemspec +0 -168
|
@@ -60,10 +60,61 @@ module Wrest #:nodoc:
|
|
|
60
60
|
def follow(redirect_request_options = {})
|
|
61
61
|
self
|
|
62
62
|
end
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
def connection_closed?
|
|
65
65
|
self[Native::StandardHeaders::Connection].downcase == Native::StandardTokens::Close.downcase
|
|
66
66
|
end
|
|
67
|
+
|
|
68
|
+
def cacheable?
|
|
69
|
+
code_cacheable? && no_cache_flag_not_set? && no_store_flag_not_set? && expires_header_not_in_past?
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def code_cacheable?
|
|
73
|
+
!code.nil? && !/2\d{2}/.match(code).nil?
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def no_cache_flag_not_set?
|
|
77
|
+
not cache_control_headers.include?('no-cache')
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def no_store_flag_not_set?
|
|
81
|
+
not cache_control_headers.include?('no-store')
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def expires_header_not_in_past?
|
|
85
|
+
expires_header = cache_control_headers.find{ |h| h.include? 'Expires' }
|
|
86
|
+
if expires_header.nil?
|
|
87
|
+
true
|
|
88
|
+
else
|
|
89
|
+
expires_on = DateTime.parse(expires_header.split("=")[1])
|
|
90
|
+
expires_on > DateTime.now
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def cache_control_headers
|
|
95
|
+
@cache_control_headers unless @cache_control_headers.nil?
|
|
96
|
+
if headers['Cache-Control'].nil? then
|
|
97
|
+
@cache_control_headers = []
|
|
98
|
+
else
|
|
99
|
+
cache_headers = headers['Cache-Control'].split(",")
|
|
100
|
+
@cache_control_headers = correct_expires_headers(cache_headers)
|
|
101
|
+
@cache_control_headers.collect
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
:private
|
|
106
|
+
|
|
107
|
+
def correct_expires_headers(cache_headers)
|
|
108
|
+
# The expires header "Expires = Sun, 06 Nov 1994 08:49:37 GMT" would have split into two ['Expires = Sun',' 06 Nov 1994 08:49:37 GMT']
|
|
109
|
+
expires_index = cache_headers.find_index(){ |a| a.include? 'Expires' }
|
|
110
|
+
if expires_index
|
|
111
|
+
expires_part_1 = cache_headers.delete(cache_headers[expires_index])
|
|
112
|
+
# earlier delete shifted the second part on same index
|
|
113
|
+
expires_part_2 = cache_headers.delete(cache_headers[expires_index])
|
|
114
|
+
cache_headers.push(expires_part_1+','+expires_part_2)
|
|
115
|
+
end
|
|
116
|
+
cache_headers
|
|
117
|
+
end
|
|
67
118
|
end
|
|
68
119
|
end
|
|
69
|
-
end
|
|
120
|
+
end
|