mysh 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +130 -160
- data/lib/mysh/commands/command_path.rb +15 -0
- data/lib/mysh/commands/help.rb +5 -14
- data/lib/mysh/commands/help.txt +19 -16
- data/lib/mysh/commands/help_math.txt +5 -2
- data/lib/mysh/commands/help_ruby.txt +15 -12
- data/lib/mysh/commands/history.rb +2 -2
- data/lib/mysh/internal.rb +3 -2
- data/lib/mysh/support/handlebars.rb +30 -0
- data/lib/mysh/version.rb +2 -2
- data/tests/my_shell_tests.rb +1 -1
- metadata +4 -3
- data/lib/mysh/support/text_erb.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc384b16374733a18131ead73b90537a16f06b1a
|
4
|
+
data.tar.gz: aaa9a7f9e10bf52d685e9fdb6a2ec1de8c92eb60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15b4e08c89be15e6ef264734cde9c2a0314dcd65ab00e5702dace3303d8c6cfd209ccb05597c8b7404c4cb94735370df7a53dc75251ff084d848cf718ff28bba
|
7
|
+
data.tar.gz: 6549e793c55788c7dc64dc147dee847140131881de18959159badaf9560cab01d2360a87973dc4adcd31c5c9dfafe0863e7f1c0301b3dc221bf95c8d129e6421
|
data/README.md
CHANGED
@@ -5,11 +5,11 @@ I thought it would be fun to experiment with that concept and see if it could
|
|
5
5
|
be taken further.
|
6
6
|
|
7
7
|
Many years ago, a popular shell program was modeled after
|
8
|
-
the 'C' programming language. It went by the csh for C-shell (by the C
|
9
|
-
Instead of 'C', my shell would be based on Ruby (were you shocked?)!
|
10
|
-
obvious name rsh for Ruby-shell was already in use by the Remote-shell. So,
|
8
|
+
the 'C' programming language. It went by the name csh for C-shell (by the C
|
9
|
+
shore :-) Instead of 'C', my shell would be based on Ruby (were you shocked?)!
|
10
|
+
The obvious name rsh for Ruby-shell was already in use by the Remote-shell. So,
|
11
11
|
given the limited scope of this effort, and not wanting to do a lot of typing
|
12
|
-
all the time, I chose the name mysh for
|
12
|
+
all the time, I chose the name mysh for MY-SHell.
|
13
13
|
|
14
14
|
Since that name was available, it would seem that no one had yet written a
|
15
15
|
shell program at this level of narcissism.
|
@@ -41,201 +41,171 @@ Or install it yourself as:
|
|
41
41
|
The mysh gem includes a simple executable called mysh. When run, the user is
|
42
42
|
presented with a command prompt:
|
43
43
|
|
44
|
-
Peter Camilleri@NCC1701G ~
|
45
44
|
$ mysh
|
46
45
|
mysh>
|
47
46
|
|
48
47
|
|
49
48
|
This prompt can be used to execute four sorts of commands:
|
50
49
|
|
51
|
-
* Internal commands that are processed directly by mysh
|
52
50
|
* Ruby expressions, which are preceded by the equal (=) sign.
|
51
|
+
* Internal commands that are processed directly by mysh
|
53
52
|
* External ruby source files that are passed on to the Ruby interpreter.
|
54
53
|
* External commands that are passed on to the standard command shell.
|
55
54
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
gamma of x and the sign of gamma of x.
|
155
|
-
log(x) Float Computes the natural log of x.
|
156
|
-
log(x,B) Float Computes the base B log of x.
|
157
|
-
log10(x) Float Returns the base 10 logarithm of x.
|
158
|
-
log2(x) Float Returns the base 2 logarithm of x.
|
159
|
-
sin(x) Float Computes the sine of x (expressed in radians).
|
160
|
-
Returns a Float in the range -1.0..1.0.
|
161
|
-
sinh(x) Float Computes the hyperbolic sine of x (expressed in radians).
|
162
|
-
sqrt(x) Float Returns the non-negative square root of x.
|
163
|
-
tan(x) Float Computes the tangent of x (expressed in radians).
|
164
|
-
tanh(x) Float Computes the hyperbolic tangent of x (expressed in radians).
|
165
|
-
|
166
|
-
PI Float The value 3.141592653589793
|
167
|
-
E Float The value 2.718281828459045
|
55
|
+
#### Ruby expressions:
|
56
|
+
|
57
|
+
* Any line beginning with an equals "=" sign will be evaluated as a Ruby
|
58
|
+
expression. This allows the mysh command line to serve as a programming,
|
59
|
+
debugging and super-calculator environment.
|
60
|
+
* Expressions ending with a backslash character "\" are continued on the next
|
61
|
+
line. The prompt changes to "mysh\" to indicate that this is going on.
|
62
|
+
* The results are displayed using the pretty-print facility.
|
63
|
+
* Auto-complete always places any file names in quotes so they can be used
|
64
|
+
as string parameters.
|
65
|
+
|
66
|
+
A few noteworthy methods exist that facilitate use of Ruby expressions:
|
67
|
+
```
|
68
|
+
reset Reset the execution environment to the default state.
|
69
|
+
result Returns the result of the previous expression.
|
70
|
+
vls "mask" List modules with version info. The optional mask string value is
|
71
|
+
used to filter for modules containing that string.
|
72
|
+
```
|
73
|
+
|
74
|
+
The Ruby expression execution environment has direct access to many advanced
|
75
|
+
Math functions. For example, to compute the cosine of 3.141592653589793 use:
|
76
|
+
```
|
77
|
+
mysh> =cos(PI)
|
78
|
+
-1.0
|
79
|
+
```
|
80
|
+
|
81
|
+
The following table describes the available math functions.
|
82
|
+
|
83
|
+
Function |Returns |Description
|
84
|
+
-----------|--------|-----------------------------------------------------
|
85
|
+
acos(x) |Float |Computes the arc cosine of x. Returns 0..PI.
|
86
|
+
acosh(x) |Float |Computes the inverse hyperbolic cosine of x.
|
87
|
+
asin(x) |Float |Computes the arc sine of x. Returns -PI/2..PI/2.
|
88
|
+
asinh(x) |Float |Computes the inverse hyperbolic sine of x.
|
89
|
+
atan(x) |Float |Computes the arc tangent of x. Returns -PI/2..PI/2.
|
90
|
+
atan2(y,x) |Float |Computes the arc tangent given y and x.
|
91
|
+
| |Returns a Float in the range -PI..PI.
|
92
|
+
atanh(x) |Float |Computes the inverse hyperbolic tangent of x.
|
93
|
+
cbrt(x) |Float |Returns the cube root of x.
|
94
|
+
cos(x) |Float |Computes the cosine of x (expressed in radians).
|
95
|
+
| |Returns a Float in the range -1.0..1.0.
|
96
|
+
cosh(x) |Float |Computes the hyperbolic cosine of x (expressed in radians).
|
97
|
+
erf(x) |Float |Calculates the error function of x.
|
98
|
+
erfc(x) |Float |Calculates the complementary error function of x.
|
99
|
+
exp(x) |Float |Returns e**x.
|
100
|
+
frexp(x) |Array |Returns a two-element array containing the normalized
|
101
|
+
| |fraction (a Float) and exponent (a Fixnum) of x.
|
102
|
+
gamma(x) |Float |Calculates the gamma function of x.
|
103
|
+
hypot(x,y) |Float |Returns sqrt(x\*\*2 + y\*\*2), the hypotenuse of a right-angled
|
104
|
+
| |triangle with sides x and y.
|
105
|
+
ldexp(m,e) |Float |Returns the value of m\*(2\*\*e) where m is the mantissa and
|
106
|
+
| |e is the power of 2 exponent.
|
107
|
+
lgamma(x) |Array |Returns a two-element array containing the log of the
|
108
|
+
| |gamma of x and the sign of gamma of x.
|
109
|
+
log(x) |Float |Computes the natural log of x.
|
110
|
+
log(x,B) |Float |Computes the base B log of x.
|
111
|
+
log10(x) |Float |Returns the base 10 logarithm of x.
|
112
|
+
log2(x) |Float |Returns the base 2 logarithm of x.
|
113
|
+
sin(x) |Float |Computes the sine of x (expressed in radians).
|
114
|
+
| |Returns a Float in the range -1.0..1.0.
|
115
|
+
sinh(x) |Float |Computes the hyperbolic sine of x (expressed in radians).
|
116
|
+
sqrt(x) |Float |Returns the non-negative square root of x.
|
117
|
+
tan(x) |Float |Computes the tangent of x (expressed in radians).
|
118
|
+
tanh(x) |Float |Computes the hyperbolic tangent of x (expressed in radians).
|
119
|
+
| |
|
120
|
+
PI |Float |The value 3.141592653589793
|
121
|
+
E |Float |The value 2.718281828459045
|
122
|
+
|
123
|
+
#### Internal mysh commands:
|
124
|
+
|
125
|
+
Internal commands are recognized by name and are executed by mysh directly.
|
126
|
+
|
127
|
+
The following set of commands are supported:
|
128
|
+
|
129
|
+
```
|
130
|
+
! Display the mysh command history.
|
131
|
+
? Display help information for mysh.
|
132
|
+
cd <dir> Change directory to the optional <dir> parameter.
|
133
|
+
Then display the current working directory.
|
134
|
+
exit Exit mysh.
|
135
|
+
help Display help information for mysh.
|
136
|
+
history Display the mysh command history.
|
137
|
+
pwd Display the current working directory.
|
138
|
+
quit Exit mysh.
|
139
|
+
```
|
140
|
+
|
141
|
+
#### External commands:
|
142
|
+
|
143
|
+
All other commands are executed by the system using the standard shell or
|
144
|
+
the appropriate ruby interpreter.
|
145
|
+
|
146
|
+
Notes:
|
147
|
+
* If an internal command has the same name as an external command, adding a
|
148
|
+
leading space will force the use of the external command.
|
149
|
+
* If the command has a '.rb' extension, it is executed by the appropriate ruby
|
150
|
+
interpreter. The interpreter used is the one specified by RbConfig.ruby
|
151
|
+
|
152
|
+
## Embedding mysh in an application.
|
168
153
|
|
169
154
|
The mysh can also be used from within a Ruby application:
|
170
155
|
|
171
156
|
```ruby
|
157
|
+
require "mysh"
|
158
|
+
|
159
|
+
#Some stuff omitted.
|
160
|
+
|
172
161
|
Mysh.run
|
173
162
|
```
|
174
163
|
|
175
|
-
|
164
|
+
#### Adding New Commands
|
176
165
|
|
177
|
-
It is possible to add new internal commands to the mysh CLI. This
|
178
|
-
depositing the appropriate ruby file in the commands folder located
|
166
|
+
It is possible to add new internal commands to the mysh CLI. This may done
|
167
|
+
manually by depositing the appropriate ruby file in the commands folder located
|
168
|
+
at:
|
179
169
|
|
180
|
-
|
170
|
+
<gem_root>/mysh/lib/mysh/commands
|
181
171
|
|
182
|
-
|
183
|
-
|
172
|
+
A survey of the contents of that folder will reveal the nature of these
|
173
|
+
command files.
|
184
174
|
|
185
|
-
|
186
|
-
|
175
|
+
New internal commands may also be added in code via the the add method of the
|
176
|
+
InternalCommand class of the Mysh module. The code to do this would look
|
177
|
+
something like this:
|
187
178
|
|
188
|
-
|
179
|
+
```ruby
|
189
180
|
module Mysh
|
190
|
-
|
191
|
-
#* cd.rb -- The mysh internal cd command.
|
192
181
|
class InternalCommand
|
193
|
-
#Add the cd command to the library.
|
194
|
-
desc = ['Change directory to the optional <dir> parameter.',
|
195
|
-
'Then display the current working directory.']
|
196
|
-
|
197
|
-
add('cd <dir>', desc) do |args|
|
198
|
-
begin
|
199
|
-
Dir.chdir(args[0]) unless args.empty?
|
200
|
-
puts decorate(Dir.pwd)
|
201
|
-
rescue => err
|
202
|
-
puts "Error: #{err}"
|
203
|
-
end
|
204
|
-
end
|
205
182
|
|
206
|
-
|
207
|
-
|
208
|
-
begin
|
209
|
-
puts decorate(Dir.pwd)
|
210
|
-
rescue => err
|
211
|
-
puts "Error: #{err}"
|
212
|
-
end
|
183
|
+
add(command_name, command_description) do |args|
|
184
|
+
# Action block goes here
|
213
185
|
end
|
214
186
|
|
215
187
|
end
|
216
188
|
end
|
217
189
|
```
|
218
190
|
|
219
|
-
Note that the plug in code is contained within the InternalCommand class under
|
220
|
-
the Mysh module umbrella. The principle method used to create internal commands
|
221
|
-
is the add method:
|
222
|
-
|
223
|
-
```ruby
|
224
|
-
add(command_name, command_description) do |args|
|
225
|
-
# Action block goes here
|
226
|
-
end
|
227
|
-
```
|
228
191
|
Where:
|
229
192
|
* command_name is the name of the command with optional argument descriptions
|
230
|
-
|
193
|
+
separated with spaces. The command is the first word of this string.
|
231
194
|
* command_description is a string or an array of strings that describe the
|
232
195
|
command.
|
233
196
|
* args is an array of zero or more arguments that were entered with the command.
|
234
197
|
|
235
|
-
Commands sometimes have more than one possible name. This is supported with
|
198
|
+
Commands sometimes have more than one possible name. This is supported with
|
199
|
+
the add_alias method:
|
236
200
|
|
237
201
|
```ruby
|
238
|
-
|
202
|
+
module Mysh
|
203
|
+
class InternalCommand
|
204
|
+
|
205
|
+
add_alias(new_name, old_name)
|
206
|
+
|
207
|
+
end
|
208
|
+
end
|
239
209
|
```
|
240
210
|
|
241
211
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
#* commands/command_path.rb -- A convenient hook to the command folder.
|
4
|
+
module Mysh
|
5
|
+
|
6
|
+
#* commands/command_path.rb -- A convenient hook to the command folder.
|
7
|
+
class InternalCommand
|
8
|
+
|
9
|
+
#Capture this folder's name.
|
10
|
+
COMMAND_PATH = File.dirname(__FILE__) + "/"
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
data/lib/mysh/commands/help.rb
CHANGED
@@ -1,25 +1,16 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
#* commands/
|
3
|
+
#* commands/help.rb -- The mysh internal help command.
|
4
4
|
module Mysh
|
5
5
|
|
6
|
-
#*
|
6
|
+
#* help.rb -- The mysh internal help command.
|
7
7
|
class InternalCommand
|
8
|
-
#Show a help file
|
9
|
-
def show_help(name)
|
10
|
-
full_name = File.dirname(__FILE__) + name
|
11
|
-
str = IO.read(full_name)
|
12
|
-
puts process_erb_string(str)
|
13
|
-
rescue StandardError, ScriptError => err
|
14
|
-
puts "Error processing file #{full_name}"
|
15
|
-
puts "#{err.class.to_s}: #{err}"
|
16
|
-
end
|
17
8
|
|
18
9
|
HELP = Hash.new(lambda {|args| puts "No help found for #{args[0]}." })
|
19
10
|
|
20
|
-
HELP[nil] = lambda {|_args|
|
21
|
-
HELP['math'] = lambda {|_args|
|
22
|
-
HELP['ruby'] = lambda {|_args|
|
11
|
+
HELP[nil] = lambda {|_args| show_file('help.txt') }
|
12
|
+
HELP['math'] = lambda {|_args| show_file('help_math.txt') }
|
13
|
+
HELP['ruby'] = lambda {|_args| show_file('help_ruby.txt') }
|
23
14
|
|
24
15
|
#Add the exit command to the library.
|
25
16
|
add('help', 'Display help information for mysh.') do |args|
|
data/lib/mysh/commands/help.txt
CHANGED
@@ -4,32 +4,35 @@ In mysh, commands fall into one of three broad categories. There are:
|
|
4
4
|
|
5
5
|
1) Ruby expressions:
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
- For more information on ruby expressions use the 'help ruby' command.
|
7
|
+
Any line beginning with an equals "=" sign will be evaluated as a Ruby
|
8
|
+
expression. This allows the mysh command line to serve as a programming,
|
9
|
+
debugging and super-calculator environment.
|
11
10
|
|
12
|
-
|
13
|
-
|
11
|
+
For more information on ruby expressions use the 'help ruby' command.
|
12
|
+
|
13
|
+
Note: This environment includes support for advanced mathematical operations.
|
14
|
+
For more information on this feature, use the 'help math' command.
|
14
15
|
|
15
16
|
2) Internal mysh commands:
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
Internal commands are processed within mysh itself. Any command that matches
|
19
|
+
the name of an internal command is processed internally by mysh.
|
20
|
+
|
21
|
+
The following set of commands are supported:
|
20
22
|
|
21
23
|
{{ format_items(InternalCommand.command_info).join("\n") }}
|
22
24
|
|
23
25
|
3) External commands:
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
interpreter. So the command "myfile.rb" is executed as
|
27
|
+
All other commands are executed by the system using the standard shell or the
|
28
|
+
appropriate ruby interpreter.
|
29
|
+
|
30
|
+
If the command has a '.rb' extension, it is executed by the appropriate ruby
|
31
|
+
interpreter. So the command "myfile.rb" is executed as
|
31
32
|
|
32
33
|
{{ RbConfig.ruby }} myfile.rb"
|
33
34
|
|
34
|
-
|
35
|
+
Note: If an internal command has the same name as an external command, adding a
|
36
|
+
leading space will force the use of the external command.
|
37
|
+
|
35
38
|
|
@@ -1,7 +1,9 @@
|
|
1
1
|
mysh Math support summary
|
2
2
|
|
3
3
|
The Ruby expression execution environment has direct access to many advanced
|
4
|
-
|
4
|
+
mathematical functions and values.
|
5
|
+
|
6
|
+
For example, to compute the cosine of 3.141592653589793 use:
|
5
7
|
|
6
8
|
mysh> =cos(PI)
|
7
9
|
-1.0
|
@@ -28,7 +30,8 @@ frexp(x) Array Returns a two-element array containing the normalized
|
|
28
30
|
gamma(x) Float Calculates the gamma function of x.
|
29
31
|
hypot(x,y) Float Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled
|
30
32
|
triangle with sides x and y.
|
31
|
-
ldexp(
|
33
|
+
ldexp(m,e) Float Returns the value of m*(2**e). Where m is the mantissa and
|
34
|
+
e is the base two exponent.
|
32
35
|
lgamma(x) Array Returns a two-element array containing the log of the
|
33
36
|
gamma of x and the sign of gamma of x.
|
34
37
|
log(x) Float Computes the natural log of x.
|
@@ -1,17 +1,20 @@
|
|
1
1
|
mysh Ruby expression support summary
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
- Auto-complete always places any file names in quotes so they can be used
|
9
|
-
as string parameters.
|
3
|
+
All command lines that begin with an equals ("=") sign are evaluated as Ruby
|
4
|
+
expressions. Lines ending with a backslash character ("\") are continued on the
|
5
|
+
next line. The prompt changes to "mysh\" to indicate that this is going on. The
|
6
|
+
command is NOT actually processed until a line with NO trailing backslash is
|
7
|
+
entered.
|
10
8
|
|
11
|
-
|
9
|
+
The results of the expression are displayed using the pretty-print facility.
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
Note: Auto-complete always places any file names in quotes so they can be used
|
12
|
+
as string parameters.
|
13
|
+
|
14
|
+
A few noteworthy special methods exist:
|
15
|
+
|
16
|
+
=reset Reset the execution environment to the default state.
|
17
|
+
=result Returns the result of the previous expression.
|
18
|
+
=vls "mask" List modules with version info. The optional mask string value is
|
19
|
+
used to filter for modules containing that string.
|
17
20
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
#* commands/
|
3
|
+
#* commands/history.rb -- The mysh internal history command.
|
4
4
|
module Mysh
|
5
5
|
|
6
|
-
#*
|
6
|
+
#* history.rb -- The mysh internal history command.
|
7
7
|
class InternalCommand
|
8
8
|
#Add the exit command to the library.
|
9
9
|
add('history', 'Display the mysh command history.') do |args|
|
data/lib/mysh/internal.rb
CHANGED
@@ -5,7 +5,8 @@ require_relative 'support/parse'
|
|
5
5
|
require_relative 'support/format'
|
6
6
|
require_relative 'support/frame'
|
7
7
|
require_relative 'support/decorate'
|
8
|
-
require_relative '
|
8
|
+
require_relative 'commands/command_path'
|
9
|
+
require_relative 'support/handlebars'
|
9
10
|
|
10
11
|
#Load up the internal commands!
|
11
|
-
Dir[
|
12
|
+
Dir[Mysh::InternalCommand::COMMAND_PATH + '*.rb'].each {|file| require file }
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
#* support/handlebars.rb -- Allow text files to embed ruby code.
|
4
|
+
module Mysh
|
5
|
+
|
6
|
+
#The mysh embedded ruby text formatting.
|
7
|
+
class InternalCommand
|
8
|
+
|
9
|
+
#Process a string with embedded Ruby code.
|
10
|
+
def expand_handlebars(str)
|
11
|
+
loop do
|
12
|
+
pre_match, match, post_match = str.partition(/{{.*?}}/m)
|
13
|
+
|
14
|
+
return pre_match if match.empty?
|
15
|
+
|
16
|
+
str = pre_match + eval(match[2...-2]) + post_match
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
#Show a file with embedded ruby handlebars.
|
21
|
+
def show_file(name)
|
22
|
+
puts expand_handlebars(IO.read(full_name = COMMAND_PATH + name))
|
23
|
+
rescue StandardError, ScriptError => err
|
24
|
+
puts "Error in file: #{full_name}\n#{err.class}: #{err}"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
data/lib/mysh/version.rb
CHANGED
data/tests/my_shell_tests.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Camilleri
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- bin/mysh
|
153
153
|
- lib/mysh.rb
|
154
154
|
- lib/mysh/commands/cd.rb
|
155
|
+
- lib/mysh/commands/command_path.rb
|
155
156
|
- lib/mysh/commands/exit.rb
|
156
157
|
- lib/mysh/commands/help.rb
|
157
158
|
- lib/mysh/commands/help.txt
|
@@ -165,9 +166,9 @@ files:
|
|
165
166
|
- lib/mysh/support/decorate.rb
|
166
167
|
- lib/mysh/support/format.rb
|
167
168
|
- lib/mysh/support/frame.rb
|
169
|
+
- lib/mysh/support/handlebars.rb
|
168
170
|
- lib/mysh/support/manage.rb
|
169
171
|
- lib/mysh/support/parse.rb
|
170
|
-
- lib/mysh/support/text_erb.rb
|
171
172
|
- lib/mysh/version.rb
|
172
173
|
- mysh.gemspec
|
173
174
|
- rakefile.rb
|
@@ -197,6 +198,6 @@ rubyforge_project:
|
|
197
198
|
rubygems_version: 2.2.2
|
198
199
|
signing_key:
|
199
200
|
specification_version: 4
|
200
|
-
summary: mysh -- a Ruby inspired command shell
|
201
|
+
summary: mysh -- a Ruby inspired command shell.
|
201
202
|
test_files: []
|
202
203
|
has_rdoc:
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
#* support/text_erb.rb -- Allow text files to embed ruby code.
|
4
|
-
module Mysh
|
5
|
-
|
6
|
-
#The mysh embedded ruby report formatting.
|
7
|
-
class InternalCommand
|
8
|
-
|
9
|
-
#Process a string with embedded Ruby code.
|
10
|
-
def process_erb_string(str)
|
11
|
-
loop do
|
12
|
-
pre_match, match, post_match = str.partition(/{{.*?}}/m)
|
13
|
-
|
14
|
-
return pre_match if match.empty?
|
15
|
-
|
16
|
-
str = pre_match + eval(match[2...-2]) + post_match
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|