obfusk-util 0.0.1.SNAPSHOT.20130725000153 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +132 -39
- data/Rakefile +16 -0
- data/lib/obfusk/util/all.rb +4 -3
- data/lib/obfusk/util/cmd.rb +3 -3
- data/lib/obfusk/util/data.rb +4 -4
- data/lib/obfusk/util/die.rb +3 -3
- data/lib/obfusk/util/fs.rb +3 -3
- data/lib/obfusk/util/message.rb +6 -12
- data/lib/obfusk/util/misc.rb +3 -3
- data/lib/obfusk/util/module.rb +11 -3
- data/lib/obfusk/util/opt.rb +3 -3
- data/lib/obfusk/util/os.rb +3 -3
- data/lib/obfusk/util/process.rb +3 -3
- data/lib/obfusk/util/run.rb +102 -9
- data/lib/obfusk/util/sh.rb +102 -0
- data/lib/obfusk/util/spec.rb +3 -3
- data/lib/obfusk/util/struct.rb +5 -4
- data/lib/obfusk/util/term.rb +3 -3
- data/lib/obfusk/util/valid.rb +4 -4
- data/lib/obfusk/util/version.rb +2 -2
- data/obfusk-util.gemspec +1 -3
- data/spec/obfusk/util/cmd_spec.rb +3 -3
- data/spec/obfusk/util/data_spec.rb +3 -3
- data/spec/obfusk/util/die_spec.rb +3 -3
- data/spec/obfusk/util/fs_spec.rb +3 -3
- data/spec/obfusk/util/message_spec.rb +3 -3
- data/spec/obfusk/util/module_spec.rb +19 -3
- data/spec/obfusk/util/opt_spec.rb +3 -3
- data/spec/obfusk/util/os_spec.rb +4 -4
- data/spec/obfusk/util/process_spec.rb +4 -4
- data/spec/obfusk/util/run_spec.rb +164 -8
- data/spec/obfusk/util/sh_spec.rb +125 -0
- data/spec/obfusk/util/spec_spec.rb +3 -3
- data/spec/obfusk/util/struct_spec.rb +3 -3
- data/spec/obfusk/util/term_spec.rb +3 -3
- data/spec/obfusk/util/valid_spec.rb +3 -3
- metadata +48 -46
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8adf3c9ae768f80d1e557b744a4dea1245efcce0
|
4
|
+
data.tar.gz: e31cde1403fc3bbd9997a80468b531cf901b404f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53faf1797b5f2be9f729ecb4b7f9f6386e0a050e1ce5872aa5cbec3861fea5cec19c60390631b12ed2c0d3573bc15a370cb787e4a7ef93c39417e8d1faa6d908
|
7
|
+
data.tar.gz: cf380054eca3d5717dd75db728b5164e22413f5af8a64327045c70770091a58646b374e9496e7aeda4b9d8ceef9899d9bb371840b0f7c687d1b3070715172f34
|
data/README.md
CHANGED
@@ -2,28 +2,33 @@
|
|
2
2
|
|
3
3
|
File : README.md
|
4
4
|
Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
Date :
|
5
|
+
Date : 2014-02-19
|
6
6
|
|
7
|
-
Copyright : Copyright (C)
|
8
|
-
Version : v0.
|
7
|
+
Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
|
+
Version : v0.4.2
|
9
9
|
|
10
10
|
[]: }}}1
|
11
11
|
|
12
|
+
[![Gem Version](https://badge.fury.io/rb/obfusk-util.png)](http://badge.fury.io/rb/obfusk-util)
|
13
|
+
|
12
14
|
## Description
|
13
|
-
[]: {{{1
|
14
15
|
|
15
16
|
[rb-]obfusk-util - miscellaneous utility library for ruby
|
16
17
|
|
17
|
-
...
|
18
|
-
|
19
|
-
[]: }}}1
|
20
|
-
|
21
18
|
## Examples
|
22
19
|
[]: {{{1
|
23
20
|
|
21
|
+
```ruby
|
22
|
+
require 'obfusk/util/all'
|
23
|
+
```
|
24
|
+
|
25
|
+
---
|
26
|
+
|
24
27
|
[]: {{{2
|
25
28
|
|
26
29
|
```ruby
|
30
|
+
require 'obfusk/util/cmd'
|
31
|
+
|
27
32
|
Obfusk::Util::Cmd.killsig 'SIGINT foo bar'
|
28
33
|
# => { command: 'foo bar', signal: 'SIGINT' }
|
29
34
|
|
@@ -40,9 +45,13 @@ Obfusk::Util::Cmd.set_vars 'echo ${FOO} ... ${BAR} ...',
|
|
40
45
|
|
41
46
|
[]: }}}2
|
42
47
|
|
48
|
+
---
|
49
|
+
|
43
50
|
[]: {{{2
|
44
51
|
|
45
52
|
```ruby
|
53
|
+
require 'obfusk/util/data'
|
54
|
+
|
46
55
|
x = { x: { y: 0 }, z: [1,2,3] }
|
47
56
|
Obfusk::Util.assoc(x, [:x,:y] => 1, [:z,1] => 99)
|
48
57
|
x[:x][:y] == 1 # => true
|
@@ -54,19 +63,27 @@ Obfusk::Util.empty_as_nil(ENV['FOO']) || default
|
|
54
63
|
|
55
64
|
[]: }}}2
|
56
65
|
|
66
|
+
---
|
67
|
+
|
57
68
|
[]: {{{2
|
58
69
|
|
59
70
|
```ruby
|
60
|
-
|
71
|
+
require 'obfusk/util/fs'
|
72
|
+
|
73
|
+
Obfusk::Util::FS.append('file', *lines)
|
61
74
|
Obfusk::Util::FS.exists? 'file-or-possibly-broken-symlink'
|
62
75
|
```
|
63
76
|
|
64
77
|
[]: }}}2
|
65
78
|
|
79
|
+
---
|
80
|
+
|
66
81
|
[]: {{{2
|
67
82
|
|
68
83
|
```ruby
|
69
|
-
|
84
|
+
require 'obfusk/util/message'
|
85
|
+
|
86
|
+
Obfusk::Util.ohai(*%w{ rackup -p 8888 })
|
70
87
|
# shows '==> rackup -p 8888' in colour
|
71
88
|
|
72
89
|
Obfusk::Util.onow 'Starting', 'foo', 'bar'
|
@@ -76,14 +93,25 @@ Obfusk::Util.onoe 'Something is wrong!' # error in colour
|
|
76
93
|
Obfusk::Util.opoo 'This looks funny!' # warning in colour
|
77
94
|
```
|
78
95
|
|
79
|
-
There are some o
|
80
|
-
operation with e.g. ohai
|
96
|
+
There are some `o*` methods all over `obfusk-util` that combine some
|
97
|
+
operation with e.g. `ohai`.
|
81
98
|
|
82
99
|
[]: }}}2
|
83
100
|
|
101
|
+
---
|
102
|
+
|
84
103
|
[]: {{{2
|
85
104
|
|
86
105
|
```ruby
|
106
|
+
require 'obfusk/util/module'
|
107
|
+
|
108
|
+
module Foo; def self.foo; 42; end; end
|
109
|
+
module Bar
|
110
|
+
# alias Foo.foo as Bar.foo and Bar.bar
|
111
|
+
Obfusk::Util.link_mod_method Foo, :foo, self
|
112
|
+
Obfusk::Util.link_mod_method Foo, :foo, self, :bar
|
113
|
+
end
|
114
|
+
|
87
115
|
Obfusk::Util.require_all 'foo/bar'
|
88
116
|
# requires foo/bar/*
|
89
117
|
|
@@ -93,20 +121,28 @@ Obfusk::Util.submodules Foo
|
|
93
121
|
|
94
122
|
[]: }}}2
|
95
123
|
|
124
|
+
---
|
125
|
+
|
96
126
|
[]: {{{2
|
97
127
|
|
98
|
-
Slightly improved OptionParser (w/o officious options):
|
128
|
+
Slightly improved `OptionParser` (w/o officious options):
|
99
129
|
|
100
130
|
```ruby
|
131
|
+
require 'obfusk/util/opt'
|
132
|
+
|
101
133
|
p = Obfusk::Util::Opt::Parser.new # ...
|
102
134
|
remaining_args = p.parse_r ARGV
|
103
135
|
```
|
104
136
|
|
105
137
|
[]: }}}2
|
106
138
|
|
139
|
+
---
|
140
|
+
|
107
141
|
[]: {{{2
|
108
142
|
|
109
143
|
```ruby
|
144
|
+
require 'obfusk/util/os'
|
145
|
+
|
110
146
|
Obfusk::Util::OS.home # => current user's home
|
111
147
|
Obfusk::Util::OS.home 'user' # => user's home
|
112
148
|
Obfusk::Util::OS.user # => current user
|
@@ -115,38 +151,97 @@ Obfusk::Util::OS.now # => current time as '%F %T'
|
|
115
151
|
|
116
152
|
[]: }}}2
|
117
153
|
|
154
|
+
---
|
155
|
+
|
118
156
|
[]: {{{2
|
119
157
|
|
120
158
|
```ruby
|
159
|
+
require 'obfusk/util/process'
|
160
|
+
|
121
161
|
Obfusk::Util::Process.age pid # => e.g. '01:06:19'
|
122
162
|
Obfusk::Util::Process.alive? pid # => false/true/:not_mine
|
123
163
|
```
|
124
164
|
|
125
165
|
[]: }}}2
|
126
166
|
|
167
|
+
---
|
168
|
+
|
127
169
|
[]: {{{2
|
128
170
|
|
129
|
-
spawn_w is spawn + wait (which is nicer than system). No
|
130
|
-
ever used; env is an option instead of an optional first
|
131
|
-
ENOENT becomes RunError
|
171
|
+
`spawn_w` is `spawn` + `wait` (which is nicer than `system`). No
|
172
|
+
shell is ever used; `env` is an option instead of an optional first
|
173
|
+
argument; `ENOENT` becomes `RunError`. See also: `exec`, `spawn`,
|
174
|
+
`system`, `capture{2,2e,3}`, `pipeline{,_r,_rw,_start,_w}`,
|
175
|
+
`popen{2,2e,3}`.
|
132
176
|
|
133
177
|
```ruby
|
134
|
-
|
135
|
-
|
178
|
+
require 'obfusk/util/run'
|
179
|
+
|
180
|
+
Obfusk::Util.spawn_w(*%w{ some command }, env: { 'FOO' => 'bar' },
|
181
|
+
chdir: 'some/dir') #, ...
|
136
182
|
# => $?
|
137
183
|
|
138
184
|
# raise RunError if command returned non-zero
|
139
185
|
Obfusk::Util.chk_exit(%w{ some command }) do |a|
|
140
186
|
# spawn + wait + ohai
|
141
|
-
Obfusk::Util.ospawn_w
|
187
|
+
Obfusk::Util.ospawn_w(*a)
|
142
188
|
end
|
143
189
|
```
|
144
190
|
|
145
191
|
[]: }}}2
|
146
192
|
|
193
|
+
---
|
194
|
+
|
147
195
|
[]: {{{2
|
148
196
|
|
149
197
|
```ruby
|
198
|
+
require 'obfusk/util/sh'
|
199
|
+
|
200
|
+
sh('echo "$0" ">>$1<<" ">>$FOO<<"', '"one"', 'FOO' => 'foo').stdout
|
201
|
+
# => %Q{bash >>"one"<< >>foo<<}
|
202
|
+
|
203
|
+
sh('echo step1; false; echo step3',
|
204
|
+
print: true, exit: true, merge: true).stdout
|
205
|
+
# => "+ echo step1\nstep1\n+ false\n"
|
206
|
+
|
207
|
+
sh? 'false'
|
208
|
+
# => false
|
209
|
+
|
210
|
+
sh! 'false'
|
211
|
+
# => RunError
|
212
|
+
```
|
213
|
+
|
214
|
+
[]: }}}2
|
215
|
+
|
216
|
+
---
|
217
|
+
|
218
|
+
[]: {{{2
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
require 'obfusk/util/spec'
|
222
|
+
|
223
|
+
Obfusk::Util.provide_stdin(input) do
|
224
|
+
# do something with $stdin
|
225
|
+
end
|
226
|
+
|
227
|
+
output = Obfusk::Util.capture_stdout do
|
228
|
+
# do something with $stdout
|
229
|
+
end
|
230
|
+
|
231
|
+
output = Obfusk::Util.capture_stderr(:tty) do
|
232
|
+
# do something with $stderr; $stderr.isatty => true
|
233
|
+
end
|
234
|
+
```
|
235
|
+
|
236
|
+
[]: }}}2
|
237
|
+
|
238
|
+
---
|
239
|
+
|
240
|
+
[]: {{{2
|
241
|
+
|
242
|
+
```ruby
|
243
|
+
require 'obfusk/util/struct'
|
244
|
+
|
150
245
|
Foo = Obfusk::Util.struct(*%w{ field1 field2 field3 }) do
|
151
246
|
def some_method; field1 + field2; end
|
152
247
|
end
|
@@ -166,9 +261,13 @@ bar.check! # => IncompleteError b/c there are empty fields
|
|
166
261
|
|
167
262
|
[]: }}}2
|
168
263
|
|
264
|
+
---
|
265
|
+
|
169
266
|
[]: {{{2
|
170
267
|
|
171
268
|
```ruby
|
269
|
+
require 'obfusk/util/term'
|
270
|
+
|
172
271
|
Obfusk::Util::Term.colour :red
|
173
272
|
# => ansi escape code if $stdout is a tty, '' otherwise
|
174
273
|
|
@@ -183,9 +282,13 @@ Obfusk::Util::Term.prompt 'foo> ', :hide # prompt for password
|
|
183
282
|
|
184
283
|
[]: }}}2
|
185
284
|
|
285
|
+
---
|
286
|
+
|
186
287
|
[]: {{{2
|
187
288
|
|
188
289
|
```ruby
|
290
|
+
require 'obfusk/util/valid'
|
291
|
+
|
189
292
|
def foo(*args_)
|
190
293
|
Obfusk::Util::Valid.args 'description', args_, 1, 3
|
191
294
|
# => ArgumentError if #args not in 1..3
|
@@ -197,36 +300,26 @@ end
|
|
197
300
|
[]: }}}1
|
198
301
|
|
199
302
|
## Specs & Docs
|
200
|
-
[]: {{{1
|
201
|
-
|
202
|
-
$ rake spec
|
203
|
-
$ rake docs
|
204
303
|
|
205
|
-
|
304
|
+
```bash
|
305
|
+
$ rake spec
|
306
|
+
$ rake docs
|
307
|
+
```
|
206
308
|
|
207
309
|
## TODO
|
208
|
-
[]: {{{1
|
209
310
|
|
210
|
-
*
|
211
|
-
*
|
212
|
-
*
|
311
|
+
* improve sh w/ fp (pipe, lines, json, blocks)?
|
312
|
+
* more specs/docs?
|
313
|
+
* split into several gems?
|
213
314
|
* ...
|
214
315
|
|
215
|
-
[]: }}}1
|
216
|
-
|
217
316
|
## License
|
218
|
-
[]: {{{1
|
219
317
|
|
220
|
-
|
221
|
-
|
222
|
-
[]: }}}1
|
318
|
+
LGPLv3+ [1].
|
223
319
|
|
224
320
|
## References
|
225
|
-
[]: {{{1
|
226
321
|
|
227
|
-
[1] GNU General Public License, version
|
228
|
-
--- http://www.
|
229
|
-
|
230
|
-
[]: }}}1
|
322
|
+
[1] GNU Lesser General Public License, version 3
|
323
|
+
--- http://www.gnu.org/licenses/lgpl-3.0.html
|
231
324
|
|
232
325
|
[]: ! ( vim: set tw=70 sw=2 sts=2 et fdm=marker : )
|
data/Rakefile
CHANGED
@@ -13,6 +13,22 @@ task 'spec:less' do
|
|
13
13
|
sh 'rspec -cfd --tty | less -R'
|
14
14
|
end
|
15
15
|
|
16
|
+
desc 'Check for warnings'
|
17
|
+
task :warn do
|
18
|
+
sh 'ruby -w -I lib -r obfusk/util/all -e ""'
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Check for warnings in specs'
|
22
|
+
task 'warn:spec' do
|
23
|
+
reqs = Dir['spec/**/*.rb'].sort.map { |x| "-r ./#{x}" } * ' '
|
24
|
+
sh "ruby -w -I lib -r rspec #{reqs} -e ''"
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Check for warnings in specs (but not void context)'
|
28
|
+
task 'warn:spec:novoid' do
|
29
|
+
sh 'rake warn:spec 2>&1 | grep -v "void context"'
|
30
|
+
end
|
31
|
+
|
16
32
|
desc 'Generate docs'
|
17
33
|
task :docs do
|
18
34
|
sh 'yardoc | cat'
|
data/lib/obfusk/util/all.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
#
|
3
3
|
# File : obfusk/util/all.rb
|
4
4
|
# Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
# Date :
|
5
|
+
# Date : 2014-02-19
|
6
6
|
#
|
7
|
-
# Copyright : Copyright (C)
|
8
|
-
# Licence :
|
7
|
+
# Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
|
+
# Licence : LGPLv3+
|
9
9
|
#
|
10
10
|
# -- ; }}}1
|
11
11
|
|
@@ -20,6 +20,7 @@ require 'obfusk/util/opt'
|
|
20
20
|
require 'obfusk/util/os'
|
21
21
|
require 'obfusk/util/process'
|
22
22
|
require 'obfusk/util/run'
|
23
|
+
require 'obfusk/util/sh'
|
23
24
|
require 'obfusk/util/spec'
|
24
25
|
require 'obfusk/util/struct'
|
25
26
|
require 'obfusk/util/term'
|
data/lib/obfusk/util/cmd.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
#
|
3
3
|
# File : obfusk/util/cmd.rb
|
4
4
|
# Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
# Date :
|
5
|
+
# Date : 2014-02-19
|
6
6
|
#
|
7
|
-
# Copyright : Copyright (C)
|
8
|
-
# Licence :
|
7
|
+
# Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
|
+
# Licence : LGPLv3+
|
9
9
|
#
|
10
10
|
# -- ; }}}1
|
11
11
|
|
data/lib/obfusk/util/data.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
#
|
3
3
|
# File : obfusk/util/data.rb
|
4
4
|
# Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
# Date :
|
5
|
+
# Date : 2014-02-19
|
6
6
|
#
|
7
|
-
# Copyright : Copyright (C)
|
8
|
-
# Licence :
|
7
|
+
# Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
|
+
# Licence : LGPLv3+
|
9
9
|
#
|
10
10
|
# -- ; }}}1
|
11
11
|
|
@@ -24,7 +24,7 @@ module Obfusk; module Util
|
|
24
24
|
case k.length
|
25
25
|
when 0; raise ArgumentError, 'empty array key'
|
26
26
|
when 1; x[k.first] = v
|
27
|
-
else h, *t = k; assoc
|
27
|
+
else h, *t = k; assoc(x[h] ||= {}, t => v)
|
28
28
|
end
|
29
29
|
else
|
30
30
|
x[k] = v
|
data/lib/obfusk/util/die.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
#
|
3
3
|
# File : obfusk/util/die.rb
|
4
4
|
# Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
# Date :
|
5
|
+
# Date : 2014-02-19
|
6
6
|
#
|
7
|
-
# Copyright : Copyright (C)
|
8
|
-
# Licence :
|
7
|
+
# Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
|
+
# Licence : LGPLv3+
|
9
9
|
#
|
10
10
|
# -- ; }}}1
|
11
11
|
|
data/lib/obfusk/util/fs.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
#
|
3
3
|
# File : obfusk/util/fs.rb
|
4
4
|
# Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
# Date :
|
5
|
+
# Date : 2014-02-19
|
6
6
|
#
|
7
|
-
# Copyright : Copyright (C)
|
8
|
-
# Licence :
|
7
|
+
# Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
|
+
# Licence : LGPLv3+
|
9
9
|
#
|
10
10
|
# -- ; }}}1
|
11
11
|
|
data/lib/obfusk/util/message.rb
CHANGED
@@ -2,13 +2,14 @@
|
|
2
2
|
#
|
3
3
|
# File : obfusk/util/message.rb
|
4
4
|
# Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
# Date :
|
5
|
+
# Date : 2014-02-19
|
6
6
|
#
|
7
|
-
# Copyright : Copyright (C)
|
8
|
-
# Licence :
|
7
|
+
# Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
|
+
# Licence : LGPLv3+
|
9
9
|
#
|
10
10
|
# -- ; }}}1
|
11
11
|
|
12
|
+
require 'obfusk/util/module'
|
12
13
|
require 'obfusk/util/term'
|
13
14
|
|
14
15
|
# my namespace
|
@@ -58,15 +59,8 @@ module Obfusk; module Util
|
|
58
59
|
': ' + what.map { |x| _tcol(:lgn) + x + _tcol(:non) } *', '
|
59
60
|
end
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
Term.colour *a
|
64
|
-
end
|
65
|
-
|
66
|
-
# Term.colour_e
|
67
|
-
def self._tcole(*a)
|
68
|
-
Term.colour_e *a
|
69
|
-
end
|
62
|
+
link_mod_method Term, :colour , self, :_tcol
|
63
|
+
link_mod_method Term, :colour_e, self, :_tcole
|
70
64
|
|
71
65
|
end; end
|
72
66
|
|
data/lib/obfusk/util/misc.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
#
|
3
3
|
# File : obfusk/util/misc.rb
|
4
4
|
# Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
# Date :
|
5
|
+
# Date : 2014-02-19
|
6
6
|
#
|
7
|
-
# Copyright : Copyright (C)
|
8
|
-
# Licence :
|
7
|
+
# Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
|
+
# Licence : LGPLv3+
|
9
9
|
#
|
10
10
|
# -- ; }}}1
|
11
11
|
|
data/lib/obfusk/util/module.rb
CHANGED
@@ -2,16 +2,24 @@
|
|
2
2
|
#
|
3
3
|
# File : obfusk/util/module.rb
|
4
4
|
# Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
# Date :
|
5
|
+
# Date : 2014-02-19
|
6
6
|
#
|
7
|
-
# Copyright : Copyright (C)
|
8
|
-
# Licence :
|
7
|
+
# Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
|
+
# Licence : LGPLv3+
|
9
9
|
#
|
10
10
|
# -- ; }}}1
|
11
11
|
|
12
12
|
# my namespace
|
13
13
|
module Obfusk; module Util
|
14
14
|
|
15
|
+
# create module method to.to_meth that calls from.from_meth
|
16
|
+
def self.link_mod_method(from, from_meth, to, to_meth = from_meth)
|
17
|
+
to.module_exec(from, from_meth, to_meth) do |f,fm,tm|
|
18
|
+
(class << self; self; end).send(:define_method, tm) \
|
19
|
+
{ |*a,&b| f.send(fm, *a, &b) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
15
23
|
# load `dir/*` (by searching for `dir/*.rb` in `$LOAD_PATH`)
|
16
24
|
#
|
17
25
|
# ```
|
data/lib/obfusk/util/opt.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
#
|
3
3
|
# File : obfusk/util/opt.rb
|
4
4
|
# Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
# Date :
|
5
|
+
# Date : 2014-02-19
|
6
6
|
#
|
7
|
-
# Copyright : Copyright (C)
|
8
|
-
# Licence :
|
7
|
+
# Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
|
+
# Licence : LGPLv3+
|
9
9
|
#
|
10
10
|
# -- ; }}}1
|
11
11
|
|
data/lib/obfusk/util/os.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
#
|
3
3
|
# File : obfusk/util/os.rb
|
4
4
|
# Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
# Date :
|
5
|
+
# Date : 2014-02-19
|
6
6
|
#
|
7
|
-
# Copyright : Copyright (C)
|
8
|
-
# Licence :
|
7
|
+
# Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
|
+
# Licence : LGPLv3+
|
9
9
|
#
|
10
10
|
# -- ; }}}1
|
11
11
|
|
data/lib/obfusk/util/process.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
#
|
3
3
|
# File : obfusk/util/process.rb
|
4
4
|
# Maintainer : Felix C. Stegerman <flx@obfusk.net>
|
5
|
-
# Date :
|
5
|
+
# Date : 2014-02-19
|
6
6
|
#
|
7
|
-
# Copyright : Copyright (C)
|
8
|
-
# Licence :
|
7
|
+
# Copyright : Copyright (C) 2014 Felix C. Stegerman
|
8
|
+
# Licence : LGPLv3+
|
9
9
|
#
|
10
10
|
# -- ; }}}1
|
11
11
|
|