gloo-lang 0.9.7 → 0.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +16 -1
- data/gloo-lang.gemspec +1 -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/engine_context.rb +25 -0
- 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 +30 -37
- 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 +23 -2
@@ -53,7 +53,7 @@ module GlooLang
|
|
53
53
|
o = find_child DO
|
54
54
|
return unless o
|
55
55
|
|
56
|
-
GlooLang::Exec::Dispatch.message 'run', o
|
56
|
+
GlooLang::Exec::Dispatch.message( @engine, 'run', o )
|
57
57
|
end
|
58
58
|
|
59
59
|
# ---------------------------------------------------------------------
|
@@ -75,7 +75,7 @@ module GlooLang
|
|
75
75
|
# for default configurations.
|
76
76
|
#
|
77
77
|
def add_default_children
|
78
|
-
fac =
|
78
|
+
fac = @engine.factory
|
79
79
|
fac.create_string WORD, '', self
|
80
80
|
fac.create_string IN, '', self
|
81
81
|
fac.create_script DO, '', self
|
@@ -127,7 +127,7 @@ module GlooLang
|
|
127
127
|
o = find_child IN
|
128
128
|
return unless o
|
129
129
|
|
130
|
-
o = GlooLang::Objs::Alias.resolve_alias( o )
|
130
|
+
o = GlooLang::Objs::Alias.resolve_alias( @engine, o )
|
131
131
|
o.children.each do |child|
|
132
132
|
set_child child
|
133
133
|
run_do
|
@@ -44,7 +44,7 @@ module GlooLang
|
|
44
44
|
o = find_child DO
|
45
45
|
return unless o
|
46
46
|
|
47
|
-
GlooLang::Exec::Dispatch.message 'run', o
|
47
|
+
GlooLang::Exec::Dispatch.message( @engine, 'run', o )
|
48
48
|
end
|
49
49
|
|
50
50
|
#
|
@@ -76,7 +76,7 @@ module GlooLang
|
|
76
76
|
# for default configurations.
|
77
77
|
#
|
78
78
|
def add_default_children
|
79
|
-
fac =
|
79
|
+
fac = @engine.factory
|
80
80
|
fac.create_int TIMES, 0, self
|
81
81
|
fac.create_int INDEX, 0, self
|
82
82
|
fac.create_script DO, '', self
|
@@ -62,7 +62,7 @@ module GlooLang
|
|
62
62
|
# Show the markdown data in the terminal.
|
63
63
|
#
|
64
64
|
def msg_show
|
65
|
-
|
65
|
+
@engine.platform.show( self.value, true, false )
|
66
66
|
end
|
67
67
|
|
68
68
|
#
|
@@ -71,7 +71,7 @@ module GlooLang
|
|
71
71
|
def msg_page
|
72
72
|
return unless self.value
|
73
73
|
|
74
|
-
|
74
|
+
@engine.platform.show( md, true, true )
|
75
75
|
end
|
76
76
|
|
77
77
|
end
|
@@ -52,7 +52,7 @@ module GlooLang
|
|
52
52
|
# for default configurations.
|
53
53
|
#
|
54
54
|
def add_default_children
|
55
|
-
fac =
|
55
|
+
fac = @engine.factory
|
56
56
|
fac.create_alias DB, nil, self
|
57
57
|
fac.create_string SQL, nil, self
|
58
58
|
fac.create_can RESULT, self
|
@@ -75,7 +75,7 @@ module GlooLang
|
|
75
75
|
def msg_run
|
76
76
|
db = db_obj
|
77
77
|
unless db
|
78
|
-
|
78
|
+
@engine.err DB_MISSING_ERR
|
79
79
|
return
|
80
80
|
end
|
81
81
|
|
@@ -94,7 +94,7 @@ module GlooLang
|
|
94
94
|
#
|
95
95
|
def db_obj
|
96
96
|
o = find_child DB
|
97
|
-
return GlooLang::Objs::Alias.resolve_alias( o )
|
97
|
+
return GlooLang::Objs::Alias.resolve_alias( @engine, o )
|
98
98
|
end
|
99
99
|
|
100
100
|
#
|
@@ -161,7 +161,7 @@ module GlooLang
|
|
161
161
|
#
|
162
162
|
def update_result_contaier( data )
|
163
163
|
r = find_child RESULT
|
164
|
-
r = GlooLang::Objs::Alias.resolve_alias( r )
|
164
|
+
r = GlooLang::Objs::Alias.resolve_alias( @engine, r )
|
165
165
|
data.each_with_index do |row, i|
|
166
166
|
can = r.find_add_child( i.to_s, 'can' )
|
167
167
|
row.each do |k, v|
|
@@ -57,7 +57,7 @@ module GlooLang
|
|
57
57
|
o = find_child DATA
|
58
58
|
return [] unless o
|
59
59
|
|
60
|
-
o = GlooLang::Objs::Alias.resolve_alias( o )
|
60
|
+
o = GlooLang::Objs::Alias.resolve_alias( @engine, o )
|
61
61
|
cols = self.columns
|
62
62
|
return o.children.map do |e|
|
63
63
|
cols.map { |h| e.find_child( h ).value }
|
@@ -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_can HEADERS, self
|
88
88
|
fac.create_can DATA, self
|
89
89
|
end
|
@@ -104,7 +104,7 @@ module GlooLang
|
|
104
104
|
#
|
105
105
|
def msg_show
|
106
106
|
title = self.value
|
107
|
-
|
107
|
+
@engine.platform.show_table headers, data, title
|
108
108
|
end
|
109
109
|
|
110
110
|
end
|
@@ -30,7 +30,7 @@ module GlooLang
|
|
30
30
|
#
|
31
31
|
def set_value( new_value )
|
32
32
|
unless new_value.is_a? DateTime
|
33
|
-
self.value =
|
33
|
+
self.value = @engine.converter.convert( new_value, 'DateTime', nil )
|
34
34
|
return
|
35
35
|
end
|
36
36
|
|
@@ -54,7 +54,7 @@ module GlooLang
|
|
54
54
|
def msg_now
|
55
55
|
t = DateTime.now.strftime( '%Y.%m.%d %I:%M:%S %P' )
|
56
56
|
self.value = t
|
57
|
-
|
57
|
+
@engine.heap.it.set_to t
|
58
58
|
end
|
59
59
|
|
60
60
|
end
|
@@ -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}`
|