net-http-follow_tail 0.0.1 → 0.0.2
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.
- data/README.md +6 -0
- data/lib/net/http/follow_tail/version.rb +7 -0
- data/lib/net/http/follow_tail.rb +5 -4
- data/net-http-follow_tail.gemspec +26 -0
- data/spec/tailer_spec.rb +1 -0
- metadata +4 -2
data/README.md
CHANGED
@@ -40,6 +40,12 @@ exposing the result of the most recent tail request at the latter the
|
|
40
40
|
current tailing state. By default it is only called when the tail
|
41
41
|
request was successful.
|
42
42
|
|
43
|
+
# Example
|
44
|
+
|
45
|
+
This module can be seen put to use at:
|
46
|
+
|
47
|
+
https://github.com/broquaint/soup-stash/blob/master/script/keeping-up-with-the-logs
|
48
|
+
|
43
49
|
# Author
|
44
50
|
|
45
51
|
Dan Brook `<dan@broquaint.com>`
|
data/lib/net/http/follow_tail.rb
CHANGED
@@ -8,6 +8,7 @@ class Net::HTTP::FollowTail
|
|
8
8
|
has :state, is_a: Symbol
|
9
9
|
has :method, is_a: Symbol
|
10
10
|
has :response, is_a: Net::HTTPSuccess
|
11
|
+
has :error, is_a: Exception
|
11
12
|
|
12
13
|
def has_response?
|
13
14
|
not @response.nil?
|
@@ -77,8 +78,8 @@ class Net::HTTP::FollowTail
|
|
77
78
|
|
78
79
|
begin
|
79
80
|
head_response = head_request
|
80
|
-
rescue Timeout::Error, SocketError, EOFError, Errno::ETIMEDOUT
|
81
|
-
return Result.new(state: :error, method: :head)
|
81
|
+
rescue Timeout::Error, SocketError, EOFError, Errno::ETIMEDOUT => err
|
82
|
+
return Result.new(state: :error, method: :head, error: err)
|
82
83
|
end
|
83
84
|
|
84
85
|
# TODO invoke head_response.value to check for non 200s.
|
@@ -90,8 +91,8 @@ class Net::HTTP::FollowTail
|
|
90
91
|
|
91
92
|
begin
|
92
93
|
get_response = get_request(size_now)
|
93
|
-
rescue Timeout::Error, SocketError, EOFError
|
94
|
-
return Result.new(state: :error, method: :get)
|
94
|
+
rescue Timeout::Error, SocketError, EOFError => err
|
95
|
+
return Result.new(state: :error, method: :get, error: err)
|
95
96
|
end
|
96
97
|
|
97
98
|
update_offset get_response.content_length
|
@@ -0,0 +1,26 @@
|
|
1
|
+
lib = File.expand_path('../lib/', __FILE__)
|
2
|
+
$:.unshift lib unless $:.include?(lib)
|
3
|
+
|
4
|
+
require "net/http/follow_tail/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'net-http-follow_tail'
|
8
|
+
s.version = Net::HTTP::FollowTail::VERSION
|
9
|
+
|
10
|
+
s.required_ruby_version = ">= 1.9"
|
11
|
+
|
12
|
+
s.summary = "Like tail -f for the web"
|
13
|
+
s.description = "Watch multiple URIs for appended content e.g log files"
|
14
|
+
|
15
|
+
s.authors = ["Dan Brook"]
|
16
|
+
s.email = 'dan@broquaint.com'
|
17
|
+
s.homepage = 'http://github.com/broquaint/net-http-follow_tail'
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n") - %w(.rvmrc .gitignore)
|
20
|
+
s.test_files = `git ls-files spec`.split("\n")
|
21
|
+
|
22
|
+
s.add_runtime_dependency 'exponential-backoff', '~> 0.0.2'
|
23
|
+
|
24
|
+
s.add_development_dependency 'rake', '~> 0.9.2'
|
25
|
+
s.add_development_dependency 'rspec', '~> 2'
|
26
|
+
end
|
data/spec/tailer_spec.rb
CHANGED
@@ -149,6 +149,7 @@ describe Net::HTTP::FollowTail::Tailer do
|
|
149
149
|
expect(result.is_error?).to be_true
|
150
150
|
expect(result.method).to be(:head)
|
151
151
|
expect(result.has_response?).to be_false
|
152
|
+
expect(result.error).to be_an_instance_of(Timeout::Error)
|
152
153
|
end
|
153
154
|
|
154
155
|
it 'to handle GET errors' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: net-http-follow_tail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: exponential-backoff
|
@@ -71,6 +71,8 @@ files:
|
|
71
71
|
- README.md
|
72
72
|
- Rakefile
|
73
73
|
- lib/net/http/follow_tail.rb
|
74
|
+
- lib/net/http/follow_tail/version.rb
|
75
|
+
- net-http-follow_tail.gemspec
|
74
76
|
- spec/follow_tail_spec.rb
|
75
77
|
- spec/spec_helper.rb
|
76
78
|
- spec/tailer_spec.rb
|