gloo 0.8.0 → 1.2.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/.gitignore +2 -1
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/LICENSE.txt +1 -1
- data/gloo.gemspec +12 -4
- data/lib/VERSION +1 -1
- data/lib/dependencies.rb +4 -4
- 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/data/mysql.rb +9 -9
- data/lib/gloo/objs/data/sqlite.rb +10 -10
- 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/verbs/help.rb +7 -189
- data/lib/gloo/verbs/version.rb +3 -3
- data/lib/gloo.rb +5 -1
- data/lib/run.rb +5 -1
- metadata +41 -177
- data/Gemfile.lock +0 -171
- 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 -30
- 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 -303
- 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/help/app/application.txt +0 -22
- data/lib/gloo/help/app/configuration.txt +0 -7
- data/lib/gloo/help/app/default_help.txt +0 -14
- data/lib/gloo/help/app/logging.txt +0 -16
- data/lib/gloo/help/core/color.txt +0 -31
- data/lib/gloo/help/core/error.txt +0 -33
- data/lib/gloo/help/core/events.txt +0 -21
- data/lib/gloo/help/core/gloo_system.txt +0 -57
- data/lib/gloo/help/core/here.txt +0 -30
- data/lib/gloo/help/core/it.txt +0 -23
- data/lib/gloo/help/core/ops.txt +0 -16
- data/lib/gloo/help/core/pathname.txt +0 -29
- data/lib/gloo/help/objs/basic/alias.txt +0 -36
- data/lib/gloo/help/objs/basic/boolean.txt +0 -28
- data/lib/gloo/help/objs/basic/container.txt +0 -33
- data/lib/gloo/help/objs/basic/decimal.txt +0 -28
- data/lib/gloo/help/objs/basic/integer.txt +0 -27
- data/lib/gloo/help/objs/basic/script.txt +0 -29
- data/lib/gloo/help/objs/basic/string.txt +0 -28
- data/lib/gloo/help/objs/basic/text.txt +0 -27
- data/lib/gloo/help/objs/basic/untyped.txt +0 -22
- data/lib/gloo/help/objs/cli/banner.txt +0 -49
- data/lib/gloo/help/objs/cli/bar.txt +0 -37
- data/lib/gloo/help/objs/cli/colorize.txt +0 -33
- data/lib/gloo/help/objs/cli/confirm.txt +0 -26
- data/lib/gloo/help/objs/cli/menu.txt +0 -44
- data/lib/gloo/help/objs/cli/menu_item.txt +0 -26
- data/lib/gloo/help/objs/cli/pastel.txt +0 -43
- data/lib/gloo/help/objs/cli/prompt.txt +0 -27
- data/lib/gloo/help/objs/cli/select.txt +0 -34
- data/lib/gloo/help/objs/ctrl/each.txt +0 -48
- data/lib/gloo/help/objs/ctrl/repeat.txt +0 -38
- data/lib/gloo/help/objs/data/markdown.txt +0 -25
- data/lib/gloo/help/objs/data/mysql.txt +0 -40
- data/lib/gloo/help/objs/data/query.txt +0 -37
- data/lib/gloo/help/objs/data/sqlite.txt +0 -26
- data/lib/gloo/help/objs/data/table.txt +0 -46
- data/lib/gloo/help/objs/dev/git_repo.txt +0 -36
- data/lib/gloo/help/objs/dev/stats.txt +0 -36
- data/lib/gloo/help/objs/dt/date.txt +0 -23
- data/lib/gloo/help/objs/dt/datetime.txt +0 -24
- data/lib/gloo/help/objs/dt/time.txt +0 -23
- data/lib/gloo/help/objs/ror/erb.txt +0 -37
- data/lib/gloo/help/objs/ror/eval.txt +0 -24
- data/lib/gloo/help/objs/snd/play.txt +0 -23
- data/lib/gloo/help/objs/snd/say.txt +0 -28
- data/lib/gloo/help/objs/system/file.txt +0 -48
- data/lib/gloo/help/objs/system/ssh_exec.txt +0 -30
- data/lib/gloo/help/objs/system/system.txt +0 -32
- data/lib/gloo/help/objs/web/http_get.txt +0 -35
- data/lib/gloo/help/objs/web/http_post.txt +0 -34
- data/lib/gloo/help/objs/web/json.txt +0 -34
- data/lib/gloo/help/objs/web/slack.txt +0 -33
- data/lib/gloo/help/objs/web/teams.txt +0 -30
- data/lib/gloo/help/objs/web/uri.txt +0 -38
- data/lib/gloo/help/verbs/alert.txt +0 -33
- data/lib/gloo/help/verbs/beep.txt +0 -25
- data/lib/gloo/help/verbs/cls.txt +0 -24
- data/lib/gloo/help/verbs/context.txt +0 -43
- data/lib/gloo/help/verbs/create.txt +0 -33
- data/lib/gloo/help/verbs/execute.txt +0 -27
- data/lib/gloo/help/verbs/help.txt +0 -34
- data/lib/gloo/help/verbs/if.txt +0 -37
- data/lib/gloo/help/verbs/list.txt +0 -34
- data/lib/gloo/help/verbs/load.txt +0 -38
- data/lib/gloo/help/verbs/move.txt +0 -42
- data/lib/gloo/help/verbs/put.txt +0 -38
- data/lib/gloo/help/verbs/quit.txt +0 -25
- data/lib/gloo/help/verbs/run.txt +0 -41
- data/lib/gloo/help/verbs/save.txt +0 -26
- data/lib/gloo/help/verbs/show.txt +0 -30
- data/lib/gloo/help/verbs/tell.txt +0 -34
- data/lib/gloo/help/verbs/unless.txt +0 -38
- data/lib/gloo/help/verbs/version.txt +0 -32
- data/lib/gloo/help/verbs/wait.txt +0 -29
- 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/query.rb +0 -176
- 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/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/wait.rb +0 -42
@@ -1,266 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# The System Object.
|
5
|
-
# A virtual Object: the system object can be used to access
|
6
|
-
# system level variables and functions. But it is not
|
7
|
-
# actually an object in the normal sense of the word.
|
8
|
-
#
|
9
|
-
require 'tty-platform'
|
10
|
-
|
11
|
-
module Gloo
|
12
|
-
module Core
|
13
|
-
class GlooSystem < Obj
|
14
|
-
|
15
|
-
KEYWORD = 'gloo'.freeze
|
16
|
-
KEYWORD_SHORT = '$'.freeze
|
17
|
-
|
18
|
-
attr_reader :pn
|
19
|
-
|
20
|
-
# Set up the object.
|
21
|
-
def initialize( pn )
|
22
|
-
@pn = pn
|
23
|
-
end
|
24
|
-
|
25
|
-
#
|
26
|
-
# The name of the object type.
|
27
|
-
#
|
28
|
-
def self.typename
|
29
|
-
return KEYWORD
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
# The short name of the object type.
|
34
|
-
#
|
35
|
-
def self.short_typename
|
36
|
-
return KEYWORD_SHORT
|
37
|
-
end
|
38
|
-
|
39
|
-
#
|
40
|
-
# The object type, suitable for display.
|
41
|
-
#
|
42
|
-
def type_display
|
43
|
-
return self.class.typename
|
44
|
-
end
|
45
|
-
|
46
|
-
# Is this the root object?
|
47
|
-
def root?
|
48
|
-
return false
|
49
|
-
end
|
50
|
-
|
51
|
-
# Can this object be created?
|
52
|
-
# This is true by default and only false for some special cases
|
53
|
-
# such as the System object.
|
54
|
-
def self.can_create?
|
55
|
-
false
|
56
|
-
end
|
57
|
-
|
58
|
-
# ---------------------------------------------------------------------
|
59
|
-
# Value
|
60
|
-
# ---------------------------------------------------------------------
|
61
|
-
|
62
|
-
#
|
63
|
-
# Get the parameter.
|
64
|
-
#
|
65
|
-
def param
|
66
|
-
return nil unless @pn && @pn.segments.count > 1
|
67
|
-
|
68
|
-
return @pn.segments[ 1..-1 ].join( '_' )
|
69
|
-
end
|
70
|
-
|
71
|
-
#
|
72
|
-
# Get the system value.
|
73
|
-
#
|
74
|
-
def value
|
75
|
-
return dispatch param
|
76
|
-
end
|
77
|
-
|
78
|
-
#
|
79
|
-
# There is no value object in the system.
|
80
|
-
#
|
81
|
-
def set_value( new_value )
|
82
|
-
# overriding base functionality with dummy function
|
83
|
-
end
|
84
|
-
|
85
|
-
#
|
86
|
-
# Get the value for display purposes.
|
87
|
-
#
|
88
|
-
def value_display
|
89
|
-
return value
|
90
|
-
end
|
91
|
-
|
92
|
-
#
|
93
|
-
# Is the value a String?
|
94
|
-
#
|
95
|
-
def value_string?
|
96
|
-
return true
|
97
|
-
end
|
98
|
-
|
99
|
-
#
|
100
|
-
# Is the value an Array?
|
101
|
-
#
|
102
|
-
def value_is_array?
|
103
|
-
return false
|
104
|
-
end
|
105
|
-
|
106
|
-
#
|
107
|
-
# Is the value a blank string?
|
108
|
-
#
|
109
|
-
def value_is_blank?
|
110
|
-
return true
|
111
|
-
end
|
112
|
-
|
113
|
-
# ---------------------------------------------------------------------
|
114
|
-
# Children
|
115
|
-
# ---------------------------------------------------------------------
|
116
|
-
|
117
|
-
# Does this object have children to add when an object
|
118
|
-
# is created in interactive mode?
|
119
|
-
# This does not apply during obj load, etc.
|
120
|
-
def add_children_on_create?
|
121
|
-
return false
|
122
|
-
end
|
123
|
-
|
124
|
-
# ---------------------------------------------------------------------
|
125
|
-
# Messages
|
126
|
-
# ---------------------------------------------------------------------
|
127
|
-
|
128
|
-
#
|
129
|
-
# Get a list of message names that this object receives.
|
130
|
-
#
|
131
|
-
def self.messages
|
132
|
-
return []
|
133
|
-
end
|
134
|
-
|
135
|
-
# Dispatch the message and get the value.
|
136
|
-
def dispatch( msg )
|
137
|
-
o = "msg_#{msg}"
|
138
|
-
return self.public_send( o ) if self.respond_to? o
|
139
|
-
|
140
|
-
$log.error "Message #{msg} not implemented"
|
141
|
-
return false
|
142
|
-
end
|
143
|
-
|
144
|
-
# Get the system hostname.
|
145
|
-
def msg_hostname
|
146
|
-
return Socket.gethostname
|
147
|
-
end
|
148
|
-
|
149
|
-
# Get the logged in User.
|
150
|
-
def msg_user
|
151
|
-
return ENV[ 'USER' ]
|
152
|
-
end
|
153
|
-
|
154
|
-
# Get the user's home directory.
|
155
|
-
def msg_user_home
|
156
|
-
return File.expand_path( '~' )
|
157
|
-
end
|
158
|
-
|
159
|
-
# Get the working directory.
|
160
|
-
def msg_working_dir
|
161
|
-
return Dir.pwd
|
162
|
-
end
|
163
|
-
|
164
|
-
# Get the Gloo home directory
|
165
|
-
def msg_gloo_home
|
166
|
-
return $settings.user_root
|
167
|
-
end
|
168
|
-
|
169
|
-
# Get the Gloo configuration directory
|
170
|
-
def msg_gloo_config
|
171
|
-
return $settings.config_path
|
172
|
-
end
|
173
|
-
|
174
|
-
# Get the Gloo projects directory
|
175
|
-
def msg_gloo_projects
|
176
|
-
return $settings.project_path
|
177
|
-
end
|
178
|
-
|
179
|
-
# Get the Gloo log directory
|
180
|
-
def msg_gloo_log
|
181
|
-
return $settings.log_path
|
182
|
-
end
|
183
|
-
|
184
|
-
# ---------------------------------------------------------------------
|
185
|
-
# Special chars
|
186
|
-
# ---------------------------------------------------------------------
|
187
|
-
|
188
|
-
# Carriage return (line feed)
|
189
|
-
def msg_line
|
190
|
-
return "\n"
|
191
|
-
end
|
192
|
-
|
193
|
-
# ---------------------------------------------------------------------
|
194
|
-
# Screen Messages
|
195
|
-
# ---------------------------------------------------------------------
|
196
|
-
|
197
|
-
# Get the number of lines on screen.
|
198
|
-
def msg_screen_lines
|
199
|
-
return Gloo::App::Settings.lines
|
200
|
-
end
|
201
|
-
|
202
|
-
# Get the number of columns on screen.
|
203
|
-
def msg_screen_cols
|
204
|
-
return Gloo::App::Settings.cols
|
205
|
-
end
|
206
|
-
|
207
|
-
# ---------------------------------------------------------------------
|
208
|
-
# Platform Messages
|
209
|
-
# ---------------------------------------------------------------------
|
210
|
-
|
211
|
-
# Get the platform CPU
|
212
|
-
def msg_platform_cpu
|
213
|
-
platform = TTY::Platform.new
|
214
|
-
return platform.cpu
|
215
|
-
end
|
216
|
-
|
217
|
-
# Get the platform Operating System
|
218
|
-
def msg_platform_os
|
219
|
-
platform = TTY::Platform.new
|
220
|
-
return platform.os
|
221
|
-
end
|
222
|
-
|
223
|
-
# Get the platform version
|
224
|
-
def msg_platform_version
|
225
|
-
platform = TTY::Platform.new
|
226
|
-
return platform.version
|
227
|
-
end
|
228
|
-
|
229
|
-
# Is the platform Windows?
|
230
|
-
def msg_platform_windows?
|
231
|
-
platform = TTY::Platform.new
|
232
|
-
return platform.windows?
|
233
|
-
end
|
234
|
-
|
235
|
-
# Is the platform Unix?
|
236
|
-
def msg_platform_unix?
|
237
|
-
platform = TTY::Platform.new
|
238
|
-
return platform.unix?
|
239
|
-
end
|
240
|
-
|
241
|
-
# Is the platform Linux?
|
242
|
-
def msg_platform_linux?
|
243
|
-
platform = TTY::Platform.new
|
244
|
-
return platform.linux?
|
245
|
-
end
|
246
|
-
|
247
|
-
# Is the platform Mac?
|
248
|
-
def msg_platform_mac?
|
249
|
-
platform = TTY::Platform.new
|
250
|
-
return platform.mac?
|
251
|
-
end
|
252
|
-
|
253
|
-
#
|
254
|
-
# Get the command to open a file on this platform.
|
255
|
-
#
|
256
|
-
def self.open_for_platform
|
257
|
-
platform = TTY::Platform.new
|
258
|
-
return 'open' if platform.mac?
|
259
|
-
return 'xdg-open' if platform.linux?
|
260
|
-
|
261
|
-
return nil
|
262
|
-
end
|
263
|
-
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
data/lib/gloo/core/heap.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# The Object Heap.
|
5
|
-
# The collection of objects that are currently in play in
|
6
|
-
# the running engine.
|
7
|
-
#
|
8
|
-
|
9
|
-
module Gloo
|
10
|
-
module Core
|
11
|
-
class Heap
|
12
|
-
|
13
|
-
# The context is a reference to an object, usually a container.
|
14
|
-
# The context will be the root by default.
|
15
|
-
attr_reader :context
|
16
|
-
|
17
|
-
attr_reader :it, :root, :error
|
18
|
-
|
19
|
-
#
|
20
|
-
# Set up the object heap.
|
21
|
-
#
|
22
|
-
def initialize
|
23
|
-
$log.debug 'object heap intialized...'
|
24
|
-
|
25
|
-
@root = Gloo::Objs::Container.new
|
26
|
-
@root.name = 'root'
|
27
|
-
|
28
|
-
@context = Pn.root
|
29
|
-
@it = It.new
|
30
|
-
@error = Error.new
|
31
|
-
end
|
32
|
-
|
33
|
-
#
|
34
|
-
# Unload the given obj--remove it from the heap.
|
35
|
-
#
|
36
|
-
def unload( obj )
|
37
|
-
can = obj.parent.nil? ? @root : obj.parent
|
38
|
-
return unless can
|
39
|
-
|
40
|
-
can.remove_child obj
|
41
|
-
end
|
42
|
-
|
43
|
-
#
|
44
|
-
# Is there one or more errors?
|
45
|
-
#
|
46
|
-
def error?
|
47
|
-
return @error.error_count.positive?
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
data/lib/gloo/core/here.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Here helper class,
|
5
|
-
# used to resolve relative referencing.
|
6
|
-
#
|
7
|
-
|
8
|
-
module Gloo
|
9
|
-
module Core
|
10
|
-
class Here
|
11
|
-
|
12
|
-
HERE = '^'.freeze
|
13
|
-
|
14
|
-
#
|
15
|
-
# Does the pathname start with here reference?
|
16
|
-
#
|
17
|
-
def self.includes_here_ref?( elements )
|
18
|
-
return elements.first.start_with?( HERE )
|
19
|
-
end
|
20
|
-
|
21
|
-
#
|
22
|
-
# Expand here reference if present.
|
23
|
-
#
|
24
|
-
def self.expand_here( pn )
|
25
|
-
target = $engine.exec_env.here_obj
|
26
|
-
|
27
|
-
here = pn.elements.first
|
28
|
-
remainder = pn.elements[ 1..-1 ].join( '.' )
|
29
|
-
|
30
|
-
here.length.times { target = target.parent }
|
31
|
-
pn.set_to "#{target.pn}.#{remainder}"
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/lib/gloo/core/it.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# It is the value of the last command that was run.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Core
|
9
|
-
class It
|
10
|
-
|
11
|
-
attr_accessor :value
|
12
|
-
|
13
|
-
#
|
14
|
-
# Set up the object.
|
15
|
-
#
|
16
|
-
def initialize
|
17
|
-
@value = nil
|
18
|
-
end
|
19
|
-
|
20
|
-
#
|
21
|
-
# Set the value of it.
|
22
|
-
#
|
23
|
-
def set_to( new_value )
|
24
|
-
@value = new_value
|
25
|
-
end
|
26
|
-
|
27
|
-
#
|
28
|
-
# Get the string representation of it.
|
29
|
-
#
|
30
|
-
def to_s
|
31
|
-
return @value.to_s
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/lib/gloo/core/literal.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# A Literal value.
|
5
|
-
# Base class for all literal values.
|
6
|
-
#
|
7
|
-
|
8
|
-
module Gloo
|
9
|
-
module Core
|
10
|
-
class Literal
|
11
|
-
|
12
|
-
attr_reader :value
|
13
|
-
|
14
|
-
#
|
15
|
-
# Create the expression from a list of tokens.
|
16
|
-
#
|
17
|
-
def initialize( value )
|
18
|
-
set_value( value )
|
19
|
-
end
|
20
|
-
|
21
|
-
#
|
22
|
-
# Set the literal value.
|
23
|
-
#
|
24
|
-
def set_value( value )
|
25
|
-
@value = value
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
data/lib/gloo/core/obj.rb
DELETED
@@ -1,303 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# An data/value object.
|
5
|
-
# Derives from the Baseo object. Is not a verb.
|
6
|
-
#
|
7
|
-
|
8
|
-
module Gloo
|
9
|
-
module Core
|
10
|
-
class Obj < Baseo
|
11
|
-
|
12
|
-
attr_accessor :value
|
13
|
-
attr_reader :children, :parent
|
14
|
-
|
15
|
-
#
|
16
|
-
# Set up the object.
|
17
|
-
#
|
18
|
-
def initialize
|
19
|
-
@value = ''
|
20
|
-
@children = []
|
21
|
-
@parent = nil
|
22
|
-
end
|
23
|
-
|
24
|
-
#
|
25
|
-
# Register object types when they are loaded.
|
26
|
-
#
|
27
|
-
def self.inherited( subclass )
|
28
|
-
Dictionary.instance.register_obj( subclass )
|
29
|
-
end
|
30
|
-
|
31
|
-
#
|
32
|
-
# The name of the object type.
|
33
|
-
#
|
34
|
-
def self.typename
|
35
|
-
raise 'this method should be overriden'
|
36
|
-
end
|
37
|
-
|
38
|
-
#
|
39
|
-
# The object type, suitable for display.
|
40
|
-
#
|
41
|
-
def type_display
|
42
|
-
return self.class.typename
|
43
|
-
end
|
44
|
-
|
45
|
-
#
|
46
|
-
# Set the parent for the object.
|
47
|
-
#
|
48
|
-
def set_parent( obj )
|
49
|
-
@parent = obj
|
50
|
-
end
|
51
|
-
|
52
|
-
#
|
53
|
-
# Is this the root object?
|
54
|
-
#
|
55
|
-
def root?
|
56
|
-
return false if @parent
|
57
|
-
return false unless name.downcase == 'root'
|
58
|
-
|
59
|
-
return true
|
60
|
-
end
|
61
|
-
|
62
|
-
# Can this object be created?
|
63
|
-
# This is true by default and only false for some special cases
|
64
|
-
# such as the System object.
|
65
|
-
def self.can_create?
|
66
|
-
true
|
67
|
-
end
|
68
|
-
|
69
|
-
#
|
70
|
-
# Get the path and name to this object.
|
71
|
-
#
|
72
|
-
def pn
|
73
|
-
str = self.name
|
74
|
-
p = self.parent
|
75
|
-
while p && !p.root?
|
76
|
-
str = "#{p.name}.#{str}"
|
77
|
-
p = p.parent
|
78
|
-
end
|
79
|
-
return str
|
80
|
-
end
|
81
|
-
|
82
|
-
#
|
83
|
-
# Generic function to get display value.
|
84
|
-
# Can be used for debugging, etc.
|
85
|
-
#
|
86
|
-
def display_value
|
87
|
-
return self.pn
|
88
|
-
end
|
89
|
-
|
90
|
-
# ---------------------------------------------------------------------
|
91
|
-
# Value
|
92
|
-
# ---------------------------------------------------------------------
|
93
|
-
|
94
|
-
#
|
95
|
-
# Set the value with any necessary type conversions.
|
96
|
-
#
|
97
|
-
def set_value( new_value )
|
98
|
-
self.value = new_value
|
99
|
-
end
|
100
|
-
|
101
|
-
#
|
102
|
-
# Get the value for display purposes.
|
103
|
-
#
|
104
|
-
def value_display
|
105
|
-
return self.value.to_s
|
106
|
-
end
|
107
|
-
|
108
|
-
#
|
109
|
-
# Does this object support multi-line values?
|
110
|
-
# Initially only true for scripts.
|
111
|
-
#
|
112
|
-
def multiline_value?
|
113
|
-
return false
|
114
|
-
end
|
115
|
-
|
116
|
-
#
|
117
|
-
# Is the value a String?
|
118
|
-
#
|
119
|
-
def value_string?
|
120
|
-
return self.value.is_a? String
|
121
|
-
end
|
122
|
-
|
123
|
-
#
|
124
|
-
# Is the value an Array?
|
125
|
-
#
|
126
|
-
def value_is_array?
|
127
|
-
return self.value.is_a? Array
|
128
|
-
end
|
129
|
-
|
130
|
-
#
|
131
|
-
# Is the value a blank string?
|
132
|
-
#
|
133
|
-
def value_is_blank?
|
134
|
-
return true if value.nil?
|
135
|
-
|
136
|
-
return self.value.to_s.strip.empty?
|
137
|
-
end
|
138
|
-
|
139
|
-
# ---------------------------------------------------------------------
|
140
|
-
# Children
|
141
|
-
# ---------------------------------------------------------------------
|
142
|
-
|
143
|
-
#
|
144
|
-
# Find a child of the given name.
|
145
|
-
# If found, return it. If not found create it.
|
146
|
-
#
|
147
|
-
def find_add_child( name, type )
|
148
|
-
child = self.find_child( name )
|
149
|
-
return child if child
|
150
|
-
|
151
|
-
params = { :name => name,
|
152
|
-
:type => type,
|
153
|
-
:value => nil,
|
154
|
-
:parent => self }
|
155
|
-
return $engine.factory.create params
|
156
|
-
end
|
157
|
-
|
158
|
-
#
|
159
|
-
# Add a child object to the container.
|
160
|
-
#
|
161
|
-
def add_child( obj )
|
162
|
-
@children << obj
|
163
|
-
obj.set_parent self
|
164
|
-
end
|
165
|
-
|
166
|
-
#
|
167
|
-
# Get the number of children.
|
168
|
-
#
|
169
|
-
def child_count
|
170
|
-
return @children.count
|
171
|
-
end
|
172
|
-
|
173
|
-
#
|
174
|
-
# Does this object contain an object with the given name?
|
175
|
-
#
|
176
|
-
def contains_child?( name )
|
177
|
-
@children.each do |o|
|
178
|
-
return true if name.downcase == o.name.downcase
|
179
|
-
end
|
180
|
-
return false
|
181
|
-
end
|
182
|
-
|
183
|
-
#
|
184
|
-
# Find a child object with the given name.
|
185
|
-
#
|
186
|
-
def find_child( name )
|
187
|
-
if name.end_with?( Gloo::Objs::Alias::ALIAS_REFERENCE )
|
188
|
-
name = name[ 0..-2 ]
|
189
|
-
end
|
190
|
-
|
191
|
-
@children.each do |o|
|
192
|
-
return o if name.downcase == o.name.downcase
|
193
|
-
end
|
194
|
-
|
195
|
-
if self.type_display == Gloo::Objs::Alias.typename
|
196
|
-
ln = Gloo::Core::Pn.new( self.value )
|
197
|
-
redirect = ln.resolve
|
198
|
-
return redirect.find_child( name )
|
199
|
-
end
|
200
|
-
return nil
|
201
|
-
end
|
202
|
-
|
203
|
-
#
|
204
|
-
# Delete all children from the container.
|
205
|
-
#
|
206
|
-
def delete_children
|
207
|
-
@children.reverse.each do |o|
|
208
|
-
self.remove_child o
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
#
|
213
|
-
# Remove the object from the children collection.
|
214
|
-
#
|
215
|
-
def remove_child( obj )
|
216
|
-
@children.delete obj
|
217
|
-
end
|
218
|
-
|
219
|
-
# Does this object have children to add when an object
|
220
|
-
# is created in interactive mode?
|
221
|
-
# This does not apply during obj load, etc.
|
222
|
-
def add_children_on_create?
|
223
|
-
return false
|
224
|
-
end
|
225
|
-
|
226
|
-
# Add children to this object.
|
227
|
-
# This is used by containers to add children needed
|
228
|
-
# for default configurations.
|
229
|
-
def add_default_children
|
230
|
-
# Override this.
|
231
|
-
end
|
232
|
-
|
233
|
-
# ---------------------------------------------------------------------
|
234
|
-
# Messages
|
235
|
-
# ---------------------------------------------------------------------
|
236
|
-
|
237
|
-
#
|
238
|
-
# Get a list of message names that this object receives.
|
239
|
-
#
|
240
|
-
def self.messages
|
241
|
-
return %w[unload]
|
242
|
-
end
|
243
|
-
|
244
|
-
#
|
245
|
-
# Can this object receive a message?
|
246
|
-
#
|
247
|
-
def can_receive_message?( msg )
|
248
|
-
msgs = self.class.messages
|
249
|
-
return msgs.include?( msg.strip.downcase )
|
250
|
-
end
|
251
|
-
|
252
|
-
#
|
253
|
-
# Sent this object the given message.
|
254
|
-
#
|
255
|
-
def send_message( msg, params = nil )
|
256
|
-
@params = params
|
257
|
-
return self.dispatch msg if self.can_receive_message? msg
|
258
|
-
|
259
|
-
$log.error "Object #{self.name} cannot receive message #{msg}"
|
260
|
-
return false
|
261
|
-
end
|
262
|
-
|
263
|
-
#
|
264
|
-
# Dispatch the message to the object.
|
265
|
-
#
|
266
|
-
def dispatch( msg )
|
267
|
-
o = "msg_#{msg}"
|
268
|
-
if self.respond_to? o
|
269
|
-
self.public_send( o )
|
270
|
-
return true
|
271
|
-
else
|
272
|
-
$log.error "Message #{msg} not implemented"
|
273
|
-
return false
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
#
|
278
|
-
# Send the object the unload message.
|
279
|
-
#
|
280
|
-
def msg_unload
|
281
|
-
if self.root?
|
282
|
-
$log.error 'Cannot unload the root object.'
|
283
|
-
return
|
284
|
-
end
|
285
|
-
|
286
|
-
$engine.event_manager.on_unload self
|
287
|
-
$engine.heap.unload self
|
288
|
-
end
|
289
|
-
|
290
|
-
# ---------------------------------------------------------------------
|
291
|
-
# Help
|
292
|
-
# ---------------------------------------------------------------------
|
293
|
-
|
294
|
-
#
|
295
|
-
# Get help for this object.
|
296
|
-
#
|
297
|
-
def self.help
|
298
|
-
return 'No help found.'
|
299
|
-
end
|
300
|
-
|
301
|
-
end
|
302
|
-
end
|
303
|
-
end
|