mysh 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +407 -87
- data/lib/mysh.rb +14 -4
- data/lib/mysh/expression.rb +10 -7
- data/lib/mysh/external_ruby.rb +1 -1
- data/lib/mysh/handlebars.rb +29 -0
- data/lib/mysh/handlebars/string.rb +22 -0
- data/lib/mysh/internal/action.rb +5 -5
- data/lib/mysh/internal/action_pool.rb +1 -1
- data/lib/mysh/internal/actions/cd.rb +2 -1
- data/lib/mysh/internal/actions/help/hbar.txt +13 -12
- data/lib/mysh/internal/actions/help/history.txt +1 -1
- data/lib/mysh/internal/actions/help/kbd.txt +1 -0
- data/lib/mysh/internal/actions/help/sub_help.rb +4 -3
- data/lib/mysh/internal/actions/help/vars.txt +34 -0
- data/lib/mysh/internal/actions/pwd.rb +1 -1
- data/lib/mysh/internal/actions/show/env.rb +3 -1
- data/lib/mysh/internal/actions/show/ruby.rb +1 -1
- data/lib/mysh/internal/actions/type.rb +1 -1
- data/lib/mysh/internal/actions/vars.rb +58 -0
- data/lib/mysh/internal/decorate.rb +13 -28
- data/lib/mysh/pre_processor.rb +11 -0
- data/lib/mysh/quick.rb +1 -0
- data/lib/mysh/shell_variables.rb +29 -0
- data/lib/mysh/shell_variables/evaluate.rb +23 -0
- data/lib/mysh/shell_variables/globalize.rb +9 -0
- data/lib/mysh/shell_variables/shell_variable_keeper.rb +36 -0
- data/lib/mysh/shell_variables/shell_variable_store.rb +76 -0
- data/lib/mysh/user_input.rb +10 -7
- data/lib/mysh/version.rb +1 -1
- data/mysh.gemspec +1 -1
- data/samples/show.txt +1 -1
- data/tests/my_shell_tests.rb +78 -5
- metadata +14 -5
- data/lib/mysh/user_input/handlebars.rb +0 -46
@@ -1,46 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
#* user_input/handlebars.rb -- Handlebar embedded ruby support.
|
4
|
-
class Object
|
5
|
-
|
6
|
-
#Show a file with embedded ruby handlebars.
|
7
|
-
#<br>Note:
|
8
|
-
#The message receiver is the evaluation host for the handlebar code.
|
9
|
-
def show_handlebar_file(name)
|
10
|
-
puts eval_handlebar_file(name)
|
11
|
-
rescue Interrupt, StandardError, ScriptError => err
|
12
|
-
puts "Error in file: #{name}\n#{err.class}: #{err}"
|
13
|
-
end
|
14
|
-
|
15
|
-
#Expand a file with embedded ruby handlebars.
|
16
|
-
#<br>Note:
|
17
|
-
#The message receiver is the evaluation host for the handlebar code.
|
18
|
-
def eval_handlebar_file(name)
|
19
|
-
eval_handlebars(IO.read(name))
|
20
|
-
end
|
21
|
-
|
22
|
-
#Process a string with backslash quotes and code embedded in handlebars.
|
23
|
-
#<br>Note:
|
24
|
-
#The message receiver is the evaluation host for the handlebar code.
|
25
|
-
def eval_handlebars(str)
|
26
|
-
do_process_handlebars(str).gsub(/\\[\{\}]/) {|found| found[1]}
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
#Process a string with code embedded in handlebars.
|
32
|
-
#<br>Note:
|
33
|
-
#The message receiver is the evaluation host for the handlebar code.
|
34
|
-
def do_process_handlebars(str)
|
35
|
-
str.gsub(/{{.*?}}/m) do |match|
|
36
|
-
code = match[2...-2]
|
37
|
-
silent = code.end_with?("#")
|
38
|
-
result = mysh_eval(code)
|
39
|
-
|
40
|
-
(result unless silent).to_s
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
|