site_watcher 0.0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/site_watcher.rb +7 -2
- data/lib/site_watcher/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea3cfe2850109db82c2266644fcc33cdbc566bd2
|
4
|
+
data.tar.gz: 8527bef8d97dc2010151c7ebd554625b03345a46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81c88964d9a96b186ffb7744a808c1046886fd4fbb8f5c4e1b9a20e2e6628b1bf5ba223b95208dcb9aaf24a56b73ed55bcebd2295513e1132ee94c15375291eb
|
7
|
+
data.tar.gz: 83668aa2bf42d9f9067a1c73b77cc4b24c494a9212457efd81e6470082c636a06c45e6cfe9e363404d946a480d7fb60d97056231a0c85b6624773f8925bac895
|
data/README.md
CHANGED
@@ -34,6 +34,9 @@ SiteWatcher.watch(every: 2) do
|
|
34
34
|
|
35
35
|
# JSON
|
36
36
|
page("http://www.bestbuy.com/api/1.0/product/summaries?skus=7522006") do
|
37
|
+
# Continue watching this page even after fulfillment
|
38
|
+
remove_on_fulfillment false
|
39
|
+
|
37
40
|
test do |json|
|
38
41
|
# `json` is a hash of the parsed JSON body.
|
39
42
|
expect(
|
@@ -44,7 +47,7 @@ SiteWatcher.watch(every: 2) do
|
|
44
47
|
end
|
45
48
|
```
|
46
49
|
|
47
|
-
This script will block until all expectations have been fulfilled.
|
50
|
+
This script will block until all expectations have been fulfilled and removed. Using `remove_on_fulfillment false` will cause it to block indefinitely.
|
48
51
|
|
49
52
|
## Testing fulfillment
|
50
53
|
|
data/lib/site_watcher.rb
CHANGED
@@ -36,7 +36,7 @@ class SiteWatcher
|
|
36
36
|
@pages.each do |page|
|
37
37
|
begin
|
38
38
|
page.__sw_run!(force)
|
39
|
-
@pages.delete(page)
|
39
|
+
@pages.delete(page) if page.__sw_remove_on_fulfillment
|
40
40
|
rescue ::RSpec::Expectations::ExpectationNotMetError
|
41
41
|
rescue => e
|
42
42
|
@logger.warn("Exception on #{page.__sw_url}: #{e.inspect}")
|
@@ -84,11 +84,12 @@ class SiteWatcher
|
|
84
84
|
|
85
85
|
class Page
|
86
86
|
include ::RSpec::Matchers
|
87
|
-
attr_reader :__sw_url
|
87
|
+
attr_reader :__sw_url, :__sw_remove_on_fulfillment
|
88
88
|
|
89
89
|
def initialize(url)
|
90
90
|
@__sw_url = url
|
91
91
|
@__sw_tests = []
|
92
|
+
@__sw_remove_on_fulfillment = true
|
92
93
|
end
|
93
94
|
|
94
95
|
def test(&block)
|
@@ -99,6 +100,10 @@ class SiteWatcher
|
|
99
100
|
@__sw_fulfilled = block
|
100
101
|
end
|
101
102
|
|
103
|
+
def remove_on_fulfillment(bool)
|
104
|
+
@__sw_remove_on_fulfillment = !!bool
|
105
|
+
end
|
106
|
+
|
102
107
|
def __sw_run!(force=false)
|
103
108
|
::OpenURI.open_uri(@__sw_url) do |response|
|
104
109
|
case response.content_type
|
data/lib/site_watcher/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: site_watcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Genco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -111,9 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
113
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.6.8
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Periodically monitor a website
|
118
118
|
test_files: []
|
119
|
-
has_rdoc:
|