snoop 0.8.0 → 0.8.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e402f8be7361f82aa03e369c4dd3a2479e930c99
4
- data.tar.gz: f03d974b6a042f46071073792787d568fe78f9b3
3
+ metadata.gz: 5374fd3cf90a61d50d6a98e643c52426065aecc6
4
+ data.tar.gz: b52af829780967314ae4cba297b88f67049255f3
5
5
  SHA512:
6
- metadata.gz: 32e12e8737830b2414f437b126cbe5c9a6ca3496f1e799572d75575741b47ca2727cfa6a13361ac1101e84e9fb3a74330b9bb3341112716bcd785bbb2691171a
7
- data.tar.gz: d5a95a8b02e38f49d48146932d901253fe13b416e0df69a1e14d1571ee5d2ea685a1a5bb7be139816d91091a558640a3cdc13dee71e63b4e2bf540c90255689c
6
+ metadata.gz: e146734d652642438bf615423846d4c8bbe932d61e03bb4abed5c2114e647b0017a564218d02f2bb353f298955ad3825b8a7571c9a1b721147d562c8765fd02e
7
+ data.tar.gz: 31cd694d9c0c39ed27dcd92762a287571cb436910f39dc0693eb42f83a7b1d4ec197563bb3a41f30440e497af70fe9b7b90e5b46867293726492f1d6910db25f
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- snoop (0.8.0)
4
+ snoop (0.8.5)
5
5
  httparty
6
6
  nokogiri
7
7
 
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
- DEFAULT_OPTIONS = {
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(url: nil, css: nil, http_client: HTTParty)
19
- raise UrlRequiredException if url.nil?
24
+ def initialize(options = {})
25
+ options = DEFAULT_INIT_OPTIONS.merge options
26
+
27
+ raise UrlRequiredException if options.fetch(:url).nil?
20
28
 
21
- @url = url
22
- @css = 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 = DEFAULT_OPTIONS.merge(options)
35
+ options = DEFAULT_NOTIFY_OPTIONS.merge options
28
36
 
29
37
  while (
30
- (options[:count] -= 1 ) >= 0 ||
31
- options[:while].call ||
32
- !options[:until].call
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[:delay]
43
+ sleep options.fetch(:delay)
36
44
  end
37
45
  end
38
46
 
data/lib/snoop/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Snoop
2
- VERSION = '0.8.0'
2
+ VERSION = '0.8.5'
3
3
  end
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.0
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