THERuSH 0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. data/bin/therush.rb +112 -0
  2. data/doc/classes/Builtin.html +175 -0
  3. data/doc/classes/Builtin.src/M000005.html +44 -0
  4. data/doc/classes/Builtin.src/M000006.html +44 -0
  5. data/doc/classes/Builtin.src/M000007.html +44 -0
  6. data/doc/classes/History.html +223 -0
  7. data/doc/classes/History.src/M000006.html +28 -0
  8. data/doc/classes/History.src/M000007.html +28 -0
  9. data/doc/classes/History.src/M000008.html +37 -0
  10. data/doc/classes/Shellfuncs.html +261 -0
  11. data/doc/classes/Shellfuncs.src/M000002.html +18 -0
  12. data/doc/classes/Shellfuncs.src/M000003.html +23 -0
  13. data/doc/classes/Shellfuncs.src/M000004.html +27 -0
  14. data/doc/classes/Shellfuncs.src/M000005.html +23 -0
  15. data/doc/created.rid +1 -0
  16. data/doc/dot/f_0.dot +14 -0
  17. data/doc/dot/f_0.png +0 -0
  18. data/doc/dot/f_1.dot +30 -0
  19. data/doc/dot/f_1.png +0 -0
  20. data/doc/dot/f_2.dot +30 -0
  21. data/doc/dot/f_2.png +0 -0
  22. data/doc/dot/f_3.dot +30 -0
  23. data/doc/dot/f_3.png +0 -0
  24. data/doc/dot/m_1_0.dot +30 -0
  25. data/doc/dot/m_1_0.png +0 -0
  26. data/doc/dot/m_2_0.dot +30 -0
  27. data/doc/dot/m_2_0.png +0 -0
  28. data/doc/dot/m_3_0.dot +30 -0
  29. data/doc/dot/m_3_0.png +0 -0
  30. data/doc/files/builtins_rb.html +107 -0
  31. data/doc/files/builtins_rb.src/M000007.html +44 -0
  32. data/doc/files/history_rb.html +108 -0
  33. data/doc/files/rubyshell_rb.html +188 -0
  34. data/doc/files/rubyshell_rb.src/M000001.html +41 -0
  35. data/doc/files/rubyshell_rb.src/M000002.html +25 -0
  36. data/doc/files/rubyshell_rb.src/M000003.html +41 -0
  37. data/doc/files/rubyshell_rb.src/M000004.html +28 -0
  38. data/doc/files/rubyshell_rb.src/M000005.html +41 -0
  39. data/doc/files/rubyshell_rb.src/M000006.html +28 -0
  40. data/doc/files/rubyshell_rb.src/M000007.html +28 -0
  41. data/doc/files/shellfuncs_rb.html +121 -0
  42. data/doc/fr_class_index.html +29 -0
  43. data/doc/fr_file_index.html +30 -0
  44. data/doc/fr_method_index.html +34 -0
  45. data/doc/index.html +24 -0
  46. data/lib/builtins.rb +39 -0
  47. data/lib/history.rb +48 -0
  48. data/lib/shellfuncs.rb +57 -0
  49. metadata +101 -0
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env ruby
2
+ # ==THERuSH
3
+ # The Highly Experimental Ruby Shell
4
+
5
+ require 'abbrev'
6
+ require 'readline'
7
+ require 'history.rb'
8
+ require 'builtins.rb'
9
+ require 'shellfuncs.rb'
10
+ require 'shellwords'
11
+
12
+ include Builtin
13
+ include History
14
+ include Shellfuncs
15
+ include Readline
16
+
17
+ ## Setup some environment variables
18
+
19
+ ## Array with the Builtins
20
+ $builtins = Array[ "cd", "!h" ]
21
+
22
+ ## Math Operators
23
+ $mathoprs = Array[ "+", "-", "*", "/", "**" ]
24
+
25
+ $temp_array = %w{ cd !h }
26
+
27
+ $path.each do | entry |
28
+ if File.directory?( "#{entry}" )
29
+ Dir.foreach( entry ) do | file |
30
+ if File.exist?( "#{entry}/#{file}" ) && !File.directory?( "#{entry}/#{file}" ) && File.executable?( "#{entry}/#{file}" ) && !$temp_array.include?( "#{file}" )
31
+ $temp_array.push( "#{file}" )
32
+ end
33
+ end
34
+ end
35
+
36
+ $comp_list = $temp_array.abbrev
37
+
38
+ Readline.completion_proc = proc do | string |
39
+ $comp_list[string]
40
+ end
41
+ end
42
+
43
+
44
+ ## The method for the built in calculator
45
+ def mathMethod( lhs, opr, rhs )
46
+
47
+ ## All this Debugging is getting tiring :D
48
+ if $DEBUG
49
+ puts "DEBUGGING VALUES: lhs: " + lhs + " opr: " + opr + " rhs: " + rhs
50
+ end
51
+
52
+ ## Convert lhs and rhs to integers
53
+ lhs = lhs.to_i
54
+ rhs = rhs.to_i
55
+
56
+ case opr
57
+ when "+" ## Our Addition case
58
+ puts lhs + rhs
59
+ when "-" ## Our subtraction case
60
+ puts lhs - rhs
61
+ when "*" ## Our multiplication case
62
+ puts lhs * rhs
63
+ when "/" ## Our Division case
64
+ puts lhs / rhs
65
+ when "**" ## Our exponentiation case
66
+ puts lhs ** rhs
67
+ else
68
+ puts "Illegal operator #{opr}"
69
+ end
70
+ end
71
+
72
+
73
+ loop do
74
+
75
+ if $DEBUG
76
+ puts "DEBUGGING VALUES: CWD: " + $cwd + " PROMPT: " + $prompt + " at Line #{__LINE__} in #{__FILE__}"
77
+ end
78
+
79
+ linein = readline( "#{$prompt}", true )
80
+
81
+ if linein.nil? ## Checks for CTRL-D and exits if it is caught
82
+ puts
83
+ exit 0
84
+ elsif linein.chomp.empty? ## Checks to see if the user just hit RETURN and skips to the next loop
85
+ Shellfuncs.envUpdate
86
+ next
87
+ else
88
+ linein = Shellwords.shellwords( linein ) ## Break up the string into tokens so we can do fun things with the "words"
89
+ cmd = linein.at(0) ## Since we reference it so often I gave it its own variable
90
+
91
+ if Shellfuncs.inPath( cmd ) ## Runs the command if its in PATH
92
+ Shellfuncs.commandRun( linein )
93
+ elsif cmd.index('/') == 0 ## If the first character is a / then run the command as an absolute path to the command
94
+ Shellfuncs.commandRun( linein )
95
+ elsif $builtins.include?( cmd ) ## Checks against our BUILTINS
96
+ ## Temporary solution until I can figure out how to directly use the Hash
97
+ case cmd
98
+ when "cd"
99
+ Builtin.chDir( linein.at(1) )
100
+ when "!h"
101
+ History.histCmd( linein.at(1) )
102
+ end
103
+ elsif $mathoprs.include?( linein.at(1) ) ## Checks for one of the defined Math Operators
104
+ mathMethod( linein.at(0), linein.at(1), linein.at(2) )
105
+ elsif cmd == "exit"
106
+ exit 0
107
+ else
108
+ puts "-rubyshell: " + cmd + ": command not found" ## Error msg for not found command
109
+ end
110
+ end
111
+ Shellfuncs.envUpdate
112
+ end
@@ -0,0 +1,175 @@
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
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: Builtin</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">Builtin</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/builtins_rb.html">
59
+ builtins.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+ <div id="description">
76
+ <p>
77
+ The library of builtin functions for THERuSH
78
+ </p>
79
+
80
+ </div>
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000006">chDir</a>&nbsp;&nbsp;
90
+ </div>
91
+ </div>
92
+
93
+ </div>
94
+
95
+
96
+ <!-- if includes -->
97
+
98
+ <div id="section">
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+ <!-- if method_list -->
108
+ <div id="methods">
109
+ <h3 class="section-bar">Public Instance methods</h3>
110
+
111
+ <div id="method-M000006" class="method-detail">
112
+ <a name="M000006"></a>
113
+
114
+ <div class="method-heading">
115
+ <a href="#M000006" class="method-signature">
116
+ <span class="method-name">chDir</span><span class="method-args">( dir )</span>
117
+ </a>
118
+ </div>
119
+
120
+ <div class="method-description">
121
+ <p>
122
+ Handles the cd builtin
123
+ </p>
124
+ <p><a class="source-toggle" href="#"
125
+ onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
126
+ <div class="method-source-code" id="M000006-source">
127
+ <pre>
128
+ <span class="ruby-comment cmt"># File builtins.rb, line 7</span>
129
+ 7: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">chDir</span>( <span class="ruby-identifier">dir</span> )
130
+ 8:
131
+ 9: <span class="ruby-comment cmt">## Only enabled if invoked with -d</span>
132
+ 10: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
133
+ 11: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">dir</span>.<span class="ruby-identifier">nil?</span>
134
+ 12: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;DEBUGGING VALUES: dir: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot; at Line #{__LINE__} in #{__FILE__}&quot;</span>
135
+ 13: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">nil?</span>
136
+ 14: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;DEBUGGING VALUES: dir: nil at Line #{__LINE__} in #{__FILE__}&quot;</span>
137
+ 15: <span class="ruby-keyword kw">end</span>
138
+ 16: <span class="ruby-keyword kw">end</span>
139
+ 17:
140
+ 18: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;~&quot;</span>
141
+ 19: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-constant">ENV</span>[<span class="ruby-value str">&quot;HOME&quot;</span>] )
142
+ 20: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">index</span>(<span class="ruby-value str">&quot;/&quot;</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-comment cmt">## Means we were passed an absolute pathname</span>
143
+ 21: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">FileTest</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">dir</span> )
144
+ 22: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">dir</span> )
145
+ 23: <span class="ruby-keyword kw">else</span>
146
+ 24: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; does not exist&quot;</span>
147
+ 25: <span class="ruby-keyword kw">end</span>
148
+ 26: <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;.&quot;</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;..&quot;</span> <span class="ruby-comment cmt">## Special Case that doesn't need checking</span>
149
+ 27: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">dir</span> )
150
+ 28: <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt">## Relative pathname</span>
151
+ 29: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">FileTest</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">dir</span> )
152
+ 30: <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">dir</span> )
153
+ 31: <span class="ruby-keyword kw">else</span>
154
+ 32: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; does not exist&quot;</span>
155
+ 33: <span class="ruby-keyword kw">end</span>
156
+ 34: <span class="ruby-keyword kw">end</span>
157
+ 35: <span class="ruby-keyword kw">end</span>
158
+ </pre>
159
+ </div>
160
+ </div>
161
+ </div>
162
+
163
+
164
+ </div>
165
+
166
+
167
+ </div>
168
+
169
+
170
+ <div id="validator-badges">
171
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
172
+ </div>
173
+
174
+ </body>
175
+ </html>
@@ -0,0 +1,44 @@
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
+
6
+ <html>
7
+ <head>
8
+ <title>chDir (Builtin)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File builtins.rb, line 7</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">chDir</span>( <span class="ruby-identifier">dir</span> )
15
+
16
+ <span class="ruby-comment cmt">## Only enabled if invoked with -d</span>
17
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
18
+ <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">dir</span>.<span class="ruby-identifier">nil?</span>
19
+ <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;DEBUGGING VALUES: dir: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">dir</span>
20
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">nil?</span>
21
+ <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;DEBUGGING VALUES: dir: nil&quot;</span>
22
+ <span class="ruby-keyword kw">end</span>
23
+ <span class="ruby-keyword kw">end</span>
24
+
25
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;~&quot;</span>
26
+ <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-constant">ENV</span>[<span class="ruby-value str">&quot;HOME&quot;</span>] )
27
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">index</span>(<span class="ruby-value str">&quot;/&quot;</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-comment cmt">## Means we were passed an absolute pathname</span>
28
+ <span class="ruby-keyword kw">if</span> <span class="ruby-constant">FileTest</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">dir</span> )
29
+ <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">dir</span> )
30
+ <span class="ruby-keyword kw">else</span>
31
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; does not exist&quot;</span>
32
+ <span class="ruby-keyword kw">end</span>
33
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;.&quot;</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;..&quot;</span> <span class="ruby-comment cmt">## Special Case that doesn't need checking</span>
34
+ <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">dir</span> )
35
+ <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt">## Relative pathname</span>
36
+ <span class="ruby-keyword kw">if</span> <span class="ruby-constant">FileTest</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">dir</span> )
37
+ <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">dir</span> )
38
+ <span class="ruby-keyword kw">else</span>
39
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; does not exist&quot;</span>
40
+ <span class="ruby-keyword kw">end</span>
41
+ <span class="ruby-keyword kw">end</span>
42
+ <span class="ruby-keyword kw">end</span></pre>
43
+ </body>
44
+ </html>
@@ -0,0 +1,44 @@
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
+
6
+ <html>
7
+ <head>
8
+ <title>chDir (Builtin)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File builtins.rb, line 7</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">chDir</span>( <span class="ruby-identifier">dir</span> )
15
+
16
+ <span class="ruby-comment cmt">## Only enabled if invoked with -d</span>
17
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
18
+ <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">dir</span>.<span class="ruby-identifier">nil?</span>
19
+ <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;DEBUGGING VALUES: dir: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">dir</span>
20
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">nil?</span>
21
+ <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;DEBUGGING VALUES: dir: nil&quot;</span>
22
+ <span class="ruby-keyword kw">end</span>
23
+ <span class="ruby-keyword kw">end</span>
24
+
25
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;~&quot;</span>
26
+ <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-constant">ENV</span>[<span class="ruby-value str">&quot;HOME&quot;</span>] )
27
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">index</span>(<span class="ruby-value str">&quot;/&quot;</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-comment cmt">## Means we were passed an absolute pathname</span>
28
+ <span class="ruby-keyword kw">if</span> <span class="ruby-constant">FileTest</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">dir</span> )
29
+ <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">dir</span> )
30
+ <span class="ruby-keyword kw">else</span>
31
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; does not exist&quot;</span>
32
+ <span class="ruby-keyword kw">end</span>
33
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;.&quot;</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;..&quot;</span> <span class="ruby-comment cmt">## Special Case that doesn't need checking</span>
34
+ <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">dir</span> )
35
+ <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt">## Relative pathname</span>
36
+ <span class="ruby-keyword kw">if</span> <span class="ruby-constant">FileTest</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">dir</span> )
37
+ <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">dir</span> )
38
+ <span class="ruby-keyword kw">else</span>
39
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; does not exist&quot;</span>
40
+ <span class="ruby-keyword kw">end</span>
41
+ <span class="ruby-keyword kw">end</span>
42
+ <span class="ruby-keyword kw">end</span></pre>
43
+ </body>
44
+ </html>
@@ -0,0 +1,44 @@
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
+
6
+ <html>
7
+ <head>
8
+ <title>chDir (Builtin)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File builtins.rb, line 10</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">chDir</span>( <span class="ruby-identifier">dir</span> )
15
+
16
+ <span class="ruby-comment cmt">## Only enabled if invoked with -d</span>
17
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
18
+ <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">dir</span>.<span class="ruby-identifier">nil?</span>
19
+ <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;DEBUGGING VALUES: dir: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">dir</span>
20
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">nil?</span>
21
+ <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;DEBUGGING VALUES: dir: nil&quot;</span>
22
+ <span class="ruby-keyword kw">end</span>
23
+ <span class="ruby-keyword kw">end</span>
24
+
25
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;~&quot;</span>
26
+ <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-constant">ENV</span>[<span class="ruby-value str">&quot;HOME&quot;</span>] )
27
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">dir</span>.<span class="ruby-identifier">index</span>(<span class="ruby-value str">&quot;/&quot;</span>) <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-comment cmt">## Means we were passed an absolute pathname</span>
28
+ <span class="ruby-keyword kw">if</span> <span class="ruby-constant">FileTest</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">dir</span> )
29
+ <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">dir</span> )
30
+ <span class="ruby-keyword kw">else</span>
31
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; does not exist&quot;</span>
32
+ <span class="ruby-keyword kw">end</span>
33
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;.&quot;</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;..&quot;</span> <span class="ruby-comment cmt">## Special Case that doesn't need checking</span>
34
+ <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">dir</span> )
35
+ <span class="ruby-keyword kw">else</span> <span class="ruby-comment cmt">## Relative pathname</span>
36
+ <span class="ruby-keyword kw">if</span> <span class="ruby-constant">FileTest</span>.<span class="ruby-identifier">directory?</span>( <span class="ruby-identifier">dir</span> )
37
+ <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">chdir</span>( <span class="ruby-identifier">dir</span> )
38
+ <span class="ruby-keyword kw">else</span>
39
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">dir</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot; does not exist&quot;</span>
40
+ <span class="ruby-keyword kw">end</span>
41
+ <span class="ruby-keyword kw">end</span>
42
+ <span class="ruby-keyword kw">end</span></pre>
43
+ </body>
44
+ </html>
@@ -0,0 +1,223 @@
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
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: History</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">History</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/history_rb.html">
59
+ history.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+ <div id="description">
76
+ <p>
77
+ Handles the <a href="History.html">History</a> functions for THERuSH
78
+ </p>
79
+
80
+ </div>
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000007">histAdd</a>&nbsp;&nbsp;
90
+ <a href="#M000008">histCmd</a>&nbsp;&nbsp;
91
+ </div>
92
+ </div>
93
+
94
+ </div>
95
+
96
+
97
+ <!-- if includes -->
98
+
99
+ <div id="section">
100
+
101
+
102
+ <div id="constants-list">
103
+ <h3 class="section-bar">Constants</h3>
104
+
105
+ <div class="name-list">
106
+ <table summary="Constants">
107
+ <tr class="top-aligned-row context-row">
108
+ <td class="context-item-name">HISTORY</td>
109
+ <td>=</td>
110
+ <td class="context-item-value">Array[]</td>
111
+ <td width="3em">&nbsp;</td>
112
+ <td class="context-item-desc">
113
+ The Array with the history commands
114
+
115
+ </td>
116
+ </tr>
117
+ </table>
118
+ </div>
119
+ </div>
120
+
121
+
122
+
123
+
124
+
125
+
126
+ <!-- if method_list -->
127
+ <div id="methods">
128
+ <h3 class="section-bar">Public Instance methods</h3>
129
+
130
+ <div id="method-M000007" class="method-detail">
131
+ <a name="M000007"></a>
132
+
133
+ <div class="method-heading">
134
+ <a href="#M000007" class="method-signature">
135
+ <span class="method-name">histAdd</span><span class="method-args">( cmd )</span>
136
+ </a>
137
+ </div>
138
+
139
+ <div class="method-description">
140
+ <p>
141
+ Adds things to the history array ignoring duplicates
142
+ </p>
143
+ <p><a class="source-toggle" href="#"
144
+ onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
145
+ <div class="method-source-code" id="M000007-source">
146
+ <pre>
147
+ <span class="ruby-comment cmt"># File history.rb, line 10</span>
148
+ 10: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">histAdd</span>( <span class="ruby-identifier">cmd</span> )
149
+ 11: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
150
+ 12: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;DEBUGGING VALUES: cmd: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">cmd</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot; at Line #{__LINE__} in #{__FILE__}&quot;</span>
151
+ 13: <span class="ruby-keyword kw">end</span>
152
+ 14:
153
+ 15: <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-constant">HISTORY</span>.<span class="ruby-identifier">include?</span>( <span class="ruby-identifier">cmd</span> )
154
+ 16: <span class="ruby-constant">HISTORY</span>.<span class="ruby-identifier">push</span>( <span class="ruby-identifier">cmd</span> )
155
+ 17: <span class="ruby-keyword kw">end</span>
156
+ 18:
157
+ 19: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
158
+ 20: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;DEBUGGING VALUES: HISTORY: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-constant">HISTORY</span>.<span class="ruby-identifier">join</span>( <span class="ruby-value str">&quot; , &quot;</span>) <span class="ruby-operator">+</span> <span class="ruby-node">&quot; at Line #{__LINE__} in #{__FILE__}&quot;</span>
159
+ 21: <span class="ruby-keyword kw">end</span>
160
+ 22: <span class="ruby-keyword kw">end</span>
161
+ </pre>
162
+ </div>
163
+ </div>
164
+ </div>
165
+
166
+ <div id="method-M000008" class="method-detail">
167
+ <a name="M000008"></a>
168
+
169
+ <div class="method-heading">
170
+ <a href="#M000008" class="method-signature">
171
+ <span class="method-name">histCmd</span><span class="method-args">( hist )</span>
172
+ </a>
173
+ </div>
174
+
175
+ <div class="method-description">
176
+ <p>
177
+ Handles <a href="History.html">History</a> Addition (!h)
178
+ </p>
179
+ <p><a class="source-toggle" href="#"
180
+ onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
181
+ <div class="method-source-code" id="M000008-source">
182
+ <pre>
183
+ <span class="ruby-comment cmt"># File history.rb, line 25</span>
184
+ 25: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">histCmd</span>( <span class="ruby-identifier">hist</span> )
185
+ 26: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$DEBUG</span>
186
+ 27: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hist</span>.<span class="ruby-identifier">nil?</span>
187
+ 28: <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;DEBUGGING VALUES: hist: nil at Line #{__LINE__} in #{__FILE__}&quot;</span>
188
+ 29: <span class="ruby-keyword kw">else</span>
189
+ 30: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;DEBUGGING VALUES: hist: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">hist</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot; at Line #{__LINE__} in #{__FILE__}&quot;</span>
190
+ 31: <span class="ruby-keyword kw">end</span>
191
+ 32: <span class="ruby-keyword kw">end</span>
192
+ 33:
193
+ 34: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">hist</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-comment cmt">## Just entering !h will print out the array</span>
194
+ 35: <span class="ruby-constant">HISTORY</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span> <span class="ruby-identifier">entry</span> <span class="ruby-operator">|</span>
195
+ 36: <span class="ruby-identifier">puts</span> <span class="ruby-constant">HISTORY</span>.<span class="ruby-identifier">index</span>( <span class="ruby-identifier">entry</span> ).<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">&quot;: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">entry</span>
196
+ 37: <span class="ruby-keyword kw">end</span>
197
+ 38: <span class="ruby-keyword kw">else</span>
198
+ 39: <span class="ruby-identifier">hist</span> = <span class="ruby-identifier">hist</span>.<span class="ruby-identifier">to_i</span>
199
+ 40: <span class="ruby-keyword kw">if</span> <span class="ruby-constant">HISTORY</span>.<span class="ruby-identifier">at</span>( <span class="ruby-identifier">hist</span> ).<span class="ruby-identifier">nil?</span>
200
+ 41: <span class="ruby-identifier">puts</span> <span class="ruby-value str">&quot;Invalid history reference&quot;</span>
201
+ 42: <span class="ruby-keyword kw">else</span>
202
+ 43: <span class="ruby-identifier">system</span>( <span class="ruby-node">&quot;#{HISTORY.at( hist )}&quot;</span> )
203
+ 44: <span class="ruby-keyword kw">end</span>
204
+ 45: <span class="ruby-keyword kw">end</span>
205
+ 46: <span class="ruby-keyword kw">end</span>
206
+ </pre>
207
+ </div>
208
+ </div>
209
+ </div>
210
+
211
+
212
+ </div>
213
+
214
+
215
+ </div>
216
+
217
+
218
+ <div id="validator-badges">
219
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
220
+ </div>
221
+
222
+ </body>
223
+ </html>