hwacha 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.travis.yml +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +14 -7
- data/lib/hwacha.rb +12 -1
- data/lib/hwacha/config.rb +6 -0
- data/lib/hwacha/version.rb +1 -1
- data/spec/lib/hwacha_spec.rb +18 -1
- metadata +14 -12
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MTBmODUxMmExYTI2YWY3NGExZWFhY2E1Njk0ZjU2NDBlMjI0OGUxOQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YTM0YzExNWNiN2M0OTFlM2RiOGUwZTlhZTE0ZTc2YzY1ZWFlMTBlYQ==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MmYzNjgzMjZiMmZmZjdlNDlkMWU0ZTJkMzhiZjJkMjg2OTAwYTNhZGI4MjMw
|
10
|
+
NzIyMDU5NTBkNjNjMGZlYjA1NDZmNzkwNDIwZTBkYjQxMjI5Zjc4MmRhYmFk
|
11
|
+
OTIyYjhiZDMxYWVkNTg5MjFkNDMzODBiYjQ3NGJhMjU5YmY2MjE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NTliYzhiM2QzNmY5YjMxNDVlYjhlNjA5NjRiMWRkMGQ3ZjliYWVhMWY5YTI5
|
14
|
+
MmFhMjdmYzllMTU5YmY0ZWEzZTJiN2ZhZTc2OTM3MjJhODFkOWM5MGJmZjVk
|
15
|
+
MDVlOTlhZGUyMjMxMjk2MTA3YWNkNjM4YTcxZTFhZGM5ZmYwNmM=
|
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# hwacha
|
1
|
+
# Hwacha [![Build Status](https://travis-ci.org/sdball/hwacha.png?branch=master)](https://travis-ci.org/sdball/hwacha)
|
2
2
|
|
3
3
|
Hwacha! Harness the power of Typhoeus to quickly check webpage responses.
|
4
4
|
|
5
|
-
##
|
5
|
+
## Examples
|
6
6
|
|
7
7
|
Check a single page.
|
8
8
|
|
@@ -17,14 +17,21 @@ hwacha.check('rakeroutes.com') do |url, response|
|
|
17
17
|
end
|
18
18
|
```
|
19
19
|
|
20
|
-
|
20
|
+
Configure the maximum number of concurrent requests.
|
21
21
|
|
22
22
|
```ruby
|
23
|
-
|
24
|
-
|
23
|
+
hwacha = Hwacha.new do |config|
|
24
|
+
config.max_concurrent_requests = 10 # 20 is the default
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
+
# a legacy integer argument is also supported
|
28
|
+
hwacha = Hwacha.new(10)
|
29
|
+
```
|
27
30
|
|
31
|
+
Check a bunch of pages! Hwacha!
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
hwacha = Hwacha.new
|
28
35
|
hwacha.check(array_of_webpage_urls) do |url, response|
|
29
36
|
# each url is enqueued in parallel using the powerful Typhoeus library!
|
30
37
|
# this block is yielded the url and response object for every response!
|
@@ -54,7 +61,7 @@ want to fire a bunch of requests and find pages that successfully respond. Ok!
|
|
54
61
|
```ruby
|
55
62
|
hwacha = Hwacha.new
|
56
63
|
|
57
|
-
|
64
|
+
hwacha.find_existing(array_of_webpage_urls) do |url|
|
58
65
|
# this block will be called for all urls that successfully respond!
|
59
66
|
# hwacha!
|
60
67
|
end
|
data/lib/hwacha.rb
CHANGED
@@ -1,9 +1,20 @@
|
|
1
1
|
require "hwacha/version"
|
2
|
+
require "hwacha/config"
|
2
3
|
require "typhoeus"
|
3
4
|
|
4
5
|
class Hwacha
|
6
|
+
attr_reader :max_concurrent_requests
|
7
|
+
|
5
8
|
def initialize(max_concurrent_requests=20)
|
6
|
-
|
9
|
+
config = Hwacha::Config.new
|
10
|
+
|
11
|
+
# support the simple legacy API
|
12
|
+
config.max_concurrent_requests = max_concurrent_requests
|
13
|
+
|
14
|
+
# the nice configuration object API
|
15
|
+
yield config if block_given?
|
16
|
+
|
17
|
+
@max_concurrent_requests = config.max_concurrent_requests
|
7
18
|
end
|
8
19
|
|
9
20
|
def check(urls)
|
data/lib/hwacha/version.rb
CHANGED
data/spec/lib/hwacha_spec.rb
CHANGED
@@ -6,7 +6,24 @@ VCR.configure do |c|
|
|
6
6
|
c.hook_into :typhoeus
|
7
7
|
end
|
8
8
|
|
9
|
-
describe Hwacha do
|
9
|
+
describe Hwacha, "initialization" do
|
10
|
+
it "defaults to 20 max concurrent requests" do
|
11
|
+
expect(Hwacha.new.max_concurrent_requests).to eq 20
|
12
|
+
end
|
13
|
+
|
14
|
+
it "takes an integer argument to set the number of max concurrent requests" do
|
15
|
+
expect(Hwacha.new(10).max_concurrent_requests).to eq 10
|
16
|
+
end
|
17
|
+
|
18
|
+
it "can set max_concurrent_requests via a configuration object" do
|
19
|
+
hwacha = Hwacha.new do |config|
|
20
|
+
config.max_concurrent_requests = 10
|
21
|
+
end
|
22
|
+
expect(hwacha.max_concurrent_requests).to eq 10
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe Hwacha, "instance methods" do
|
10
27
|
let(:url_with_success_response) { 'rakeroutes.com' }
|
11
28
|
let(:url_with_404_response) { 'rakeroutes.com/this-url-does-not-exist' }
|
12
29
|
let(:not_a_url) { '' }
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hwacha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Ball
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - '>='
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - '>='
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -42,42 +42,42 @@ dependencies:
|
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - '>='
|
45
|
+
- - ! '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - '>='
|
52
|
+
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - '>='
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - '>='
|
66
|
+
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: vcr
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - '>='
|
73
|
+
- - ! '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - '>='
|
80
|
+
- - ! '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
description: Harness the power of Typhoeus to quickly check webpage responses.
|
@@ -88,6 +88,7 @@ extensions: []
|
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
90
|
- .gitignore
|
91
|
+
- .travis.yml
|
91
92
|
- Gemfile
|
92
93
|
- Gemfile.lock
|
93
94
|
- LICENSE
|
@@ -95,6 +96,7 @@ files:
|
|
95
96
|
- Rakefile
|
96
97
|
- hwacha.gemspec
|
97
98
|
- lib/hwacha.rb
|
99
|
+
- lib/hwacha/config.rb
|
98
100
|
- lib/hwacha/version.rb
|
99
101
|
- spec/fixtures/cassettes/not_a_url.yml
|
100
102
|
- spec/fixtures/cassettes/url_with_404_response.yml
|
@@ -111,12 +113,12 @@ require_paths:
|
|
111
113
|
- lib
|
112
114
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
115
|
requirements:
|
114
|
-
- - '>='
|
116
|
+
- - ! '>='
|
115
117
|
- !ruby/object:Gem::Version
|
116
118
|
version: '0'
|
117
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
120
|
requirements:
|
119
|
-
- - '>='
|
121
|
+
- - ! '>='
|
120
122
|
- !ruby/object:Gem::Version
|
121
123
|
version: '0'
|
122
124
|
requirements: []
|