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
data/lib/gloo/exec/exec_env.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# The execution environment.
|
5
|
-
# The current state of running scripts and messaging.
|
6
|
-
#
|
7
|
-
|
8
|
-
module Gloo
|
9
|
-
module Exec
|
10
|
-
class ExecEnv
|
11
|
-
|
12
|
-
attr_accessor :verbs, :actions, :scripts, :here
|
13
|
-
|
14
|
-
VERB_STACK = 'verbs'.freeze
|
15
|
-
ACTION_STACK = 'actions'.freeze
|
16
|
-
SCRIPT_STACK = 'scripts'.freeze
|
17
|
-
HERE_STACK = 'here'.freeze
|
18
|
-
|
19
|
-
#
|
20
|
-
# Set up the execution environment.
|
21
|
-
#
|
22
|
-
def initialize
|
23
|
-
$log.debug 'exec env intialized...'
|
24
|
-
|
25
|
-
@verbs = Gloo::Exec::Stack.new VERB_STACK
|
26
|
-
@actions = Gloo::Exec::Stack.new ACTION_STACK
|
27
|
-
@scripts = Gloo::Exec::Stack.new SCRIPT_STACK
|
28
|
-
@here = Gloo::Exec::Stack.new HERE_STACK
|
29
|
-
end
|
30
|
-
|
31
|
-
#
|
32
|
-
# Get the here object.
|
33
|
-
#
|
34
|
-
def here_obj
|
35
|
-
return nil if @here.stack.empty?
|
36
|
-
|
37
|
-
return @here.stack.last
|
38
|
-
end
|
39
|
-
|
40
|
-
#
|
41
|
-
# Push a script onto the stack.
|
42
|
-
#
|
43
|
-
def push_script( script )
|
44
|
-
@scripts.push script
|
45
|
-
@here.push script.obj
|
46
|
-
end
|
47
|
-
|
48
|
-
#
|
49
|
-
# Pop a script off the stack.
|
50
|
-
#
|
51
|
-
def pop_script
|
52
|
-
@scripts.pop
|
53
|
-
@here.pop
|
54
|
-
end
|
55
|
-
|
56
|
-
#
|
57
|
-
# Push an action onto the stack.
|
58
|
-
#
|
59
|
-
def push_action( action )
|
60
|
-
@actions.push action
|
61
|
-
# @here.push action.to
|
62
|
-
end
|
63
|
-
|
64
|
-
#
|
65
|
-
# Pop an action off the stack.
|
66
|
-
#
|
67
|
-
def pop_action
|
68
|
-
@actions.pop
|
69
|
-
# @here.pop
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
data/lib/gloo/exec/runner.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# The Runner is a static helper function.
|
5
|
-
# It is used to send the run command to verbs.
|
6
|
-
#
|
7
|
-
|
8
|
-
module Gloo
|
9
|
-
module Exec
|
10
|
-
class Runner
|
11
|
-
|
12
|
-
#
|
13
|
-
# Dispatch run command to a verb.
|
14
|
-
# We abstract this out in case there are things
|
15
|
-
# that need to be done before or after a verb
|
16
|
-
# is done running.
|
17
|
-
#
|
18
|
-
def self.go( verb )
|
19
|
-
$log.debug "running verb #{verb.type_display}"
|
20
|
-
$engine.heap.error.start_tracking
|
21
|
-
$engine.exec_env.verbs.push verb
|
22
|
-
verb&.run
|
23
|
-
$engine.exec_env.verbs.pop
|
24
|
-
$engine.heap.error.clear_if_no_errors
|
25
|
-
end
|
26
|
-
|
27
|
-
#
|
28
|
-
# Send 'run' message to the object.
|
29
|
-
# Resolve the path_name and then send the run message.
|
30
|
-
#
|
31
|
-
def self.run( path_name )
|
32
|
-
$log.debug "running script at #{path_name}"
|
33
|
-
pn = Gloo::Core::Pn.new path_name
|
34
|
-
o = pn.resolve
|
35
|
-
|
36
|
-
if o
|
37
|
-
o.send_message 'run'
|
38
|
-
else
|
39
|
-
$log.error "Could not send message to object. Bad path: #{path_name}"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/lib/gloo/exec/script.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# A script to be run.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Exec
|
9
|
-
class Script
|
10
|
-
|
11
|
-
attr_accessor :obj
|
12
|
-
|
13
|
-
#
|
14
|
-
# Set up the script.
|
15
|
-
#
|
16
|
-
def initialize( obj )
|
17
|
-
@obj = obj
|
18
|
-
end
|
19
|
-
|
20
|
-
#
|
21
|
-
# Run the script.
|
22
|
-
# The script might be a single string or an array
|
23
|
-
# of lines.
|
24
|
-
#
|
25
|
-
def run
|
26
|
-
$engine.exec_env.push_script self
|
27
|
-
|
28
|
-
if @obj.value.is_a? String
|
29
|
-
$engine.parser.run @obj.value
|
30
|
-
elsif @obj.value.is_a? Array
|
31
|
-
@obj.value.each do |line|
|
32
|
-
$engine.parser.run line
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
$engine.exec_env.pop_script
|
37
|
-
end
|
38
|
-
|
39
|
-
#
|
40
|
-
# Generic function to get display value.
|
41
|
-
# Can be used for debugging, etc.
|
42
|
-
#
|
43
|
-
def display_value
|
44
|
-
return @obj.pn
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
data/lib/gloo/exec/stack.rb
DELETED
@@ -1,78 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# A stack of items, a call stack.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Exec
|
9
|
-
class Stack
|
10
|
-
|
11
|
-
attr_accessor :stack
|
12
|
-
|
13
|
-
#
|
14
|
-
# Set up the stack.
|
15
|
-
#
|
16
|
-
def initialize( name )
|
17
|
-
@name = name
|
18
|
-
clear_stack
|
19
|
-
$log.debug "#{name} stack intialized..."
|
20
|
-
end
|
21
|
-
|
22
|
-
#
|
23
|
-
# Push an item onto the stack.
|
24
|
-
#
|
25
|
-
def push( obj )
|
26
|
-
$log.debug "#{@name}:push #{obj.display_value}"
|
27
|
-
@stack.push obj
|
28
|
-
self.update_out_file if $settings.debug
|
29
|
-
end
|
30
|
-
|
31
|
-
#
|
32
|
-
# Pop an item from the stack.
|
33
|
-
#
|
34
|
-
def pop
|
35
|
-
o = @stack.pop
|
36
|
-
$log.debug "#{@name}:pop #{o.display_value}"
|
37
|
-
self.update_out_file if $settings.debug
|
38
|
-
end
|
39
|
-
|
40
|
-
#
|
41
|
-
# Get the current size of the call stack.
|
42
|
-
#
|
43
|
-
def size
|
44
|
-
return @stack.size
|
45
|
-
end
|
46
|
-
|
47
|
-
#
|
48
|
-
# Get stack data for output.
|
49
|
-
#
|
50
|
-
def out_data
|
51
|
-
return @stack.map( &:display_value ).join( "\n" )
|
52
|
-
end
|
53
|
-
|
54
|
-
#
|
55
|
-
# Get the file we'll write debug information for the stack.
|
56
|
-
#
|
57
|
-
def out_file
|
58
|
-
return File.join( $settings.debug_path, @name )
|
59
|
-
end
|
60
|
-
|
61
|
-
#
|
62
|
-
# Update the stack trace file.
|
63
|
-
#
|
64
|
-
def update_out_file
|
65
|
-
File.write( self.out_file, self.out_data )
|
66
|
-
end
|
67
|
-
|
68
|
-
#
|
69
|
-
# Clear the stack and the output file.
|
70
|
-
#
|
71
|
-
def clear_stack
|
72
|
-
@stack = []
|
73
|
-
self.update_out_file
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
data/lib/gloo/expr/expression.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# An Expression that can be evaluated.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Expr
|
9
|
-
class Expression
|
10
|
-
|
11
|
-
# ---------------------------------------------------------------------
|
12
|
-
# Constructor
|
13
|
-
# ---------------------------------------------------------------------
|
14
|
-
|
15
|
-
#
|
16
|
-
# Create the expression from a list of tokens.
|
17
|
-
#
|
18
|
-
def initialize( tokens )
|
19
|
-
@tokens = tokens
|
20
|
-
@symbols = []
|
21
|
-
@left = nil
|
22
|
-
@right = nil
|
23
|
-
@op = nil
|
24
|
-
end
|
25
|
-
|
26
|
-
# ---------------------------------------------------------------------
|
27
|
-
# Evaluate Expression
|
28
|
-
# ---------------------------------------------------------------------
|
29
|
-
|
30
|
-
#
|
31
|
-
# Evaluate the expression and return the value.
|
32
|
-
#
|
33
|
-
def evaluate
|
34
|
-
identify_tokens
|
35
|
-
|
36
|
-
@symbols.each do |sym|
|
37
|
-
if sym.is_a? Gloo::Core::Op
|
38
|
-
@op = sym
|
39
|
-
elsif @left.nil?
|
40
|
-
@left = sym
|
41
|
-
else
|
42
|
-
@right = sym
|
43
|
-
end
|
44
|
-
|
45
|
-
perform_op if @left && @right
|
46
|
-
end
|
47
|
-
|
48
|
-
return @left.value if @left.is_a? Gloo::Core::Literal
|
49
|
-
return resolve_ref @left if @left.is_a? Gloo::Core::Pn
|
50
|
-
|
51
|
-
return @left
|
52
|
-
end
|
53
|
-
|
54
|
-
# ---------------------------------------------------------------------
|
55
|
-
# Private functions
|
56
|
-
# ---------------------------------------------------------------------
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
#
|
61
|
-
# Perform the operation.
|
62
|
-
#
|
63
|
-
def perform_op
|
64
|
-
@op ||= Gloo::Core::Op.default_op
|
65
|
-
l = evaluate_sym @left
|
66
|
-
r = evaluate_sym @right
|
67
|
-
@left = @op.perform l, r
|
68
|
-
@right = nil
|
69
|
-
@op = nil
|
70
|
-
end
|
71
|
-
|
72
|
-
#
|
73
|
-
# Evaluate the symbol and get a simple value.
|
74
|
-
#
|
75
|
-
def evaluate_sym( sym )
|
76
|
-
return sym.value if sym.is_a? Gloo::Core::Literal
|
77
|
-
return resolve_ref sym if sym.is_a? Gloo::Core::Pn
|
78
|
-
|
79
|
-
return sym
|
80
|
-
end
|
81
|
-
|
82
|
-
#
|
83
|
-
# resolve an object reference and get the value.
|
84
|
-
#
|
85
|
-
def resolve_ref( ref )
|
86
|
-
return ref.src if ref.named_color?
|
87
|
-
|
88
|
-
ob = ref.resolve
|
89
|
-
return ob.value if ob
|
90
|
-
end
|
91
|
-
|
92
|
-
#
|
93
|
-
# Identify each token in the list.
|
94
|
-
#
|
95
|
-
def identify_tokens
|
96
|
-
@tokens.each do |o|
|
97
|
-
@symbols << identify_token( o )
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
#
|
102
|
-
# Identify the tokens and create appropriate symbols.
|
103
|
-
#
|
104
|
-
def identify_token( token )
|
105
|
-
return Gloo::Core::Op.create_op( token ) if Gloo::Core::Op.op?( token )
|
106
|
-
|
107
|
-
return LBoolean.new( token ) if LBoolean.boolean?( token )
|
108
|
-
return LInteger.new( token ) if LInteger.integer?( token )
|
109
|
-
return LString.new( token ) if LString.string?( token )
|
110
|
-
return LDecimal.new( token ) if LDecimal.decimal?( token )
|
111
|
-
|
112
|
-
# last chance: an Object reference
|
113
|
-
return Gloo::Core::Pn.new( token )
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
data/lib/gloo/expr/l_boolean.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
|
-
# An Expression that can be evaluated.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Expr
|
9
|
-
class LBoolean < Gloo::Core::Literal
|
10
|
-
|
11
|
-
#
|
12
|
-
# Is the given token a boolean?
|
13
|
-
#
|
14
|
-
def self.boolean?( token )
|
15
|
-
return Gloo::Objs::Boolean.boolean? token
|
16
|
-
end
|
17
|
-
|
18
|
-
#
|
19
|
-
# Set the value, converting to an boolean.
|
20
|
-
#
|
21
|
-
def set_value( value )
|
22
|
-
@value = Gloo::Objs::Boolean.coerse_to_bool value
|
23
|
-
end
|
24
|
-
|
25
|
-
#
|
26
|
-
# Get string representation
|
27
|
-
#
|
28
|
-
def to_s
|
29
|
-
return 'false' unless @value
|
30
|
-
|
31
|
-
return @value.to_s
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/lib/gloo/expr/l_decimal.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# A literal decimal value.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Expr
|
9
|
-
class LDecimal < Gloo::Core::Literal
|
10
|
-
|
11
|
-
#
|
12
|
-
# Is the given token a decimal?
|
13
|
-
#
|
14
|
-
def self.decimal?( token )
|
15
|
-
return true if token.is_a? Numeric
|
16
|
-
|
17
|
-
s = token.strip
|
18
|
-
return s.to_f.to_s == s
|
19
|
-
end
|
20
|
-
|
21
|
-
#
|
22
|
-
# Set the value, converting to an integer.
|
23
|
-
#
|
24
|
-
def set_value( value )
|
25
|
-
value = value.to_s if value.is_a? Numeric
|
26
|
-
|
27
|
-
@value = value.to_f
|
28
|
-
end
|
29
|
-
|
30
|
-
#
|
31
|
-
# Get string representation
|
32
|
-
#
|
33
|
-
def to_s
|
34
|
-
return self.value.to_s
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/lib/gloo/expr/l_integer.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# An Expression that can be evaluated.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Expr
|
9
|
-
class LInteger < Gloo::Core::Literal
|
10
|
-
|
11
|
-
#
|
12
|
-
# Is the given token an integer?
|
13
|
-
#
|
14
|
-
def self.integer?( token )
|
15
|
-
return true if token.is_a? Integer
|
16
|
-
|
17
|
-
s = token.strip
|
18
|
-
return s.to_i.to_s == s
|
19
|
-
end
|
20
|
-
|
21
|
-
#
|
22
|
-
# Set the value, converting to an integer.
|
23
|
-
#
|
24
|
-
def set_value( value )
|
25
|
-
@value = value.to_i
|
26
|
-
end
|
27
|
-
|
28
|
-
#
|
29
|
-
# Get string representation
|
30
|
-
#
|
31
|
-
def to_s
|
32
|
-
return self.value.to_s
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/lib/gloo/expr/l_string.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# An Expression that can be evaluated.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Expr
|
9
|
-
class LString < Gloo::Core::Literal
|
10
|
-
|
11
|
-
#
|
12
|
-
# Set the value, triming opening and closing
|
13
|
-
# quotations if necessary.
|
14
|
-
#
|
15
|
-
def set_value( value )
|
16
|
-
@value = value
|
17
|
-
return unless value
|
18
|
-
|
19
|
-
@value = LString.strip_quotes( @value )
|
20
|
-
end
|
21
|
-
|
22
|
-
#
|
23
|
-
# Is the given token a string?
|
24
|
-
#
|
25
|
-
def self.string?( token )
|
26
|
-
return false unless token.is_a? String
|
27
|
-
return true if token.start_with?( '"' )
|
28
|
-
return true if token.start_with?( "'" )
|
29
|
-
|
30
|
-
return false
|
31
|
-
end
|
32
|
-
|
33
|
-
#
|
34
|
-
# Given a string with leading and trailing quotes,
|
35
|
-
# strip them out.
|
36
|
-
#
|
37
|
-
def self.strip_quotes( str )
|
38
|
-
if str.start_with?( '"' )
|
39
|
-
str = str[ 1..-1 ]
|
40
|
-
str = str[ 0..-2 ] if str.end_with?( '"' )
|
41
|
-
return str
|
42
|
-
elsif str.start_with?( "'" )
|
43
|
-
str = str[ 1..-1 ]
|
44
|
-
str = str[ 0..-2 ] if str.end_with?( "'" )
|
45
|
-
return str
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
#
|
50
|
-
# Get string representation
|
51
|
-
#
|
52
|
-
def to_s
|
53
|
-
return self.value
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/lib/gloo/expr/op_div.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Division operator.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Expr
|
9
|
-
class OpDiv < Gloo::Core::Op
|
10
|
-
|
11
|
-
#
|
12
|
-
# Perform the operation and return the result.
|
13
|
-
#
|
14
|
-
def perform( left, right )
|
15
|
-
return left / right.to_i if left.is_a? Integer
|
16
|
-
|
17
|
-
return left / right.to_f if left.is_a? Numeric
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/gloo/expr/op_minus.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Subtraction operator.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Expr
|
9
|
-
class OpMinus < Gloo::Core::Op
|
10
|
-
|
11
|
-
#
|
12
|
-
# Perform the operation and return the result.
|
13
|
-
#
|
14
|
-
def perform( left, right )
|
15
|
-
return left - right.to_i if left.is_a? Integer
|
16
|
-
|
17
|
-
return left - right.to_f if left.is_a? Numeric
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/gloo/expr/op_mult.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Multiplication operator.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Expr
|
9
|
-
class OpMult < Gloo::Core::Op
|
10
|
-
|
11
|
-
#
|
12
|
-
# Perform the operation and return the result.
|
13
|
-
#
|
14
|
-
def perform( left, right )
|
15
|
-
return left * right.to_i if left.is_a? Integer
|
16
|
-
|
17
|
-
return left * right.to_f if left.is_a? Numeric
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/gloo/expr/op_plus.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Addition operator.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Gloo
|
8
|
-
module Expr
|
9
|
-
class OpPlus < Gloo::Core::Op
|
10
|
-
|
11
|
-
#
|
12
|
-
# Perform the operation and return the result.
|
13
|
-
#
|
14
|
-
def perform( left, right )
|
15
|
-
return left + right.to_s if left.is_a? String
|
16
|
-
|
17
|
-
return left + right.to_i if left.is_a? Integer
|
18
|
-
|
19
|
-
return left + right.to_f if left.is_a? Numeric
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
GLOO APPLICATION
|
2
|
-
|
3
|
-
DESCRIPTION
|
4
|
-
Gloo scripting language. A scripting language built on ruby.
|
5
|
-
More information coming soon.
|
6
|
-
|
7
|
-
SYNOPSIS
|
8
|
-
gloo [global option] [file]
|
9
|
-
|
10
|
-
GLOBAL OPTIONS
|
11
|
-
--cli - Run in CLI mode
|
12
|
-
- If no options are specified, this is the default.
|
13
|
-
--version - Show application version
|
14
|
-
--help - Show this help page
|
15
|
-
|
16
|
-
FILE
|
17
|
-
TODO: document running a gloo script
|
18
|
-
how to reference files by relative path in gloo folder
|
19
|
-
and also by absolute path
|
20
|
-
|
21
|
-
SEE ALSO
|
22
|
-
application, configuration
|
@@ -1,14 +0,0 @@
|
|
1
|
-
GLOO HELP
|
2
|
-
|
3
|
-
TODO: write this article
|
4
|
-
|
5
|
-
LISTS
|
6
|
-
Show options for object and verb lists
|
7
|
-
|
8
|
-
DETAIL
|
9
|
-
How to get help detail for verbs and objects
|
10
|
-
How to see a help pages
|
11
|
-
How to see a list of help pages (topics)
|
12
|
-
|
13
|
-
SEE ALSO
|
14
|
-
application, configuration
|
@@ -1,16 +0,0 @@
|
|
1
|
-
GLOO APPLICATION LOGGING
|
2
|
-
|
3
|
-
DESCRIPTION
|
4
|
-
Gloo writes to the gloo.log as well as to the console.
|
5
|
-
Debug messages are written to the log only, but other messages
|
6
|
-
are also written to the console unless the application is
|
7
|
-
running in quiet mode.
|
8
|
-
|
9
|
-
CONFIGURATION
|
10
|
-
The application logs folder is in the gloo folder.
|
11
|
-
When gloo is run, the gloo.log file will be written to.
|
12
|
-
|
13
|
-
TAIL
|
14
|
-
Example tail command to watch the gloo log:
|
15
|
-
|
16
|
-
tail -f ~/gloo/logs/gloo.log
|