mysh 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc384b16374733a18131ead73b90537a16f06b1a
4
- data.tar.gz: aaa9a7f9e10bf52d685e9fdb6a2ec1de8c92eb60
3
+ metadata.gz: 6d1ba8a1e0f44a3d96f072108abe9bba55aefebf
4
+ data.tar.gz: f5811e7f8aeba916be0b9dccd4864282314cb0f0
5
5
  SHA512:
6
- metadata.gz: 15b4e08c89be15e6ef264734cde9c2a0314dcd65ab00e5702dace3303d8c6cfd209ccb05597c8b7404c4cb94735370df7a53dc75251ff084d848cf718ff28bba
7
- data.tar.gz: 6549e793c55788c7dc64dc147dee847140131881de18959159badaf9560cab01d2360a87973dc4adcd31c5c9dfafe0863e7f1c0301b3dc221bf95c8d129e6421
6
+ metadata.gz: a81089b6f2bf37d034eb8d1860774999e531ac34042d371dc9348090639f232c4d177cbfaee70220e24f68bd7a4e63420d39ba5fa983d14a1d3034a92d0bf432
7
+ data.tar.gz: 57a32385f635325c19ea131c79c1e8463ec7f405ff11a4e35934a64bae57baf54b07c8069c7050ce9f4b7f353b492d289f66fc854d97399437ce8c8c1439bef3
data/README.md CHANGED
@@ -20,6 +20,9 @@ command shell within Ruby applications and Rails web sites.
20
20
  See the original article at:
21
21
  (http://www.blackbytes.info/2016/07/writing-a-shell-in-ruby/)
22
22
 
23
+ By the way. The briefest look at the code will reveal that mysh has grown to be
24
+ way more than 25 lines long. Gotta love dem features!
25
+
23
26
  ## Installation
24
27
 
25
28
  Add this line to your application's Gemfile:
@@ -80,45 +83,37 @@ mysh> =cos(PI)
80
83
 
81
84
  The following table describes the available math functions.
82
85
 
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
86
+ Function |Type |Description
87
+ -----------|------|-----------------------------------------------------
88
+ acos(x) |Float |The arc cosine of x. Returns 0..π.
89
+ acosh(x) |Float |The inverse hyperbolic cosine of x.
90
+ asin(x) |Float |The arc sine of x. Returns -π/2..π/2.
91
+ asinh(x) |Float |The inverse hyperbolic sine of x.
92
+ atan(x) |Float |The arc tangent of x. Returns -π/2..π/2.
93
+ atan2(y,x) |Float |The arc tangent given y and x. Returns -π..π.
94
+ atanh(x) |Float |The inverse hyperbolic tangent of x.
95
+ cbrt(x) |Float |The cube root of x. (∛x)
96
+ cos(x) |Float |The cosine of x (in radians). Returns -1.0..1.0.
97
+ cosh(x) |Float |The hyperbolic cosine of x (in radians).
98
+ erf(x) |Float |The error function of x.
99
+ erfc(x) |Float |The complementary error function of x.
100
+ exp(x) |Float |Raise e to the power of x. (e<sup>x</sup>).
101
+ frexp(x) |Array |Extracts a two-element array containing [fraction, exponent].
102
+ gamma(x) |Float |The gamma function of x. (&#915;x).
103
+ hypot(x,y) |Float |The hypotenuse of a right-angled triangle. &#8730;(x&#178; + y&#178;)
104
+ ldexp(m,e) |Float |Builds a value where f is the fraction and e is the exponent.
105
+ lgamma(x) |Array |Builds a two-element array [ln(&#124;&#915;x&#124;), sign(&#915;x)]
106
+ log(x) |Float |The natural log of x. (log<sub>e</sub> x) or (ln x).
107
+ log(x,b) |Float |The base b log of x. (log<sub>b</sub> x).
108
+ log10(x) |Float |The base 10 log of x. (log<sub>10</sub> x).
109
+ log2(x) |Float |The base 2 log of x. (log<sub>2</sub> x).
110
+ sin(x) |Float |The sine of x (in radians). Returns -1.0..1.0.
111
+ sinh(x) |Float |The hyperbolic sine of x (in radians).
112
+ sqrt(x) |Float |The non-negative square root of x. (&#8730;x).
113
+ tan(x) |Float |The tangent of x (in radians).
114
+ tanh(x) |Float |The hyperbolic tangent of x (in radians).
115
+ E |Float |The value e (2.718281828459045)
116
+ PI |Float |The value &#960; (3.141592653589793)
122
117
 
123
118
  #### Internal mysh commands:
124
119
 
@@ -129,8 +124,8 @@ The following set of commands are supported:
129
124
  ```
130
125
  ! Display the mysh command history.
131
126
  ? Display help information for mysh.
132
- cd <dir> Change directory to the optional <dir> parameter.
133
- Then display the current working directory.
127
+ cd <dir> Change directory to the optional <dir> parameter
128
+ and then display the current working directory.
134
129
  exit Exit mysh.
135
130
  help Display help information for mysh.
136
131
  history Display the mysh command history.
@@ -31,9 +31,9 @@ module Mysh
31
31
  input = @input.readline(prompt: 'mysh>')
32
32
 
33
33
  begin
34
- @exec_host.execute(input) ||
35
- InternalCommand.execute(input) ||
36
- ruby_execute(input) ||
34
+ @exec_host.execute(input) ||
35
+ Command.execute(input) ||
36
+ ruby_execute(input) ||
37
37
  system(input)
38
38
  rescue Interrupt => err
39
39
  puts err
@@ -4,12 +4,12 @@
4
4
  module Mysh
5
5
 
6
6
  #* cd.rb -- The mysh internal cd command.
7
- class InternalCommand
7
+ class Command
8
8
  #Add the cd command to the library.
9
- desc = ['Change directory to the optional <dir> parameter.',
10
- 'Then display the current working directory.']
9
+ desc = ['Change directory to the optional <dir> parameter',
10
+ 'and then display the current working directory.']
11
11
 
12
- add('cd <dir>', desc) do |args|
12
+ COMMANDS.add('cd <dir>', desc) do |args|
13
13
  begin
14
14
  Dir.chdir(args[0]) unless args.empty?
15
15
  puts decorate(Dir.pwd)
@@ -19,7 +19,7 @@ module Mysh
19
19
  end
20
20
 
21
21
  #Add the pwd command to the library.
22
- add('pwd', 'Display the current working directory.') do |args|
22
+ COMMANDS.add('pwd', 'Display the current working directory.') do |args|
23
23
  begin
24
24
  puts decorate(Dir.pwd)
25
25
  rescue => err
@@ -4,7 +4,7 @@
4
4
  module Mysh
5
5
 
6
6
  #* commands/command_path.rb -- A convenient hook to the command folder.
7
- class InternalCommand
7
+ class Command
8
8
 
9
9
  #Capture this folder's name.
10
10
  COMMAND_PATH = File.dirname(__FILE__) + "/"
@@ -4,13 +4,13 @@
4
4
  module Mysh
5
5
 
6
6
  #* exit.rb -- The mysh internal exit command.
7
- class InternalCommand
7
+ class Command
8
8
  #Add the exit command to the library.
9
- add('exit', 'Exit mysh.') do |args|
9
+ COMMANDS.add('exit', 'Exit mysh.') do |args|
10
10
  raise MiniReadlineEOI
11
11
  end
12
12
 
13
- add_alias('quit', 'exit')
13
+ COMMANDS.add_alias('quit', 'exit')
14
14
  end
15
15
  end
16
16
 
@@ -4,20 +4,39 @@
4
4
  module Mysh
5
5
 
6
6
  #* help.rb -- The mysh internal help command.
7
- class InternalCommand
7
+ class Command
8
8
 
9
- HELP = Hash.new(lambda {|args| puts "No help found for #{args[0]}." })
9
+ # Help topics
10
+ HELP = CommandPool.new do |args|
11
+ puts "No help found for #{args[0].inspect}."
12
+ end
13
+
14
+ HELP.add("", "General help on mysh.") do |args|
15
+ show_file('help.txt')
16
+ end
17
+
18
+ HELP.add("math", "Help on mysh math functions.") do |args|
19
+ show_file('help_math.txt')
20
+ end
21
+
22
+ HELP.add("=", "Help on mysh ruby expressions.") do |args|
23
+ show_file('help_expr.txt')
24
+ end
25
+
26
+ HELP.add("help", "Help on mysh help.") do |args|
27
+ show_file('help_help.txt')
28
+ end
29
+
30
+ HELP.add_alias('?', 'help')
10
31
 
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') }
32
+ # The base help command.
33
+ desc = 'Display help information for mysh with an optional topic.'
14
34
 
15
- #Add the exit command to the library.
16
- add('help', 'Display help information for mysh.') do |args|
17
- instance_exec(args, &HELP[args[0]])
35
+ COMMANDS.add('help <topic>', desc) do |args|
36
+ HELP[args[0] || ""].execute(args)
18
37
  end
19
38
 
20
- add_alias('?', 'help')
39
+ COMMANDS.add_alias('? <topic>', 'help')
21
40
 
22
41
  end
23
42
 
@@ -1,5 +1,9 @@
1
1
  mysh (MY ruby SHell) version: {{ Mysh::VERSION }}
2
2
 
3
+ The mysh is a shell program inspired by the Ruby programming language in the
4
+ same way the csh was inspired by the "C" programming language. The name rsh
5
+ was already widely in use so it was mysh for some extra ego.
6
+
3
7
  In mysh, commands fall into one of three broad categories. There are:
4
8
 
5
9
  1) Ruby expressions:
@@ -8,7 +12,7 @@ Any line beginning with an equals "=" sign will be evaluated as a Ruby
8
12
  expression. This allows the mysh command line to serve as a programming,
9
13
  debugging and super-calculator environment.
10
14
 
11
- For more information on ruby expressions use the 'help ruby' command.
15
+ For more information on ruby expressions use the 'help =' command.
12
16
 
13
17
  Note: This environment includes support for advanced mathematical operations.
14
18
  For more information on this feature, use the 'help math' command.
@@ -20,7 +24,7 @@ the name of an internal command is processed internally by mysh.
20
24
 
21
25
  The following set of commands are supported:
22
26
 
23
- {{ format_items(InternalCommand.command_info).join("\n") }}
27
+ {{ format_items(COMMANDS.command_info).join("\n") }}
24
28
 
25
29
  3) External commands:
26
30
 
@@ -1,4 +1,4 @@
1
- mysh Ruby expression support summary
1
+ mysh Ruby expression support summary:
2
2
 
3
3
  All command lines that begin with an equals ("=") sign are evaluated as Ruby
4
4
  expressions. Lines ending with a backslash character ("\") are continued on the
@@ -0,0 +1,9 @@
1
+ mysh Help command summary:
2
+
3
+ The help (or ?) command is used to get either general help about mysh
4
+ or an optional specified topic.
5
+
6
+ The available help topics are:
7
+
8
+ {{ format_items(HELP.command_info).join("\n") }}
9
+
@@ -1,4 +1,4 @@
1
- mysh Math support summary
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.
@@ -8,43 +8,36 @@ For example, to compute the cosine of 3.141592653589793 use:
8
8
  mysh> =cos(PI)
9
9
  -1.0
10
10
 
11
- Method Returns Description
12
- ======= ======= ================================================
13
- acos(x) Float Computes the arc cosine of x. Returns 0..PI.
14
- acosh(x) Float Computes the inverse hyperbolic cosine of x.
15
- asin(x) Float Computes the arc sine of x. Returns -PI/2..PI/2.
16
- asinh(x) Float Computes the inverse hyperbolic sine of x.
17
- atan(x) Float Computes the arc tangent of x. Returns -PI/2..PI/2.
18
- atan2(y,x) Float Computes the arc tangent given y and x.
19
- Returns a Float in the range -PI..PI.
20
- atanh(x) Float Computes the inverse hyperbolic tangent of x.
21
- cbrt(x) Float Returns the cube root of x.
22
- cos(x) Float Computes the cosine of x (expressed in radians).
23
- Returns a Float in the range -1.0..1.0.
24
- cosh(x) Float Computes the hyperbolic cosine of x (expressed in radians).
25
- erf(x) Float Calculates the error function of x.
26
- erfc(x) Float Calculates the complementary error function of x.
27
- exp(x) Float Returns e**x.
28
- frexp(x) Array Returns a two-element array containing the normalized
29
- fraction (a Float) and exponent (a Fixnum) of x.
30
- gamma(x) Float Calculates the gamma function of x.
31
- hypot(x,y) Float Returns sqrt(x**2 + y**2), the hypotenuse of a right-angled
32
- triangle with sides x and y.
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.
35
- lgamma(x) Array Returns a two-element array containing the log of the
36
- gamma of x and the sign of gamma of x.
37
- log(x) Float Computes the natural log of x.
38
- log(x,B) Float Computes the base B log of x.
39
- log10(x) Float Returns the base 10 logarithm of x.
40
- log2(x) Float Returns the base 2 logarithm of x.
41
- sin(x) Float Computes the sine of x (expressed in radians).
42
- Returns a Float in the range -1.0..1.0.
43
- sinh(x) Float Computes the hyperbolic sine of x (expressed in radians).
44
- sqrt(x) Float Returns the non-negative square root of x.
45
- tan(x) Float Computes the tangent of x (expressed in radians).
46
- tanh(x) Float Computes the hyperbolic tangent of x (expressed in radians).
11
+ Method Type Description
12
+ ======= ===== ================================================
13
+ acos(x) Float The arc cosine of x. Returns 0..PI.
14
+ acosh(x) Float The inverse hyperbolic cosine of x.
15
+ asin(x) Float The arc sine of x. Returns -PI/2..PI/2.
16
+ asinh(x) Float The inverse hyperbolic sine of x.
17
+ atan(x) Float The arc tangent of x. Returns -PI/2..PI/2.
18
+ atan2(y,x) Float The arc tangent given y and x. Returns -PI..PI.
19
+ atanh(x) Float The inverse hyperbolic tangent of x.
20
+ cbrt(x) Float The cube root of x.
21
+ cos(x) Float The cosine of x (in radians). Returns -1.0..1.0.
22
+ cosh(x) Float The hyperbolic cosine of x (in radians).
23
+ erf(x) Float The error function of x.
24
+ erfc(x) Float The complementary error function of x.
25
+ exp(x) Float Raise e to the xth. (e**x).
26
+ frexp(x) Array Extracts a two-element array containing [fraction, exponent].
27
+ gamma(x) Float The gamma function of x.
28
+ hypot(x,y) Float The hypotenuse of a right-angled triangle with sides x & y.
29
+ ldexp(f,e) Float Builds a value where f is the fraction and e is the exponent.
30
+ lgamma(x) Array Builds a two-element array [ln(gamma(x)), sign(gamma(x))]
31
+ log(x) Float The natural log of x.
32
+ log(x,B) Float The base B log of x.
33
+ log10(x) Float The base 10 logarithm of x.
34
+ log2(x) Float The base 2 logarithm of x.
35
+ sin(x) Float The sine of x (in radians). Returns -1.0..1.0.
36
+ sinh(x) Float The hyperbolic sine of x (in radians).
37
+ sqrt(x) Float The non-negative square root of x.
38
+ tan(x) Float The tangent of x (in radians).
39
+ tanh(x) Float The hyperbolic tangent of x (in radians).
47
40
 
48
- PI Float The value 3.141592653589793
49
- E Float The value 2.718281828459045
41
+ E Float The value 2.718281828459045
42
+ PI Float The value 3.141592653589793
50
43
 
@@ -4,9 +4,9 @@
4
4
  module Mysh
5
5
 
6
6
  #* history.rb -- The mysh internal history command.
7
- class InternalCommand
7
+ class Command
8
8
  #Add the exit command to the library.
9
- add('history', 'Display the mysh command history.') do |args|
9
+ COMMANDS.add('history', 'Display the mysh command history.') do |args|
10
10
  history = Mysh.input.history
11
11
 
12
12
  #The history command should not be part of the history.
@@ -15,7 +15,7 @@ module Mysh
15
15
  puts history
16
16
  end
17
17
 
18
- add_alias('!', 'history')
18
+ COMMANDS.add_alias('!', 'history')
19
19
  end
20
20
  end
21
21
 
@@ -1,12 +1,13 @@
1
1
  # coding: utf-8
2
2
 
3
+ require_relative 'commands/command_path'
4
+ require_relative 'support/frame'
5
+ require_relative 'support/command_pool'
3
6
  require_relative 'support/manage'
4
7
  require_relative 'support/parse'
5
8
  require_relative 'support/format'
6
- require_relative 'support/frame'
7
9
  require_relative 'support/decorate'
8
- require_relative 'commands/command_path'
9
10
  require_relative 'support/handlebars'
10
11
 
11
12
  #Load up the internal commands!
12
- Dir[Mysh::InternalCommand::COMMAND_PATH + '*.rb'].each {|file| require file }
13
+ Dir[Mysh::Command::COMMAND_PATH + '*.rb'].each {|file| require file }
@@ -0,0 +1,54 @@
1
+ # coding: utf-8
2
+
3
+ #* support/command_pool.rb -- A managed hash of mysh commands.
4
+ module Mysh
5
+
6
+ #* support/command_pool.rb -- A managed hash of mysh commands.
7
+ class CommandPool
8
+
9
+ #Create a new command pool
10
+ def initialize(&default_action)
11
+ @pool = {}
12
+
13
+ if default_action
14
+ @pool.default = Command.new("", "", &default_action)
15
+ end
16
+ end
17
+
18
+ #Get a command.
19
+ def [](index)
20
+ @pool[index]
21
+ end
22
+
23
+ #Add a command.
24
+ def add(name, description, &action)
25
+ split_name = name.split[0] || ""
26
+
27
+ @pool[split_name] = Command.new(name, description, &action)
28
+ end
29
+
30
+ #Add an alias for an existing command.
31
+ def add_alias(new_name, old_name)
32
+ unless (command = @pool[old_name])
33
+ fail "Error adding alias #{new_name} for #{old_name}"
34
+ end
35
+
36
+ split_name = new_name.split[0]
37
+
38
+ @pool[split_name] =
39
+ Command.new(new_name, command.description, &command.action)
40
+ end
41
+
42
+ #Get information on all commands.
43
+ def command_info
44
+ @pool
45
+ .values
46
+ .map {|command| command.command_info }
47
+ .sort {|first, second| first[0] <=> second[0] }
48
+ end
49
+
50
+ end
51
+
52
+
53
+ end
54
+
@@ -4,7 +4,7 @@
4
4
  module Mysh
5
5
 
6
6
  #The mysh internal file name beauty treatments.
7
- class InternalCommand
7
+ class Command
8
8
 
9
9
  #Make the file name fit the local system.
10
10
  def decorate(name)
@@ -4,15 +4,7 @@
4
4
  module Mysh
5
5
 
6
6
  #The mysh internal command class level report formatting.
7
- class InternalCommand
8
-
9
- #Get information on all commands.
10
- def self.command_info
11
- @commands
12
- .values
13
- .map {|command| command.command_info }
14
- .sort {|first, second| first[0] <=> second[0] }
15
- end
7
+ class Command
16
8
 
17
9
  #Display an array of items.
18
10
  def display_items(items)
@@ -4,7 +4,7 @@
4
4
  module Mysh
5
5
 
6
6
  #The mysh internal command instance data and methods.
7
- class InternalCommand
7
+ class Command
8
8
  #The name of the command.
9
9
  attr_reader :name
10
10
 
@@ -4,7 +4,7 @@
4
4
  module Mysh
5
5
 
6
6
  #The mysh embedded ruby text formatting.
7
- class InternalCommand
7
+ class Command
8
8
 
9
9
  #Process a string with embedded Ruby code.
10
10
  def expand_handlebars(str)
@@ -4,31 +4,10 @@
4
4
  module Mysh
5
5
 
6
6
  #The mysh internal command class level data and methods.
7
- class InternalCommand
7
+ class Command
8
8
 
9
9
  #Set up the command library hash.
10
- @commands = {}
11
-
12
- class << self
13
- #The command library, a hash.
14
- attr_reader :commands
15
- end
16
-
17
- #Add a command to the command library.
18
- def self.add(name, description, &action)
19
- @commands[name.split[0]] = new(name, description, &action)
20
- end
21
-
22
- #Add an alias for an existing command.
23
- def self.add_alias(new_name, old_name)
24
- unless (command = @commands[old_name])
25
- fail "Error adding alias #{new_name} for #{old_name}"
26
- end
27
-
28
- @commands[new_name] = new(new_name.split[0],
29
- command.description,
30
- &command.action)
31
- end
10
+ COMMANDS = CommandPool.new
32
11
 
33
12
  #Execute an internal command
34
13
  def self.execute(str)
@@ -4,7 +4,7 @@
4
4
  module Mysh
5
5
 
6
6
  #The mysh internal command instance data and methods.
7
- class InternalCommand
7
+ class Command
8
8
 
9
9
  #Parse a command string for use by commands.
10
10
  #<br>Endemic Code Smells
@@ -22,7 +22,7 @@ module Mysh
22
22
  end
23
23
  end
24
24
 
25
- [@commands[result.shift], result]
25
+ [COMMANDS[result.shift], result]
26
26
  end
27
27
 
28
28
  private
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Mysh
4
4
  #The version string of MY SHell.
5
- VERSION = "0.1.13"
5
+ VERSION = "0.1.14"
6
6
 
7
7
  #A brief summary of this gem.
8
8
  SUMMARY = "mysh -- a Ruby inspired command shell."
@@ -13,34 +13,32 @@ class MyShellTester < Minitest::Test
13
13
 
14
14
  def test_that_module_entities_exists
15
15
  assert_equal(Module, Mysh.class)
16
- assert_equal(Class, Mysh::InternalCommand.class)
16
+ assert_equal(Class, Mysh::Command.class)
17
17
  assert_equal(Class, Mysh::ExecHost.class)
18
18
  end
19
19
 
20
20
  def test_for_internal_commands
21
- assert(Mysh::InternalCommand.commands['exit'], "The exit command is missing.")
22
- assert(Mysh::InternalCommand.commands['quit'], "The quit command is missing.")
21
+ assert(Mysh::Command::COMMANDS['exit'], "The exit command is missing.")
22
+ assert(Mysh::Command::COMMANDS['quit'], "The quit command is missing.")
23
23
 
24
- assert(Mysh::InternalCommand.commands['history'], "The history command is missing.")
25
- assert(Mysh::InternalCommand.commands['!'], "The ! command is missing.")
24
+ assert(Mysh::Command::COMMANDS['history'], "The history command is missing.")
25
+ assert(Mysh::Command::COMMANDS['!'], "The ! command is missing.")
26
26
 
27
- assert(Mysh::InternalCommand.commands['help'], "The help command is missing.")
28
- assert(Mysh::InternalCommand.commands['?'], "The ? command is missing.")
27
+ assert(Mysh::Command::COMMANDS['help'], "The help command is missing.")
28
+ assert(Mysh::Command::COMMANDS['?'], "The ? command is missing.")
29
29
 
30
- assert(Mysh::InternalCommand.commands['cd'], "The cd command is missing.")
31
- assert(Mysh::InternalCommand.commands['pwd'], "The pwd command is missing.")
30
+ assert(Mysh::Command::COMMANDS['cd'], "The cd command is missing.")
31
+ assert(Mysh::Command::COMMANDS['pwd'], "The pwd command is missing.")
32
32
 
33
- assert_raises { Mysh::InternalCommand.add_alias('blam', 'shazzam') }
33
+ assert_raises { Mysh::Command::COMMANDS.add_alias('blam', 'shazzam') }
34
34
  end
35
35
 
36
36
  def test_handlebars
37
- cmd = Mysh::InternalCommand.commands['help']
37
+ cmd = Mysh::Command::COMMANDS['help']
38
38
 
39
39
  assert_equal("ABC 123 DEF",
40
40
  cmd.expand_handlebars("ABC {{ (1..3).to_a.join }} DEF"))
41
41
 
42
42
  end
43
43
 
44
-
45
-
46
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Camilleri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-29 00:00:00.000000000 Z
11
+ date: 2016-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -156,13 +156,15 @@ files:
156
156
  - lib/mysh/commands/exit.rb
157
157
  - lib/mysh/commands/help.rb
158
158
  - lib/mysh/commands/help.txt
159
+ - lib/mysh/commands/help_expr.txt
160
+ - lib/mysh/commands/help_help.txt
159
161
  - lib/mysh/commands/help_math.txt
160
- - lib/mysh/commands/help_ruby.txt
161
162
  - lib/mysh/commands/history.rb
162
163
  - lib/mysh/expression.rb
163
164
  - lib/mysh/external_ruby.rb
164
165
  - lib/mysh/internal.rb
165
166
  - lib/mysh/smart_source.rb
167
+ - lib/mysh/support/command_pool.rb
166
168
  - lib/mysh/support/decorate.rb
167
169
  - lib/mysh/support/format.rb
168
170
  - lib/mysh/support/frame.rb