tins 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/tins/attempt.rb +2 -1
- data/lib/tins/null.rb +12 -0
- data/lib/tins/version.rb +1 -1
- data/tests/null_test.rb +3 -0
- data/tests/try_test.rb +10 -1
- data/tins.gemspec +5 -5
- metadata +76 -73
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.7
|
data/lib/tins/attempt.rb
CHANGED
@@ -9,6 +9,7 @@ module Tins
|
|
9
9
|
attempts = opts[:attempts] || 1
|
10
10
|
exception_class = opts[:exception_class] if opts.key?(:exception_class)
|
11
11
|
sleep = opts[:sleep]
|
12
|
+
reraise = opts[:reraise]
|
12
13
|
end
|
13
14
|
return if attempts <= 0
|
14
15
|
count = 0
|
@@ -32,7 +33,7 @@ module Tins
|
|
32
33
|
sleep_duration(sleep, count)
|
33
34
|
retry
|
34
35
|
end
|
35
|
-
false
|
36
|
+
reraise ? raise : false
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
data/lib/tins/null.rb
CHANGED
data/lib/tins/version.rb
CHANGED
data/tests/null_test.rb
CHANGED
@@ -10,6 +10,9 @@ module Tins
|
|
10
10
|
assert_equal NULL, NULL.foo.bar
|
11
11
|
assert_equal 'NULL', NULL.inspect
|
12
12
|
assert_equal '', NULL.to_s
|
13
|
+
assert_equal 0, NULL.to_i
|
14
|
+
assert_equal 0.0, NULL.to_f
|
15
|
+
assert_equal [], NULL.to_a
|
13
16
|
assert_equal 1, Null(1)
|
14
17
|
assert_equal NULL, Null(nil)
|
15
18
|
assert_equal NULL, NULL::NULL
|
data/tests/try_test.rb
CHANGED
@@ -26,9 +26,18 @@ module Tins
|
|
26
26
|
def test_attempt_exception
|
27
27
|
assert attempt(:attempts => 1, :exception_class => MyException) { |c| c != 1 and raise MyException }
|
28
28
|
assert attempt(:attempts => 3, :exception_class => MyException) { |c| c != 1 and raise MyException }
|
29
|
-
assert_equal false, attempt(:attempts => 3, :exception_class => MyException) { |c| c != 4 and raise MyException }
|
30
29
|
assert_nil attempt(:attempts => 0, :exception_class => MyException) { |c| c != 4 and raise MyException }
|
31
30
|
assert_raise(Exception) { attempt(:attempts => 3, :exception_class => MyException) { raise Exception } }
|
32
31
|
end
|
32
|
+
|
33
|
+
def test_reraise_exception
|
34
|
+
tries = 0
|
35
|
+
assert_raise(MyException) do
|
36
|
+
attempt(:attempts => 3, :exception_class => MyException, :reraise => true) do |c|
|
37
|
+
tries = c; raise MyException
|
38
|
+
end
|
39
|
+
end
|
40
|
+
assert_equal 3, tries
|
41
|
+
end
|
33
42
|
end
|
34
43
|
end
|
data/tins.gemspec
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "tins"
|
5
|
-
s.version = "0.3.
|
5
|
+
s.version = "0.3.7"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Florian Frank"]
|
9
|
-
s.date = "
|
9
|
+
s.date = "2012-01-05"
|
10
10
|
s.description = "All the stuff that isn't good/big enough for a real library."
|
11
11
|
s.email = "flori@ping.de"
|
12
|
-
s.extra_rdoc_files = ["README.rdoc", "lib/spruz.rb", "lib/tins/
|
12
|
+
s.extra_rdoc_files = ["README.rdoc", "lib/spruz.rb", "lib/tins/alias.rb", "lib/tins/attempt.rb", "lib/tins/bijection.rb", "lib/tins/count_by.rb", "lib/tins/deep_dup.rb", "lib/tins/file_binary.rb", "lib/tins/find.rb", "lib/tins/generator.rb", "lib/tins/go.rb", "lib/tins/hash_symbolize_keys_recursive.rb", "lib/tins/hash_union.rb", "lib/tins/limited.rb", "lib/tins/lines_file.rb", "lib/tins/memoize.rb", "lib/tins/minimize.rb", "lib/tins/module_group.rb", "lib/tins/null.rb", "lib/tins/once.rb", "lib/tins/p.rb", "lib/tins/partial_application.rb", "lib/tins/range_plus.rb", "lib/tins/require_maybe.rb", "lib/tins/round.rb", "lib/tins/secure_write.rb", "lib/tins/shuffle.rb", "lib/tins/string_camelize.rb", "lib/tins/string_underscore.rb", "lib/tins/string_version.rb", "lib/tins/subhash.rb", "lib/tins/time_dummy.rb", "lib/tins/to_proc.rb", "lib/tins/uniq_by.rb", "lib/tins/version.rb", "lib/tins/write.rb", "lib/tins/xt/attempt.rb", "lib/tins/xt/blank.rb", "lib/tins/xt/count_by.rb", "lib/tins/xt/deep_dup.rb", "lib/tins/xt/file_binary.rb", "lib/tins/xt/full.rb", "lib/tins/xt/hash_symbolize_keys_recursive.rb", "lib/tins/xt/hash_union.rb", "lib/tins/xt/irb.rb", "lib/tins/xt/named.rb", "lib/tins/xt/null.rb", "lib/tins/xt/p.rb", "lib/tins/xt/partial_application.rb", "lib/tins/xt/range_plus.rb", "lib/tins/xt/require_maybe.rb", "lib/tins/xt/round.rb", "lib/tins/xt/secure_write.rb", "lib/tins/xt/shuffle.rb", "lib/tins/xt/string.rb", "lib/tins/xt/string_camelize.rb", "lib/tins/xt/string_underscore.rb", "lib/tins/xt/string_version.rb", "lib/tins/xt/subhash.rb", "lib/tins/xt/symbol_to_proc.rb", "lib/tins/xt/time_dummy.rb", "lib/tins/xt/uniq_by.rb", "lib/tins/xt/write.rb", "lib/tins/xt.rb", "lib/tins.rb"]
|
13
13
|
s.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE", "README.rdoc", "Rakefile", "TODO", "VERSION", "lib/spruz", "lib/spruz.rb", "lib/tins.rb", "lib/tins/alias.rb", "lib/tins/attempt.rb", "lib/tins/bijection.rb", "lib/tins/count_by.rb", "lib/tins/deep_dup.rb", "lib/tins/file_binary.rb", "lib/tins/find.rb", "lib/tins/generator.rb", "lib/tins/go.rb", "lib/tins/hash_symbolize_keys_recursive.rb", "lib/tins/hash_union.rb", "lib/tins/limited.rb", "lib/tins/lines_file.rb", "lib/tins/memoize.rb", "lib/tins/minimize.rb", "lib/tins/module_group.rb", "lib/tins/null.rb", "lib/tins/once.rb", "lib/tins/p.rb", "lib/tins/partial_application.rb", "lib/tins/range_plus.rb", "lib/tins/require_maybe.rb", "lib/tins/round.rb", "lib/tins/secure_write.rb", "lib/tins/shuffle.rb", "lib/tins/string_camelize.rb", "lib/tins/string_underscore.rb", "lib/tins/string_version.rb", "lib/tins/subhash.rb", "lib/tins/time_dummy.rb", "lib/tins/to_proc.rb", "lib/tins/uniq_by.rb", "lib/tins/version.rb", "lib/tins/write.rb", "lib/tins/xt.rb", "lib/tins/xt/attempt.rb", "lib/tins/xt/blank.rb", "lib/tins/xt/count_by.rb", "lib/tins/xt/deep_dup.rb", "lib/tins/xt/file_binary.rb", "lib/tins/xt/full.rb", "lib/tins/xt/hash_symbolize_keys_recursive.rb", "lib/tins/xt/hash_union.rb", "lib/tins/xt/irb.rb", "lib/tins/xt/named.rb", "lib/tins/xt/null.rb", "lib/tins/xt/p.rb", "lib/tins/xt/partial_application.rb", "lib/tins/xt/range_plus.rb", "lib/tins/xt/require_maybe.rb", "lib/tins/xt/round.rb", "lib/tins/xt/secure_write.rb", "lib/tins/xt/shuffle.rb", "lib/tins/xt/string.rb", "lib/tins/xt/string_camelize.rb", "lib/tins/xt/string_underscore.rb", "lib/tins/xt/string_version.rb", "lib/tins/xt/subhash.rb", "lib/tins/xt/symbol_to_proc.rb", "lib/tins/xt/time_dummy.rb", "lib/tins/xt/uniq_by.rb", "lib/tins/xt/write.rb", "tests/bijection_test.rb", "tests/blank_full_test.rb", "tests/count_by_test.rb", "tests/deep_dup_test.rb", "tests/file_binary_test.rb", "tests/find_test.rb", "tests/generator_test.rb", "tests/hash_symbolize_keys_recursive_test.rb", "tests/hash_union_test.rb", "tests/limited_test.rb", "tests/lines_file_test.rb", "tests/memoize_test.rb", "tests/minimize_test.rb", "tests/module_group_test.rb", "tests/named_test.rb", "tests/null_test.rb", "tests/partial_application_test.rb", "tests/range_plus_test.rb", "tests/require_maybe_test.rb", "tests/round_test.rb", "tests/secure_write_test.rb", "tests/shuffle_test.rb", "tests/string_camelize_test.rb", "tests/string_underscore_test.rb", "tests/string_version_test.rb", "tests/subhash_test.rb", "tests/test_helper.rb", "tests/time_dummy_test.rb", "tests/try_test.rb", "tests/uniq_by_test.rb", "tins.gemspec"]
|
14
14
|
s.homepage = "http://flori.github.com/tins"
|
15
15
|
s.rdoc_options = ["--title", "Tins - Useful stuff.", "--main", "README.rdoc"]
|
16
16
|
s.require_paths = ["lib"]
|
17
|
-
s.rubygems_version = "1.8.
|
17
|
+
s.rubygems_version = "1.8.13"
|
18
18
|
s.summary = "Useful stuff."
|
19
|
-
s.test_files = ["tests/
|
19
|
+
s.test_files = ["tests/bijection_test.rb", "tests/blank_full_test.rb", "tests/count_by_test.rb", "tests/deep_dup_test.rb", "tests/file_binary_test.rb", "tests/find_test.rb", "tests/generator_test.rb", "tests/hash_symbolize_keys_recursive_test.rb", "tests/hash_union_test.rb", "tests/limited_test.rb", "tests/lines_file_test.rb", "tests/memoize_test.rb", "tests/minimize_test.rb", "tests/module_group_test.rb", "tests/named_test.rb", "tests/null_test.rb", "tests/partial_application_test.rb", "tests/range_plus_test.rb", "tests/require_maybe_test.rb", "tests/round_test.rb", "tests/secure_write_test.rb", "tests/shuffle_test.rb", "tests/string_camelize_test.rb", "tests/string_underscore_test.rb", "tests/string_version_test.rb", "tests/subhash_test.rb", "tests/test_helper.rb", "tests/time_dummy_test.rb", "tests/try_test.rb", "tests/uniq_by_test.rb", "tests/bijection_test.rb", "tests/blank_full_test.rb", "tests/count_by_test.rb", "tests/deep_dup_test.rb", "tests/file_binary_test.rb", "tests/find_test.rb", "tests/generator_test.rb", "tests/hash_symbolize_keys_recursive_test.rb", "tests/hash_union_test.rb", "tests/limited_test.rb", "tests/lines_file_test.rb", "tests/memoize_test.rb", "tests/minimize_test.rb", "tests/module_group_test.rb", "tests/named_test.rb", "tests/null_test.rb", "tests/partial_application_test.rb", "tests/range_plus_test.rb", "tests/require_maybe_test.rb", "tests/round_test.rb", "tests/secure_write_test.rb", "tests/shuffle_test.rb", "tests/string_camelize_test.rb", "tests/string_underscore_test.rb", "tests/string_version_test.rb", "tests/subhash_test.rb", "tests/time_dummy_test.rb", "tests/try_test.rb", "tests/uniq_by_test.rb"]
|
20
20
|
|
21
21
|
if s.respond_to? :specification_version then
|
22
22
|
s.specification_version = 3
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gem_hadar
|
16
|
-
requirement: &
|
16
|
+
requirement: &2160957480 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.1.4
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2160957480
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: test-unit
|
27
|
-
requirement: &
|
27
|
+
requirement: &2160956700 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '2.3'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2160956700
|
36
36
|
description: All the stuff that isn't good/big enough for a real library.
|
37
37
|
email: flori@ping.de
|
38
38
|
executables: []
|
@@ -40,68 +40,68 @@ extensions: []
|
|
40
40
|
extra_rdoc_files:
|
41
41
|
- README.rdoc
|
42
42
|
- lib/spruz.rb
|
43
|
-
- lib/tins/hash_symbolize_keys_recursive.rb
|
44
|
-
- lib/tins/string_underscore.rb
|
45
|
-
- lib/tins/hash_union.rb
|
46
|
-
- lib/tins/write.rb
|
47
|
-
- lib/tins/version.rb
|
48
43
|
- lib/tins/alias.rb
|
49
|
-
- lib/tins/
|
50
|
-
- lib/tins/
|
44
|
+
- lib/tins/attempt.rb
|
45
|
+
- lib/tins/bijection.rb
|
46
|
+
- lib/tins/count_by.rb
|
47
|
+
- lib/tins/deep_dup.rb
|
48
|
+
- lib/tins/file_binary.rb
|
51
49
|
- lib/tins/find.rb
|
52
50
|
- lib/tins/generator.rb
|
53
|
-
- lib/tins/
|
54
|
-
- lib/tins/
|
55
|
-
- lib/tins/
|
56
|
-
- lib/tins/memoize.rb
|
57
|
-
- lib/tins/lines_file.rb
|
58
|
-
- lib/tins/subhash.rb
|
59
|
-
- lib/tins/bijection.rb
|
51
|
+
- lib/tins/go.rb
|
52
|
+
- lib/tins/hash_symbolize_keys_recursive.rb
|
53
|
+
- lib/tins/hash_union.rb
|
60
54
|
- lib/tins/limited.rb
|
61
|
-
- lib/tins/
|
62
|
-
- lib/tins/
|
55
|
+
- lib/tins/lines_file.rb
|
56
|
+
- lib/tins/memoize.rb
|
57
|
+
- lib/tins/minimize.rb
|
63
58
|
- lib/tins/module_group.rb
|
64
59
|
- lib/tins/null.rb
|
60
|
+
- lib/tins/once.rb
|
61
|
+
- lib/tins/p.rb
|
62
|
+
- lib/tins/partial_application.rb
|
63
|
+
- lib/tins/range_plus.rb
|
65
64
|
- lib/tins/require_maybe.rb
|
65
|
+
- lib/tins/round.rb
|
66
66
|
- lib/tins/secure_write.rb
|
67
|
-
- lib/tins/
|
68
|
-
- lib/tins/
|
67
|
+
- lib/tins/shuffle.rb
|
68
|
+
- lib/tins/string_camelize.rb
|
69
|
+
- lib/tins/string_underscore.rb
|
69
70
|
- lib/tins/string_version.rb
|
70
|
-
- lib/tins/
|
71
|
-
- lib/tins/
|
71
|
+
- lib/tins/subhash.rb
|
72
|
+
- lib/tins/time_dummy.rb
|
73
|
+
- lib/tins/to_proc.rb
|
74
|
+
- lib/tins/uniq_by.rb
|
75
|
+
- lib/tins/version.rb
|
76
|
+
- lib/tins/write.rb
|
77
|
+
- lib/tins/xt/attempt.rb
|
78
|
+
- lib/tins/xt/blank.rb
|
79
|
+
- lib/tins/xt/count_by.rb
|
80
|
+
- lib/tins/xt/deep_dup.rb
|
81
|
+
- lib/tins/xt/file_binary.rb
|
82
|
+
- lib/tins/xt/full.rb
|
72
83
|
- lib/tins/xt/hash_symbolize_keys_recursive.rb
|
73
|
-
- lib/tins/xt/string_underscore.rb
|
74
84
|
- lib/tins/xt/hash_union.rb
|
75
|
-
- lib/tins/xt/write.rb
|
76
85
|
- lib/tins/xt/irb.rb
|
77
|
-
- lib/tins/xt/
|
78
|
-
- lib/tins/xt/string_camelize.rb
|
79
|
-
- lib/tins/xt/shuffle.rb
|
80
|
-
- lib/tins/xt/deep_dup.rb
|
81
|
-
- lib/tins/xt/symbol_to_proc.rb
|
82
|
-
- lib/tins/xt/subhash.rb
|
83
|
-
- lib/tins/xt/attempt.rb
|
86
|
+
- lib/tins/xt/named.rb
|
84
87
|
- lib/tins/xt/null.rb
|
88
|
+
- lib/tins/xt/p.rb
|
89
|
+
- lib/tins/xt/partial_application.rb
|
90
|
+
- lib/tins/xt/range_plus.rb
|
85
91
|
- lib/tins/xt/require_maybe.rb
|
92
|
+
- lib/tins/xt/round.rb
|
86
93
|
- lib/tins/xt/secure_write.rb
|
87
|
-
- lib/tins/xt/
|
94
|
+
- lib/tins/xt/shuffle.rb
|
95
|
+
- lib/tins/xt/string.rb
|
96
|
+
- lib/tins/xt/string_camelize.rb
|
97
|
+
- lib/tins/xt/string_underscore.rb
|
88
98
|
- lib/tins/xt/string_version.rb
|
89
|
-
- lib/tins/xt/
|
90
|
-
- lib/tins/xt/
|
99
|
+
- lib/tins/xt/subhash.rb
|
100
|
+
- lib/tins/xt/symbol_to_proc.rb
|
91
101
|
- lib/tins/xt/time_dummy.rb
|
92
|
-
- lib/tins/xt/string.rb
|
93
|
-
- lib/tins/xt/full.rb
|
94
|
-
- lib/tins/xt/range_plus.rb
|
95
|
-
- lib/tins/xt/count_by.rb
|
96
|
-
- lib/tins/xt/blank.rb
|
97
102
|
- lib/tins/xt/uniq_by.rb
|
98
|
-
- lib/tins/
|
99
|
-
- lib/tins/
|
100
|
-
- lib/tins/partial_application.rb
|
101
|
-
- lib/tins/time_dummy.rb
|
102
|
-
- lib/tins/range_plus.rb
|
103
|
-
- lib/tins/count_by.rb
|
104
|
-
- lib/tins/uniq_by.rb
|
103
|
+
- lib/tins/xt/write.rb
|
104
|
+
- lib/tins/xt.rb
|
105
105
|
- lib/tins.rb
|
106
106
|
files:
|
107
107
|
- .gitignore
|
@@ -223,6 +223,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
223
223
|
- - ! '>='
|
224
224
|
- !ruby/object:Gem::Version
|
225
225
|
version: '0'
|
226
|
+
segments:
|
227
|
+
- 0
|
228
|
+
hash: -1627888393150619400
|
226
229
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
227
230
|
none: false
|
228
231
|
requirements:
|
@@ -231,38 +234,38 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
234
|
version: '0'
|
232
235
|
requirements: []
|
233
236
|
rubyforge_project:
|
234
|
-
rubygems_version: 1.8.
|
237
|
+
rubygems_version: 1.8.13
|
235
238
|
signing_key:
|
236
239
|
specification_version: 3
|
237
240
|
summary: Useful stuff.
|
238
241
|
test_files:
|
239
|
-
- tests/generator_test.rb
|
240
|
-
- tests/null_test.rb
|
241
|
-
- tests/find_test.rb
|
242
|
-
- tests/range_plus_test.rb
|
243
|
-
- tests/deep_dup_test.rb
|
244
242
|
- tests/bijection_test.rb
|
245
|
-
- tests/memoize_test.rb
|
246
|
-
- tests/limited_test.rb
|
247
|
-
- tests/count_by_test.rb
|
248
243
|
- tests/blank_full_test.rb
|
244
|
+
- tests/count_by_test.rb
|
245
|
+
- tests/deep_dup_test.rb
|
249
246
|
- tests/file_binary_test.rb
|
250
|
-
- tests/
|
251
|
-
- tests/
|
252
|
-
- tests/try_test.rb
|
253
|
-
- tests/require_maybe_test.rb
|
254
|
-
- tests/uniq_by_test.rb
|
255
|
-
- tests/time_dummy_test.rb
|
256
|
-
- tests/string_camelize_test.rb
|
257
|
-
- tests/lines_file_test.rb
|
258
|
-
- tests/string_underscore_test.rb
|
247
|
+
- tests/find_test.rb
|
248
|
+
- tests/generator_test.rb
|
259
249
|
- tests/hash_symbolize_keys_recursive_test.rb
|
260
|
-
- tests/named_test.rb
|
261
250
|
- tests/hash_union_test.rb
|
262
|
-
- tests/
|
263
|
-
- tests/
|
251
|
+
- tests/limited_test.rb
|
252
|
+
- tests/lines_file_test.rb
|
253
|
+
- tests/memoize_test.rb
|
264
254
|
- tests/minimize_test.rb
|
255
|
+
- tests/module_group_test.rb
|
256
|
+
- tests/named_test.rb
|
257
|
+
- tests/null_test.rb
|
258
|
+
- tests/partial_application_test.rb
|
259
|
+
- tests/range_plus_test.rb
|
260
|
+
- tests/require_maybe_test.rb
|
265
261
|
- tests/round_test.rb
|
266
|
-
- tests/
|
262
|
+
- tests/secure_write_test.rb
|
267
263
|
- tests/shuffle_test.rb
|
268
|
-
- tests/
|
264
|
+
- tests/string_camelize_test.rb
|
265
|
+
- tests/string_underscore_test.rb
|
266
|
+
- tests/string_version_test.rb
|
267
|
+
- tests/subhash_test.rb
|
268
|
+
- tests/test_helper.rb
|
269
|
+
- tests/time_dummy_test.rb
|
270
|
+
- tests/try_test.rb
|
271
|
+
- tests/uniq_by_test.rb
|