facets 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.rdoc +331 -35
- data/MANIFEST +685 -826
- data/{doc/guide/notes.rd → NOTES} +0 -0
- data/README.rdoc +73 -25
- data/Rakefile +245 -2
- data/TODO +5 -0
- data/demo/hook.rd +47 -0
- data/demo/scenario_require.rd +9 -0
- data/doc/README.more +24 -6
- data/doc/manual/about.rb +47 -0
- data/doc/manual/annotations.rdoc +60 -0
- data/doc/manual/associations.rdoc +55 -0
- data/doc/manual/blockups.rdoc +101 -0
- data/doc/manual/capsule.rdoc +34 -0
- data/doc/manual/command.rdoc +177 -0
- data/doc/manual/core.rdoc +37 -0
- data/doc/manual/faq.rdoc +32 -0
- data/doc/manual/typecast.html +112 -0
- data/lib/core/facets.rb +359 -11
- data/lib/core/facets/array/combination.rb +3 -3
- data/lib/core/facets/array/index.rb +4 -1
- data/lib/core/facets/array/permutation.rb +2 -2
- data/lib/core/facets/array/product.rb +1 -1
- data/lib/core/facets/binding/eval.rb +1 -1
- data/lib/core/facets/denumerable.rb +76 -0
- data/lib/core/facets/duplicable.rb +34 -0
- data/lib/core/facets/enumerable/count.rb +10 -4
- data/lib/core/facets/enumerable/defer.rb +77 -0
- data/lib/core/facets/enumerable/each_by.rb +1 -1
- data/lib/core/facets/enumerable/every.rb +35 -0
- data/lib/{more/facets/elementwise.rb → core/facets/enumerable/ewise.rb} +0 -0
- data/lib/core/facets/enumerable/filter.rb +25 -0
- data/lib/core/facets/enumerable/group_by.rb +1 -1
- data/lib/core/facets/enumerable/none.rb +3 -2
- data/lib/core/facets/enumerable/one.rb +3 -2
- data/lib/core/facets/enumerable/per.rb +61 -0
- data/lib/core/facets/exception/raised.rb +14 -0
- data/lib/core/facets/integer/odd.rb +5 -1
- data/lib/core/facets/kernel/__dir__.rb +13 -3
- data/lib/core/facets/kernel/__here__.rb +14 -0
- data/lib/core/facets/kernel/__method__.rb +9 -3
- data/lib/core/facets/kernel/ask.rb +1 -0
- data/lib/core/facets/kernel/equate.rb +13 -0
- data/lib/core/facets/kernel/extension.rb +9 -0
- data/lib/core/facets/kernel/identical.rb +4 -0
- data/lib/core/facets/kernel/instance_exec.rb +2 -1
- data/lib/core/facets/kernel/method.rb +49 -0
- data/lib/core/facets/kernel/object_send.rb +2 -2
- data/lib/core/facets/kernel/{state.rb → object_state.rb} +23 -12
- data/lib/core/facets/kernel/require_all.rb +6 -1
- data/lib/core/facets/kernel/require_local.rb +8 -1
- data/lib/core/facets/kernel/require_relative.rb +52 -0
- data/lib/core/facets/kernel/source_location.rb +13 -0
- data/lib/core/facets/kernel/tap.rb +13 -6
- data/lib/core/facets/module/attr_setter.rb +57 -0
- data/lib/core/facets/module/instance_method.rb +24 -0
- data/lib/core/facets/module/module_load.rb +60 -44
- data/lib/core/facets/module/module_require.rb +1 -0
- data/lib/core/facets/nilclass/to_f.rb +1 -1
- data/lib/core/facets/objectspace/op_fetch.rb +3 -0
- data/lib/core/facets/proc/curry.rb +4 -3
- data/lib/core/facets/string/bytes.rb +10 -4
- data/lib/core/facets/string/camelcase.rb +6 -5
- data/lib/core/facets/string/chars.rb +5 -1
- data/lib/core/facets/string/each_char.rb +1 -1
- data/lib/core/facets/string/each_word.rb +1 -1
- data/lib/core/facets/string/lines.rb +11 -4
- data/lib/core/facets/string/start_with.rb +9 -2
- data/lib/core/facets/string/unfold.rb +27 -0
- data/lib/core/facets/symbol/succ.rb +3 -3
- data/lib/core/facets/symbol/thrown.rb +20 -0
- data/lib/core/facets/symbol/to_proc.rb +3 -2
- data/lib/core/facets/time/to_time.rb +1 -1
- data/lib/core/facets/to_hash.rb +41 -100
- data/lib/core/facets/unboundmethod/name.rb +20 -23
- data/lib/more/facets/ansicode.rb +1 -10
- data/lib/more/facets/autoarray.rb +3 -31
- data/lib/more/facets/basicobject.rb +73 -0
- data/lib/more/facets/blankslate.rb +2 -66
- data/lib/{lore → more}/facets/cgi.rb +0 -0
- data/lib/more/facets/class_extend.rb +1 -0
- data/lib/{lore → more}/facets/continuation.rb +0 -0
- data/lib/{lore → more}/facets/date.rb +3 -3
- data/lib/more/facets/enumargs.rb +192 -0
- data/lib/more/facets/enumerablepass.rb +2 -216
- data/lib/more/facets/enumerator.rb +62 -0
- data/lib/more/facets/{equatable.rb → equitable.rb} +11 -11
- data/lib/more/facets/expirable.rb +13 -41
- data/lib/{lore → more}/facets/fileutils.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/head.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/safe_ln.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/slice.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/tail.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/wc.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/whereis.rb +0 -0
- data/lib/{lore → more}/facets/fileutils/which.rb +0 -0
- data/lib/{lore → more}/facets/getoptlong.rb +0 -0
- data/lib/more/facets/hook.rb +2 -29
- data/lib/more/facets/inheritor.rb +2 -2
- data/lib/more/facets/instance_eval.rb +50 -0
- data/lib/more/facets/instance_function.rb +78 -0
- data/lib/more/facets/main.rb +20 -15
- data/lib/more/facets/memoize.rb +1 -113
- data/lib/more/facets/module/attr.rb +83 -0
- data/lib/more/facets/module/attr_tester.rb +44 -0
- data/lib/more/facets/module/attr_toggler.rb +59 -0
- data/lib/more/facets/module/attr_validator.rb +34 -0
- data/lib/more/facets/{class_extension.rb → module/class_extend.rb} +21 -13
- data/lib/more/facets/once.rb +59 -0
- data/lib/more/facets/openmodule.rb +1 -0
- data/lib/more/facets/orderedhash.rb +1 -33
- data/lib/{lore → more}/facets/ostruct.rb +0 -0
- data/lib/more/facets/ostructable.rb +1 -4
- data/lib/more/facets/partial.rb +18 -16
- data/lib/{lore → more}/facets/pathname.rb +0 -0
- data/lib/more/facets/preinitialize.rb +157 -0
- data/lib/{lore → more}/facets/rbconfig.rb +0 -0
- data/lib/more/facets/recorder.rb +1 -2
- data/lib/{lore → more}/facets/set.rb +0 -0
- data/lib/{lore → more}/facets/shellwords.rb +0 -0
- data/lib/{lore → more}/facets/uri.rb +0 -0
- data/lib/{lore → more}/facets/yaml.rb +0 -0
- data/lib/{lore → more}/facets/zlib.rb +0 -0
- data/meta/loadpath +0 -1
- data/meta/sitemap +4 -0
- data/meta/version +1 -1
- data/test/core/enumerable/test_count.rb +1 -1
- data/test/{more/test_filter.rb → core/enumerable/test_defer.rb} +24 -22
- data/test/{more/test_elementor.rb → core/enumerable/test_every.rb} +2 -15
- data/test/core/enumerable/test_ewise.rb +23 -0
- data/test/core/enumerable/test_per.rb +18 -0
- data/test/core/enumerable/test_take.rb +13 -0
- data/test/core/kernel/test_deepcopy.rb +1 -1
- data/test/{more/test_1stclassmethod.rb → core/kernel/test_method.rb} +2 -7
- data/test/core/kernel/test_tap.rb +1 -1
- data/test/core/proc/test_curry.rb +11 -0
- data/test/core/string/test_bytes.rb +1 -1
- data/test/core/string/test_camelcase.rb +23 -6
- data/test/core/string/test_lines.rb +1 -1
- data/test/core/string/test_unfold.rb +14 -0
- data/test/{more → core}/test_blank.rb +0 -0
- data/test/{more → core}/test_boolean.rb +0 -0
- data/test/{more → core}/test_functor.rb +0 -0
- data/test/{lore → more}/test_basicobject.rb +0 -0
- data/test/more/{test_class_extension.rb → test_class_extend.rb} +6 -6
- data/test/{lore → more}/test_continuation.rb +0 -0
- data/test/{lore → more}/test_date.rb +0 -0
- data/test/more/{test_enumerablepass.rb → test_enumargs.rb} +2 -4
- data/test/more/{test_equatable.rb → test_equitable.rb} +2 -2
- data/test/more/{test_instantise.rb → test_instance_function.rb} +3 -2
- data/test/more/test_memoize.rb +1 -1
- data/test/{lore → more}/test_ostruct.rb +0 -0
- metadata +865 -1016
- data/RELEASE +0 -38
- data/doc/README.lore +0 -51
- data/doc/log/basic_stats/index.html +0 -39
- data/doc/log/changelog.html +0 -648
- data/doc/log/changelog.txt +0 -217
- data/doc/log/stats/index.html +0 -39
- data/doc/log/testlog.txt +0 -278
- data/doc/notes/CHANGES +0 -2529
- data/doc/rdoc/lore/classes/Array.html +0 -176
- data/doc/rdoc/lore/classes/CGI.html +0 -191
- data/doc/rdoc/lore/classes/Config.html +0 -135
- data/doc/rdoc/lore/classes/Continuation.html +0 -113
- data/doc/rdoc/lore/classes/Date.html +0 -631
- data/doc/rdoc/lore/classes/DateTime.html +0 -583
- data/doc/rdoc/lore/classes/Enumerable.html +0 -89
- data/doc/rdoc/lore/classes/Enumerable/Enumerator.html +0 -147
- data/doc/rdoc/lore/classes/File.html +0 -128
- data/doc/rdoc/lore/classes/FileUtils.html +0 -434
- data/doc/rdoc/lore/classes/GetoptLong.html +0 -118
- data/doc/rdoc/lore/classes/GetoptLong/DSL.html +0 -208
- data/doc/rdoc/lore/classes/Kernel.html +0 -135
- data/doc/rdoc/lore/classes/Logger.html +0 -229
- data/doc/rdoc/lore/classes/Logger/Ansicolor.html +0 -277
- data/doc/rdoc/lore/classes/Logger/LogDevice.html +0 -121
- data/doc/rdoc/lore/classes/NilClass.html +0 -119
- data/doc/rdoc/lore/classes/OpenStruct.html +0 -432
- data/doc/rdoc/lore/classes/Pathname.html +0 -353
- data/doc/rdoc/lore/classes/Set.html +0 -117
- data/doc/rdoc/lore/classes/Shellwords.html +0 -111
- data/doc/rdoc/lore/classes/String.html +0 -140
- data/doc/rdoc/lore/classes/Time.html +0 -154
- data/doc/rdoc/lore/classes/URI.html +0 -454
- data/doc/rdoc/lore/classes/URI/Hash.html +0 -105
- data/doc/rdoc/lore/classes/URI/Kernel.html +0 -122
- data/doc/rdoc/lore/classes/Zlib.html +0 -188
- data/doc/rdoc/lore/created.rid +0 -1
- data/doc/rdoc/lore/files/README.html +0 -286
- data/doc/rdoc/lore/files/doc/README_lore.html +0 -155
- data/doc/rdoc/lore/files/lib/lore/facets/basicobject_rb.html +0 -118
- data/doc/rdoc/lore/files/lib/lore/facets/cgi_rb.html +0 -111
- data/doc/rdoc/lore/files/lib/lore/facets/continuation_rb.html +0 -147
- data/doc/rdoc/lore/files/lib/lore/facets/date_rb.html +0 -97
- data/doc/rdoc/lore/files/lib/lore/facets/enumerator_rb.html +0 -111
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/head_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/safe_ln_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/slice_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/tail_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/wc_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/whereis_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils/which_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/fileutils_rb.html +0 -131
- data/doc/rdoc/lore/files/lib/lore/facets/getoptlong_rb.html +0 -135
- data/doc/rdoc/lore/files/lib/lore/facets/logger_rb.html +0 -142
- data/doc/rdoc/lore/files/lib/lore/facets/ostruct_rb.html +0 -135
- data/doc/rdoc/lore/files/lib/lore/facets/pathname_rb.html +0 -145
- data/doc/rdoc/lore/files/lib/lore/facets/rbconfig_rb.html +0 -124
- data/doc/rdoc/lore/files/lib/lore/facets/set_rb.html +0 -96
- data/doc/rdoc/lore/files/lib/lore/facets/shellwords_rb.html +0 -124
- data/doc/rdoc/lore/files/lib/lore/facets/uri_rb.html +0 -125
- data/doc/rdoc/lore/files/lib/lore/facets/yaml_rb.html +0 -146
- data/doc/rdoc/lore/files/lib/lore/facets/zlib_rb.html +0 -97
- data/doc/rdoc/lore/fr_class_index.html +0 -73
- data/doc/rdoc/lore/fr_file_index.html +0 -71
- data/doc/rdoc/lore/fr_method_index.html +0 -177
- data/doc/rdoc/lore/index.html +0 -26
- data/doc/rdoc/lore/rdoc-style.css +0 -177
- data/doc/release-notes/RELEASE-2.0.5 +0 -8
- data/doc/release-notes/RELEASE-2.1.0 +0 -9
- data/doc/release-notes/RELEASE-2.1.1 +0 -5
- data/doc/release-notes/RELEASE-2.1.2 +0 -6
- data/doc/release-notes/RELEASE-2.1.3 +0 -5
- data/doc/release-notes/RELEASE-2.2.0 +0 -14
- data/doc/release-notes/RELEASE-2.2.1 +0 -4
- data/doc/release-notes/RELEASE-2.3.0 +0 -6
- data/doc/release-notes/RELEASE-2.4.0 +0 -70
- data/doc/release-notes/RELEASE-2.4.1 +0 -8
- data/doc/release-notes/RELEASE-2.4.2 +0 -4
- data/doc/release-notes/RELEASE-2.4.3 +0 -78
- data/doc/release-notes/RELEASE-2.4.4 +0 -38
- data/doc/release-notes/RELEASE-2.4.5 +0 -37
- data/doc/release-notes/RELEASE-2.5.0 +0 -83
- data/lib/core/facets/kernel/instance.rb +0 -19
- data/lib/lore/facets/basicobject.rb +0 -14
- data/lib/lore/facets/enumerator.rb +0 -67
- data/lib/lore/facets/logger.rb +0 -291
- data/lib/more/facets/1stclassmethod.rb +0 -140
- data/lib/more/facets/advisable.rb +0 -162
- data/lib/more/facets/association.rb +0 -210
- data/lib/more/facets/attr.rb +0 -209
- data/lib/more/facets/basex.rb +0 -37
- data/lib/more/facets/bbcode.rb +0 -397
- data/lib/more/facets/bicrypt.rb +0 -265
- data/lib/more/facets/binreadable.rb +0 -221
- data/lib/more/facets/censor.rb +0 -97
- data/lib/more/facets/classmethods.rb +0 -199
- data/lib/more/facets/consoleutils.rb +0 -99
- data/lib/more/facets/crypt.rb +0 -166
- data/lib/more/facets/dependency.rb +0 -151
- data/lib/more/facets/downloader.rb +0 -281
- data/lib/more/facets/duplicable.rb +0 -43
- data/lib/more/facets/elementor.rb +0 -133
- data/lib/more/facets/filter.rb +0 -121
- data/lib/more/facets/heap.rb +0 -22
- data/lib/more/facets/infinity.rb +0 -193
- data/lib/more/facets/ini.rb +0 -264
- data/lib/more/facets/instantise.rb +0 -1
- data/lib/more/facets/instantize.rb +0 -95
- data/lib/more/facets/interval.rb +0 -282
- data/lib/more/facets/iteration.rb +0 -65
- data/lib/more/facets/linkedlist.rb +0 -222
- data/lib/more/facets/lrucache.rb +0 -157
- data/lib/more/facets/matcher.rb +0 -140
- data/lib/more/facets/memoizer.rb +0 -74
- data/lib/more/facets/minitar.rb +0 -1063
- data/lib/more/facets/nackclass.rb +0 -41
- data/lib/more/facets/net/smtp_tls.rb +0 -131
- data/lib/more/facets/nilstatus.rb +0 -48
- data/lib/more/facets/overload.rb +0 -94
- data/lib/more/facets/paramix.rb +0 -202
- data/lib/more/facets/pool.rb +0 -91
- data/lib/more/facets/pqueue.rb +0 -449
- data/lib/more/facets/pry.rb +0 -32
- data/lib/more/facets/reflection.rb +0 -145
- data/lib/more/facets/semaphore.rb +0 -92
- data/lib/more/facets/settings.rb +0 -248
- data/lib/more/facets/snapshot.rb +0 -209
- data/lib/more/facets/sparse_array.rb +0 -809
- data/lib/more/facets/string/mask.rb +0 -278
- data/lib/more/facets/string/obfuscate.rb +0 -65
- data/lib/more/facets/string/stylize.rb +0 -169
- data/lib/more/facets/string/words.rb +0 -167
- data/lib/more/facets/syncarray.rb +0 -114
- data/lib/more/facets/synchash.rb +0 -157
- data/lib/more/facets/typecast.rb +0 -261
- data/lib/more/facets/uninheritable.rb +0 -50
- data/lib/more/facets/xmlhash.rb +0 -112
- data/lib/more/facets/xoxo.rb +0 -259
- data/lib/more/facets/ziputils.rb +0 -490
- data/task/conflicts +0 -63
- data/task/coverage.rake +0 -37
- data/task/methods +0 -49
- data/task/rdoc.rake +0 -17
- data/task/setup.rake +0 -38
- data/task/test.rake +0 -145
- data/test/more/test_advisable.rb +0 -71
- data/test/more/test_association.rb +0 -38
- data/test/more/test_bbcode.rb +0 -21
- data/test/more/test_binreadable.rb +0 -50
- data/test/more/test_buildable.rb +0 -73
- data/test/more/test_classmethods.rb +0 -56
- data/test/more/test_crypt.rb +0 -32
- data/test/more/test_dependency.rb +0 -69
- data/test/more/test_elementwise.rb +0 -25
- data/test/more/test_infinity.rb +0 -40
- data/test/more/test_interval.rb +0 -151
- data/test/more/test_linkedlist.rb +0 -41
- data/test/more/test_lrucache.rb +0 -14
- data/test/more/test_overload.rb +0 -160
- data/test/more/test_paramix.rb +0 -170
- data/test/more/test_prototype.rb +0 -35
- data/test/more/test_snapshot.rb +0 -21
- data/test/more/test_sparsearray.rb +0 -279
- data/test/more/test_syncarray.rb +0 -15
- data/test/more/test_synchash.rb +0 -16
- data/test/more/test_typecast.rb +0 -54
- data/test/more/test_uninheritable.rb +0 -31
- data/test/more/test_xoxo.rb +0 -274
- data/test/test_facets.rb +0 -9
@@ -1,89 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
<html>
|
6
|
-
<head>
|
7
|
-
<title>Module: Enumerable</title>
|
8
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
10
|
-
|
11
|
-
<script language="JavaScript" type="text/javascript">
|
12
|
-
// <![CDATA[
|
13
|
-
|
14
|
-
function toggleSource( id )
|
15
|
-
{
|
16
|
-
var elem
|
17
|
-
var link
|
18
|
-
|
19
|
-
if( document.getElementById )
|
20
|
-
{
|
21
|
-
elem = document.getElementById( id )
|
22
|
-
link = document.getElementById( "l_" + id )
|
23
|
-
}
|
24
|
-
else if ( document.all )
|
25
|
-
{
|
26
|
-
elem = eval( "document.all." + id )
|
27
|
-
link = eval( "document.all.l_" + id )
|
28
|
-
}
|
29
|
-
else
|
30
|
-
return false;
|
31
|
-
|
32
|
-
if( elem.style.display == "block" )
|
33
|
-
{
|
34
|
-
elem.style.display = "none"
|
35
|
-
link.innerHTML = "+"
|
36
|
-
}
|
37
|
-
else
|
38
|
-
{
|
39
|
-
elem.style.display = "block"
|
40
|
-
link.innerHTML = "-"
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
function openCode( url )
|
45
|
-
{
|
46
|
-
window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
|
47
|
-
}
|
48
|
-
// ]]>
|
49
|
-
</script>
|
50
|
-
</head>
|
51
|
-
|
52
|
-
<body>
|
53
|
-
<table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
|
54
|
-
<td class="file-title"><span class="file-title-prefix">Module</span><br />Enumerable</td>
|
55
|
-
<td align="right">
|
56
|
-
<table cellspacing="0" cellpadding="2">
|
57
|
-
<tr valign="top">
|
58
|
-
<td>In:</td>
|
59
|
-
<td>
|
60
|
-
<a href="../files/lib/lore/facets/enumerator_rb.html">lib/lore/facets/enumerator.rb</a>
|
61
|
-
</td>
|
62
|
-
</tr>
|
63
|
-
</table>
|
64
|
-
</td>
|
65
|
-
</tr>
|
66
|
-
</table>
|
67
|
-
<!-- banner header -->
|
68
|
-
|
69
|
-
<div id="bodyContent">
|
70
|
-
<div id="content">
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
<div class="sectiontitle">Classes and Modules</div>
|
79
|
-
Class <a href="Enumerable/Enumerator.html" class="link">Enumerable::Enumerator</a><br />
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
</div>
|
85
|
-
|
86
|
-
</div>
|
87
|
-
|
88
|
-
</body>
|
89
|
-
</html>
|
@@ -1,147 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
<html>
|
6
|
-
<head>
|
7
|
-
<title>Class: Enumerable::Enumerator</title>
|
8
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
10
|
-
|
11
|
-
<script language="JavaScript" type="text/javascript">
|
12
|
-
// <![CDATA[
|
13
|
-
|
14
|
-
function toggleSource( id )
|
15
|
-
{
|
16
|
-
var elem
|
17
|
-
var link
|
18
|
-
|
19
|
-
if( document.getElementById )
|
20
|
-
{
|
21
|
-
elem = document.getElementById( id )
|
22
|
-
link = document.getElementById( "l_" + id )
|
23
|
-
}
|
24
|
-
else if ( document.all )
|
25
|
-
{
|
26
|
-
elem = eval( "document.all." + id )
|
27
|
-
link = eval( "document.all.l_" + id )
|
28
|
-
}
|
29
|
-
else
|
30
|
-
return false;
|
31
|
-
|
32
|
-
if( elem.style.display == "block" )
|
33
|
-
{
|
34
|
-
elem.style.display = "none"
|
35
|
-
link.innerHTML = "+"
|
36
|
-
}
|
37
|
-
else
|
38
|
-
{
|
39
|
-
elem.style.display = "block"
|
40
|
-
link.innerHTML = "-"
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
function openCode( url )
|
45
|
-
{
|
46
|
-
window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
|
47
|
-
}
|
48
|
-
// ]]>
|
49
|
-
</script>
|
50
|
-
</head>
|
51
|
-
|
52
|
-
<body>
|
53
|
-
<table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
|
54
|
-
<td class="file-title"><span class="file-title-prefix">Class</span><br />Enumerable::Enumerator</td>
|
55
|
-
<td align="right">
|
56
|
-
<table cellspacing="0" cellpadding="2">
|
57
|
-
<tr valign="top">
|
58
|
-
<td>In:</td>
|
59
|
-
<td>
|
60
|
-
<a href="../../files/lib/lore/facets/enumerator_rb.html">lib/lore/facets/enumerator.rb</a>
|
61
|
-
</td>
|
62
|
-
</tr>
|
63
|
-
<tr>
|
64
|
-
<td>Parent:</td>
|
65
|
-
<td>
|
66
|
-
Object
|
67
|
-
</td>
|
68
|
-
</tr>
|
69
|
-
</table>
|
70
|
-
</td>
|
71
|
-
</tr>
|
72
|
-
</table>
|
73
|
-
<!-- banner header -->
|
74
|
-
|
75
|
-
<div id="bodyContent">
|
76
|
-
<div id="content">
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
<div class="sectiontitle">Methods</div>
|
82
|
-
<span style="padding-right: 5px;"><a href="#M000131">new</a></span>
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
<div class="sectiontitle">Public Class methods</div>
|
90
|
-
<div class="method">
|
91
|
-
<div class="title">
|
92
|
-
<a name="M000131"></a><b>new</b>(*args, &block)
|
93
|
-
</div>
|
94
|
-
<div class="description">
|
95
|
-
<p>
|
96
|
-
Provides the ruby-1.9 block form of <a
|
97
|
-
href="Enumerator.html">Enumerator</a>, where you can write:
|
98
|
-
</p>
|
99
|
-
<pre>
|
100
|
-
obj = Enumerator.new do |yielder|
|
101
|
-
.. do stuff
|
102
|
-
yielder.yield data # or: yielder << data
|
103
|
-
.. etc
|
104
|
-
end
|
105
|
-
</pre>
|
106
|
-
<p>
|
107
|
-
When obj.each is called, the block is run once. It should call
|
108
|
-
yielder.yield with each item it wishes to generate.
|
109
|
-
</p>
|
110
|
-
<p>
|
111
|
-
Example:
|
112
|
-
</p>
|
113
|
-
<pre>
|
114
|
-
fib = Enumerator.new { |y|
|
115
|
-
a = b = 1
|
116
|
-
loop {
|
117
|
-
y << a
|
118
|
-
a, b = b, a + b
|
119
|
-
}
|
120
|
-
}
|
121
|
-
|
122
|
-
assert_equal [1, 1, 2, 3, 5, 8, 13, 21, 34, 55], fib.take(10)
|
123
|
-
</pre>
|
124
|
-
</div>
|
125
|
-
<div class="sourcecode">
|
126
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000131_source')" id="l_M000131_source">+</a> ]</p>
|
127
|
-
<div id="M000131_source" class="dyn-source">
|
128
|
-
<pre>
|
129
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/enumerator.rb, line 34</span>
|
130
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
131
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
132
|
-
<span class="ruby-ivar">@body</span> = <span class="ruby-identifier">block</span>
|
133
|
-
<span class="ruby-identifier">old_initialize</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">:_start</span>)
|
134
|
-
<span class="ruby-keyword kw">else</span>
|
135
|
-
<span class="ruby-identifier">old_initialize</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
136
|
-
<span class="ruby-keyword kw">end</span>
|
137
|
-
<span class="ruby-keyword kw">end</span>
|
138
|
-
</pre>
|
139
|
-
</div>
|
140
|
-
</div>
|
141
|
-
</div>
|
142
|
-
</div>
|
143
|
-
|
144
|
-
</div>
|
145
|
-
|
146
|
-
</body>
|
147
|
-
</html>
|
@@ -1,128 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
<html>
|
6
|
-
<head>
|
7
|
-
<title>Class: File</title>
|
8
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
10
|
-
|
11
|
-
<script language="JavaScript" type="text/javascript">
|
12
|
-
// <![CDATA[
|
13
|
-
|
14
|
-
function toggleSource( id )
|
15
|
-
{
|
16
|
-
var elem
|
17
|
-
var link
|
18
|
-
|
19
|
-
if( document.getElementById )
|
20
|
-
{
|
21
|
-
elem = document.getElementById( id )
|
22
|
-
link = document.getElementById( "l_" + id )
|
23
|
-
}
|
24
|
-
else if ( document.all )
|
25
|
-
{
|
26
|
-
elem = eval( "document.all." + id )
|
27
|
-
link = eval( "document.all.l_" + id )
|
28
|
-
}
|
29
|
-
else
|
30
|
-
return false;
|
31
|
-
|
32
|
-
if( elem.style.display == "block" )
|
33
|
-
{
|
34
|
-
elem.style.display = "none"
|
35
|
-
link.innerHTML = "+"
|
36
|
-
}
|
37
|
-
else
|
38
|
-
{
|
39
|
-
elem.style.display = "block"
|
40
|
-
link.innerHTML = "-"
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
function openCode( url )
|
45
|
-
{
|
46
|
-
window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
|
47
|
-
}
|
48
|
-
// ]]>
|
49
|
-
</script>
|
50
|
-
</head>
|
51
|
-
|
52
|
-
<body>
|
53
|
-
<table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
|
54
|
-
<td class="file-title"><span class="file-title-prefix">Class</span><br />File</td>
|
55
|
-
<td align="right">
|
56
|
-
<table cellspacing="0" cellpadding="2">
|
57
|
-
<tr valign="top">
|
58
|
-
<td>In:</td>
|
59
|
-
<td>
|
60
|
-
<a href="../files/lib/lore/facets/yaml_rb.html">lib/lore/facets/yaml.rb</a>
|
61
|
-
</td>
|
62
|
-
</tr>
|
63
|
-
<tr>
|
64
|
-
<td>Parent:</td>
|
65
|
-
<td>
|
66
|
-
Object
|
67
|
-
</td>
|
68
|
-
</tr>
|
69
|
-
</table>
|
70
|
-
</td>
|
71
|
-
</tr>
|
72
|
-
</table>
|
73
|
-
<!-- banner header -->
|
74
|
-
|
75
|
-
<div id="bodyContent">
|
76
|
-
<div id="content">
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
<div class="sectiontitle">Methods</div>
|
82
|
-
<span style="padding-right: 5px;"><a href="#M000097">yaml?</a></span>
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
<div class="sectiontitle">Public Class methods</div>
|
90
|
-
<div class="method">
|
91
|
-
<div class="title">
|
92
|
-
<a name="M000097"></a><b>yaml?</b>(file)
|
93
|
-
</div>
|
94
|
-
<div class="description">
|
95
|
-
<p>
|
96
|
-
Is a file a YAML file?
|
97
|
-
</p>
|
98
|
-
<p>
|
99
|
-
Note this isn‘t perfect. At present it depends on the use use of an
|
100
|
-
initial document separator (eg. ’—’). With YAML 1.1 the
|
101
|
-
%YAML delaration will be manditory, so in the future this can be adapted to
|
102
|
-
fit that standard.
|
103
|
-
</p>
|
104
|
-
</div>
|
105
|
-
<div class="sourcecode">
|
106
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000097_source')" id="l_M000097_source">+</a> ]</p>
|
107
|
-
<div id="M000097_source" class="dyn-source">
|
108
|
-
<pre>
|
109
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/yaml.rb, line 65</span>
|
110
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">yaml?</span>(<span class="ruby-identifier">file</span>)
|
111
|
-
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">file</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
112
|
-
<span class="ruby-keyword kw">until</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">eof?</span>
|
113
|
-
<span class="ruby-identifier">line</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">gets</span>
|
114
|
-
<span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^---/</span>
|
115
|
-
<span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^(\s*#.*?|\s*)$/</span>
|
116
|
-
<span class="ruby-keyword kw">end</span>
|
117
|
-
<span class="ruby-keyword kw">end</span>
|
118
|
-
<span class="ruby-keyword kw">end</span>
|
119
|
-
</pre>
|
120
|
-
</div>
|
121
|
-
</div>
|
122
|
-
</div>
|
123
|
-
</div>
|
124
|
-
|
125
|
-
</div>
|
126
|
-
|
127
|
-
</body>
|
128
|
-
</html>
|
@@ -1,434 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
<html>
|
6
|
-
<head>
|
7
|
-
<title>Module: FileUtils</title>
|
8
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
9
|
-
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
10
|
-
|
11
|
-
<script language="JavaScript" type="text/javascript">
|
12
|
-
// <![CDATA[
|
13
|
-
|
14
|
-
function toggleSource( id )
|
15
|
-
{
|
16
|
-
var elem
|
17
|
-
var link
|
18
|
-
|
19
|
-
if( document.getElementById )
|
20
|
-
{
|
21
|
-
elem = document.getElementById( id )
|
22
|
-
link = document.getElementById( "l_" + id )
|
23
|
-
}
|
24
|
-
else if ( document.all )
|
25
|
-
{
|
26
|
-
elem = eval( "document.all." + id )
|
27
|
-
link = eval( "document.all.l_" + id )
|
28
|
-
}
|
29
|
-
else
|
30
|
-
return false;
|
31
|
-
|
32
|
-
if( elem.style.display == "block" )
|
33
|
-
{
|
34
|
-
elem.style.display = "none"
|
35
|
-
link.innerHTML = "+"
|
36
|
-
}
|
37
|
-
else
|
38
|
-
{
|
39
|
-
elem.style.display = "block"
|
40
|
-
link.innerHTML = "-"
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
function openCode( url )
|
45
|
-
{
|
46
|
-
window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
|
47
|
-
}
|
48
|
-
// ]]>
|
49
|
-
</script>
|
50
|
-
</head>
|
51
|
-
|
52
|
-
<body>
|
53
|
-
<table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
|
54
|
-
<td class="file-title"><span class="file-title-prefix">Module</span><br />FileUtils</td>
|
55
|
-
<td align="right">
|
56
|
-
<table cellspacing="0" cellpadding="2">
|
57
|
-
<tr valign="top">
|
58
|
-
<td>In:</td>
|
59
|
-
<td>
|
60
|
-
<a href="../files/lib/lore/facets/fileutils/which_rb.html">lib/lore/facets/fileutils/which.rb</a>
|
61
|
-
<a href="../files/lib/lore/facets/fileutils/whereis_rb.html">lib/lore/facets/fileutils/whereis.rb</a>
|
62
|
-
<a href="../files/lib/lore/facets/fileutils/wc_rb.html">lib/lore/facets/fileutils/wc.rb</a>
|
63
|
-
<a href="../files/lib/lore/facets/fileutils/slice_rb.html">lib/lore/facets/fileutils/slice.rb</a>
|
64
|
-
<a href="../files/lib/lore/facets/fileutils/safe_ln_rb.html">lib/lore/facets/fileutils/safe_ln.rb</a>
|
65
|
-
</td>
|
66
|
-
</tr>
|
67
|
-
</table>
|
68
|
-
</td>
|
69
|
-
</tr>
|
70
|
-
</table>
|
71
|
-
<!-- banner header -->
|
72
|
-
|
73
|
-
<div id="bodyContent">
|
74
|
-
<div id="content">
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
<div class="sectiontitle">Methods</div>
|
80
|
-
<span style="padding-right: 5px;"><a href="#M000120">head</a></span>
|
81
|
-
<span style="padding-right: 5px;"><a href="#M000123">safe_ln</a></span>
|
82
|
-
<span style="padding-right: 5px;"><a href="#M000122">slice</a></span>
|
83
|
-
<span style="padding-right: 5px;"><a href="#M000121">tail</a></span>
|
84
|
-
<span style="padding-right: 5px;"><a href="#M000119">wc</a></span>
|
85
|
-
<span style="padding-right: 5px;"><a href="#M000118">whereis</a></span>
|
86
|
-
<span style="padding-right: 5px;"><a href="#M000117">which</a></span>
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
<div class="sectiontitle">Constants</div>
|
92
|
-
<table border='0' cellpadding='5'>
|
93
|
-
<tr valign='top'>
|
94
|
-
<td class="attr-name">Win32Exts</td>
|
95
|
-
<td>=</td>
|
96
|
-
<td class="attr-value">%w{.exe .com .bat .cmd}</td>
|
97
|
-
</tr>
|
98
|
-
<tr valign='top'>
|
99
|
-
<td class="attr-name">Win32Exts</td>
|
100
|
-
<td>=</td>
|
101
|
-
<td class="attr-value">%w{.exe .com .bat .cmd}</td>
|
102
|
-
</tr>
|
103
|
-
<tr valign='top'>
|
104
|
-
<td class="attr-name">LINKING_SUPPORTED</td>
|
105
|
-
<td>=</td>
|
106
|
-
<td class="attr-value">[true]</td>
|
107
|
-
</tr>
|
108
|
-
</table>
|
109
|
-
|
110
|
-
|
111
|
-
<div class="sectiontitle">Public Instance methods</div>
|
112
|
-
<div class="method">
|
113
|
-
<div class="title">
|
114
|
-
<a name="M000120"></a><b>head</b>(filename,lines=10) {|| ...}
|
115
|
-
</div>
|
116
|
-
<div class="description">
|
117
|
-
<p>
|
118
|
-
In block form, yields the first number of ((<b>lines</b>)) of file
|
119
|
-
((<b>filename</b>)). In non-block form, it returns an array of the first
|
120
|
-
number of ((<b>lines</b>)).
|
121
|
-
</p>
|
122
|
-
<pre>
|
123
|
-
# Returns first 10 lines of 'myfile'
|
124
|
-
FileUtils.head("myfile")
|
125
|
-
</pre>
|
126
|
-
</div>
|
127
|
-
<div class="sourcecode">
|
128
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000120_source')" id="l_M000120_source">+</a> ]</p>
|
129
|
-
<div id="M000120_source" class="dyn-source">
|
130
|
-
<pre>
|
131
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/fileutils/slice.rb, line 11</span>
|
132
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">head</span>(<span class="ruby-identifier">filename</span>,<span class="ruby-identifier">lines</span>=<span class="ruby-value">10</span>) <span class="ruby-comment cmt">#:yield:</span>
|
133
|
-
<span class="ruby-identifier">a</span> = []
|
134
|
-
<span class="ruby-constant">IO</span>.<span class="ruby-identifier">foreach</span>(<span class="ruby-identifier">filename</span>){<span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
|
135
|
-
<span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">lines</span> <span class="ruby-operator"><=</span> <span class="ruby-value">0</span>
|
136
|
-
<span class="ruby-identifier">lines</span> <span class="ruby-operator">-=</span> <span class="ruby-value">1</span>
|
137
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
138
|
-
<span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">line</span>
|
139
|
-
<span class="ruby-keyword kw">else</span>
|
140
|
-
<span class="ruby-identifier">a</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">line</span>
|
141
|
-
<span class="ruby-keyword kw">end</span>
|
142
|
-
}
|
143
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">a</span>
|
144
|
-
<span class="ruby-keyword kw">end</span>
|
145
|
-
</pre>
|
146
|
-
</div>
|
147
|
-
</div>
|
148
|
-
</div>
|
149
|
-
<div class="method">
|
150
|
-
<div class="title">
|
151
|
-
<a name="M000123"></a><b>safe_ln</b>(*args)
|
152
|
-
</div>
|
153
|
-
<div class="description">
|
154
|
-
<p>
|
155
|
-
Attempt to do a normal file link, but fall back to a copy if the link
|
156
|
-
fails.
|
157
|
-
</p>
|
158
|
-
<p>
|
159
|
-
CREDIT Jim Weirich
|
160
|
-
</p>
|
161
|
-
</div>
|
162
|
-
<div class="sourcecode">
|
163
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000123_source')" id="l_M000123_source">+</a> ]</p>
|
164
|
-
<div id="M000123_source" class="dyn-source">
|
165
|
-
<pre>
|
166
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/fileutils/safe_ln.rb, line 14</span>
|
167
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">safe_ln</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
168
|
-
<span class="ruby-keyword kw">unless</span> <span class="ruby-constant">LINKING_SUPPORTED</span>[<span class="ruby-value">0</span>]
|
169
|
-
<span class="ruby-identifier">cp</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
170
|
-
<span class="ruby-keyword kw">else</span>
|
171
|
-
<span class="ruby-keyword kw">begin</span>
|
172
|
-
<span class="ruby-identifier">ln</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
173
|
-
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">EOPNOTSUPP</span>
|
174
|
-
<span class="ruby-constant">LINKING_SUPPORTED</span>[<span class="ruby-value">0</span>] = <span class="ruby-keyword kw">false</span>
|
175
|
-
<span class="ruby-identifier">cp</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
176
|
-
<span class="ruby-keyword kw">end</span>
|
177
|
-
<span class="ruby-keyword kw">end</span>
|
178
|
-
<span class="ruby-keyword kw">end</span>
|
179
|
-
</pre>
|
180
|
-
</div>
|
181
|
-
</div>
|
182
|
-
</div>
|
183
|
-
<div class="method">
|
184
|
-
<div class="title">
|
185
|
-
<a name="M000122"></a><b>slice</b>(filename,from,to) {|| ...}
|
186
|
-
</div>
|
187
|
-
<div class="description">
|
188
|
-
<p>
|
189
|
-
In block form, yields lines ((<b>from</b>))-((<b>to</b>)). In non-block
|
190
|
-
form, returns an array of lines ((<b>from</b>))-((<b>to</b>)).
|
191
|
-
</p>
|
192
|
-
<pre>
|
193
|
-
# Returns lines 8-12 of 'myfile'
|
194
|
-
FileUtils.body("myfile",8,12)
|
195
|
-
</pre>
|
196
|
-
<p>
|
197
|
-
CREDIT Shashank <a href="Date.html">Date</a>, via Daniel Berger.
|
198
|
-
</p>
|
199
|
-
</div>
|
200
|
-
<div class="sourcecode">
|
201
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000122_source')" id="l_M000122_source">+</a> ]</p>
|
202
|
-
<div id="M000122_source" class="dyn-source">
|
203
|
-
<pre>
|
204
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/fileutils/slice.rb, line 48</span>
|
205
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">slice</span>(<span class="ruby-identifier">filename</span>,<span class="ruby-identifier">from</span>,<span class="ruby-identifier">to</span>) <span class="ruby-comment cmt">#:yield:</span>
|
206
|
-
<span class="ruby-constant">IO</span>.<span class="ruby-identifier">readlines</span>(<span class="ruby-identifier">filename</span>)[<span class="ruby-identifier">from</span><span class="ruby-operator">-</span><span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">to</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>]
|
207
|
-
<span class="ruby-keyword kw">end</span>
|
208
|
-
</pre>
|
209
|
-
</div>
|
210
|
-
</div>
|
211
|
-
</div>
|
212
|
-
<div class="method">
|
213
|
-
<div class="title">
|
214
|
-
<a name="M000121"></a><b>tail</b>(filename,lines=10)
|
215
|
-
</div>
|
216
|
-
<div class="description">
|
217
|
-
<p>
|
218
|
-
In block form, yields the last number of ((<b>lines</b>)) of file
|
219
|
-
((<b>filename</b>)). In non-block form, it returns the lines as an array.
|
220
|
-
</p>
|
221
|
-
<p>
|
222
|
-
Note that this method slurps the entire file, so I don‘t recommend it
|
223
|
-
for very large files. If you want an advanced form of ((<b><a
|
224
|
-
href="FileUtils.html#M000121">tail</a></b>)), I suggest using file-<a
|
225
|
-
href="FileUtils.html#M000121">tail</a>, by Florian Frank (available on the
|
226
|
-
RAA). And no <a href="FileUtils.html#M000121">tail</a> -f.
|
227
|
-
</p>
|
228
|
-
<pre>
|
229
|
-
# Returns last 3 lines of 'myfile'
|
230
|
-
FileUtils.tail("myfile",3)
|
231
|
-
</pre>
|
232
|
-
</div>
|
233
|
-
<div class="sourcecode">
|
234
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000121_source')" id="l_M000121_source">+</a> ]</p>
|
235
|
-
<div id="M000121_source" class="dyn-source">
|
236
|
-
<pre>
|
237
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/fileutils/slice.rb, line 36</span>
|
238
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">tail</span>(<span class="ruby-identifier">filename</span>,<span class="ruby-identifier">lines</span>=<span class="ruby-value">10</span>) <span class="ruby-comment cmt">#:yield</span>
|
239
|
-
<span class="ruby-constant">IO</span>.<span class="ruby-identifier">readlines</span>(<span class="ruby-identifier">filename</span>).<span class="ruby-identifier">reverse</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">lines</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>].<span class="ruby-identifier">reverse</span>
|
240
|
-
<span class="ruby-keyword kw">end</span>
|
241
|
-
</pre>
|
242
|
-
</div>
|
243
|
-
</div>
|
244
|
-
</div>
|
245
|
-
<div class="method">
|
246
|
-
<div class="title">
|
247
|
-
<a name="M000119"></a><b>wc</b>(filename,option='all')
|
248
|
-
</div>
|
249
|
-
<div class="description">
|
250
|
-
<p>
|
251
|
-
With no arguments, returns a four element array consisting of the number of
|
252
|
-
bytes, characters, words and lines in <em>filename</em>, respectively.
|
253
|
-
</p>
|
254
|
-
<p>
|
255
|
-
Valid options are <tt>bytes</tt>, <tt>characters</tt> (or just
|
256
|
-
‘chars’), <tt>words</tt> and <tt>lines</tt>.
|
257
|
-
</p>
|
258
|
-
<pre>
|
259
|
-
# Return the number of words in 'myfile'
|
260
|
-
FileUtils.wc("myfile",'words')
|
261
|
-
</pre>
|
262
|
-
<p>
|
263
|
-
CREDIT Daniel J. Berger
|
264
|
-
</p>
|
265
|
-
</div>
|
266
|
-
<div class="sourcecode">
|
267
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000119_source')" id="l_M000119_source">+</a> ]</p>
|
268
|
-
<div id="M000119_source" class="dyn-source">
|
269
|
-
<pre>
|
270
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/fileutils/wc.rb, line 16</span>
|
271
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">wc</span>(<span class="ruby-identifier">filename</span>,<span class="ruby-identifier">option</span>=<span class="ruby-value str">'all'</span>)
|
272
|
-
<span class="ruby-identifier">option</span>.<span class="ruby-identifier">downcase!</span>
|
273
|
-
<span class="ruby-identifier">valid</span> = <span class="ruby-node">%w/all bytes characters chars lines words/</span>
|
274
|
-
|
275
|
-
<span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">valid</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">option</span>)
|
276
|
-
<span class="ruby-identifier">raise</span> <span class="ruby-node">"Invalid option: '#{option}'"</span>
|
277
|
-
<span class="ruby-keyword kw">end</span>
|
278
|
-
|
279
|
-
<span class="ruby-identifier">n</span> = <span class="ruby-value">0</span>
|
280
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">option</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'lines'</span>
|
281
|
-
<span class="ruby-constant">IO</span>.<span class="ruby-identifier">foreach</span>(<span class="ruby-identifier">filename</span>){ <span class="ruby-identifier">n</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> }
|
282
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">n</span>
|
283
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">option</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'bytes'</span>
|
284
|
-
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filename</span>){ <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
285
|
-
<span class="ruby-identifier">f</span>.<span class="ruby-identifier">each_byte</span>{ <span class="ruby-identifier">n</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span> }
|
286
|
-
}
|
287
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">n</span>
|
288
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">option</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'characters'</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">option</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'chars'</span>
|
289
|
-
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filename</span>){ <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
290
|
-
<span class="ruby-keyword kw">while</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">getc</span>
|
291
|
-
<span class="ruby-identifier">n</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
292
|
-
<span class="ruby-keyword kw">end</span>
|
293
|
-
}
|
294
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">n</span>
|
295
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">option</span> <span class="ruby-operator">==</span> <span class="ruby-value str">'words'</span>
|
296
|
-
<span class="ruby-constant">IO</span>.<span class="ruby-identifier">foreach</span>(<span class="ruby-identifier">filename</span>){ <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
|
297
|
-
<span class="ruby-identifier">n</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>.<span class="ruby-identifier">length</span>
|
298
|
-
}
|
299
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">n</span>
|
300
|
-
<span class="ruby-keyword kw">else</span>
|
301
|
-
<span class="ruby-identifier">bytes</span>,<span class="ruby-identifier">chars</span>,<span class="ruby-identifier">lines</span>,<span class="ruby-identifier">words</span> = <span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-value">0</span>,<span class="ruby-value">0</span>
|
302
|
-
<span class="ruby-constant">IO</span>.<span class="ruby-identifier">foreach</span>(<span class="ruby-identifier">filename</span>){ <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
|
303
|
-
<span class="ruby-identifier">lines</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
304
|
-
<span class="ruby-identifier">words</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>.<span class="ruby-identifier">length</span>
|
305
|
-
<span class="ruby-identifier">chars</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>(<span class="ruby-value str">''</span>).<span class="ruby-identifier">length</span>
|
306
|
-
}
|
307
|
-
<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">filename</span>){ <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
308
|
-
<span class="ruby-keyword kw">while</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">getc</span>
|
309
|
-
<span class="ruby-identifier">bytes</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
|
310
|
-
<span class="ruby-keyword kw">end</span>
|
311
|
-
}
|
312
|
-
<span class="ruby-keyword kw">return</span> [<span class="ruby-identifier">bytes</span>,<span class="ruby-identifier">chars</span>,<span class="ruby-identifier">words</span>,<span class="ruby-identifier">lines</span>]
|
313
|
-
<span class="ruby-keyword kw">end</span>
|
314
|
-
<span class="ruby-keyword kw">end</span>
|
315
|
-
</pre>
|
316
|
-
</div>
|
317
|
-
</div>
|
318
|
-
</div>
|
319
|
-
<div class="method">
|
320
|
-
<div class="title">
|
321
|
-
<a name="M000118"></a><b>whereis</b>(prog, path=ENV['PATH']) {|| ...}
|
322
|
-
</div>
|
323
|
-
<div class="sourcecode">
|
324
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000118_source')" id="l_M000118_source">+</a> ]</p>
|
325
|
-
<div id="M000118_source" class="dyn-source">
|
326
|
-
<pre>
|
327
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/fileutils/whereis.rb, line 23</span>
|
328
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">whereis</span>(<span class="ruby-identifier">prog</span>, <span class="ruby-identifier">path</span>=<span class="ruby-constant">ENV</span>[<span class="ruby-value str">'PATH'</span>]) <span class="ruby-comment cmt">#:yield:</span>
|
329
|
-
<span class="ruby-identifier">dirs</span> = []
|
330
|
-
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH_SEPARATOR</span>).<span class="ruby-identifier">each</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span>
|
331
|
-
<span class="ruby-comment cmt"># Windows checks against specific extensions</span>
|
332
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">ALT_SEPARATOR</span>
|
333
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">prog</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value str">'.'</span>)
|
334
|
-
<span class="ruby-identifier">f</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">dir</span>,<span class="ruby-identifier">prog</span>)
|
335
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">executable?</span>(<span class="ruby-identifier">f</span>) <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">f</span>)
|
336
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
337
|
-
<span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\//</span>,<span class="ruby-value str">'\\'</span>)
|
338
|
-
<span class="ruby-keyword kw">else</span>
|
339
|
-
<span class="ruby-identifier">dirs</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\//</span>,<span class="ruby-value str">'\\'</span>)
|
340
|
-
<span class="ruby-keyword kw">end</span>
|
341
|
-
<span class="ruby-keyword kw">end</span>
|
342
|
-
<span class="ruby-keyword kw">else</span>
|
343
|
-
<span class="ruby-constant">Win32Exts</span>.<span class="ruby-identifier">find_all</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">ext</span><span class="ruby-operator">|</span>
|
344
|
-
<span class="ruby-identifier">f</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">dir</span>,<span class="ruby-identifier">prog</span><span class="ruby-operator">+</span><span class="ruby-identifier">ext</span>)
|
345
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">executable?</span>(<span class="ruby-identifier">f</span>) <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">f</span>)
|
346
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
347
|
-
<span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\//</span>,<span class="ruby-value str">'\\'</span>)
|
348
|
-
<span class="ruby-keyword kw">else</span>
|
349
|
-
<span class="ruby-identifier">dirs</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\//</span>,<span class="ruby-value str">'\\'</span>)
|
350
|
-
<span class="ruby-keyword kw">end</span>
|
351
|
-
<span class="ruby-keyword kw">end</span>
|
352
|
-
}
|
353
|
-
<span class="ruby-keyword kw">end</span>
|
354
|
-
<span class="ruby-keyword kw">else</span>
|
355
|
-
<span class="ruby-identifier">f</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">dir</span>,<span class="ruby-identifier">prog</span>)
|
356
|
-
<span class="ruby-comment cmt"># Avoid /usr/lib/ruby, for example</span>
|
357
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">executable?</span>(<span class="ruby-identifier">f</span>) <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">f</span>)
|
358
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
359
|
-
<span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">f</span>
|
360
|
-
<span class="ruby-keyword kw">else</span>
|
361
|
-
<span class="ruby-identifier">dirs</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">f</span>
|
362
|
-
<span class="ruby-keyword kw">end</span>
|
363
|
-
<span class="ruby-keyword kw">end</span>
|
364
|
-
<span class="ruby-keyword kw">end</span>
|
365
|
-
}
|
366
|
-
<span class="ruby-identifier">dirs</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-value">? </span><span class="ruby-keyword kw">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">dirs</span>
|
367
|
-
<span class="ruby-keyword kw">end</span>
|
368
|
-
</pre>
|
369
|
-
</div>
|
370
|
-
</div>
|
371
|
-
</div>
|
372
|
-
<div class="method">
|
373
|
-
<div class="title">
|
374
|
-
<a name="M000117"></a><b>which</b>(prog, path=ENV['PATH'])
|
375
|
-
</div>
|
376
|
-
<div class="description">
|
377
|
-
<p>
|
378
|
-
Looks for the first occurrence of <em>program</em> within <em>path</em>.
|
379
|
-
</p>
|
380
|
-
<p>
|
381
|
-
On the MS Windows platform, it looks for executables ending with .exe, .bat
|
382
|
-
and .com, <a href="FileUtils.html#M000117">which</a> you may optionally
|
383
|
-
include in the program name. Returns <tt>nil</tt> if not found.
|
384
|
-
</p>
|
385
|
-
<p>
|
386
|
-
CREDIT Daniel J. Berger & Michael Granger
|
387
|
-
</p>
|
388
|
-
</div>
|
389
|
-
<div class="sourcecode">
|
390
|
-
<p class="source-link">[ <a href="javascript:toggleSource('M000117_source')" id="l_M000117_source">+</a> ]</p>
|
391
|
-
<div id="M000117_source" class="dyn-source">
|
392
|
-
<pre>
|
393
|
-
<span class="ruby-comment cmt"># File lib/lore/facets/fileutils/which.rb, line 24</span>
|
394
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">which</span>(<span class="ruby-identifier">prog</span>, <span class="ruby-identifier">path</span>=<span class="ruby-constant">ENV</span>[<span class="ruby-value str">'PATH'</span>])
|
395
|
-
<span class="ruby-identifier">path</span>.<span class="ruby-identifier">split</span>(<span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">PATH_SEPARATOR</span>).<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">dir</span><span class="ruby-operator">|</span>
|
396
|
-
<span class="ruby-comment cmt"># Windows checks against specific extensions</span>
|
397
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-constant">ALT_SEPARATOR</span>
|
398
|
-
<span class="ruby-identifier">ext</span> = <span class="ruby-constant">Win32Exts</span>.<span class="ruby-identifier">find</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">ext</span><span class="ruby-operator">|</span>
|
399
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">prog</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value str">'.'</span>) <span class="ruby-comment cmt"># Assume extension already included</span>
|
400
|
-
<span class="ruby-identifier">f</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">dir</span>,<span class="ruby-identifier">prog</span>)
|
401
|
-
<span class="ruby-keyword kw">else</span>
|
402
|
-
<span class="ruby-identifier">f</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">dir</span>,<span class="ruby-identifier">prog</span><span class="ruby-operator">+</span><span class="ruby-identifier">ext</span>)
|
403
|
-
<span class="ruby-keyword kw">end</span>
|
404
|
-
<span class="ruby-constant">File</span>.<span class="ruby-identifier">executable?</span>(<span class="ruby-identifier">f</span>) <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">f</span>)
|
405
|
-
}
|
406
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">ext</span>
|
407
|
-
<span class="ruby-comment cmt"># Use backslashes, not forward slashes</span>
|
408
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">prog</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-value str">'.'</span>) <span class="ruby-comment cmt"># Assume extension already included</span>
|
409
|
-
<span class="ruby-identifier">f</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>( <span class="ruby-identifier">dir</span>, <span class="ruby-identifier">prog</span> ).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\//</span>,<span class="ruby-value str">'\\'</span>)
|
410
|
-
<span class="ruby-keyword kw">else</span>
|
411
|
-
<span class="ruby-identifier">f</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>( <span class="ruby-identifier">dir</span>, <span class="ruby-identifier">prog</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">ext</span> ).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/\//</span>,<span class="ruby-value str">'\\'</span>)
|
412
|
-
<span class="ruby-keyword kw">end</span>
|
413
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">f</span>
|
414
|
-
<span class="ruby-keyword kw">end</span>
|
415
|
-
<span class="ruby-keyword kw">else</span>
|
416
|
-
<span class="ruby-identifier">f</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">dir</span>,<span class="ruby-identifier">prog</span>)
|
417
|
-
<span class="ruby-comment cmt"># Avoid /usr/lib/ruby, for example</span>
|
418
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">executable?</span>(<span class="ruby-identifier">f</span>) <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">directory?</span>(<span class="ruby-identifier">f</span>)
|
419
|
-
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">File</span><span class="ruby-operator">::</span><span class="ruby-identifier">join</span>( <span class="ruby-identifier">dir</span>, <span class="ruby-identifier">prog</span> )
|
420
|
-
<span class="ruby-keyword kw">end</span>
|
421
|
-
<span class="ruby-keyword kw">end</span>
|
422
|
-
}
|
423
|
-
<span class="ruby-keyword kw">nil</span>
|
424
|
-
<span class="ruby-keyword kw">end</span>
|
425
|
-
</pre>
|
426
|
-
</div>
|
427
|
-
</div>
|
428
|
-
</div>
|
429
|
-
</div>
|
430
|
-
|
431
|
-
</div>
|
432
|
-
|
433
|
-
</body>
|
434
|
-
</html>
|