webcache 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 858b4f7979d6b627f12f892a89fc3d59a1ec6c35
4
- data.tar.gz: 682fe41640ac5365e156d02f6cec2a2f0a268ea1
3
+ metadata.gz: 9edc3145e92b9f4a08aff555ba0b420d9346386a
4
+ data.tar.gz: 9f654e4874b7e55ee1ea0a0311c55db83872cc60
5
5
  SHA512:
6
- metadata.gz: bcf255cae0c88b380940123f80501ec118710e59f90120669c725c839e690c746c2dc76e9f73b92638939f11a34426a949329d08ba3c0333850df323a43b89fe
7
- data.tar.gz: d5642ccf57db1a1ee47464f4c9ecf378f95b57100489a12967b57daca4d84ea4e98b7061d91cd5470fdf3055b6feaf8c964b78408fc8d53915d8cfa30897e235
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
@@ -1,3 +1,3 @@
1
1
  class WebCache
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -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, open_uri_options)
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 open_uri_options
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.2.3
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: 2016-07-29 00:00:00.000000000 Z
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