webcache 0.2.3 → 0.3.0
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.
- checksums.yaml +4 -4
- data/README.md +18 -0
- data/lib/webcache/version.rb +1 -1
- data/lib/webcache/web_cache.rb +6 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9edc3145e92b9f4a08aff555ba0b420d9346386a
|
4
|
+
data.tar.gz: 9f654e4874b7e55ee1ea0a0311c55db83872cc60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0271f6a7a1e75b84754d8a7e0877243cc407f7374ce7ece6a634ae5d56e1b6ee965b695262109051d1aa72c6bf7ee24dc396049a0cec3600d88b88122487fdc9
|
7
|
+
data.tar.gz: 4a19051e54fd769e19c5dafac9956a9166def2b2fddc4b0d1fb3d7307e9d6ddb8a0d62f082dc01ed08dd135d4f1e68a1b02a93611897387593314b169c2ddbd9
|
data/README.md
CHANGED
@@ -90,6 +90,21 @@ cache.cached? 'http://example.com'
|
|
90
90
|
# => true
|
91
91
|
```
|
92
92
|
|
93
|
+
|
94
|
+
Basic Authentication and Additional Options
|
95
|
+
--------------------------------------------------
|
96
|
+
WebCache uses Ruby's [Open URI][1] to download. If you wish to modify
|
97
|
+
the options it uses, simply update the `options` hash.
|
98
|
+
|
99
|
+
For example, to use HTTP basic authentication, use something like this:
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
cache = WebCache.new
|
103
|
+
cache.options[:http_basic_authentication] = ["user", "pass123!"]
|
104
|
+
response = cache.get 'http://example.com'
|
105
|
+
```
|
106
|
+
|
107
|
+
|
93
108
|
Response Object
|
94
109
|
--------------------------------------------------
|
95
110
|
|
@@ -118,3 +133,6 @@ puts response
|
|
118
133
|
puts response.error
|
119
134
|
# => '404 Not Found'
|
120
135
|
```
|
136
|
+
|
137
|
+
|
138
|
+
[1]: http://ruby-doc.org/stdlib-2.0.0/libdoc/open-uri/rdoc/OpenURI/OpenRead.html#method-i-open
|
data/lib/webcache/version.rb
CHANGED
data/lib/webcache/web_cache.rb
CHANGED
@@ -44,6 +44,10 @@ class WebCache
|
|
44
44
|
@enabled = false
|
45
45
|
end
|
46
46
|
|
47
|
+
def options
|
48
|
+
@options ||= default_open_uri_options
|
49
|
+
end
|
50
|
+
|
47
51
|
private
|
48
52
|
|
49
53
|
def get_path(url)
|
@@ -63,7 +67,7 @@ class WebCache
|
|
63
67
|
|
64
68
|
def http_get(url)
|
65
69
|
begin
|
66
|
-
Response.new open(url,
|
70
|
+
Response.new open(url, options)
|
67
71
|
rescue => e
|
68
72
|
Response.new error: e.message, base_uri: url, content: e.message
|
69
73
|
end
|
@@ -78,7 +82,7 @@ class WebCache
|
|
78
82
|
# open_uri_redirections gem)
|
79
83
|
# 2. Disable SSL verification, otherwise, some https sites that show
|
80
84
|
# properly in the browser, will return an error.
|
81
|
-
def
|
85
|
+
def default_open_uri_options
|
82
86
|
{
|
83
87
|
allow_redirections: :all,
|
84
88
|
ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webcache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open_uri_redirections
|