gloo 0.7.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/Gemfile.lock +46 -39
- data/LICENSE.txt +1 -1
- data/gloo.gemspec +12 -6
- data/lib/VERSION +1 -1
- data/lib/dependencies.rb +28 -0
- data/lib/gloo/app/info.rb +3 -1
- data/lib/gloo/app/log.rb +1 -29
- data/lib/gloo/app/platform.rb +142 -0
- data/lib/gloo/objs/cli/banner.rb +2 -2
- data/lib/gloo/objs/cli/bar.rb +4 -4
- data/lib/gloo/objs/cli/colorize.rb +3 -3
- data/lib/gloo/objs/cli/confirm.rb +3 -3
- data/lib/gloo/objs/cli/menu.rb +9 -9
- data/lib/gloo/objs/cli/menu_item.rb +2 -2
- data/lib/gloo/objs/cli/pastel.rb +2 -2
- data/lib/gloo/objs/cli/prompt.rb +4 -4
- data/lib/gloo/objs/cli/select.rb +4 -4
- data/lib/gloo/objs/dev/git.rb +7 -7
- data/lib/gloo/objs/dev/stats.rb +8 -5
- data/lib/gloo/objs/snd/play.rb +1 -1
- data/lib/gloo/objs/snd/say.rb +2 -2
- data/lib/gloo/objs/system/file_handle.rb +9 -9
- data/lib/gloo/objs/system/ssh_exec.rb +3 -3
- data/lib/gloo/objs/system/system.rb +2 -2
- data/lib/gloo/verbs/alert.rb +7 -7
- data/lib/gloo/verbs/beep.rb +1 -1
- data/lib/gloo/verbs/cls.rb +2 -2
- data/lib/gloo.rb +7 -7
- data/lib/run.rb +7 -5
- metadata +42 -147
- data/lib/gloo/app/args.rb +0 -112
- data/lib/gloo/app/engine.rb +0 -230
- data/lib/gloo/app/help.rb +0 -156
- data/lib/gloo/app/mode.rb +0 -27
- data/lib/gloo/app/settings.rb +0 -186
- data/lib/gloo/convert/converter.rb +0 -35
- data/lib/gloo/convert/string_to_datetime.rb +0 -21
- data/lib/gloo/convert/string_to_decimal.rb +0 -20
- data/lib/gloo/convert/string_to_integer.rb +0 -20
- data/lib/gloo/core/baseo.rb +0 -28
- data/lib/gloo/core/dictionary.rb +0 -181
- data/lib/gloo/core/error.rb +0 -61
- data/lib/gloo/core/event_manager.rb +0 -44
- data/lib/gloo/core/factory.rb +0 -210
- data/lib/gloo/core/gloo_system.rb +0 -266
- data/lib/gloo/core/heap.rb +0 -52
- data/lib/gloo/core/here.rb +0 -36
- data/lib/gloo/core/it.rb +0 -36
- data/lib/gloo/core/literal.rb +0 -30
- data/lib/gloo/core/obj.rb +0 -305
- data/lib/gloo/core/obj_finder.rb +0 -30
- data/lib/gloo/core/op.rb +0 -40
- data/lib/gloo/core/parser.rb +0 -59
- data/lib/gloo/core/pn.rb +0 -188
- data/lib/gloo/core/tokens.rb +0 -165
- data/lib/gloo/core/verb.rb +0 -86
- data/lib/gloo/exec/action.rb +0 -48
- data/lib/gloo/exec/dispatch.rb +0 -40
- data/lib/gloo/exec/exec_env.rb +0 -74
- data/lib/gloo/exec/runner.rb +0 -45
- data/lib/gloo/exec/script.rb +0 -49
- data/lib/gloo/exec/stack.rb +0 -78
- data/lib/gloo/expr/expression.rb +0 -118
- data/lib/gloo/expr/l_boolean.rb +0 -36
- data/lib/gloo/expr/l_decimal.rb +0 -39
- data/lib/gloo/expr/l_integer.rb +0 -37
- data/lib/gloo/expr/l_string.rb +0 -58
- data/lib/gloo/expr/op_div.rb +0 -22
- data/lib/gloo/expr/op_minus.rb +0 -22
- data/lib/gloo/expr/op_mult.rb +0 -22
- data/lib/gloo/expr/op_plus.rb +0 -24
- data/lib/gloo/objs/basic/alias.rb +0 -78
- data/lib/gloo/objs/basic/boolean.rb +0 -120
- data/lib/gloo/objs/basic/container.rb +0 -76
- data/lib/gloo/objs/basic/decimal.rb +0 -76
- data/lib/gloo/objs/basic/integer.rb +0 -73
- data/lib/gloo/objs/basic/script.rb +0 -99
- data/lib/gloo/objs/basic/string.rb +0 -77
- data/lib/gloo/objs/basic/text.rb +0 -87
- data/lib/gloo/objs/basic/untyped.rb +0 -41
- data/lib/gloo/objs/ctrl/each.rb +0 -279
- data/lib/gloo/objs/ctrl/repeat.rb +0 -108
- data/lib/gloo/objs/data/markdown.rb +0 -84
- data/lib/gloo/objs/data/mysql.rb +0 -192
- data/lib/gloo/objs/data/query.rb +0 -176
- data/lib/gloo/objs/data/sqlite.rb +0 -159
- data/lib/gloo/objs/data/table.rb +0 -140
- data/lib/gloo/objs/dt/date.rb +0 -50
- data/lib/gloo/objs/dt/datetime.rb +0 -62
- data/lib/gloo/objs/dt/time.rb +0 -50
- data/lib/gloo/objs/ror/erb.rb +0 -116
- data/lib/gloo/objs/ror/eval.rb +0 -107
- data/lib/gloo/objs/web/http_get.rb +0 -159
- data/lib/gloo/objs/web/http_post.rb +0 -183
- data/lib/gloo/objs/web/json.rb +0 -135
- data/lib/gloo/objs/web/slack.rb +0 -130
- data/lib/gloo/objs/web/teams.rb +0 -117
- data/lib/gloo/objs/web/uri.rb +0 -148
- data/lib/gloo/persist/file_loader.rb +0 -191
- data/lib/gloo/persist/file_saver.rb +0 -49
- data/lib/gloo/persist/file_storage.rb +0 -45
- data/lib/gloo/persist/line_splitter.rb +0 -81
- data/lib/gloo/persist/persist_man.rb +0 -120
- data/lib/gloo/utils/format.rb +0 -21
- data/lib/gloo/utils/stats.rb +0 -205
- data/lib/gloo/utils/words.rb +0 -19
- data/lib/gloo/verbs/context.rb +0 -62
- data/lib/gloo/verbs/create.rb +0 -68
- data/lib/gloo/verbs/execute.rb +0 -56
- data/lib/gloo/verbs/help.rb +0 -264
- data/lib/gloo/verbs/if.rb +0 -92
- data/lib/gloo/verbs/list.rb +0 -98
- data/lib/gloo/verbs/load.rb +0 -45
- data/lib/gloo/verbs/move.rb +0 -89
- data/lib/gloo/verbs/put.rb +0 -94
- data/lib/gloo/verbs/quit.rb +0 -40
- data/lib/gloo/verbs/run.rb +0 -75
- data/lib/gloo/verbs/save.rb +0 -39
- data/lib/gloo/verbs/show.rb +0 -64
- data/lib/gloo/verbs/tell.rb +0 -79
- data/lib/gloo/verbs/unless.rb +0 -92
- data/lib/gloo/verbs/version.rb +0 -37
- data/lib/gloo/verbs/wait.rb +0 -42
data/lib/gloo/utils/words.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Utilities related to words (strings).
|
5
|
-
#
|
6
|
-
|
7
|
-
require 'active_support/inflector'
|
8
|
-
|
9
|
-
module Gloo
|
10
|
-
module Utils
|
11
|
-
class Words
|
12
|
-
|
13
|
-
def self.pluralize( word )
|
14
|
-
return word.pluralize
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/lib/gloo/verbs/context.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Set the current context pointer.
|
5
|
-
# Alternatively if no value is provided, just show the context.
|
6
|
-
#
|
7
|
-
|
8
|
-
module Gloo
|
9
|
-
module Verbs
|
10
|
-
class Context < Gloo::Core::Verb
|
11
|
-
|
12
|
-
KEYWORD = 'context'.freeze
|
13
|
-
KEYWORD_SHORT = '@'.freeze
|
14
|
-
|
15
|
-
#
|
16
|
-
# Run the verb.
|
17
|
-
#
|
18
|
-
def run
|
19
|
-
set_context if @tokens.token_count > 1
|
20
|
-
show_context
|
21
|
-
end
|
22
|
-
|
23
|
-
#
|
24
|
-
# Show the current context.
|
25
|
-
#
|
26
|
-
def show_context
|
27
|
-
$log.show "Context: #{$engine.heap.context}"
|
28
|
-
end
|
29
|
-
|
30
|
-
#
|
31
|
-
# Get the Verb's keyword.
|
32
|
-
#
|
33
|
-
def self.keyword
|
34
|
-
return KEYWORD
|
35
|
-
end
|
36
|
-
|
37
|
-
#
|
38
|
-
# Get the Verb's keyword shortcut.
|
39
|
-
#
|
40
|
-
def self.keyword_shortcut
|
41
|
-
return KEYWORD_SHORT
|
42
|
-
end
|
43
|
-
|
44
|
-
# ---------------------------------------------------------------------
|
45
|
-
# Private functions
|
46
|
-
# ---------------------------------------------------------------------
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
#
|
51
|
-
# Set the context to the given path.
|
52
|
-
#
|
53
|
-
def set_context
|
54
|
-
path = @tokens.second
|
55
|
-
$engine.heap.context.set_to path
|
56
|
-
$engine.heap.it.set_to path
|
57
|
-
$log.debug "Context set to #{$engine.heap.context}"
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
data/lib/gloo/verbs/create.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Create an object, optionally of a type.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Verbs
|
9
|
-
class Create < Gloo::Core::Verb
|
10
|
-
|
11
|
-
KEYWORD = 'create'.freeze
|
12
|
-
KEYWORD_SHORT = '`'.freeze
|
13
|
-
AS = 'as'.freeze
|
14
|
-
VAL = ':'.freeze
|
15
|
-
NO_NAME_ERR = 'Object name is missing!'.freeze
|
16
|
-
|
17
|
-
#
|
18
|
-
# Run the verb.
|
19
|
-
#
|
20
|
-
def run
|
21
|
-
name = @tokens.second
|
22
|
-
type = @tokens.after_token( AS )
|
23
|
-
value = @tokens.after_token( VAL )
|
24
|
-
|
25
|
-
unless name
|
26
|
-
$engine.err NO_NAME_ERR
|
27
|
-
return
|
28
|
-
end
|
29
|
-
create name, type, value
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
# Get the Verb's keyword.
|
34
|
-
#
|
35
|
-
def self.keyword
|
36
|
-
return KEYWORD
|
37
|
-
end
|
38
|
-
|
39
|
-
#
|
40
|
-
# Get the Verb's keyword shortcut.
|
41
|
-
#
|
42
|
-
def self.keyword_shortcut
|
43
|
-
return KEYWORD_SHORT
|
44
|
-
end
|
45
|
-
|
46
|
-
# ---------------------------------------------------------------------
|
47
|
-
# Private functions
|
48
|
-
# ---------------------------------------------------------------------
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
#
|
53
|
-
# Create an object with given name of given type with
|
54
|
-
# the given initial value.
|
55
|
-
#
|
56
|
-
def create( name, type, value )
|
57
|
-
if Gloo::Expr::LString.string?( value )
|
58
|
-
value = Gloo::Expr::LString.strip_quotes( value )
|
59
|
-
end
|
60
|
-
obj = $engine.factory.create( { name: name, type: type, value: value } )
|
61
|
-
|
62
|
-
obj.add_default_children if obj&.add_children_on_create?
|
63
|
-
$engine.heap.it.set_to value
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
data/lib/gloo/verbs/execute.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Execute a shell command.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Verbs
|
9
|
-
class Execute < Gloo::Core::Verb
|
10
|
-
|
11
|
-
KEYWORD = 'execute'.freeze
|
12
|
-
KEYWORD_SHORT = 'exec'.freeze
|
13
|
-
MISSING_EXPR_ERR = 'Missing Expression!'.freeze
|
14
|
-
|
15
|
-
#
|
16
|
-
# Run the verb.
|
17
|
-
#
|
18
|
-
def run
|
19
|
-
if @tokens.token_count < 2
|
20
|
-
$engine.err MISSING_EXPR_ERR
|
21
|
-
return
|
22
|
-
end
|
23
|
-
|
24
|
-
expr = Gloo::Expr::Expression.new( @tokens.params )
|
25
|
-
cmd = expr.evaluate
|
26
|
-
$log.debug "starting cmd: #{cmd}"
|
27
|
-
|
28
|
-
pid = fork { exec( cmd ) }
|
29
|
-
Process.wait pid
|
30
|
-
|
31
|
-
# pid = spawn cmd
|
32
|
-
# Process.wait pid
|
33
|
-
$log.debug "done executing cmd: #{cmd}"
|
34
|
-
|
35
|
-
# system expr.evaluate #, chdir: Dir.pwd
|
36
|
-
# `#{expr.evaluate}`
|
37
|
-
# exec expr.evaluate
|
38
|
-
end
|
39
|
-
|
40
|
-
#
|
41
|
-
# Get the Verb's keyword.
|
42
|
-
#
|
43
|
-
def self.keyword
|
44
|
-
return KEYWORD
|
45
|
-
end
|
46
|
-
|
47
|
-
#
|
48
|
-
# Get the Verb's keyword shortcut.
|
49
|
-
#
|
50
|
-
def self.keyword_shortcut
|
51
|
-
return KEYWORD_SHORT
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
data/lib/gloo/verbs/help.rb
DELETED
@@ -1,264 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Show the help information.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Verbs
|
9
|
-
class Help < Gloo::Core::Verb
|
10
|
-
|
11
|
-
KEYWORD = 'help'.freeze
|
12
|
-
KEYWORD_SHORT = '?'.freeze
|
13
|
-
DEFAULT_HELP = 'default_help'.freeze
|
14
|
-
HELP_NOT_FOUND_ERR = 'Help command could not be found:'.freeze
|
15
|
-
|
16
|
-
DISPATCH = {
|
17
|
-
settings: 'show_settings',
|
18
|
-
keywords: 'show_keywords',
|
19
|
-
verb: 'show_verbs',
|
20
|
-
verbs: 'show_verbs',
|
21
|
-
v: 'show_verbs',
|
22
|
-
obj: 'show_objs',
|
23
|
-
object: 'show_objs',
|
24
|
-
objects: 'show_objs',
|
25
|
-
o: 'show_objs',
|
26
|
-
topics: 'show_topics'
|
27
|
-
}.freeze
|
28
|
-
|
29
|
-
#
|
30
|
-
# Run the verb.
|
31
|
-
#
|
32
|
-
def run
|
33
|
-
opts = @tokens.second if @tokens
|
34
|
-
opts = opts.strip.downcase if opts
|
35
|
-
|
36
|
-
if opts
|
37
|
-
dispatch opts
|
38
|
-
else
|
39
|
-
$engine.help.page_topic DEFAULT_HELP
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
#
|
44
|
-
# Get the text for the list of verbs.
|
45
|
-
#
|
46
|
-
def get_verb_list
|
47
|
-
out = "Verbs:\n"
|
48
|
-
str = ''
|
49
|
-
verbs = $engine.dictionary.get_verbs.sort_by( &:keyword )
|
50
|
-
verbs.each_with_index do |v, i|
|
51
|
-
cut = v.keyword_shortcut.ljust( 5, ' ' )
|
52
|
-
str << " #{cut} #{v.keyword.ljust( 20, ' ' )}"
|
53
|
-
if ( ( i + 1 ) % 3 ).zero?
|
54
|
-
out << "#{str}\n"
|
55
|
-
str = ''
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
return out
|
60
|
-
end
|
61
|
-
|
62
|
-
#
|
63
|
-
# Lookup the opts in the dispatch table.
|
64
|
-
#
|
65
|
-
def lookup_opts( opts )
|
66
|
-
return DISPATCH[ opts.to_sym ]
|
67
|
-
end
|
68
|
-
|
69
|
-
#
|
70
|
-
# Get the text for the list of verbs.
|
71
|
-
#
|
72
|
-
def get_obj_list
|
73
|
-
out = "Object Types:\n"
|
74
|
-
str = ''
|
75
|
-
objs = $engine.dictionary.get_obj_types.sort_by( &:typename )
|
76
|
-
objs.each_with_index do |o, i|
|
77
|
-
name = o.typename
|
78
|
-
if o.short_typename != o.typename
|
79
|
-
name = "#{name} (#{o.short_typename})"
|
80
|
-
end
|
81
|
-
str << " #{name.ljust( 30, ' ' )}"
|
82
|
-
if ( ( i + 1 ) % 4 ).zero?
|
83
|
-
out << "#{str}\n"
|
84
|
-
str = ''
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
return out
|
89
|
-
end
|
90
|
-
|
91
|
-
#
|
92
|
-
# Get the list of help topics.
|
93
|
-
#
|
94
|
-
def get_topics
|
95
|
-
out = "Help Topics:\n"
|
96
|
-
str = ''
|
97
|
-
objs = $engine.help.topics.keys.sort
|
98
|
-
objs.each_with_index do |o, i|
|
99
|
-
str << " #{o.ljust( 30, ' ' )}"
|
100
|
-
if ( ( i + 1 ) % 4 ).zero?
|
101
|
-
out << "#{str}\n"
|
102
|
-
str = ''
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
return out
|
107
|
-
end
|
108
|
-
|
109
|
-
#
|
110
|
-
# Get the Verb's keyword.
|
111
|
-
#
|
112
|
-
def self.keyword
|
113
|
-
return KEYWORD
|
114
|
-
end
|
115
|
-
|
116
|
-
#
|
117
|
-
# Get the Verb's keyword shortcut.
|
118
|
-
#
|
119
|
-
def self.keyword_shortcut
|
120
|
-
return KEYWORD_SHORT
|
121
|
-
end
|
122
|
-
|
123
|
-
# ---------------------------------------------------------------------
|
124
|
-
# Private functions
|
125
|
-
# ---------------------------------------------------------------------
|
126
|
-
|
127
|
-
private
|
128
|
-
|
129
|
-
#
|
130
|
-
# Report an error with the inline help.
|
131
|
-
#
|
132
|
-
def report_help_error( opts )
|
133
|
-
$engine.err "#{HELP_NOT_FOUND_ERR} '#{opts}'"
|
134
|
-
end
|
135
|
-
|
136
|
-
#
|
137
|
-
# Dispatch the help to the right place.
|
138
|
-
#
|
139
|
-
def dispatch( opts )
|
140
|
-
return if dispatch_help_page( opts )
|
141
|
-
|
142
|
-
$log.debug 'looking for built in help topic'
|
143
|
-
cmd = DISPATCH[ opts.to_sym ]
|
144
|
-
if cmd
|
145
|
-
$log.debug 'found help index'
|
146
|
-
send cmd
|
147
|
-
else
|
148
|
-
$log.debug 'looking for entity help'
|
149
|
-
entity_help opts
|
150
|
-
end
|
151
|
-
rescue
|
152
|
-
report_help_error opts
|
153
|
-
end
|
154
|
-
|
155
|
-
#
|
156
|
-
# Dispatch to a help page if we can find one.
|
157
|
-
#
|
158
|
-
def dispatch_help_page( opts )
|
159
|
-
if $engine.help.topic? opts
|
160
|
-
$log.debug 'found expanded help topic'
|
161
|
-
$engine.help.page_topic opts
|
162
|
-
return true
|
163
|
-
end
|
164
|
-
|
165
|
-
key = $engine.dictionary.lookup_keyword opts
|
166
|
-
if $engine.help.topic? key
|
167
|
-
$log.debug 'found expanded help topic'
|
168
|
-
$engine.help.page_topic key
|
169
|
-
return true
|
170
|
-
end
|
171
|
-
|
172
|
-
return false
|
173
|
-
end
|
174
|
-
|
175
|
-
#
|
176
|
-
# Write output to it and show it unless we are in
|
177
|
-
# silent mode.
|
178
|
-
#
|
179
|
-
def show_output( out )
|
180
|
-
$engine.heap.it.set_to out
|
181
|
-
puts out unless $engine.args.quiet?
|
182
|
-
end
|
183
|
-
|
184
|
-
#
|
185
|
-
# List all help topics (articles)
|
186
|
-
#
|
187
|
-
def show_topics
|
188
|
-
out = self.get_topics
|
189
|
-
show_output out
|
190
|
-
end
|
191
|
-
|
192
|
-
#
|
193
|
-
# Dispatch the help command to a verb or object
|
194
|
-
# if we can find one matching the request.
|
195
|
-
#
|
196
|
-
def entity_help( opts )
|
197
|
-
return if try_verb_help opts
|
198
|
-
return if try_object_help opts
|
199
|
-
|
200
|
-
report_help_error opts
|
201
|
-
end
|
202
|
-
|
203
|
-
#
|
204
|
-
# See if there is a verb we can show help
|
205
|
-
# information about.
|
206
|
-
#
|
207
|
-
def try_verb_help( opts )
|
208
|
-
if $engine.dictionary.verb?( opts )
|
209
|
-
t = $engine.dictionary.find_verb( opts )
|
210
|
-
out = t.send 'help'
|
211
|
-
show_output out
|
212
|
-
return true
|
213
|
-
end
|
214
|
-
|
215
|
-
return false
|
216
|
-
end
|
217
|
-
|
218
|
-
#
|
219
|
-
# See if there is a verb we can show help
|
220
|
-
# information about.
|
221
|
-
#
|
222
|
-
def try_object_help( opts )
|
223
|
-
if $engine.dictionary.obj?( opts )
|
224
|
-
t = $engine.dictionary.find_obj( opts )
|
225
|
-
out = t.send 'help'
|
226
|
-
show_output out
|
227
|
-
return true
|
228
|
-
end
|
229
|
-
|
230
|
-
return false
|
231
|
-
end
|
232
|
-
|
233
|
-
#
|
234
|
-
# Show application settings.
|
235
|
-
#
|
236
|
-
def show_settings
|
237
|
-
$settings.show
|
238
|
-
end
|
239
|
-
|
240
|
-
#
|
241
|
-
# Show all keywords: verbs and objects.
|
242
|
-
#
|
243
|
-
def show_keywords
|
244
|
-
$engine.dictionary.show_keywords
|
245
|
-
end
|
246
|
-
|
247
|
-
#
|
248
|
-
# List the verbs
|
249
|
-
#
|
250
|
-
def show_verbs
|
251
|
-
show_output get_verb_list
|
252
|
-
end
|
253
|
-
|
254
|
-
#
|
255
|
-
# List the object types
|
256
|
-
#
|
257
|
-
def show_objs
|
258
|
-
out = self.get_obj_list
|
259
|
-
show_output out
|
260
|
-
end
|
261
|
-
|
262
|
-
end
|
263
|
-
end
|
264
|
-
end
|
data/lib/gloo/verbs/if.rb
DELETED
@@ -1,92 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# If something is true, do something.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Verbs
|
9
|
-
class If < Gloo::Core::Verb
|
10
|
-
|
11
|
-
KEYWORD = 'if'.freeze
|
12
|
-
KEYWORD_SHORT = 'if'.freeze
|
13
|
-
THEN = 'then'.freeze
|
14
|
-
MISSING_EXPR_ERR = 'Missing Expression!'.freeze
|
15
|
-
|
16
|
-
#
|
17
|
-
# Run the verb.
|
18
|
-
#
|
19
|
-
def run
|
20
|
-
value = value_tokens
|
21
|
-
return if value.nil?
|
22
|
-
|
23
|
-
return unless evals_true( value )
|
24
|
-
|
25
|
-
run_then
|
26
|
-
end
|
27
|
-
|
28
|
-
#
|
29
|
-
# Get the Verb's keyword.
|
30
|
-
#
|
31
|
-
def self.keyword
|
32
|
-
return KEYWORD
|
33
|
-
end
|
34
|
-
|
35
|
-
#
|
36
|
-
# Get the Verb's keyword shortcut.
|
37
|
-
#
|
38
|
-
def self.keyword_shortcut
|
39
|
-
return KEYWORD_SHORT
|
40
|
-
end
|
41
|
-
|
42
|
-
# ---------------------------------------------------------------------
|
43
|
-
# Private functions
|
44
|
-
# ---------------------------------------------------------------------
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
#
|
49
|
-
# Get the list of tokens that represent the parameters
|
50
|
-
# of the if command.
|
51
|
-
#
|
52
|
-
def value_tokens
|
53
|
-
value = @tokens.before_token( THEN )
|
54
|
-
if value && value.count > 1
|
55
|
-
# The first token is the verb, so we drop it.
|
56
|
-
value = value[ 1..-1 ]
|
57
|
-
else
|
58
|
-
$engine.err MISSING_EXPR_ERR
|
59
|
-
end
|
60
|
-
|
61
|
-
return value
|
62
|
-
end
|
63
|
-
|
64
|
-
#
|
65
|
-
# Does the given value evalute to true?
|
66
|
-
#
|
67
|
-
def evals_true( value )
|
68
|
-
eval_result = false
|
69
|
-
if value.count.positive?
|
70
|
-
expr = Gloo::Expr::Expression.new( value )
|
71
|
-
result = expr.evaluate
|
72
|
-
eval_result = true if result == true
|
73
|
-
eval_result = true if result.is_a?( Numeric ) && result != 0
|
74
|
-
end
|
75
|
-
|
76
|
-
return eval_result
|
77
|
-
end
|
78
|
-
|
79
|
-
#
|
80
|
-
# Run the 'then' command.
|
81
|
-
#
|
82
|
-
def run_then
|
83
|
-
cmd = @tokens.expr_after( THEN )
|
84
|
-
i = $engine.parser.parse_immediate cmd
|
85
|
-
return unless i
|
86
|
-
|
87
|
-
i.run
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
data/lib/gloo/verbs/list.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# List out an object and it's children.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Verbs
|
9
|
-
class List < Gloo::Core::Verb
|
10
|
-
|
11
|
-
KEYWORD = 'list'.freeze
|
12
|
-
KEYWORD_SHORT = '.'.freeze
|
13
|
-
TARGET_MISSING_ERR = 'Object does not exist: '.freeze
|
14
|
-
|
15
|
-
#
|
16
|
-
# Run the verb.
|
17
|
-
#
|
18
|
-
def run
|
19
|
-
levels = determine_levels
|
20
|
-
target = self.determine_target
|
21
|
-
obj = target.resolve
|
22
|
-
if obj
|
23
|
-
show_target( obj, levels )
|
24
|
-
else
|
25
|
-
$engine.err "#{TARGET_MISSING_ERR} #{target}"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
#
|
30
|
-
# Determine the target object for the show command.
|
31
|
-
#
|
32
|
-
def determine_target
|
33
|
-
return $engine.heap.context if @tokens.token_count == 1
|
34
|
-
|
35
|
-
return Gloo::Core::Pn.new( @tokens.second )
|
36
|
-
end
|
37
|
-
|
38
|
-
#
|
39
|
-
# Get the Verb's keyword.
|
40
|
-
#
|
41
|
-
def self.keyword
|
42
|
-
return KEYWORD
|
43
|
-
end
|
44
|
-
|
45
|
-
#
|
46
|
-
# Get the Verb's keyword shortcut.
|
47
|
-
#
|
48
|
-
def self.keyword_shortcut
|
49
|
-
return KEYWORD_SHORT
|
50
|
-
end
|
51
|
-
|
52
|
-
# ---------------------------------------------------------------------
|
53
|
-
# Private functions
|
54
|
-
# ---------------------------------------------------------------------
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
#
|
59
|
-
# Show the target object.
|
60
|
-
#
|
61
|
-
def show_target( obj, levels, indent = '' )
|
62
|
-
show_obj( obj, indent )
|
63
|
-
return if levels.zero?
|
64
|
-
|
65
|
-
obj.children.each do |o|
|
66
|
-
show_target( o, levels - 1, "#{indent} " )
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
#
|
71
|
-
# Show object in standard format.
|
72
|
-
#
|
73
|
-
def show_obj( obj, indent = ' ' )
|
74
|
-
if obj.multiline_value? && obj.value_is_array?
|
75
|
-
$log.show "#{indent}#{obj.name} [#{obj.type_display}] :"
|
76
|
-
obj.value.each do |line|
|
77
|
-
$log.show "#{indent} #{line}"
|
78
|
-
end
|
79
|
-
else
|
80
|
-
$log.show "#{indent}#{obj.name} [#{obj.type_display}] : #{obj.value}"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
#
|
85
|
-
# Determine how many levels to show.
|
86
|
-
#
|
87
|
-
def determine_levels
|
88
|
-
# Check settings for the default value.
|
89
|
-
levels = $settings.list_indent
|
90
|
-
return levels if levels
|
91
|
-
|
92
|
-
# Last chance: use the default
|
93
|
-
return 1
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
data/lib/gloo/verbs/load.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Save an object to a file or other persistance mechcanism.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Verbs
|
9
|
-
class Load < Gloo::Core::Verb
|
10
|
-
|
11
|
-
KEYWORD = 'load'.freeze
|
12
|
-
KEYWORD_SHORT = '<'.freeze
|
13
|
-
MISSING_EXPR_ERR = 'Missing Expression!'.freeze
|
14
|
-
|
15
|
-
#
|
16
|
-
# Run the verb.
|
17
|
-
#
|
18
|
-
def run
|
19
|
-
fn = @tokens.second
|
20
|
-
|
21
|
-
if fn
|
22
|
-
$log.debug "Getting ready to load file: #{fn}"
|
23
|
-
$engine.persist_man.load fn
|
24
|
-
else
|
25
|
-
$engine.err MISSING_EXPR_ERR
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
#
|
30
|
-
# Get the Verb's keyword.
|
31
|
-
#
|
32
|
-
def self.keyword
|
33
|
-
return KEYWORD
|
34
|
-
end
|
35
|
-
|
36
|
-
#
|
37
|
-
# Get the Verb's keyword shortcut.
|
38
|
-
#
|
39
|
-
def self.keyword_shortcut
|
40
|
-
return KEYWORD_SHORT
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|