snoop 0.8.0 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -0
- data/lib/snoop/http.rb +19 -11
- data/lib/snoop/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5374fd3cf90a61d50d6a98e643c52426065aecc6
|
4
|
+
data.tar.gz: b52af829780967314ae4cba297b88f67049255f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e146734d652642438bf615423846d4c8bbe932d61e03bb4abed5c2114e647b0017a564218d02f2bb353f298955ad3825b8a7571c9a1b721147d562c8765fd02e
|
7
|
+
data.tar.gz: 31cd694d9c0c39ed27dcd92762a287571cb436910f39dc0693eb42f83a7b1d4ec197563bb3a41f30440e497af70fe9b7b90e5b46867293726492f1d6910db25f
|
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
# Snoop
|
2
|
+
[![Travis CI](https://travis-ci.org/chrishunt/snoop.png)](https://travis-ci.org/chrishunt/snoop)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/chrishunt/snoop.png)](https://codeclimate.com/github/chrishunt/snoop)
|
4
|
+
|
2
5
|
Snoop on content, be notified when it changes.
|
3
6
|
|
4
7
|
## Usage
|
data/lib/snoop/http.rb
CHANGED
@@ -5,7 +5,13 @@ module Snoop
|
|
5
5
|
class Http
|
6
6
|
UrlRequiredException = Class.new(StandardError)
|
7
7
|
|
8
|
-
|
8
|
+
DEFAULT_INIT_OPTIONS = {
|
9
|
+
url: nil,
|
10
|
+
css: nil,
|
11
|
+
http_client: HTTParty
|
12
|
+
}
|
13
|
+
|
14
|
+
DEFAULT_NOTIFY_OPTIONS = {
|
9
15
|
delay: 0,
|
10
16
|
count: 1,
|
11
17
|
while: -> { false },
|
@@ -15,24 +21,26 @@ module Snoop
|
|
15
21
|
attr_reader :url, :css, :http_client
|
16
22
|
attr_accessor :content
|
17
23
|
|
18
|
-
def initialize(
|
19
|
-
|
24
|
+
def initialize(options = {})
|
25
|
+
options = DEFAULT_INIT_OPTIONS.merge options
|
26
|
+
|
27
|
+
raise UrlRequiredException if options.fetch(:url).nil?
|
20
28
|
|
21
|
-
@url
|
22
|
-
@css
|
23
|
-
@http_client = http_client
|
29
|
+
@url = options.fetch :url
|
30
|
+
@css = options.fetch :css
|
31
|
+
@http_client = options.fetch :http_client
|
24
32
|
end
|
25
33
|
|
26
34
|
def notify(options = {})
|
27
|
-
options =
|
35
|
+
options = DEFAULT_NOTIFY_OPTIONS.merge options
|
28
36
|
|
29
37
|
while (
|
30
|
-
(options[:count] -= 1
|
31
|
-
options
|
32
|
-
!options
|
38
|
+
(options[:count] -= 1) >= 0 ||
|
39
|
+
options.fetch(:while).call ||
|
40
|
+
!options.fetch(:until).call
|
33
41
|
)
|
34
42
|
yield content if content_changed?
|
35
|
-
sleep options
|
43
|
+
sleep options.fetch(:delay)
|
36
44
|
end
|
37
45
|
end
|
38
46
|
|
data/lib/snoop/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snoop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Hunt
|
@@ -116,6 +116,7 @@ extensions: []
|
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
118
|
- .gitignore
|
119
|
+
- .travis.yml
|
119
120
|
- Gemfile
|
120
121
|
- Gemfile.lock
|
121
122
|
- LICENSE.txt
|