bonehead 0.0.1
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 +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/bonehead.rb +36 -0
- data/lib/bonehead/version.rb +3 -0
- metadata +82 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: f946c727b0535d65f9ec4fd58815fc081b429051
|
|
4
|
+
data.tar.gz: 60d39aeaa8593f9c600da923f1f4784a35891e38
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 2b4d925ab8111601c2808343498b7cbc2bb9fc5024e0ea7b8ce802c72b53df791a836cc57c63795bcfacd6a297f7b45db00d2b8d5222b77bb31fd1fb426b726a
|
|
7
|
+
data.tar.gz: 9e6ae21fcce6f0c50af332ca9a3ddebd810c30383f5f97fe587d78fa00913ec402f5b72608e0db5f2394516b30115bfe7294c143bdad1d5137602d015bb93fa6
|
checksums.yaml.gz.sig
ADDED
|
Binary file
|
data.tar.gz.sig
ADDED
|
Binary file
|
data/lib/bonehead.rb
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Bonehead
|
|
2
|
+
extend self
|
|
3
|
+
|
|
4
|
+
# Public: Executes a block of code and retries it up to `tries` times if an
|
|
5
|
+
# exception was raised.
|
|
6
|
+
#
|
|
7
|
+
# tries - An Integer (default: Float::Infinity).
|
|
8
|
+
# exceptions - A list of Exceptions (default: StandardError).
|
|
9
|
+
#
|
|
10
|
+
# Examples
|
|
11
|
+
#
|
|
12
|
+
# class Wrapper
|
|
13
|
+
# include Bonehead
|
|
14
|
+
#
|
|
15
|
+
# def login(username, password)
|
|
16
|
+
# insist(5, HTTPError) do
|
|
17
|
+
# HTTP.post "..."
|
|
18
|
+
# end
|
|
19
|
+
# end
|
|
20
|
+
# end
|
|
21
|
+
#
|
|
22
|
+
# Returns the return value of the block.
|
|
23
|
+
def insist(tries = Float::Infinity, *exceptions, &block)
|
|
24
|
+
exceptions << StandardError if exceptions.empty?
|
|
25
|
+
|
|
26
|
+
catch :__BONEHEAD__ do
|
|
27
|
+
tries.times do |i|
|
|
28
|
+
begin
|
|
29
|
+
throw :__BONEHEAD__, yield(i.succ)
|
|
30
|
+
rescue *exceptions
|
|
31
|
+
tries.pred == i ? raise : next
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: bonehead
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jip van Reijsen
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain:
|
|
11
|
+
- |
|
|
12
|
+
-----BEGIN CERTIFICATE-----
|
|
13
|
+
MIIDhTCCAm2gAwIBAgIBATANBgkqhkiG9w0BAQUFADBEMRYwFAYDVQQDDA1qaXB2
|
|
14
|
+
YW5yZWlqc2VuMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZ
|
|
15
|
+
FgNjb20wHhcNMTMwODA4MjEzMDE4WhcNMTQwODA4MjEzMDE4WjBEMRYwFAYDVQQD
|
|
16
|
+
DA1qaXB2YW5yZWlqc2VuMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJ
|
|
17
|
+
k/IsZAEZFgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQClzSDD
|
|
18
|
+
gHU5xJorLZBEClUFIQsAVUToqrIY25G50wd3tRRitsD4+8TKNcH/afmTZ7itFd47
|
|
19
|
+
Y38wLZHJ3QGNWWUzKSp75hwY1YjFT/WTt2CBU/Yisawy2Ah04fEDDNtXnUm/a4Nf
|
|
20
|
+
cm1iJCSO0gYqihYx/cjt8ZzMUZGQc0HjYg7jzOGOdjsozJDUtrPK+7njgJeRznBu
|
|
21
|
+
Zglx4JcSvSnUe3KnZYiHUAfNMbHZC6aDoWJNEJWIugDOC4ERFDQTl3u6X4WtMgK0
|
|
22
|
+
veZT7x84/+o2OAkXrj6Vbz4idyFlaOi+4yl5b0YJLZdzHSZEIoROzELt3kfRYIUe
|
|
23
|
+
+KW3UGk4RtI/zzO1AgMBAAGjgYEwfzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAd
|
|
24
|
+
BgNVHQ4EFgQUVokOPAdYy4XiyylEpkAbiU8TclUwIgYDVR0RBBswGYEXamlwdmFu
|
|
25
|
+
cmVpanNlbkBnbWFpbC5jb20wIgYDVR0SBBswGYEXamlwdmFucmVpanNlbkBnbWFp
|
|
26
|
+
bC5jb20wDQYJKoZIhvcNAQEFBQADggEBADg9YN9UgiC7XpRuWGs/CP1sRXuiKFHL
|
|
27
|
+
sZCWGXivJK5VVIjUAABVDU0bG8z7kf8k2LMoXY2reVjhdKjrYYkFVMqY0U207xMA
|
|
28
|
+
seECzepUAXMMbLtppejnTNoIgz+w6nNfIwTutKdLx8xXGpa3z5AqYdmCWfuIj77G
|
|
29
|
+
3T7twg/E2UReEgkHWULU05ISp0SODfCJzq21nKReppwVumyGBmyCOBz+uM27OXxc
|
|
30
|
+
336lVuJ9KEoETd0t0biCkWVE2illvjAj0HuCi4mSA5QRkr2FbWkgFQXiMAcaakcW
|
|
31
|
+
xr2cJv1xwkNLUhdO3OoK0ix8tfsubY0PhA8xi8a016pr7xYJD+xUPiA=
|
|
32
|
+
-----END CERTIFICATE-----
|
|
33
|
+
date: 2014-01-17 00:00:00.000000000 Z
|
|
34
|
+
dependencies:
|
|
35
|
+
- !ruby/object:Gem::Dependency
|
|
36
|
+
name: cutest
|
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
|
38
|
+
requirements:
|
|
39
|
+
- - "~>"
|
|
40
|
+
- !ruby/object:Gem::Version
|
|
41
|
+
version: '1.2'
|
|
42
|
+
type: :development
|
|
43
|
+
prerelease: false
|
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - "~>"
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '1.2'
|
|
49
|
+
description: Retry blocks of code when they raise an exception.
|
|
50
|
+
email:
|
|
51
|
+
- jipvanreijsen@gmail.com
|
|
52
|
+
executables: []
|
|
53
|
+
extensions: []
|
|
54
|
+
extra_rdoc_files: []
|
|
55
|
+
files:
|
|
56
|
+
- lib/bonehead.rb
|
|
57
|
+
- lib/bonehead/version.rb
|
|
58
|
+
homepage: https://github.com/britishtea/bonehead
|
|
59
|
+
licenses:
|
|
60
|
+
- MIT
|
|
61
|
+
metadata: {}
|
|
62
|
+
post_install_message:
|
|
63
|
+
rdoc_options: []
|
|
64
|
+
require_paths:
|
|
65
|
+
- lib
|
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
|
+
requirements:
|
|
68
|
+
- - ">="
|
|
69
|
+
- !ruby/object:Gem::Version
|
|
70
|
+
version: '0'
|
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
requirements: []
|
|
77
|
+
rubyforge_project:
|
|
78
|
+
rubygems_version: 2.2.0
|
|
79
|
+
signing_key:
|
|
80
|
+
specification_version: 4
|
|
81
|
+
summary: Retry blocks of code when they raise an exception.
|
|
82
|
+
test_files: []
|
metadata.gz.sig
ADDED
|
Binary file
|