cached_mechanize2 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -19
- data/cached_mechanize2.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 789cc37fc2b7d44aaf2f961e078a67e01427679b
|
4
|
+
data.tar.gz: c5e62d2f817d061d307aac3c5ea40ea30c48e3b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2e9803954106a6831990a35a331a3d038bd09ef3d5a7a5824472d34506ab3ccc1102d78610ac313f4ae80e5aae3c528980cca69b13752f186e6c0fc3f0c42a9
|
7
|
+
data.tar.gz: 1505b798b563dde3f5d817ffdccfadc3c9e1355d39a75935a5ab9feec29952e4dea55a96f5efcfcfeb73d3b804483587a5f937026d7e221ba040c52639d16df7
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ is a small wrapper around [Mechanize](https://github.com/sparklemotion/mechanize
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem '
|
9
|
+
gem 'cached_mechanize2'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
@@ -14,7 +14,7 @@ And then execute:
|
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
|
-
$ gem install
|
17
|
+
$ gem install cached_mechanize2
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
@@ -25,7 +25,7 @@ To configure the backend use this syntax:
|
|
25
25
|
CachedMechanize.configure do |config|
|
26
26
|
config.cache_class = CachedMechanize::CacheBackends::FileCache
|
27
27
|
config.cache_options = {
|
28
|
-
path
|
28
|
+
:path => "/path/to/my/cached_files"
|
29
29
|
}
|
30
30
|
end
|
31
31
|
|
@@ -34,26 +34,21 @@ Now you can use this class like you would use Mechanize:
|
|
34
34
|
agent = CachedMechanize.new
|
35
35
|
doc = agent.get('http://www.imdb.com')
|
36
36
|
|
37
|
-
|
37
|
+
## Quick deviation from original code
|
38
38
|
|
39
|
-
|
39
|
+
The original author 'wukerplank' added some code to control cache time-out, but I dont need this and I discovered that the overloading and change of syntax from current version mechanize's 'get' command seemed to cause errors in running, and the link click function stopped working, so i left the expire time in as a hard coded value and returned the 'get' method signature back to normal.
|
40
40
|
|
41
|
-
|
41
|
+
Here is what is now removed, and can be ignored (easy to fiddle with the code if you need this)
|
42
42
|
|
43
|
-
|
44
|
-
referer: 'http://thatothersite.com',
|
45
|
-
expires_after: 42
|
46
|
-
})
|
43
|
+
By default all retrieved pages will be cached for one day (86400 seconds). To change this behaviour you can provide an `expires_after` option:
|
47
44
|
|
48
|
-
|
45
|
+
doc = agent.get('http://www.imdb.com', expires_after: 42)
|
49
46
|
|
50
|
-
|
51
|
-
|
47
|
+
Note that the syntax has changed! If you want to provide parameters, additional headers or a referer, you can do it like this:
|
48
|
+
|
49
|
+
doc = agent.get('http://www.imdb.com', {
|
50
|
+
referer: 'http://thatothersite.com',
|
51
|
+
expires_after: 42
|
52
|
+
})
|
52
53
|
|
53
|
-
## Contributing
|
54
54
|
|
55
|
-
1. Fork it ( http://github.com/wukerplank/cached_mechanize/fork )
|
56
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
57
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
58
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
59
|
-
5. Create new Pull Request
|
data/cached_mechanize2.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "cached_mechanize2"
|
7
|
-
spec.version = "0.1.
|
7
|
+
spec.version = "0.1.1"
|
8
8
|
spec.authors = ["johnwylie"]
|
9
9
|
spec.email = ["johnwylie70@gmail.com"]
|
10
10
|
spec.summary = %q{A small wrapper around Mechanize to enable caching for GET requests.}
|