gloo-lang 0.9.6 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/lib/VERSION +1 -1
- data/lib/gloo_lang/app/args.rb +3 -2
- data/lib/gloo_lang/app/engine.rb +25 -26
- data/lib/gloo_lang/app/help.rb +10 -9
- data/lib/gloo_lang/app/log.rb +5 -3
- data/lib/gloo_lang/app/settings.rb +10 -9
- data/lib/gloo_lang/convert/converter.rb +9 -2
- data/lib/gloo_lang/core/baseo.rb +2 -1
- data/lib/gloo_lang/core/dictionary.rb +16 -6
- data/lib/gloo_lang/core/event_manager.rb +9 -8
- data/lib/gloo_lang/core/factory.rb +11 -10
- data/lib/gloo_lang/core/gloo_system.rb +9 -8
- data/lib/gloo_lang/core/heap.rb +5 -4
- data/lib/gloo_lang/core/here.rb +2 -2
- data/lib/gloo_lang/core/obj.rb +9 -8
- data/lib/gloo_lang/core/obj_finder.rb +3 -3
- data/lib/gloo_lang/core/parser.rb +6 -5
- data/lib/gloo_lang/core/pn.rb +20 -16
- data/lib/gloo_lang/core/verb.rb +2 -1
- data/lib/gloo_lang/exec/dispatch.rb +8 -8
- data/lib/gloo_lang/exec/exec_env.rb +7 -6
- data/lib/gloo_lang/exec/runner.rb +10 -10
- data/lib/gloo_lang/exec/script.rb +6 -5
- data/lib/gloo_lang/exec/stack.rb +8 -7
- data/lib/gloo_lang/expr/expression.rb +3 -2
- data/lib/gloo_lang/objs/basic/alias.rb +4 -4
- data/lib/gloo_lang/objs/basic/boolean.rb +3 -3
- data/lib/gloo_lang/objs/basic/container.rb +2 -2
- data/lib/gloo_lang/objs/basic/decimal.rb +3 -3
- data/lib/gloo_lang/objs/basic/integer.rb +3 -3
- data/lib/gloo_lang/objs/basic/script.rb +1 -1
- data/lib/gloo_lang/objs/basic/string.rb +3 -3
- data/lib/gloo_lang/objs/basic/text.rb +2 -2
- data/lib/gloo_lang/objs/ctrl/each.rb +3 -3
- data/lib/gloo_lang/objs/ctrl/repeat.rb +2 -2
- data/lib/gloo_lang/objs/data/markdown.rb +2 -2
- data/lib/gloo_lang/objs/data/query.rb +4 -4
- data/lib/gloo_lang/objs/data/table.rb +3 -3
- data/lib/gloo_lang/objs/dt/date.rb +1 -1
- data/lib/gloo_lang/objs/dt/datetime.rb +2 -2
- data/lib/gloo_lang/objs/dt/time.rb +1 -1
- data/lib/gloo_lang/objs/ror/erb.rb +2 -2
- data/lib/gloo_lang/objs/ror/eval.rb +3 -3
- data/lib/gloo_lang/objs/web/http_get.rb +3 -3
- data/lib/gloo_lang/objs/web/http_post.rb +8 -8
- data/lib/gloo_lang/objs/web/json.rb +5 -5
- data/lib/gloo_lang/objs/web/slack.rb +1 -1
- data/lib/gloo_lang/objs/web/teams.rb +1 -1
- data/lib/gloo_lang/objs/web/uri.rb +6 -6
- data/lib/gloo_lang/persist/file_loader.rb +6 -5
- data/lib/gloo_lang/persist/file_saver.rb +2 -1
- data/lib/gloo_lang/persist/file_storage.rb +6 -5
- data/lib/gloo_lang/persist/persist_man.rb +9 -8
- data/lib/gloo_lang/utils/stats.rb +5 -4
- data/lib/gloo_lang/verbs/context.rb +4 -4
- data/lib/gloo_lang/verbs/create.rb +3 -3
- data/lib/gloo_lang/verbs/execute.rb +4 -4
- data/lib/gloo_lang/verbs/help.rb +23 -23
- data/lib/gloo_lang/verbs/if.rb +3 -3
- data/lib/gloo_lang/verbs/list.rb +7 -7
- data/lib/gloo_lang/verbs/load.rb +3 -3
- data/lib/gloo_lang/verbs/move.rb +6 -6
- data/lib/gloo_lang/verbs/put.rb +6 -6
- data/lib/gloo_lang/verbs/quit.rb +1 -1
- data/lib/gloo_lang/verbs/run.rb +5 -5
- data/lib/gloo_lang/verbs/save.rb +1 -1
- data/lib/gloo_lang/verbs/show.rb +5 -5
- data/lib/gloo_lang/verbs/tell.rb +5 -4
- data/lib/gloo_lang/verbs/unless.rb +3 -3
- data/lib/gloo_lang/verbs/version.rb +1 -1
- data/lib/gloo_lang/verbs/wait.rb +1 -1
- metadata +2 -4
- data/lib/gloo_lang/objs/data/mysql.rb +0 -192
- data/lib/gloo_lang/objs/data/sqlite.rb +0 -159
@@ -57,7 +57,7 @@ module GlooLang
|
|
57
57
|
|
58
58
|
body = find_child PARAMS
|
59
59
|
body.children.each do |child|
|
60
|
-
child = GlooLang::Objs::Alias.resolve_alias( child )
|
60
|
+
child = GlooLang::Objs::Alias.resolve_alias( @engine, child )
|
61
61
|
h[ child.name ] = child.value
|
62
62
|
end
|
63
63
|
|
@@ -83,7 +83,7 @@ module GlooLang
|
|
83
83
|
# for default configurations.
|
84
84
|
#
|
85
85
|
def add_default_children
|
86
|
-
fac =
|
86
|
+
fac = @engine.factory
|
87
87
|
fac.create_text TEMPLATE, '', self
|
88
88
|
fac.create_can PARAMS, self
|
89
89
|
fac.create_text RESULT, '', self
|
@@ -68,7 +68,7 @@ module GlooLang
|
|
68
68
|
# for default configurations.
|
69
69
|
#
|
70
70
|
def add_default_children
|
71
|
-
fac =
|
71
|
+
fac = @engine.factory
|
72
72
|
fac.create_string CMD, DEFAULT_CMD, self
|
73
73
|
fac.create_string RESULT, nil, self
|
74
74
|
end
|
@@ -96,9 +96,9 @@ module GlooLang
|
|
96
96
|
result = eval cmd
|
97
97
|
# rubocop:enable Security/Eval
|
98
98
|
set_result result
|
99
|
-
|
99
|
+
@engine.heap.it.set_to result
|
100
100
|
rescue => e
|
101
|
-
|
101
|
+
@engine.err e.message
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -53,7 +53,7 @@ module GlooLang
|
|
53
53
|
# for default configurations.
|
54
54
|
#
|
55
55
|
def add_default_children
|
56
|
-
fac =
|
56
|
+
fac = @engine.factory
|
57
57
|
fac.create_string URL, DEFAULT_URL, self
|
58
58
|
fac.create_can PARAMS, self
|
59
59
|
fac.create_string RESULT, nil, self
|
@@ -75,7 +75,7 @@ module GlooLang
|
|
75
75
|
#
|
76
76
|
def msg_run
|
77
77
|
url = full_url_value
|
78
|
-
|
78
|
+
@engine.log.debug url
|
79
79
|
r = GlooLang::Objs::HttpGet.invoke_request( url, skip_ssl_verify? )
|
80
80
|
update_result r
|
81
81
|
end
|
@@ -146,7 +146,7 @@ module GlooLang
|
|
146
146
|
params.children.each do |child|
|
147
147
|
p << ( p.empty? ? '?' : '&' )
|
148
148
|
|
149
|
-
child = GlooLang::Objs::Alias.resolve_alias( child )
|
149
|
+
child = GlooLang::Objs::Alias.resolve_alias( @engine, child )
|
150
150
|
|
151
151
|
# TODO: Quote URL params for safety
|
152
152
|
p << "#{child.name}=#{child.value}"
|
@@ -52,7 +52,7 @@ module GlooLang
|
|
52
52
|
|
53
53
|
body = find_child BODY
|
54
54
|
body.children.each do |child|
|
55
|
-
child_val = GlooLang::Objs::Alias.resolve_alias( child )
|
55
|
+
child_val = GlooLang::Objs::Alias.resolve_alias( @engine, child )
|
56
56
|
h[ child.name ] = child_val.value
|
57
57
|
end
|
58
58
|
|
@@ -88,7 +88,7 @@ module GlooLang
|
|
88
88
|
# for default configurations.
|
89
89
|
#
|
90
90
|
def add_default_children
|
91
|
-
fac =
|
91
|
+
fac = @engine.factory
|
92
92
|
fac.create_string URL, 'https://web.site/', self
|
93
93
|
fac.create_can BODY, self
|
94
94
|
end
|
@@ -111,9 +111,9 @@ module GlooLang
|
|
111
111
|
uri = uri_value
|
112
112
|
return unless uri
|
113
113
|
|
114
|
-
|
114
|
+
@engine.log.debug "posting to: #{uri}"
|
115
115
|
body = self.body_as_json
|
116
|
-
|
116
|
+
@engine.log.debug "posting body: #{body}"
|
117
117
|
data = GlooLang::Objs::HttpPost.post_json( uri, body, skip_ssl_verify? )
|
118
118
|
self.update_result data
|
119
119
|
end
|
@@ -136,8 +136,8 @@ module GlooLang
|
|
136
136
|
request.body = body
|
137
137
|
|
138
138
|
result = http.request request # Net::HTTPResponse object
|
139
|
-
|
140
|
-
|
139
|
+
@engine.log.debug result.code
|
140
|
+
@engine.log.debug result.message
|
141
141
|
return result.body
|
142
142
|
end
|
143
143
|
end
|
@@ -157,8 +157,8 @@ module GlooLang
|
|
157
157
|
#
|
158
158
|
# # Send the payload to the endpoint.
|
159
159
|
# result = n.start { |http| http.request( request ) }
|
160
|
-
#
|
161
|
-
#
|
160
|
+
# @engine.log.debug result.code
|
161
|
+
# @engine.log.debug result.message
|
162
162
|
# return result.body
|
163
163
|
# end
|
164
164
|
|
@@ -74,14 +74,14 @@ module GlooLang
|
|
74
74
|
#
|
75
75
|
def msg_get
|
76
76
|
if @params&.token_count&.positive?
|
77
|
-
expr = GlooLang::Expr::Expression.new( @params.tokens )
|
77
|
+
expr = GlooLang::Expr::Expression.new( @engine, @params.tokens )
|
78
78
|
data = expr.evaluate
|
79
79
|
end
|
80
80
|
return unless data
|
81
81
|
|
82
82
|
h = JSON.parse( self.value )
|
83
83
|
field = h[ data ]
|
84
|
-
|
84
|
+
@engine.heap.it.set_to field
|
85
85
|
return field
|
86
86
|
end
|
87
87
|
|
@@ -92,13 +92,13 @@ module GlooLang
|
|
92
92
|
#
|
93
93
|
def msg_parse
|
94
94
|
if @params&.token_count&.positive?
|
95
|
-
pn = GlooLang::Core::Pn.new @params.tokens.first
|
95
|
+
pn = GlooLang::Core::Pn.new( @engine, @params.tokens.first )
|
96
96
|
unless pn&.exists?
|
97
|
-
|
97
|
+
@engine.err 'Destination path for parsed objects does not exist'
|
98
98
|
return
|
99
99
|
end
|
100
100
|
else
|
101
|
-
|
101
|
+
@engine.err 'Destination path for parsed objects is required'
|
102
102
|
return
|
103
103
|
end
|
104
104
|
parent = pn.resolve
|
@@ -96,7 +96,7 @@ module GlooLang
|
|
96
96
|
# for default configurations.
|
97
97
|
#
|
98
98
|
def add_default_children
|
99
|
-
fac =
|
99
|
+
fac = @engine.factory
|
100
100
|
fac.create_string URL, 'https://hooks.slack.com/services/...', self
|
101
101
|
fac.create_string MSG, 'textual message', self
|
102
102
|
fac.create_string USER, 'Slack Bot', self
|
@@ -84,7 +84,7 @@ module GlooLang
|
|
84
84
|
# for default configurations.
|
85
85
|
#
|
86
86
|
def add_default_children
|
87
|
-
fac =
|
87
|
+
fac = @engine.factory
|
88
88
|
fac.create_string URL, DEFAULT_URL, self
|
89
89
|
fac.create_string TITLE, '', self
|
90
90
|
fac.create_string COLOR, DEFAULT_COLOR, self
|
@@ -68,7 +68,7 @@ module GlooLang
|
|
68
68
|
cert = response.peer_cert
|
69
69
|
o = cert.not_after
|
70
70
|
|
71
|
-
|
71
|
+
@engine.heap.it.set_to o
|
72
72
|
return o
|
73
73
|
end
|
74
74
|
|
@@ -80,7 +80,7 @@ module GlooLang
|
|
80
80
|
return unless value
|
81
81
|
|
82
82
|
o = URI( value ).fragment
|
83
|
-
|
83
|
+
@engine.heap.it.set_to o
|
84
84
|
return o
|
85
85
|
end
|
86
86
|
|
@@ -92,7 +92,7 @@ module GlooLang
|
|
92
92
|
return unless value
|
93
93
|
|
94
94
|
o = URI( value ).query
|
95
|
-
|
95
|
+
@engine.heap.it.set_to o
|
96
96
|
return o
|
97
97
|
end
|
98
98
|
|
@@ -104,7 +104,7 @@ module GlooLang
|
|
104
104
|
return unless value
|
105
105
|
|
106
106
|
o = URI( value ).path
|
107
|
-
|
107
|
+
@engine.heap.it.set_to o
|
108
108
|
return o
|
109
109
|
end
|
110
110
|
|
@@ -116,7 +116,7 @@ module GlooLang
|
|
116
116
|
return unless value
|
117
117
|
|
118
118
|
o = URI( value ).host
|
119
|
-
|
119
|
+
@engine.heap.it.set_to o
|
120
120
|
return o
|
121
121
|
end
|
122
122
|
|
@@ -128,7 +128,7 @@ module GlooLang
|
|
128
128
|
return unless value
|
129
129
|
|
130
130
|
o = URI( value ).scheme
|
131
|
-
|
131
|
+
@engine.heap.it.set_to o
|
132
132
|
return o
|
133
133
|
end
|
134
134
|
|
@@ -17,7 +17,8 @@ module GlooLang
|
|
17
17
|
#
|
18
18
|
# Set up a file storage for an object.
|
19
19
|
#
|
20
|
-
def initialize( pn )
|
20
|
+
def initialize( engine, pn )
|
21
|
+
@engine = engine
|
21
22
|
@pn = pn
|
22
23
|
@tabs = 0
|
23
24
|
@obj = nil
|
@@ -33,14 +34,14 @@ module GlooLang
|
|
33
34
|
#
|
34
35
|
def load
|
35
36
|
unless File.exist?( @pn )
|
36
|
-
|
37
|
+
@engine.log.error "File '#{@pn}' does not exist."
|
37
38
|
return
|
38
39
|
end
|
39
40
|
|
40
|
-
|
41
|
+
@engine.log.debug "Loading file '#{@pn}'"
|
41
42
|
@tabs = 0
|
42
43
|
@parent_stack = []
|
43
|
-
@parent =
|
44
|
+
@parent = @engine.heap.root
|
44
45
|
@parent_stack.push @parent
|
45
46
|
f = File.open( @pn, 'r' )
|
46
47
|
f.each_line do |line|
|
@@ -150,7 +151,7 @@ module GlooLang
|
|
150
151
|
@block_value = ''
|
151
152
|
end
|
152
153
|
params = { name: name, type: type, value: value, parent: @parent }
|
153
|
-
@last =
|
154
|
+
@last = @engine.factory.create( params )
|
154
155
|
|
155
156
|
if value.empty? && @last&.multiline_value?
|
156
157
|
@multi_indent = 0
|
@@ -13,7 +13,8 @@ module GlooLang
|
|
13
13
|
#
|
14
14
|
# Set up a file storage for an object.
|
15
15
|
#
|
16
|
-
def initialize( pn, obj = nil )
|
16
|
+
def initialize( engine, pn, obj = nil )
|
17
|
+
@engine = engine
|
17
18
|
@obj = obj
|
18
19
|
@pn = pn
|
19
20
|
end
|
@@ -22,7 +23,7 @@ module GlooLang
|
|
22
23
|
# Save the object to the file.
|
23
24
|
#
|
24
25
|
def save
|
25
|
-
fs = FileSaver.new @pn, @obj
|
26
|
+
fs = FileSaver.new( @engine, @pn, @obj )
|
26
27
|
fs.save
|
27
28
|
end
|
28
29
|
|
@@ -30,13 +31,13 @@ module GlooLang
|
|
30
31
|
# Load the object from the file.
|
31
32
|
#
|
32
33
|
def load
|
33
|
-
fl = FileLoader.new @pn
|
34
|
+
fl = FileLoader.new( @engine, @pn )
|
34
35
|
fl.load
|
35
36
|
@obj = fl.obj
|
36
37
|
if @obj
|
37
|
-
|
38
|
+
@engine.log.debug "Loaded object: #{@obj.name}"
|
38
39
|
else
|
39
|
-
|
40
|
+
@engine.log.error "Error loading file at #{@pn}"
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
@@ -15,7 +15,8 @@ module GlooLang
|
|
15
15
|
#
|
16
16
|
# Contructor for the persistence manager.
|
17
17
|
#
|
18
|
-
def initialize
|
18
|
+
def initialize( engine )
|
19
|
+
@engine = engine
|
19
20
|
@maps = []
|
20
21
|
end
|
21
22
|
|
@@ -41,10 +42,10 @@ module GlooLang
|
|
41
42
|
# Save one object to the file.
|
42
43
|
#
|
43
44
|
def save_one( name )
|
44
|
-
ref = GlooLang::Core::Pn.new name
|
45
|
+
ref = GlooLang::Core::Pn.new( @engine, name )
|
45
46
|
obj = ref.resolve
|
46
47
|
pn = get_full_path_name name
|
47
|
-
fs = GlooLang::Persist::FileStorage.new( pn, obj )
|
48
|
+
fs = GlooLang::Persist::FileStorage.new( @engine, pn, obj )
|
48
49
|
fs.save
|
49
50
|
end
|
50
51
|
|
@@ -56,11 +57,11 @@ module GlooLang
|
|
56
57
|
return unless pns
|
57
58
|
|
58
59
|
pns.each do |pn|
|
59
|
-
|
60
|
-
fs = GlooLang::Persist::FileStorage.new( pn )
|
60
|
+
@engine.log.debug "Load file(s) at: #{pn}"
|
61
|
+
fs = GlooLang::Persist::FileStorage.new( @engine, pn )
|
61
62
|
fs.load
|
62
63
|
@maps << fs
|
63
|
-
|
64
|
+
@engine.event_manager.on_load fs.obj
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
@@ -72,7 +73,7 @@ module GlooLang
|
|
72
73
|
|
73
74
|
if name.strip[ -1 ] == '*'
|
74
75
|
pns = []
|
75
|
-
dir = File.join(
|
76
|
+
dir = File.join( @engine.settings.project_path, name[ 0..-2 ] )
|
76
77
|
Dir.glob( "#{dir}*.gloo" ).each do |f|
|
77
78
|
pns << f
|
78
79
|
end
|
@@ -82,7 +83,7 @@ module GlooLang
|
|
82
83
|
return [ ext_path ] if self.gloo_file?( ext_path )
|
83
84
|
|
84
85
|
full_name = "#{name}#{file_ext}"
|
85
|
-
return [ File.join(
|
86
|
+
return [ File.join( @engine.settings.project_path, full_name ) ]
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
@@ -17,7 +17,8 @@ module GlooLang
|
|
17
17
|
#
|
18
18
|
# Create a stats utility class for the given directory.
|
19
19
|
#
|
20
|
-
def initialize( dir, types, skip = [] )
|
20
|
+
def initialize( engine, dir, types, skip = [] )
|
21
|
+
@engine = engine
|
21
22
|
@dir = dir
|
22
23
|
setup_loc types
|
23
24
|
@skip = skip
|
@@ -34,8 +35,8 @@ module GlooLang
|
|
34
35
|
def valid?
|
35
36
|
return true if @dir && File.directory?( @dir )
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
@engine.err DIR_NOT_FOUND_ERR
|
39
|
+
@engine.heap.it.set_to false
|
39
40
|
|
40
41
|
return false
|
41
42
|
end
|
@@ -136,7 +137,7 @@ module GlooLang
|
|
136
137
|
def generate
|
137
138
|
return if @folders
|
138
139
|
|
139
|
-
|
140
|
+
@engine.log.debug 'Generating...'
|
140
141
|
@folders = []
|
141
142
|
@types = {}
|
142
143
|
@file_cnt = 0
|
@@ -24,7 +24,7 @@ module GlooLang
|
|
24
24
|
# Show the current context.
|
25
25
|
#
|
26
26
|
def show_context
|
27
|
-
|
27
|
+
@engine.log.show "Context: #{@engine.heap.context}"
|
28
28
|
end
|
29
29
|
|
30
30
|
#
|
@@ -52,9 +52,9 @@ module GlooLang
|
|
52
52
|
#
|
53
53
|
def set_context
|
54
54
|
path = @tokens.second
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
@engine.heap.context.set_to path
|
56
|
+
@engine.heap.it.set_to path
|
57
|
+
@engine.log.debug "Context set to #{@engine.heap.context}"
|
58
58
|
end
|
59
59
|
|
60
60
|
end
|
@@ -23,7 +23,7 @@ module GlooLang
|
|
23
23
|
value = @tokens.after_token( VAL )
|
24
24
|
|
25
25
|
unless name
|
26
|
-
|
26
|
+
@engine.err NO_NAME_ERR
|
27
27
|
return
|
28
28
|
end
|
29
29
|
create name, type, value
|
@@ -57,10 +57,10 @@ module GlooLang
|
|
57
57
|
if GlooLang::Expr::LString.string?( value )
|
58
58
|
value = GlooLang::Expr::LString.strip_quotes( value )
|
59
59
|
end
|
60
|
-
obj =
|
60
|
+
obj = @engine.factory.create( { name: name, type: type, value: value } )
|
61
61
|
|
62
62
|
obj.add_default_children if obj&.add_children_on_create?
|
63
|
-
|
63
|
+
@engine.heap.it.set_to value
|
64
64
|
end
|
65
65
|
|
66
66
|
end
|
@@ -17,20 +17,20 @@ module GlooLang
|
|
17
17
|
#
|
18
18
|
def run
|
19
19
|
if @tokens.token_count < 2
|
20
|
-
|
20
|
+
@engine.err MISSING_EXPR_ERR
|
21
21
|
return
|
22
22
|
end
|
23
23
|
|
24
|
-
expr = GlooLang::Expr::Expression.new( @tokens.params )
|
24
|
+
expr = GlooLang::Expr::Expression.new( @engine, @tokens.params )
|
25
25
|
cmd = expr.evaluate
|
26
|
-
|
26
|
+
@engine.log.debug "starting cmd: #{cmd}"
|
27
27
|
|
28
28
|
pid = fork { exec( cmd ) }
|
29
29
|
Process.wait pid
|
30
30
|
|
31
31
|
# pid = spawn cmd
|
32
32
|
# Process.wait pid
|
33
|
-
|
33
|
+
@engine.log.debug "done executing cmd: #{cmd}"
|
34
34
|
|
35
35
|
# system expr.evaluate #, chdir: Dir.pwd
|
36
36
|
# `#{expr.evaluate}`
|
data/lib/gloo_lang/verbs/help.rb
CHANGED
@@ -36,7 +36,7 @@ module GlooLang
|
|
36
36
|
if opts
|
37
37
|
dispatch opts
|
38
38
|
else
|
39
|
-
|
39
|
+
@engine.help.page_topic DEFAULT_HELP
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -46,7 +46,7 @@ module GlooLang
|
|
46
46
|
def get_verb_list
|
47
47
|
out = "Verbs:\n"
|
48
48
|
str = ''
|
49
|
-
verbs =
|
49
|
+
verbs = @engine.dictionary.get_verbs.sort_by( &:keyword )
|
50
50
|
verbs.each_with_index do |v, i|
|
51
51
|
cut = v.keyword_shortcut.ljust( 5, ' ' )
|
52
52
|
str << " #{cut} #{v.keyword.ljust( 20, ' ' )}"
|
@@ -72,7 +72,7 @@ module GlooLang
|
|
72
72
|
def get_obj_list
|
73
73
|
out = "Object Types:\n"
|
74
74
|
str = ''
|
75
|
-
objs =
|
75
|
+
objs = @engine.dictionary.get_obj_types.sort_by( &:typename )
|
76
76
|
objs.each_with_index do |o, i|
|
77
77
|
name = o.typename
|
78
78
|
if o.short_typename != o.typename
|
@@ -94,7 +94,7 @@ module GlooLang
|
|
94
94
|
def get_topics
|
95
95
|
out = "Help Topics:\n"
|
96
96
|
str = ''
|
97
|
-
objs =
|
97
|
+
objs = @engine.help.topics.keys.sort
|
98
98
|
objs.each_with_index do |o, i|
|
99
99
|
str << " #{o.ljust( 30, ' ' )}"
|
100
100
|
if ( ( i + 1 ) % 4 ).zero?
|
@@ -130,7 +130,7 @@ module GlooLang
|
|
130
130
|
# Report an error with the inline help.
|
131
131
|
#
|
132
132
|
def report_help_error( opts )
|
133
|
-
|
133
|
+
@engine.err "#{HELP_NOT_FOUND_ERR} '#{opts}'"
|
134
134
|
end
|
135
135
|
|
136
136
|
#
|
@@ -139,13 +139,13 @@ module GlooLang
|
|
139
139
|
def dispatch( opts )
|
140
140
|
return if dispatch_help_page( opts )
|
141
141
|
|
142
|
-
|
142
|
+
@engine.log.debug 'looking for built in help topic'
|
143
143
|
cmd = DISPATCH[ opts.to_sym ]
|
144
144
|
if cmd
|
145
|
-
|
145
|
+
@engine.log.debug 'found help index'
|
146
146
|
send cmd
|
147
147
|
else
|
148
|
-
|
148
|
+
@engine.log.debug 'looking for entity help'
|
149
149
|
entity_help opts
|
150
150
|
end
|
151
151
|
rescue
|
@@ -156,16 +156,16 @@ module GlooLang
|
|
156
156
|
# Dispatch to a help page if we can find one.
|
157
157
|
#
|
158
158
|
def dispatch_help_page( opts )
|
159
|
-
if
|
160
|
-
|
161
|
-
|
159
|
+
if @engine.help.topic? opts
|
160
|
+
@engine.log.debug 'found expanded help topic'
|
161
|
+
@engine.help.page_topic opts
|
162
162
|
return true
|
163
163
|
end
|
164
164
|
|
165
|
-
key =
|
166
|
-
if
|
167
|
-
|
168
|
-
|
165
|
+
key = @engine.dictionary.lookup_keyword opts
|
166
|
+
if @engine.help.topic? key
|
167
|
+
@engine.log.debug 'found expanded help topic'
|
168
|
+
@engine.help.page_topic key
|
169
169
|
return true
|
170
170
|
end
|
171
171
|
|
@@ -177,8 +177,8 @@ module GlooLang
|
|
177
177
|
# silent mode.
|
178
178
|
#
|
179
179
|
def show_output( out )
|
180
|
-
|
181
|
-
puts out unless
|
180
|
+
@engine.heap.it.set_to out
|
181
|
+
puts out unless @engine.args.quiet?
|
182
182
|
end
|
183
183
|
|
184
184
|
#
|
@@ -205,8 +205,8 @@ module GlooLang
|
|
205
205
|
# information about.
|
206
206
|
#
|
207
207
|
def try_verb_help( opts )
|
208
|
-
if
|
209
|
-
t =
|
208
|
+
if @engine.dictionary.verb?( opts )
|
209
|
+
t = @engine.dictionary.find_verb( opts )
|
210
210
|
out = t.send 'help'
|
211
211
|
show_output out
|
212
212
|
return true
|
@@ -220,8 +220,8 @@ module GlooLang
|
|
220
220
|
# information about.
|
221
221
|
#
|
222
222
|
def try_object_help( opts )
|
223
|
-
if
|
224
|
-
t =
|
223
|
+
if @engine.dictionary.obj?( opts )
|
224
|
+
t = @engine.dictionary.find_obj( opts )
|
225
225
|
out = t.send 'help'
|
226
226
|
show_output out
|
227
227
|
return true
|
@@ -234,14 +234,14 @@ module GlooLang
|
|
234
234
|
# Show application settings.
|
235
235
|
#
|
236
236
|
def show_settings
|
237
|
-
|
237
|
+
@engine.settings.show
|
238
238
|
end
|
239
239
|
|
240
240
|
#
|
241
241
|
# Show all keywords: verbs and objects.
|
242
242
|
#
|
243
243
|
def show_keywords
|
244
|
-
|
244
|
+
@engine.dictionary.show_keywords
|
245
245
|
end
|
246
246
|
|
247
247
|
#
|
data/lib/gloo_lang/verbs/if.rb
CHANGED
@@ -55,7 +55,7 @@ module GlooLang
|
|
55
55
|
# The first token is the verb, so we drop it.
|
56
56
|
value = value[ 1..-1 ]
|
57
57
|
else
|
58
|
-
|
58
|
+
@engine.err MISSING_EXPR_ERR
|
59
59
|
end
|
60
60
|
|
61
61
|
return value
|
@@ -67,7 +67,7 @@ module GlooLang
|
|
67
67
|
def evals_true( value )
|
68
68
|
eval_result = false
|
69
69
|
if value.count.positive?
|
70
|
-
expr = GlooLang::Expr::Expression.new( value )
|
70
|
+
expr = GlooLang::Expr::Expression.new( @engine, value )
|
71
71
|
result = expr.evaluate
|
72
72
|
eval_result = true if result == true
|
73
73
|
eval_result = true if result.is_a?( Numeric ) && result != 0
|
@@ -81,7 +81,7 @@ module GlooLang
|
|
81
81
|
#
|
82
82
|
def run_then
|
83
83
|
cmd = @tokens.expr_after( THEN )
|
84
|
-
i =
|
84
|
+
i = @engine.parser.parse_immediate cmd
|
85
85
|
return unless i
|
86
86
|
|
87
87
|
i.run
|
data/lib/gloo_lang/verbs/list.rb
CHANGED
@@ -22,7 +22,7 @@ module GlooLang
|
|
22
22
|
if obj
|
23
23
|
show_target( obj, levels )
|
24
24
|
else
|
25
|
-
|
25
|
+
@engine.err "#{TARGET_MISSING_ERR} #{target}"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -30,9 +30,9 @@ module GlooLang
|
|
30
30
|
# Determine the target object for the show command.
|
31
31
|
#
|
32
32
|
def determine_target
|
33
|
-
return
|
33
|
+
return @engine.heap.context if @tokens.token_count == 1
|
34
34
|
|
35
|
-
return GlooLang::Core::Pn.new( @tokens.second )
|
35
|
+
return GlooLang::Core::Pn.new( @engine, @tokens.second )
|
36
36
|
end
|
37
37
|
|
38
38
|
#
|
@@ -72,12 +72,12 @@ module GlooLang
|
|
72
72
|
#
|
73
73
|
def show_obj( obj, indent = ' ' )
|
74
74
|
if obj.multiline_value? && obj.value_is_array?
|
75
|
-
|
75
|
+
@engine.log.show "#{indent}#{obj.name} [#{obj.type_display}] :"
|
76
76
|
obj.value.each do |line|
|
77
|
-
|
77
|
+
@engine.log.show "#{indent} #{line}"
|
78
78
|
end
|
79
79
|
else
|
80
|
-
|
80
|
+
@engine.log.show "#{indent}#{obj.name} [#{obj.type_display}] : #{obj.value}"
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -86,7 +86,7 @@ module GlooLang
|
|
86
86
|
#
|
87
87
|
def determine_levels
|
88
88
|
# Check settings for the default value.
|
89
|
-
levels =
|
89
|
+
levels = @engine.settings.list_indent
|
90
90
|
return levels if levels
|
91
91
|
|
92
92
|
# Last chance: use the default
|