ruby-nuggets 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/lib/nuggets/io/redirect.rb +5 -0
- data/lib/nuggets/io/redirect_mixin.rb +51 -0
- data/lib/nuggets/version.rb +1 -1
- metadata +178 -158
data/README
CHANGED
@@ -0,0 +1,51 @@
|
|
1
|
+
#--
|
2
|
+
###############################################################################
|
3
|
+
# #
|
4
|
+
# A component of ruby-nuggets, some extensions to the Ruby programming #
|
5
|
+
# language. #
|
6
|
+
# #
|
7
|
+
# Copyright (C) 2007-2012 Jens Wille #
|
8
|
+
# #
|
9
|
+
# Authors: #
|
10
|
+
# Jens Wille <jens.wille@uni-koeln.de> #
|
11
|
+
# #
|
12
|
+
# ruby-nuggets is free software; you can redistribute it and/or modify it #
|
13
|
+
# under the terms of the GNU Affero General Public License as published by #
|
14
|
+
# the Free Software Foundation; either version 3 of the License, or (at your #
|
15
|
+
# option) any later version. #
|
16
|
+
# #
|
17
|
+
# ruby-nuggets is distributed in the hope that it will be useful, but WITHOUT #
|
18
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License #
|
20
|
+
# for more details. #
|
21
|
+
# #
|
22
|
+
# You should have received a copy of the GNU Affero General Public License #
|
23
|
+
# along with ruby-nuggets. If not, see <http://www.gnu.org/licenses/>. #
|
24
|
+
# #
|
25
|
+
###############################################################################
|
26
|
+
#++
|
27
|
+
|
28
|
+
require 'nuggets/io/null_mixin'
|
29
|
+
|
30
|
+
module Nuggets
|
31
|
+
class IO
|
32
|
+
module RedirectMixin
|
33
|
+
|
34
|
+
def redirect(target = NullMixin::NULL, mode = 'w')
|
35
|
+
unless target.is_a?(self.class)
|
36
|
+
target = ::File.open(target, mode)
|
37
|
+
close_target = true
|
38
|
+
end
|
39
|
+
|
40
|
+
prev = dup
|
41
|
+
reopen(target)
|
42
|
+
|
43
|
+
yield
|
44
|
+
ensure
|
45
|
+
reopen(prev) if prev
|
46
|
+
target.close if close_target
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/nuggets/version.rb
CHANGED
metadata
CHANGED
@@ -1,222 +1,242 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-nuggets
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 55
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 8
|
9
|
+
- 4
|
10
|
+
version: 0.8.4
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Jens Wille
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2012-01-09 00:00:00 Z
|
13
19
|
dependencies: []
|
20
|
+
|
14
21
|
description: Some extensions to the Ruby programming language.
|
15
22
|
email: jens.wille@uni-koeln.de
|
16
23
|
executables: []
|
24
|
+
|
17
25
|
extensions: []
|
18
|
-
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
19
28
|
- README
|
20
29
|
- COPYING
|
21
30
|
- ChangeLog
|
22
|
-
files:
|
23
|
-
- lib/nuggets
|
24
|
-
- lib/nuggets/
|
25
|
-
- lib/nuggets/
|
26
|
-
- lib/nuggets/
|
27
|
-
- lib/nuggets/
|
28
|
-
- lib/nuggets/
|
29
|
-
- lib/nuggets/
|
30
|
-
- lib/nuggets/
|
31
|
-
- lib/nuggets/
|
32
|
-
- lib/nuggets/
|
33
|
-
- lib/nuggets/
|
34
|
-
- lib/nuggets/
|
35
|
-
- lib/nuggets/
|
36
|
-
- lib/nuggets/env/user_home_mixin.rb
|
31
|
+
files:
|
32
|
+
- lib/nuggets.rb
|
33
|
+
- lib/nuggets/range/quantile_mixin.rb
|
34
|
+
- lib/nuggets/range/quantile.rb
|
35
|
+
- lib/nuggets/hash/unroll_mixin.rb
|
36
|
+
- lib/nuggets/hash/insert.rb
|
37
|
+
- lib/nuggets/hash/nest.rb
|
38
|
+
- lib/nuggets/hash/deep_merge_mixin.rb
|
39
|
+
- lib/nuggets/hash/only.rb
|
40
|
+
- lib/nuggets/hash/deep_merge.rb
|
41
|
+
- lib/nuggets/hash/at.rb
|
42
|
+
- lib/nuggets/hash/in_order.rb
|
43
|
+
- lib/nuggets/hash/nest_mixin.rb
|
44
|
+
- lib/nuggets/hash/unroll.rb
|
37
45
|
- lib/nuggets/env/user_home.rb
|
38
46
|
- lib/nuggets/env/user_encoding.rb
|
39
47
|
- lib/nuggets/env/set.rb
|
48
|
+
- lib/nuggets/env/user_home_mixin.rb
|
49
|
+
- lib/nuggets/env/set_mixin.rb
|
50
|
+
- lib/nuggets/env/user_encoding_mixin.rb
|
51
|
+
- lib/nuggets/net/success.rb
|
40
52
|
- lib/nuggets/object/silence_mixin.rb
|
41
|
-
- lib/nuggets/object/boolean.rb
|
42
53
|
- lib/nuggets/object/uniclass.rb
|
43
|
-
- lib/nuggets/object/msend_mixin.rb
|
44
|
-
- lib/nuggets/object/blank_mixin.rb
|
45
|
-
- lib/nuggets/object/singleton_class_mixin.rb
|
46
54
|
- lib/nuggets/object/singleton_class.rb
|
47
|
-
- lib/nuggets/object/metaclass.rb
|
48
|
-
- lib/nuggets/object/virtual_class.rb
|
49
|
-
- lib/nuggets/object/eigenclass.rb
|
50
|
-
- lib/nuggets/object/silence.rb
|
51
|
-
- lib/nuggets/object/boolean_mixin.rb
|
52
55
|
- lib/nuggets/object/msend.rb
|
56
|
+
- lib/nuggets/object/virtual_class.rb
|
53
57
|
- lib/nuggets/object/ghost_class.rb
|
58
|
+
- lib/nuggets/object/boolean.rb
|
54
59
|
- lib/nuggets/object/blank.rb
|
55
|
-
- lib/nuggets/
|
56
|
-
- lib/nuggets/
|
57
|
-
- lib/nuggets/
|
58
|
-
- lib/nuggets/
|
59
|
-
- lib/nuggets/
|
60
|
-
- lib/nuggets/
|
61
|
-
- lib/nuggets/
|
62
|
-
- lib/nuggets/
|
63
|
-
- lib/nuggets/
|
64
|
-
- lib/nuggets/
|
65
|
-
- lib/nuggets/
|
66
|
-
- lib/nuggets/
|
67
|
-
- lib/nuggets/
|
68
|
-
- lib/nuggets/
|
69
|
-
- lib/nuggets/
|
70
|
-
- lib/nuggets/
|
71
|
-
- lib/nuggets/
|
72
|
-
- lib/nuggets/
|
73
|
-
- lib/nuggets/
|
74
|
-
- lib/nuggets/
|
75
|
-
- lib/nuggets/
|
76
|
-
- lib/nuggets/
|
77
|
-
- lib/nuggets/
|
78
|
-
- lib/nuggets/enumerable/minmax.rb
|
79
|
-
- lib/nuggets/enumerable/all_any_extended.rb
|
80
|
-
- lib/nuggets/hash/nest.rb
|
81
|
-
- lib/nuggets/hash/unroll.rb
|
82
|
-
- lib/nuggets/hash/in_order.rb
|
83
|
-
- lib/nuggets/hash/insert.rb
|
84
|
-
- lib/nuggets/hash/deep_merge_mixin.rb
|
85
|
-
- lib/nuggets/hash/unroll_mixin.rb
|
86
|
-
- lib/nuggets/hash/only.rb
|
87
|
-
- lib/nuggets/hash/deep_merge.rb
|
88
|
-
- lib/nuggets/hash/nest_mixin.rb
|
89
|
-
- lib/nuggets/hash/at.rb
|
60
|
+
- lib/nuggets/object/boolean_mixin.rb
|
61
|
+
- lib/nuggets/object/metaclass.rb
|
62
|
+
- lib/nuggets/object/msend_mixin.rb
|
63
|
+
- lib/nuggets/object/singleton_class_mixin.rb
|
64
|
+
- lib/nuggets/object/eigenclass.rb
|
65
|
+
- lib/nuggets/object/silence.rb
|
66
|
+
- lib/nuggets/object/blank_mixin.rb
|
67
|
+
- lib/nuggets/version.rb
|
68
|
+
- lib/nuggets/statistics_mixins.rb
|
69
|
+
- lib/nuggets/file/ext.rb
|
70
|
+
- lib/nuggets/file/replace_mixin.rb
|
71
|
+
- lib/nuggets/file/which_mixin.rb
|
72
|
+
- lib/nuggets/file/which.rb
|
73
|
+
- lib/nuggets/file/ext_mixin.rb
|
74
|
+
- lib/nuggets/file/replace.rb
|
75
|
+
- lib/nuggets/file/sub_mixin.rb
|
76
|
+
- lib/nuggets/file/sub.rb
|
77
|
+
- lib/nuggets/integer/map_mixin.rb
|
78
|
+
- lib/nuggets/integer/to_binary_s.rb
|
79
|
+
- lib/nuggets/integer/length_mixin.rb
|
80
|
+
- lib/nuggets/integer/length.rb
|
81
|
+
- lib/nuggets/integer/map.rb
|
82
|
+
- lib/nuggets/integer/factorial.rb
|
90
83
|
- lib/nuggets/tempfile/open.rb
|
91
|
-
- lib/nuggets/
|
92
|
-
- lib/nuggets/
|
93
|
-
- lib/nuggets/
|
94
|
-
- lib/nuggets/
|
95
|
-
- lib/nuggets/
|
96
|
-
- lib/nuggets/
|
97
|
-
- lib/nuggets/
|
98
|
-
- lib/nuggets/
|
99
|
-
- lib/nuggets/
|
100
|
-
- lib/nuggets/
|
101
|
-
- lib/nuggets/
|
102
|
-
- lib/nuggets/
|
103
|
-
- lib/nuggets/
|
104
|
-
- lib/nuggets/array/in_order.rb
|
105
|
-
- lib/nuggets/array/shuffle.rb
|
106
|
-
- lib/nuggets/array/monotone.rb
|
107
|
-
- lib/nuggets/array/histogram.rb
|
108
|
-
- lib/nuggets/array/median.rb
|
109
|
-
- lib/nuggets/array/variance.rb
|
84
|
+
- lib/nuggets/string/word_wrap.rb
|
85
|
+
- lib/nuggets/string/capitalize_first.rb
|
86
|
+
- lib/nuggets/string/wc.rb
|
87
|
+
- lib/nuggets/string/evaluate.rb
|
88
|
+
- lib/nuggets/string/msub.rb
|
89
|
+
- lib/nuggets/string/nsub.rb
|
90
|
+
- lib/nuggets/string/xor.rb
|
91
|
+
- lib/nuggets/string/wc_mixin.rb
|
92
|
+
- lib/nuggets/string/case.rb
|
93
|
+
- lib/nuggets/string/xor_mixin.rb
|
94
|
+
- lib/nuggets/string/evaluate_mixin.rb
|
95
|
+
- lib/nuggets/string/sub_with_md.rb
|
96
|
+
- lib/nuggets/all.rb
|
110
97
|
- lib/nuggets/array/correlation.rb
|
111
|
-
- lib/nuggets/array/
|
98
|
+
- lib/nuggets/array/shuffle.rb
|
112
99
|
- lib/nuggets/array/regression_mixin.rb
|
113
100
|
- lib/nuggets/array/limit.rb
|
114
|
-
- lib/nuggets/array/variance_mixin.rb
|
115
|
-
- lib/nuggets/array/only.rb
|
116
101
|
- lib/nuggets/array/runiq.rb
|
102
|
+
- lib/nuggets/array/variance.rb
|
103
|
+
- lib/nuggets/array/histogram.rb
|
104
|
+
- lib/nuggets/array/standard_deviation_mixin.rb
|
105
|
+
- lib/nuggets/array/median.rb
|
106
|
+
- lib/nuggets/array/to_hash.rb
|
107
|
+
- lib/nuggets/array/combination.rb
|
108
|
+
- lib/nuggets/array/monotone.rb
|
117
109
|
- lib/nuggets/array/mode.rb
|
118
|
-
- lib/nuggets/array/
|
110
|
+
- lib/nuggets/array/variance_mixin.rb
|
111
|
+
- lib/nuggets/array/rand.rb
|
112
|
+
- lib/nuggets/array/standard_deviation.rb
|
113
|
+
- lib/nuggets/array/correlation_mixin.rb
|
114
|
+
- lib/nuggets/array/only.rb
|
115
|
+
- lib/nuggets/array/mean_mixin.rb
|
119
116
|
- lib/nuggets/array/regression.rb
|
120
|
-
- lib/nuggets/array/runiq_mixin.rb
|
121
117
|
- lib/nuggets/array/mode_mixin.rb
|
122
|
-
- lib/nuggets/
|
123
|
-
- lib/nuggets/
|
124
|
-
- lib/nuggets/
|
125
|
-
- lib/nuggets/
|
126
|
-
- lib/nuggets/
|
127
|
-
- lib/nuggets/
|
128
|
-
- lib/nuggets/
|
129
|
-
- lib/nuggets/
|
130
|
-
- lib/nuggets/integer/to_binary_s.rb
|
131
|
-
- lib/nuggets/all_mixins.rb
|
132
|
-
- lib/nuggets/string/msub.rb
|
133
|
-
- lib/nuggets/string/evaluate.rb
|
134
|
-
- lib/nuggets/string/evaluate_mixin.rb
|
135
|
-
- lib/nuggets/string/nsub.rb
|
136
|
-
- lib/nuggets/string/xor_mixin.rb
|
137
|
-
- lib/nuggets/string/wc.rb
|
138
|
-
- lib/nuggets/string/sub_with_md.rb
|
139
|
-
- lib/nuggets/string/wc_mixin.rb
|
140
|
-
- lib/nuggets/string/case.rb
|
141
|
-
- lib/nuggets/string/word_wrap.rb
|
142
|
-
- lib/nuggets/string/xor.rb
|
143
|
-
- lib/nuggets/string/capitalize_first.rb
|
144
|
-
- lib/nuggets/numeric/to_multiple.rb
|
145
|
-
- lib/nuggets/numeric/signum.rb
|
146
|
-
- lib/nuggets/numeric/between.rb
|
118
|
+
- lib/nuggets/array/limit_mixin.rb
|
119
|
+
- lib/nuggets/array/flatten_once.rb
|
120
|
+
- lib/nuggets/array/in_order.rb
|
121
|
+
- lib/nuggets/array/mean.rb
|
122
|
+
- lib/nuggets/array/median_mixin.rb
|
123
|
+
- lib/nuggets/array/histogram_mixin.rb
|
124
|
+
- lib/nuggets/array/format.rb
|
125
|
+
- lib/nuggets/array/runiq_mixin.rb
|
147
126
|
- lib/nuggets/numeric/limit.rb
|
127
|
+
- lib/nuggets/numeric/between.rb
|
148
128
|
- lib/nuggets/numeric/duration.rb
|
149
|
-
- lib/nuggets.rb
|
150
|
-
-
|
129
|
+
- lib/nuggets/numeric/to_multiple.rb
|
130
|
+
- lib/nuggets/numeric/signum.rb
|
131
|
+
- lib/nuggets/all_mixins.rb
|
132
|
+
- lib/nuggets/util/ansicolor2css.rb
|
133
|
+
- lib/nuggets/util/content_type.rb
|
134
|
+
- lib/nuggets/util/dotted_decimal.rb
|
135
|
+
- lib/nuggets/util/ruby.rb
|
136
|
+
- lib/nuggets/util/added_methods.rb
|
137
|
+
- lib/nuggets/util/cli.rb
|
138
|
+
- lib/nuggets/util/i18n.rb
|
139
|
+
- lib/nuggets/util/added_methods/init.rb
|
140
|
+
- lib/nuggets/util/pluggable.rb
|
141
|
+
- lib/nuggets/proc/bind_mixin.rb
|
142
|
+
- lib/nuggets/proc/bind.rb
|
143
|
+
- lib/nuggets/statistics.rb
|
144
|
+
- lib/nuggets/io/redirect_mixin.rb
|
145
|
+
- lib/nuggets/io/modes.rb
|
146
|
+
- lib/nuggets/io/interact.rb
|
147
|
+
- lib/nuggets/io/redirect.rb
|
148
|
+
- lib/nuggets/io/null_mixin.rb
|
149
|
+
- lib/nuggets/io/null.rb
|
150
|
+
- lib/nuggets/io/agrep.rb
|
151
|
+
- lib/nuggets/io/interact_mixin.rb
|
152
|
+
- lib/nuggets/uri/content_type.rb
|
153
|
+
- lib/nuggets/uri/redirect_mixin.rb
|
154
|
+
- lib/nuggets/uri/redirect.rb
|
155
|
+
- lib/nuggets/uri/exist_mixin.rb
|
156
|
+
- lib/nuggets/uri/content_type_mixin.rb
|
157
|
+
- lib/nuggets/uri/exist.rb
|
158
|
+
- lib/nuggets/enumerable/all_any_extended.rb
|
159
|
+
- lib/nuggets/enumerable/minmax.rb
|
160
|
+
- lib/nuggets/enumerable/agrep.rb
|
151
161
|
- ChangeLog
|
152
162
|
- COPYING
|
163
|
+
- README
|
153
164
|
- Rakefile
|
154
|
-
- spec/nuggets/
|
155
|
-
- spec/nuggets/
|
156
|
-
- spec/nuggets/
|
157
|
-
- spec/nuggets/
|
165
|
+
- spec/nuggets/range/quantile_spec.rb
|
166
|
+
- spec/nuggets/hash/nest_spec.rb
|
167
|
+
- spec/nuggets/hash/unroll_spec.rb
|
168
|
+
- spec/nuggets/hash/deep_merge_spec.rb
|
169
|
+
- spec/nuggets/env/set_spec.rb
|
158
170
|
- spec/nuggets/env/user_home_spec.rb
|
159
171
|
- spec/nuggets/env/user_encoding_spec.rb
|
160
|
-
- spec/nuggets/env/set_spec.rb
|
161
172
|
- spec/nuggets/object/silence_spec.rb
|
162
|
-
- spec/nuggets/object/msend_spec.rb
|
163
173
|
- spec/nuggets/object/singleton_class_spec.rb
|
164
|
-
- spec/nuggets/object/
|
174
|
+
- spec/nuggets/object/msend_spec.rb
|
165
175
|
- spec/nuggets/object/blank_spec.rb
|
166
|
-
- spec/nuggets/
|
167
|
-
- spec/nuggets/
|
168
|
-
- spec/nuggets/
|
169
|
-
- spec/nuggets/
|
170
|
-
- spec/nuggets/
|
171
|
-
- spec/nuggets/
|
176
|
+
- spec/nuggets/object/boolean_spec.rb
|
177
|
+
- spec/nuggets/file/ext_spec.rb
|
178
|
+
- spec/nuggets/file/sub_spec.rb
|
179
|
+
- spec/nuggets/file/replace_spec.rb
|
180
|
+
- spec/nuggets/file/which_spec.rb
|
181
|
+
- spec/nuggets/integer/map_spec.rb
|
182
|
+
- spec/nuggets/integer/length_spec.rb
|
183
|
+
- spec/nuggets/string/evaluate_spec.rb
|
184
|
+
- spec/nuggets/string/xor_spec.rb
|
185
|
+
- spec/nuggets/string/wc_spec.rb
|
186
|
+
- spec/nuggets/array/regression_spec.rb
|
187
|
+
- spec/nuggets/array/limit_spec.rb
|
172
188
|
- spec/nuggets/array/correlation_spec.rb
|
189
|
+
- spec/nuggets/array/standard_deviation_spec.rb
|
173
190
|
- spec/nuggets/array/mode_spec.rb
|
174
|
-
- spec/nuggets/array/mean_spec.rb
|
175
191
|
- spec/nuggets/array/histogram_spec.rb
|
176
|
-
- spec/nuggets/array/variance_spec.rb
|
177
|
-
- spec/nuggets/array/limit_spec.rb
|
178
|
-
- spec/nuggets/array/regression_spec.rb
|
179
|
-
- spec/nuggets/array/standard_deviation_spec.rb
|
180
192
|
- spec/nuggets/array/median_spec.rb
|
193
|
+
- spec/nuggets/array/mean_spec.rb
|
194
|
+
- spec/nuggets/array/variance_spec.rb
|
181
195
|
- spec/nuggets/array/runiq_spec.rb
|
182
|
-
- spec/nuggets/
|
183
|
-
- spec/nuggets/
|
184
|
-
- spec/nuggets/
|
185
|
-
- spec/nuggets/string/wc_spec.rb
|
186
|
-
- spec/nuggets/string/evaluate_spec.rb
|
187
|
-
- spec/nuggets/string/xor_spec.rb
|
196
|
+
- spec/nuggets/proc/bind_spec.rb
|
197
|
+
- spec/nuggets/uri/content_type_spec.rb
|
198
|
+
- spec/nuggets/uri/exist_spec.rb
|
188
199
|
- spec/spec_helper.rb
|
189
200
|
- .rspec
|
190
|
-
homepage: http://prometheus.rubyforge.org/
|
201
|
+
homepage: http://prometheus.rubyforge.org/ruby-nuggets
|
191
202
|
licenses: []
|
203
|
+
|
192
204
|
post_install_message:
|
193
|
-
rdoc_options:
|
205
|
+
rdoc_options:
|
206
|
+
- --main
|
207
|
+
- README
|
208
|
+
- --all
|
194
209
|
- --charset
|
195
210
|
- UTF-8
|
196
|
-
- --line-numbers
|
197
|
-
- --all
|
198
211
|
- --title
|
199
|
-
- ruby-nuggets Application documentation (v0.8.
|
200
|
-
- --
|
201
|
-
|
202
|
-
require_paths:
|
212
|
+
- ruby-nuggets Application documentation (v0.8.4)
|
213
|
+
- --line-numbers
|
214
|
+
require_paths:
|
203
215
|
- lib
|
204
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
216
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
205
217
|
none: false
|
206
|
-
requirements:
|
207
|
-
- -
|
208
|
-
- !ruby/object:Gem::Version
|
209
|
-
|
210
|
-
|
218
|
+
requirements:
|
219
|
+
- - ">="
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
hash: 3
|
222
|
+
segments:
|
223
|
+
- 0
|
224
|
+
version: "0"
|
225
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
211
226
|
none: false
|
212
|
-
requirements:
|
213
|
-
- -
|
214
|
-
- !ruby/object:Gem::Version
|
215
|
-
|
227
|
+
requirements:
|
228
|
+
- - ">="
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
hash: 3
|
231
|
+
segments:
|
232
|
+
- 0
|
233
|
+
version: "0"
|
216
234
|
requirements: []
|
235
|
+
|
217
236
|
rubyforge_project: prometheus
|
218
237
|
rubygems_version: 1.8.15
|
219
238
|
signing_key:
|
220
239
|
specification_version: 3
|
221
240
|
summary: Some extensions to the Ruby programming language.
|
222
241
|
test_files: []
|
242
|
+
|