mysh 0.5.4 → 0.5.5

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: 5478d3cef2ba8f978c1820f27a6216f333c8a059
4
- data.tar.gz: f3e32f21470957690111afa9d643dcc8a5d12017
3
+ metadata.gz: 7f28af55da066abdf2b23c0dc611aa50a3df29fb
4
+ data.tar.gz: aa51017dff9ea5eecd03e13a4779df9a8d5d8cf5
5
5
  SHA512:
6
- metadata.gz: 9a48b751d65e6651dd798c09b50ba1db4a024b7637f9031de6e30b5984cfb6f8a62a3986a40b33a68e610bb3ed1d98b9285169c2a79b937a2b2fb4b0399af211
7
- data.tar.gz: 7fa25e64465fa35dc01bb5763e16ba1134c844fc37cfd0485f34a212cbaa0ca60b7d97fc949c5ac553f7ba1fdc07046cc31031c786d07348ff01d490b2b366fb
6
+ metadata.gz: 480fb4f616671c91a265c828230d69acd23294c4b4bce7a147632b4cff1d7789fb8e271de80d3154218b28bd87d85a28562df7659e2a1cd33eef2344a19c2be4
7
+ data.tar.gz: 579b5dbf09be38d59e7d9cf8178c853a14bcdd68b5d21d9da183d4d45da2503ed3874b408dda5fb024bfb461e1d59f4248428087db08471706594aa14c0138b7
data/README.md CHANGED
@@ -220,7 +220,7 @@ To assist in the creation of well formatted output, the mysh environment
220
220
  provides a number of "helper" methods in the Array and String classes. These
221
221
  are:
222
222
 
223
- * String#decorate - given a string with a file path/name value, express that
223
+ * String#to_host_spec - given a string with a file path/name value, express that
224
224
  string in a manner compatible with the current operating environment.
225
225
  * Array#format_mysh_columns - take an array and convert it to a string with nice
226
226
  regular columns.
@@ -232,7 +232,7 @@ bullet points. The appearance of each point depends on its structure. See below:
232
232
  This must all be confusing. Some examples may help:
233
233
 
234
234
  ```
235
- mysh>=puts "lib/mysh/expression/lineage.rb".decorate
235
+ mysh>=puts "lib/mysh/expression/lineage.rb".to_host_spec
236
236
  lib\mysh\expression\lineage.rb
237
237
 
238
238
  mysh>=(1..100).to_a.puts_mysh_columns
@@ -376,6 +376,8 @@ $h | The home folder's path
376
376
  $post_prompt| The prompt used when a line is continued with a trailing \\ character. By default this is the same as the normal prompt.
377
377
  $pre_prompt | A prompt string displayed before the actual command prompt. Delete the pre_prompt variable to disable pre-prompting.
378
378
  $prompt | The user prompt.
379
+ $r | The location of the Ruby compiler.
380
+ $s | The location of the host command interpreter.
379
381
  $t | The current time.
380
382
  $time_fmt | The format for the time: "%H:%M"
381
383
  $u | The current user.
@@ -391,9 +393,9 @@ environment. Just a few reminders:
391
393
 
392
394
  * Any line beginning with an equals "=" sign will be evaluated as a Ruby
393
395
  expression.
394
- * Expressions ending with a backslash character "\" are continued on the next
395
- line. The prompt changes to end with a "\" character to indicate that this is
396
- going on.
396
+ * Expressions ending with a backslash character "\\" are continued on the next
397
+ line. The prompt changes to end with a "\\" character to indicate that this
398
+ is going on.
397
399
  * The results of the expression are displayed using the pretty-print facility.
398
400
  * Auto-complete always places any file names in quotes so they can be used
399
401
  as string parameters.
@@ -476,18 +478,23 @@ Topic | Description
476
478
  none | General help on mysh.
477
479
  ! | Help on the history command.
478
480
  $ | Help on mysh variables.
481
+ % | Help on timed command execution.
479
482
  = | Help on ruby expressions.
480
483
  ? | This help on the help command.
481
484
  @ | Help on the show command.
485
+ args | Help on mysh command arguments.
482
486
  env | Help on the show env command.
483
487
  gls | Help on gls internal mysh command.
484
488
  help | This help on the help command.
485
489
  history | Help on the history command.
490
+ init | Help on mysh initialization.
486
491
  kbd | Help on mysh keyboard mapping.
487
492
  math | Help on math functions.
493
+ mls | Help on mls internal mysh command.
488
494
  quick | Help on quick commands.
489
495
  ruby | Help on the show ruby command.
490
496
  show | Help on the show command.
497
+ types | Help on mysh file types.
491
498
  usage | Help on mysh usage options.
492
499
  {{ | Help on mysh handlebars.
493
500
 
@@ -507,6 +514,7 @@ environment.
507
514
 
508
515
  Topic | Description
509
516
  ---------|----------------------------------------------------
517
+ about | A brief description of the mysh shell program.
510
518
  version | The version of mysh in use.
511
519
  init file| The init file in use or <none found> or <none>.
512
520
  user | The current user name.
@@ -556,14 +564,14 @@ Command | Description
556
564
  ---------------|----------------------------------------------------
557
565
  cd {dir} | Change directory to the optional dir parameter and then display the current working directory.
558
566
  exit | Exit mysh.
559
- gls {-l} {mask}| Display the loaded ruby gems. Use optional -l for a more details and a mask to limit output.
567
+ gls {-l} {mask}| Display the loaded ruby gems. See ?gls for more.
560
568
  history {index}| The mysh command history. If an index is specified, get the command with that index value.
561
569
  load file | Load a ruby program, mysh script, or text file into the mysh environment.
570
+ mls {mask} | Display modules with version info. See ?mls for more.
562
571
  pwd | Display the current working directory.
563
572
  quit | Exit mysh.
564
573
  say <stuff> | Display the text in the command arguments.
565
574
  type file | Display a text file with support for optional embedded handlebars and mysh variables.
566
- vls {mask} | Display the loaded modules, matching the optional mask, that have version info.
567
575
 
568
576
  Notes:
569
577
  1. The notation {x} means that x is optional.
@@ -600,7 +608,7 @@ Extension | Description
600
608
  ---------------|----------------------------------------------------
601
609
  .rb | A ruby source file executed via a new instance of the compiler.
602
610
  .mysh | A mysh script file. Commands in this file are executed as if the user typed them in at the console.
603
- .txt | A text file. The file (with any embedded code and veriables) is displayed on the console.
611
+ .txt | A text file. The file (with any embedded code and variables) is displayed on the console.
604
612
 
605
613
  Here is a sample session with an external Ruby program.
606
614
 
@@ -764,11 +772,17 @@ Process the string for embedded variables and handlebars. By default,
764
772
  any embedded ruby is evaluated in the mysh global expression binding. However,
765
773
  another BindingWrapper instance may be passed to access an alternative binding.
766
774
 
767
- ###### "string".decorate
768
- Given a string with a file spec, decorate that string so that it is more
769
- pleasing to the local environment. This is a great boon to writing effortless
775
+ ###### "string".to_host_spec
776
+ Given a string with a file spec, to_host_spec adjusts that string so that it is
777
+ more pleasing to the local environment. This is a great boon to writing
778
+ effortless portable code.
779
+
780
+ ###### "string".to_std_spec
781
+ Given a string with a file spec, to_std_spec adjusts that string so that it is
782
+ compatible with standard usage. This is a great boon to writing effortless
770
783
  portable code.
771
784
 
785
+
772
786
  #### Adding Help Topics
773
787
 
774
788
  In mysh, help topics are generally implemented as text files often augmented
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
3
  require 'pp'
4
- require 'mathn'
5
4
  require_relative 'expression/lineage'
6
5
 
7
6
  #* mysh/expression.rb -- The mysh ruby expression processor.
@@ -9,6 +8,10 @@ require_relative 'expression/lineage'
9
8
  #* :reek:ModuleInitialize -- False positive
10
9
  module Mysh
11
10
 
11
+ #Set up some popular constants
12
+ E = Math::E
13
+ PI = Math::PI
14
+
12
15
  #Reset the state of the execution hosting environment.
13
16
  #<br>Endemic Code Smells
14
17
  # :reek:TooManyStatements -- False positive
@@ -20,7 +20,7 @@ module Mysh
20
20
  end
21
21
 
22
22
  if $mysh_init_file
23
- mysh "load #{$mysh_init_file.decorate}"
23
+ mysh "load #{$mysh_init_file.to_host_spec}"
24
24
  else
25
25
  $mysh_init_file = '<none found>'
26
26
  end
@@ -32,7 +32,7 @@ module Mysh
32
32
 
33
33
  #Get the parameter text.
34
34
  def raw_body
35
- @raw_body ||= @raw[(raw_command.length)..-1]
35
+ @raw_body ||= @raw[(raw_command.length + 1)..-1] || ""
36
36
  end
37
37
 
38
38
  #Get the preprocessed argument text.
@@ -42,7 +42,8 @@ module Mysh
42
42
 
43
43
  #Access the massaged text.
44
44
  def cooked
45
- raw_command + cooked_body
45
+ body = cooked_body
46
+ raw_command + (body.empty? ? "" : " " + body)
46
47
  end
47
48
 
48
49
  #Get the parsed arguments
@@ -5,7 +5,7 @@ require_relative 'internal/action'
5
5
  require_relative 'internal/action_pool'
6
6
  require_relative 'internal/manage'
7
7
  require_relative 'internal/format'
8
- require_relative 'internal/decorate'
8
+ require_relative 'internal/to_file_spec'
9
9
 
10
10
  #Load up the internal actions!
11
11
  Dir[Mysh::Action::ACTIONS_PATH + '*.rb'].each {|file| require file }
@@ -22,7 +22,7 @@ module Mysh
22
22
 
23
23
  #Does this action exist?
24
24
  def exists?(index)
25
- @pool.has_key?(index)
25
+ @pool.key?(index)
26
26
  end
27
27
 
28
28
  #Add an action to the pool.
@@ -10,7 +10,7 @@ module Mysh
10
10
  action = lambda do |input|
11
11
  args = input.args
12
12
  Dir.chdir(args[0]) unless args.empty?
13
- puts Dir.pwd.decorate
13
+ puts Dir.pwd.to_host_spec
14
14
  end
15
15
 
16
16
  COMMANDS.add_action(Action.new('cd <dir>', desc, &action))
@@ -8,7 +8,7 @@ module Mysh
8
8
 
9
9
  #Skip over the argument for pre_boot.
10
10
  def pre_boot(read_point)
11
- file_name = get_arg(read_point).decorate
11
+ file_name = get_arg(read_point).to_host_spec
12
12
 
13
13
  if $mysh_init_file
14
14
  $mysh_init_file = $mysh_init_file.in_array + [file_name]
@@ -13,7 +13,7 @@ module Mysh
13
13
 
14
14
  #Execute the load command line option.
15
15
  def post_boot(read_point)
16
- mysh "load #{get_arg(read_point).decorate}"
16
+ mysh "load #{get_arg(read_point).to_host_spec}"
17
17
  end
18
18
 
19
19
  end
@@ -0,0 +1,20 @@
1
+ Available mysh command line arguments are:
2
+
3
+ Option+Short Forms Description Default
4
+ ================== =========== =======
5
+ --debug -d Turn on mysh debugging. false
6
+ --no-debug -nd Turn off mysh debugging.
7
+ --help -? -h Display mysh usage info and exit.
8
+ --init -i <name> Initialize mysh by loading the specified file.*
9
+ --no-init -ni Do not load a file to initialize mysh.
10
+ --load -l <name> Load the specified file into the mysh.
11
+ --post-prompt -pp "str" Set the mysh line continuation prompt to "str". $prompt
12
+ --no-post-prompt -npp Turn off mysh line continuation prompting.
13
+ --pre-prompt -pr"str" Set the mysh pre prompt to "str". \$w
14
+ --no-pre-prompt -npr Turn off mysh pre prompting.
15
+
16
+ --prompt -p "str" Set the mysh prompt to "str". "mysh"
17
+ --no-prompt -np Turn off mysh prompting.
18
+ --quit Quit out of the mysh program.
19
+
20
+ * See ?init for more details on the default file loaded.
@@ -14,6 +14,7 @@ java - Is the current platform powered by Java?
14
14
  term - What terminal is defined by the system, if one is defined.
15
15
  disp - What display is defined by the system, if one is defined.
16
16
  edit - What editor is defined by the system, if one is defined.
17
+ PID - The process ID of the mysh program.
17
18
 
18
19
  path - An easy-to-read, formatted version of the current search path.
19
20
 
@@ -6,7 +6,6 @@ usage template for this command is:
6
6
  mysh>gls <options> <mask>
7
7
 
8
8
  Where:
9
-
10
9
  <options> is one of:
11
10
  "-l" -- display detailed information on the selected gems.
12
11
  none -- display only the names of the selected gems.
@@ -0,0 +1,32 @@
1
+ Help: mysh initialization summary:
2
+
3
+ When mysh starts up, it must be initialized and acclimated to its environment.
4
+ The boot/initialization process of mysh is somewhat modeled after that of the
5
+ famous bash shell. On startup:
6
+
7
+ 1 Option values are initialized to their initial, default values.
8
+
9
+ 2 Process pre-boot command line options: Some command line options are
10
+ processed early. These are --help, -h, -?, --init, -i, --no-init, and -ni.
11
+ See Usage above for details on these.
12
+
13
+ 3 Try to load and execute the mysh_init file. There are three possible files
14
+ for this role. In priority order they are
15
+
16
+ ~/mysh_init.mysh,
17
+ ~/mysh_init.rb,
18
+ ~/mysh_init.txt.
19
+
20
+ NOTE: If an init file is specified with the --init option, or disabled with
21
+ the --no-init option, then this step is skipped.
22
+
23
+ 4 The rest of the command line options are processed at this time.
24
+
25
+ It should be noted that in the event of a conflict in settings during the boot
26
+ process, the last command/option encountered shall prevail. For example if
27
+ the ~/mysh_init.mysh contains the line:
28
+
29
+ \$debug = true
30
+
31
+ and the command line has the -nd option, then debug mode will be disabled
32
+ because the -nd command line option is processed after the mysh_init file.
@@ -0,0 +1,25 @@
1
+ Help: mysh mls command summary:
2
+
3
+ The mls (module list) command is used to provide version information for the
4
+ loaded ruby modules. The usage template for this command is:
5
+
6
+ mysh>mls <mask>
7
+
8
+ Where:
9
+ <mask> is an optional, case-sensitive pattern for filtering out the modules
10
+ displayed. If omitted, all modules are displayed.
11
+
12
+ Examples:
13
+
14
+ mysh>mls
15
+ DidYouMean 1.0.0
16
+ Gem 2.5.2
17
+ InArray 0.1.8
18
+ MiniReadline 0.8.0
19
+ Mysh 0.5.4
20
+ VersionLS 0.4.1
21
+
22
+ mysh>mls M
23
+ DidYouMean 1.0.0
24
+ MiniReadline 0.8.0
25
+ Mysh 0.5.4
@@ -14,7 +14,7 @@ module Mysh
14
14
 
15
15
  #Execute a help command.
16
16
  def process_command(_args)
17
- mysh "load #{(ACTIONS_PATH + 'help/' + @file_name).decorate}"
17
+ mysh "load #{(ACTIONS_PATH + 'help/' + @file_name).to_host_spec}"
18
18
  end
19
19
 
20
20
  end
@@ -25,6 +25,7 @@ module Mysh
25
25
  ['$', 'Help on mysh variables.', 'vars.txt' ],
26
26
  ['show', 'Help on the show command.', 'show.txt' ],
27
27
  ['@', 'Help on the show command.', 'show.txt' ],
28
+ ['%', 'Help on timed command execution.', 'timed.txt' ],
28
29
  ['env', 'Help on the show env command.', 'env.txt' ],
29
30
  ['ruby', 'Help on the show ruby command.', 'ruby.txt' ],
30
31
  ['math', 'Help on math functions.', 'math.txt' ],
@@ -32,10 +33,14 @@ module Mysh
32
33
  ['=', 'Help on ruby expressions.', 'expr.txt' ],
33
34
  ['quick', 'Help on quick commands.', 'quick.txt' ],
34
35
  ['gls', 'Help on gls internal mysh command.', 'gls.txt' ],
36
+ ['mls', 'Help on mls internal mysh command.', 'mls.txt' ],
35
37
  ['!', 'Help on the history command.', 'history.txt'],
36
38
  ['history', 'Help on the history command.', 'history.txt'],
37
39
  ['kbd', 'Help on mysh keyboard mapping.', 'kbd.txt' ],
38
40
  ['{{', 'Help on mysh handlebars.', 'hbar.txt' ],
41
+ ['init', 'Help on mysh initialization.', 'init.txt' ],
42
+ ['args', 'Help on mysh command arguments.', 'args.txt' ],
43
+ ['types', 'Help on mysh file types.', 'types.txt' ],
39
44
  ['help', 'This help on the help command.', 'h_o_h.txt' ],
40
45
  ['?', 'This help on the help command.', 'h_o_h.txt' ]
41
46
  ]
@@ -0,0 +1,18 @@
1
+ Help: mysh timed command summary:
2
+
3
+ Any command starting with a first character of % will be timed by mysh. This
4
+ timing occurs in real time at the accuracy of the host timing facilities
5
+ accessed by Ruby. No accounting for system access or other tasks is made.
6
+
7
+ Examples:
8
+
9
+ mysh>%say hello world
10
+ hello world
11
+ Elapsed execution time = 0.000 seconds.
12
+
13
+ mysh>%ls
14
+ CODE_OF_CONDUCT.md LICENSE.txt lib pkg samples
15
+ Gemfile README.md mysh.gemspec rakefile.rb tests
16
+ Gemfile.lock bin mysh.reek reek.txt
17
+ Elapsed execution time = 0.047 seconds.
18
+
@@ -0,0 +1,18 @@
1
+ Help: mysh supported file types.
2
+
3
+ The mysh shell has direct support for three types of external files. These are
4
+ mysh shell scripts, Ruby source files, and augmented text files
5
+
6
+ 1) The mysh shell scripts are identified by the ".mysh" file suffix. These
7
+ files contain mysh commands and are interpreted as if typed at the command
8
+ prompt by the user.
9
+
10
+ 2) The Ruby source files are just that, Ruby code that is loaded into mysh and
11
+ executed in the mysh context. These have access to the full power of the
12
+ Ruby Language system.
13
+
14
+ 3) The augmented text files are simple text files augmented with support for
15
+ mysh shell variables ($$var) and embedded code {\{ Ruby code goes here }}
16
+
17
+ This help file is an example of an augmented text file.
18
+
@@ -27,6 +27,8 @@ $$post_prompt The prompt used when a line is continued with a trailing \\
27
27
  $$pre_prompt A prompt string displayed before the actual command prompt.
28
28
  Delete the pre_prompt variable to disable pre-prompting.
29
29
  $$prompt The user prompt.
30
+ $$r The location of the Ruby interpreter.
31
+ $$s The location of the host command processor.
30
32
  $$t The current time.
31
33
  $$time_fmt The format for the time: "%H:%M". ie: 20:11
32
34
  $$u The current user.
@@ -56,7 +56,7 @@ module Mysh
56
56
  end
57
57
 
58
58
  #Add the history commands to the library.
59
- desc = 'Display the mysh command history. See ?! for more info.'
59
+ desc = 'Display the mysh command history. See ?! for more.'
60
60
  COMMANDS.add_action(HistoryCommand.new('history <arg>', desc))
61
61
  #The history command action object.
62
62
  HISTORY_COMMAND = HistoryCommand.new('!<arg>', desc)
@@ -32,5 +32,5 @@ module Mysh
32
32
  end
33
33
  end
34
34
 
35
- COMMANDS.add_action(Action.new('load file', desc, &action))
35
+ COMMANDS.add_action(Action.new('load <file>', desc, &action))
36
36
  end
@@ -2,12 +2,11 @@
2
2
 
3
3
  require 'vls'
4
4
 
5
- #* mysh/internal/actions/vls.rb -- The mysh module vls (Version LS) command.
5
+ #* mysh/internal/actions/mls.rb -- The mysh module ls command.
6
6
  module Mysh
7
7
 
8
- #Add the vls command to the library.
9
- desc = 'Display the loaded modules, matching the optional mask, that ' +
10
- 'have version info.'
8
+ #Add the mls command to the library.
9
+ desc = 'Display modules with version info. See ?mls for more.'
11
10
 
12
11
  action = lambda do |input|
13
12
  filter = input.args[0] || /./
@@ -20,5 +19,5 @@ module Mysh
20
19
  end
21
20
  end
22
21
 
23
- COMMANDS.add_action(Action.new('vls <mask>', desc, &action))
22
+ COMMANDS.add_action(Action.new('mls <mask>', desc, &action))
24
23
  end
@@ -4,7 +4,7 @@
4
4
  module Mysh
5
5
 
6
6
  desc = 'Display the current working directory.'
7
- action = lambda {|_input| puts Dir.pwd.decorate}
7
+ action = lambda {|_input| puts Dir.pwd.to_host_spec}
8
8
 
9
9
  COMMANDS.add_action(Action.new('pwd', desc, &action))
10
10
  end
@@ -19,19 +19,22 @@ module Mysh
19
19
  #<br>Endemic Code Smells
20
20
  #* :reek:UtilityFunction
21
21
  def info
22
- [["version", Mysh::VERSION],
23
- ["init file", $mysh_init_file.decorate],
22
+ [["about", Mysh::SUMMARY],
23
+ ["version", Mysh::VERSION],
24
+ ["init file", $mysh_init_file.to_host_spec],
24
25
  ["user", ENV['USER']],
25
- ["home", (ENV['HOME'] || "").decorate],
26
- ["name", $PROGRAM_NAME.decorate],
27
- ["os shell", (ENV['SHELL'] || ENV['ComSpec'] || "").decorate],
26
+ ["home", (ENV['HOME'] || "").to_host_spec],
27
+ ["name", $PROGRAM_NAME.to_host_spec],
28
+ ["os shell", (ENV['SHELL'] || ENV['ComSpec'] || "").to_host_spec],
28
29
  ["host", ENV['HOSTNAME'] || ENV['COMPUTERNAME']],
29
30
  ["os", ENV['OS']],
30
31
  ["platform", MiniReadline::TERM_PLATFORM],
31
32
  ["java?", MiniReadline::TERM_JAVA ? true : false],
32
33
  ["term", ENV['TERM']],
33
34
  ["disp", ENV['DISPLAY']],
34
- ["edit", ENV['EDITOR']]]
35
+ ["edit", ENV['EDITOR']],
36
+ ["PID", $PROCESS_ID]
37
+ ]
35
38
  end
36
39
 
37
40
  #Get the path.
@@ -19,7 +19,7 @@ module Mysh
19
19
  #<br>Endemic Code Smells
20
20
  #* :reek:UtilityFunction
21
21
  def info
22
- [["location", RbConfig.ruby.decorate],
22
+ [["location", RbConfig.ruby.to_host_spec],
23
23
  ["description", RUBY_DESCRIPTION],
24
24
  ["version", RUBY_VERSION],
25
25
  ["jversion", (JRUBY_VERSION rescue nil)],
@@ -18,5 +18,5 @@ module Mysh
18
18
  end
19
19
  end
20
20
 
21
- COMMANDS.add_action(Action.new('type file', desc, &action))
21
+ COMMANDS.add_action(Action.new('type <file>', desc, &action))
22
22
  end
@@ -1,10 +1,10 @@
1
1
  # coding: utf-8
2
2
 
3
- #* mysh/internal/decorate.rb -- mysh internal file name beauty treatments.
3
+ #* mysh/internal/to_host_spec.rb -- mysh internal file name beauty treatments.
4
4
  class String
5
5
 
6
6
  #Make the file name fit the local system.
7
- def decorate
7
+ def to_host_spec
8
8
  self.dress_up_slashes
9
9
  .dress_up_quotes
10
10
  end
@@ -19,4 +19,8 @@ class String
19
19
  self[' '] ? "\"#{self}\"" : self
20
20
  end
21
21
 
22
+ #Make the file name fit the standard notation.
23
+ def to_std_spec
24
+ self.gsub("\\", "/")
25
+ end
22
26
  end
@@ -17,12 +17,13 @@ module Mysh
17
17
  MNV[:pre_prompt] = "$w"
18
18
 
19
19
  MNV[:d] = "{{ Time.now.strftime(MNV[:date_fmt]) }}"
20
- MNV[:h] = "{{ ENV['HOME'].decorate }}"
20
+ MNV[:h] = "{{ ENV['HOME'].to_host_spec }}"
21
+ MNV[:r] = "{{ RbConfig.ruby.to_host_spec }}"
22
+ MNV[:s] = "{{ (ENV['SHELL'] || ENV['ComSpec'] || '').to_host_spec }}"
21
23
  MNV[:t] = "{{ Time.now.strftime(MNV[:time_fmt]) }}"
22
24
  MNV[:u] = "{{ ENV['USER'] }}"
23
- MNV[:w] = "{{ Dir.pwd.decorate }}"
25
+ MNV[:w] = "{{ Dir.pwd.to_host_spec }}"
24
26
 
25
27
  MNV[:date_fmt] = "%Y-%m-%d"
26
28
  MNV[:time_fmt] = "%H:%M"
27
-
28
29
  end
@@ -14,10 +14,11 @@ class String
14
14
 
15
15
  #Evaluate any variable substitutions in the input.
16
16
  def eval_variables
17
- self.gsub(/(\$\$)|(\$[a-z][a-z0-9_]*)/) do |str|
17
+ self.gsub(/((?<!\\)\$\$)|((?<!\\)\$[a-z][a-z0-9_]*)/) do |str|
18
18
  sym = str[1..-1].to_sym
19
19
  MNV.key?(sym) ? MNV[sym].to_s : str
20
- end
20
+ end.gsub(/\\\$/, "$")
21
+
21
22
  end
22
23
 
23
24
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Mysh
4
4
  #The version string of MY SHell.
5
- VERSION = "0.5.4"
5
+ VERSION = "0.5.5"
6
6
 
7
7
  #A brief summary of this gem.
8
8
  SUMMARY = "mysh -- a Ruby inspired command line shell."
@@ -199,7 +199,7 @@ class MyShellTester < Minitest::Test
199
199
  assert_equal('@last 45 "is finished" 4 ever', wrapper.cooked)
200
200
 
201
201
  assert_equal('@last', wrapper.raw_command)
202
- assert_equal(' 45 "is finished" {{ 2+2 }} ever', wrapper.raw_body)
202
+ assert_equal('45 "is finished" {{ 2+2 }} ever', wrapper.raw_body)
203
203
 
204
204
  assert_equal('@', wrapper.quick_command)
205
205
  assert_equal('last 45 "is finished" {{ 2+2 }} ever', wrapper.quick_body)
@@ -213,6 +213,26 @@ class MyShellTester < Minitest::Test
213
213
  assert_equal('last 45 "is finished" {{ 2+2 }} ever', wrapper.raw_body)
214
214
  assert_equal(["@", "last", "45", "is finished", "4", "ever"], wrapper.parsed)
215
215
  assert_equal(["last", "45", "is finished", "4", "ever"], wrapper.args)
216
+
217
+ Mysh.process_string("$unjust = him")
218
+ wrapper = Mysh::InputWrapper.new "Lock $unjust up!"
219
+
220
+ assert_equal("Lock $unjust up!", wrapper.raw)
221
+ assert_equal("Lock him up!", wrapper.cooked)
222
+ assert_equal("Lock", wrapper.raw_command)
223
+ assert_equal("$unjust up!", wrapper.raw_body)
224
+ assert_equal("him up!", wrapper.cooked_body)
225
+
226
+ wrapper = Mysh::InputWrapper.new "Test"
227
+ assert_equal("Test", wrapper.raw)
228
+ assert_equal("Test", wrapper.cooked)
229
+ assert_equal("Test", wrapper.raw_command)
230
+ assert_equal("", wrapper.raw_body)
231
+ assert_equal("", wrapper.cooked_body)
232
+ end
233
+
234
+ def test_to_std_spec
235
+ assert_equal("test\\foo\\bar.rb".to_std_spec, "test/foo/bar.rb")
216
236
  end
217
237
 
218
238
  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.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Camilleri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-20 00:00:00.000000000 Z
11
+ date: 2018-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -180,6 +180,7 @@ files:
180
180
  - lib/mysh/internal/actions/exit.rb
181
181
  - lib/mysh/internal/actions/gls.rb
182
182
  - lib/mysh/internal/actions/help.rb
183
+ - lib/mysh/internal/actions/help/args.txt
183
184
  - lib/mysh/internal/actions/help/env.txt
184
185
  - lib/mysh/internal/actions/help/expr.txt
185
186
  - lib/mysh/internal/actions/help/gls.txt
@@ -187,16 +188,21 @@ files:
187
188
  - lib/mysh/internal/actions/help/hbar.txt
188
189
  - lib/mysh/internal/actions/help/help.txt
189
190
  - lib/mysh/internal/actions/help/history.txt
191
+ - lib/mysh/internal/actions/help/init.txt
190
192
  - lib/mysh/internal/actions/help/kbd.txt
191
193
  - lib/mysh/internal/actions/help/math.txt
194
+ - lib/mysh/internal/actions/help/mls.txt
192
195
  - lib/mysh/internal/actions/help/quick.txt
193
196
  - lib/mysh/internal/actions/help/ruby.txt
194
197
  - lib/mysh/internal/actions/help/show.txt
195
198
  - lib/mysh/internal/actions/help/sub_help.rb
199
+ - lib/mysh/internal/actions/help/timed.txt
200
+ - lib/mysh/internal/actions/help/types.txt
196
201
  - lib/mysh/internal/actions/help/usage.txt
197
202
  - lib/mysh/internal/actions/help/vars.txt
198
203
  - lib/mysh/internal/actions/history.rb
199
204
  - lib/mysh/internal/actions/load.rb
205
+ - lib/mysh/internal/actions/mls.rb
200
206
  - lib/mysh/internal/actions/pwd.rb
201
207
  - lib/mysh/internal/actions/quit.rb
202
208
  - lib/mysh/internal/actions/say.rb
@@ -205,8 +211,6 @@ files:
205
211
  - lib/mysh/internal/actions/show/ruby.rb
206
212
  - lib/mysh/internal/actions/type.rb
207
213
  - lib/mysh/internal/actions/vars.rb
208
- - lib/mysh/internal/actions/vls.rb
209
- - lib/mysh/internal/decorate.rb
210
214
  - lib/mysh/internal/format.rb
211
215
  - lib/mysh/internal/format/array.rb
212
216
  - lib/mysh/internal/format/bullets.rb
@@ -215,6 +219,7 @@ files:
215
219
  - lib/mysh/internal/format/object.rb
216
220
  - lib/mysh/internal/format/string.rb
217
221
  - lib/mysh/internal/manage.rb
222
+ - lib/mysh/internal/to_file_spec.rb
218
223
  - lib/mysh/pre_processor.rb
219
224
  - lib/mysh/process.rb
220
225
  - lib/mysh/quick.rb