hwacha 0.1.0 → 0.2.0

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,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1f62d12690e2705f9a389645b8dce348d48910e0
4
- data.tar.gz: 1e9990d81ca4176385a2f2bd43272e7b915f3edf
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTBmODUxMmExYTI2YWY3NGExZWFhY2E1Njk0ZjU2NDBlMjI0OGUxOQ==
5
+ data.tar.gz: !binary |-
6
+ YTM0YzExNWNiN2M0OTFlM2RiOGUwZTlhZTE0ZTc2YzY1ZWFlMTBlYQ==
5
7
  SHA512:
6
- metadata.gz: ecc0e7b3d69d53f46e1a4f9e6016dcc778265b6a124f5c38dda504e90ce51605c456f23d4956a937636a597b3ae8f52dc44859321e92cabf845fdd06380442dd
7
- data.tar.gz: 05a854a534eaff9713fac5b70b87fa8973e56526a02139b1297bb23c7cd313c41607c12821bd130b18dca36c5220a6aaaf2f5a431642689ad287e98863e35c7a
8
+ metadata.gz: !binary |-
9
+ MmYzNjgzMjZiMmZmZjdlNDlkMWU0ZTJkMzhiZjJkMjg2OTAwYTNhZGI4MjMw
10
+ NzIyMDU5NTBkNjNjMGZlYjA1NDZmNzkwNDIwZTBkYjQxMjI5Zjc4MmRhYmFk
11
+ OTIyYjhiZDMxYWVkNTg5MjFkNDMzODBiYjQ3NGJhMjU5YmY2MjE=
12
+ data.tar.gz: !binary |-
13
+ NTliYzhiM2QzNmY5YjMxNDVlYjhlNjA5NjRiMWRkMGQ3ZjliYWVhMWY5YTI5
14
+ MmFhMjdmYzllMTU5YmY0ZWEzZTJiN2ZhZTc2OTM3MjJhODFkOWM5MGJmZjVk
15
+ MDVlOTlhZGUyMjMxMjk2MTA3YWNkNjM4YTcxZTFhZGM5ZmYwNmM=
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hwacha (0.1.0)
4
+ hwacha (0.2.0)
5
5
  typhoeus
6
6
 
7
7
  GEM
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
- ## Example
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
- Check a bunch of pages! Hwacha!
20
+ Configure the maximum number of concurrent requests.
21
21
 
22
22
  ```ruby
23
- # 20 is also the default
24
- maximum_number_of_requests_to_work_on_in_parallel = 20
23
+ hwacha = Hwacha.new do |config|
24
+ config.max_concurrent_requests = 10 # 20 is the default
25
+ end
25
26
 
26
- hwacha = Hwacha.new(maximum_number_of_requests_to_work_on_in_parallel)
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
- Hwacha.find_existing(array_of_webpage_urls) do |url|
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
@@ -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
- @max_concurrent_requests = max_concurrent_requests
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)
@@ -0,0 +1,6 @@
1
+ require 'ostruct'
2
+
3
+ class Hwacha
4
+ class Config < OpenStruct
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  class Hwacha
2
- VERSION = "0.1.0" # woo, beta!
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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.1.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: 2013-12-03 00:00:00.000000000 Z
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: []