gloo 0.5.0 → 0.6.0
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/.gitignore +1 -0
- data/Gemfile.lock +5 -1
- data/gloo.gemspec +2 -0
- data/lib/gloo/app/engine.rb +3 -0
- data/lib/gloo/app/info.rb +1 -1
- data/lib/gloo/app/settings.rb +49 -5
- data/lib/gloo/core/factory.rb +2 -2
- data/lib/gloo/core/here.rb +36 -0
- data/lib/gloo/core/obj.rb +8 -0
- data/lib/gloo/core/pn.rb +2 -0
- data/lib/gloo/core/verb.rb +8 -0
- data/lib/gloo/exec/action.rb +48 -0
- data/lib/gloo/exec/dispatch.rb +15 -5
- data/lib/gloo/exec/exec_env.rb +62 -0
- data/lib/gloo/exec/runner.rb +4 -2
- data/lib/gloo/{core → exec}/script.rb +21 -9
- data/lib/gloo/exec/stack.rb +78 -0
- data/lib/gloo/objs/basic/container.rb +22 -1
- data/lib/gloo/objs/basic/script.rb +1 -1
- data/lib/gloo/objs/cli/menu.rb +2 -2
- data/lib/gloo/objs/data/table.rb +1 -1
- data/lib/gloo/objs/web/http_post.rb +27 -12
- metadata +47 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d78e3893a4d68e8c47bfa5eadaf88b540eb1370eba87883cdb4280bc2b707af3
|
4
|
+
data.tar.gz: a4eca4c6ab8df0554b17b5ccedd2efb62357be12c03abe3e3301a993a0599847
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 649c9ae168c9933cf139cb6526697b6960f37570edc027840e9a40c51f5e3995d87f575812af918f2463965caa878825c6c554011f969063407ee8cf96fd73d7
|
7
|
+
data.tar.gz: 7c2ba8c60a18b36425b8cc436b3fcf40fa6e3a3da437559669e56efc73e3ca891731405bb5e53a672be5fc7ceeff2b22b4db2062dfb03e766264e53d4417d959
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gloo (0.5.
|
4
|
+
gloo (0.5.4)
|
5
5
|
activesupport (~> 5.2, >= 5.2.4.3)
|
6
6
|
chronic (~> 0.10, >= 0.10.2)
|
7
7
|
colorize (~> 0.8, >= 0.8.1)
|
8
|
+
json (~> 2.1, >= 2.1.0)
|
9
|
+
openssl (~> 2.1, >= 2.1.0)
|
8
10
|
tty (~> 0.8, >= 0.8.1)
|
9
11
|
|
10
12
|
GEM
|
@@ -22,9 +24,11 @@ GEM
|
|
22
24
|
equatable (0.6.1)
|
23
25
|
i18n (1.8.5)
|
24
26
|
concurrent-ruby (~> 1.0)
|
27
|
+
json (2.3.1)
|
25
28
|
kramdown (1.16.2)
|
26
29
|
minitest (5.11.3)
|
27
30
|
necromancer (0.5.1)
|
31
|
+
openssl (2.2.0)
|
28
32
|
pastel (0.7.4)
|
29
33
|
equatable (~> 0.6)
|
30
34
|
tty-color (~> 0.5)
|
data/gloo.gemspec
CHANGED
@@ -37,4 +37,6 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_dependency 'chronic', '~> 0.10', '>= 0.10.2'
|
38
38
|
spec.add_dependency 'colorize', '~> 0.8', '>= 0.8.1'
|
39
39
|
spec.add_dependency 'tty', '~> 0.8', '>= 0.8.1'
|
40
|
+
spec.add_dependency 'json', '~> 2.1', '>= 2.1.0'
|
41
|
+
spec.add_dependency 'openssl', '~> 2.1', '>= 2.1.0'
|
40
42
|
end
|
data/lib/gloo/app/engine.rb
CHANGED
@@ -15,6 +15,7 @@ module Gloo
|
|
15
15
|
attr_reader :args, :mode, :running
|
16
16
|
attr_reader :dictionary, :parser, :heap, :factory
|
17
17
|
attr_accessor :last_cmd, :persist_man, :event_manager
|
18
|
+
attr_accessor :exec_env
|
18
19
|
|
19
20
|
# Set up the engine with basic elements.
|
20
21
|
def initialize( params = [] )
|
@@ -41,6 +42,8 @@ module Gloo
|
|
41
42
|
@persist_man = Gloo::Persist::PersistMan.new
|
42
43
|
@event_manager = Gloo::Core::EventManager.new
|
43
44
|
|
45
|
+
@exec_env = Gloo::Exec::ExecEnv.new
|
46
|
+
|
44
47
|
run_mode
|
45
48
|
end
|
46
49
|
|
data/lib/gloo/app/info.rb
CHANGED
data/lib/gloo/app/settings.rb
CHANGED
@@ -14,8 +14,11 @@ module Gloo
|
|
14
14
|
|
15
15
|
attr_reader :user_root, :log_path, :config_path, :project_path
|
16
16
|
attr_reader :start_with, :list_indent, :tmp_path
|
17
|
+
attr_reader :debug_path, :debug
|
17
18
|
|
19
|
+
#
|
18
20
|
# Load setting from the yml file.
|
21
|
+
#
|
19
22
|
def initialize( mode )
|
20
23
|
@mode = mode
|
21
24
|
init_root
|
@@ -23,6 +26,9 @@ module Gloo
|
|
23
26
|
init_user_settings
|
24
27
|
end
|
25
28
|
|
29
|
+
#
|
30
|
+
# Initialize gloo's root path.
|
31
|
+
#
|
26
32
|
def init_root
|
27
33
|
if in_test_mode?
|
28
34
|
path = File.dirname( File.dirname( File.absolute_path( __FILE__ ) ) )
|
@@ -34,19 +40,25 @@ module Gloo
|
|
34
40
|
end
|
35
41
|
end
|
36
42
|
|
43
|
+
#
|
37
44
|
# Are we in test mode?
|
45
|
+
#
|
38
46
|
def in_test_mode?
|
39
47
|
return @mode == 'TEST'
|
40
48
|
end
|
41
49
|
|
50
|
+
#
|
42
51
|
# Get the project path for the current mode.
|
52
|
+
#
|
43
53
|
def project_path_for_mode( settings )
|
44
54
|
return File.join( @user_root, 'projects' ) if in_test_mode?
|
45
55
|
|
46
56
|
return settings[ 'gloo' ][ 'project_path' ]
|
47
57
|
end
|
48
58
|
|
59
|
+
#
|
49
60
|
# Get the app's required directories.
|
61
|
+
#
|
50
62
|
def init_path_settings
|
51
63
|
Dir.mkdir( @user_root ) unless File.exist?( @user_root )
|
52
64
|
|
@@ -58,31 +70,44 @@ module Gloo
|
|
58
70
|
|
59
71
|
@tmp_path = File.join( @user_root, 'tmp' )
|
60
72
|
Dir.mkdir( @tmp_path ) unless File.exist?( @tmp_path )
|
73
|
+
|
74
|
+
@debug_path = File.join( @user_root, 'debug' )
|
75
|
+
Dir.mkdir( @debug_path ) unless File.exist?( @debug_path )
|
61
76
|
end
|
62
77
|
|
78
|
+
#
|
63
79
|
# Initialize the user settings for the currently
|
64
80
|
# running environment.
|
81
|
+
#
|
65
82
|
def init_user_settings
|
66
83
|
settings = get_settings
|
67
84
|
|
68
85
|
@project_path = project_path_for_mode settings
|
69
86
|
@start_with = settings[ 'gloo' ][ 'start_with' ]
|
70
87
|
@list_indent = settings[ 'gloo' ][ 'list_indent' ]
|
88
|
+
|
89
|
+
@debug = settings[ 'gloo' ][ 'debug' ]
|
71
90
|
end
|
72
91
|
|
92
|
+
#
|
73
93
|
# Get the app's required directories.
|
94
|
+
#
|
74
95
|
def get_settings
|
75
96
|
f = File.join( @config_path, 'gloo.yml' )
|
76
97
|
create_settings( f ) unless File.exist?( f )
|
77
98
|
return YAML.load_file f
|
78
99
|
end
|
79
100
|
|
101
|
+
#
|
80
102
|
# Create settings file.
|
103
|
+
#
|
81
104
|
def create_settings( file )
|
82
105
|
IO.write( file, get_default_settings )
|
83
106
|
end
|
84
107
|
|
108
|
+
#
|
85
109
|
# Get the value for default settings.
|
110
|
+
#
|
86
111
|
def get_default_settings
|
87
112
|
projects = File.join( @user_root, 'projects' )
|
88
113
|
str = <<~TEXT
|
@@ -90,6 +115,7 @@ module Gloo
|
|
90
115
|
project_path: #{projects}
|
91
116
|
start_with:
|
92
117
|
list_indent: 1
|
118
|
+
debug: false
|
93
119
|
TEXT
|
94
120
|
return str
|
95
121
|
end
|
@@ -100,32 +126,50 @@ module Gloo
|
|
100
126
|
#
|
101
127
|
def show
|
102
128
|
puts "\nApplication Settings:".blue
|
103
|
-
puts ' User Root Path is here: '.yellow + @user_root.white
|
104
|
-
puts ' Projects directory: '.yellow + @project_path.white
|
105
|
-
puts ' Tmp directory: '.yellow + @tmp_path.white
|
106
129
|
puts ' Startup with: '.yellow + @start_with.white
|
107
130
|
puts ' Indent in Listing: '.yellow + @list_indent.to_s.white
|
108
|
-
puts ''
|
109
131
|
puts ' Screen Lines: '.yellow + Gloo::App::Settings.lines.to_s.white
|
110
132
|
puts ' Page Size: '.yellow + Gloo::App::Settings.page_size.to_s.white
|
111
133
|
puts ''
|
134
|
+
self.show_paths
|
135
|
+
puts ''
|
136
|
+
end
|
137
|
+
|
138
|
+
#
|
139
|
+
# Show path settings
|
140
|
+
#
|
141
|
+
def show_paths
|
142
|
+
puts ' User Root Path is here: '.yellow + @user_root.white
|
143
|
+
puts ' Projects Path: '.yellow + @project_path.white
|
144
|
+
puts ' Tmp Path: '.yellow + @tmp_path.white
|
145
|
+
puts ' Debug Path: '.yellow + @debug_path.white
|
112
146
|
end
|
113
147
|
|
114
|
-
#
|
148
|
+
#
|
149
|
+
# Get the number of vertical lines on screen.
|
150
|
+
#
|
115
151
|
def self.lines
|
116
152
|
TTY::Screen.rows
|
117
153
|
end
|
118
154
|
|
155
|
+
#
|
156
|
+
# Get the number of horizontal columns on screen.
|
157
|
+
#
|
119
158
|
def self.cols
|
120
159
|
TTY::Screen.cols
|
121
160
|
end
|
122
161
|
|
162
|
+
#
|
123
163
|
# Get the default page size.
|
164
|
+
# This is the number of lines of text we can show.
|
165
|
+
#
|
124
166
|
def self.page_size
|
125
167
|
Settings.lines - 3
|
126
168
|
end
|
127
169
|
|
170
|
+
#
|
128
171
|
# How many lines should we use for a preview?
|
172
|
+
#
|
129
173
|
def self.preview_lines
|
130
174
|
return 7
|
131
175
|
end
|
data/lib/gloo/core/factory.rb
CHANGED
@@ -117,11 +117,11 @@ module Gloo
|
|
117
117
|
end
|
118
118
|
|
119
119
|
if pn.exists? && params[ :squash_duplicates ]
|
120
|
-
$log.debug "Updating existing object: #{
|
120
|
+
$log.debug "Updating existing object: #{obj_name}"
|
121
121
|
return self.update_existing pn, params[ :value ]
|
122
122
|
end
|
123
123
|
|
124
|
-
$log.debug "Creating new object: #{
|
124
|
+
$log.debug "Creating new object: #{obj_name}"
|
125
125
|
return create_new obj_name, params[ :value ], objtype, parent
|
126
126
|
end
|
127
127
|
|
@@ -0,0 +1,36 @@
|
|
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/obj.rb
CHANGED
@@ -73,6 +73,14 @@ module Gloo
|
|
73
73
|
return str
|
74
74
|
end
|
75
75
|
|
76
|
+
#
|
77
|
+
# Generic function to get display value.
|
78
|
+
# Can be used for debugging, etc.
|
79
|
+
#
|
80
|
+
def display_value
|
81
|
+
return self.pn
|
82
|
+
end
|
83
|
+
|
76
84
|
# ---------------------------------------------------------------------
|
77
85
|
# Value
|
78
86
|
# ---------------------------------------------------------------------
|
data/lib/gloo/core/pn.rb
CHANGED
@@ -138,6 +138,8 @@ module Gloo
|
|
138
138
|
return $engine.heap.error if self.error?
|
139
139
|
return Gloo::Core::GlooSystem.new( self ) if self.gloo_sys?
|
140
140
|
|
141
|
+
Here.expand_here( self ) if Here.includes_here_ref?( @elements )
|
142
|
+
|
141
143
|
parent = self.get_parent
|
142
144
|
return nil unless parent
|
143
145
|
|
data/lib/gloo/core/verb.rb
CHANGED
@@ -58,6 +58,14 @@ module Gloo
|
|
58
58
|
return self.class.keyword
|
59
59
|
end
|
60
60
|
|
61
|
+
#
|
62
|
+
# Generic function to get display value.
|
63
|
+
# Can be used for debugging, etc.
|
64
|
+
#
|
65
|
+
def display_value
|
66
|
+
return self.class.keyword
|
67
|
+
end
|
68
|
+
|
61
69
|
# ---------------------------------------------------------------------
|
62
70
|
# Help
|
63
71
|
# ---------------------------------------------------------------------
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# An action is a message sent to an object with optional parameters.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Exec
|
9
|
+
class Action
|
10
|
+
|
11
|
+
attr_accessor :msg, :to, :params
|
12
|
+
|
13
|
+
#
|
14
|
+
# Set up the action.
|
15
|
+
#
|
16
|
+
def initialize( msg, to, params = nil )
|
17
|
+
@msg = msg
|
18
|
+
@to = to
|
19
|
+
@params = params
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# The action is valid if the object can receive
|
24
|
+
# the message specified.
|
25
|
+
#
|
26
|
+
def valid?
|
27
|
+
return @to.can_receive_message?( @msg )
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# Execute the action.
|
32
|
+
# Dispatch the message to the object.
|
33
|
+
#
|
34
|
+
def dispatch
|
35
|
+
@to.send_message @msg, @params
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Generic function to get display value.
|
40
|
+
# Can be used for debugging, etc.
|
41
|
+
#
|
42
|
+
def display_value
|
43
|
+
return "#{@msg} -> #{@to.pn}"
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/gloo/exec/dispatch.rb
CHANGED
@@ -16,13 +16,23 @@ module Gloo
|
|
16
16
|
# Dispatch the given message to the given object.
|
17
17
|
#
|
18
18
|
def self.message( msg, to_obj, params = nil )
|
19
|
-
$log.debug "
|
19
|
+
$log.debug "Dispatch message #{msg} to #{to_obj.name}"
|
20
|
+
a = Gloo::Exec::Action.new msg, to_obj, params
|
21
|
+
Gloo::Exec::Dispatch.action a
|
22
|
+
end
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
24
|
+
#
|
25
|
+
# Dispatch an action.
|
26
|
+
#
|
27
|
+
def self.action( action )
|
28
|
+
unless action.valid?
|
29
|
+
$log.warn "Object #{action.to.name} does not respond to #{action.msg}"
|
25
30
|
end
|
31
|
+
|
32
|
+
$engine.exec_env.push_action action
|
33
|
+
$log.debug "Sending message #{action.msg} to #{action.to.name}"
|
34
|
+
action.dispatch
|
35
|
+
$engine.exec_env.pop_action
|
26
36
|
end
|
27
37
|
|
28
38
|
end
|
@@ -0,0 +1,62 @@
|
|
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 stack.
|
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
|
+
def push_script( script )
|
41
|
+
@scripts.push script
|
42
|
+
@here.push script.obj
|
43
|
+
end
|
44
|
+
|
45
|
+
def pop_script
|
46
|
+
@scripts.pop
|
47
|
+
@here.pop
|
48
|
+
end
|
49
|
+
|
50
|
+
def push_action( action )
|
51
|
+
@actions.push action
|
52
|
+
# @here.push action.to
|
53
|
+
end
|
54
|
+
|
55
|
+
def pop_action
|
56
|
+
@actions.pop
|
57
|
+
# @here.pop
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/gloo/exec/runner.rb
CHANGED
@@ -16,9 +16,11 @@ module Gloo
|
|
16
16
|
# is done running.
|
17
17
|
#
|
18
18
|
def self.go( verb )
|
19
|
-
$log.debug "
|
19
|
+
$log.debug "running verb #{verb.type_display}"
|
20
20
|
$engine.heap.error.start_tracking
|
21
|
+
$engine.exec_env.verbs.push verb
|
21
22
|
verb&.run
|
23
|
+
$engine.exec_env.verbs.pop
|
22
24
|
$engine.heap.error.clear_if_no_errors
|
23
25
|
end
|
24
26
|
|
@@ -27,7 +29,7 @@ module Gloo
|
|
27
29
|
# Resolve the path_name and then send the run message.
|
28
30
|
#
|
29
31
|
def self.run( path_name )
|
30
|
-
$log.debug "
|
32
|
+
$log.debug "running script at #{path_name}"
|
31
33
|
pn = Gloo::Core::Pn.new path_name
|
32
34
|
o = pn.resolve
|
33
35
|
|
@@ -5,31 +5,43 @@
|
|
5
5
|
#
|
6
6
|
|
7
7
|
module Gloo
|
8
|
-
module
|
8
|
+
module Exec
|
9
9
|
class Script
|
10
10
|
|
11
|
+
attr_accessor :obj
|
12
|
+
|
13
|
+
#
|
11
14
|
# Set up the script.
|
15
|
+
#
|
12
16
|
def initialize( obj )
|
13
17
|
@obj = obj
|
14
18
|
end
|
15
19
|
|
20
|
+
#
|
16
21
|
# Run the script.
|
22
|
+
# The script might be a single string or an array
|
23
|
+
# of lines.
|
24
|
+
#
|
17
25
|
def run
|
26
|
+
$engine.exec_env.push_script self
|
27
|
+
|
18
28
|
if @obj.value.is_a? String
|
19
|
-
|
29
|
+
$engine.parser.run @obj.value
|
20
30
|
elsif @obj.value.is_a? Array
|
21
31
|
@obj.value.each do |line|
|
22
|
-
|
32
|
+
$engine.parser.run line
|
23
33
|
end
|
24
34
|
end
|
25
|
-
end
|
26
35
|
|
27
|
-
|
28
|
-
|
29
|
-
i = $engine.parser.parse_immediate line
|
30
|
-
return unless i
|
36
|
+
$engine.exec_env.pop_script
|
37
|
+
end
|
31
38
|
|
32
|
-
|
39
|
+
#
|
40
|
+
# Generic function to get display value.
|
41
|
+
# Can be used for debugging, etc.
|
42
|
+
#
|
43
|
+
def display_value
|
44
|
+
return @obj.pn
|
33
45
|
end
|
34
46
|
|
35
47
|
end
|
@@ -0,0 +1,78 @@
|
|
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
|
@@ -3,6 +3,8 @@
|
|
3
3
|
#
|
4
4
|
# An object that contains a collection of other objects.
|
5
5
|
#
|
6
|
+
require 'tty-table'
|
7
|
+
require 'pastel'
|
6
8
|
|
7
9
|
module Gloo
|
8
10
|
module Objs
|
@@ -33,7 +35,7 @@ module Gloo
|
|
33
35
|
# Get a list of message names that this object receives.
|
34
36
|
#
|
35
37
|
def self.messages
|
36
|
-
return super + %w[count delete_children]
|
38
|
+
return super + %w[count delete_children show_key_value_table]
|
37
39
|
end
|
38
40
|
|
39
41
|
#
|
@@ -52,6 +54,23 @@ module Gloo
|
|
52
54
|
self.delete_children
|
53
55
|
end
|
54
56
|
|
57
|
+
#
|
58
|
+
# Show the given table data.
|
59
|
+
#
|
60
|
+
def msg_show_key_value_table
|
61
|
+
data = self.children.map { |o| [ o.name, o.value ] }
|
62
|
+
pastel = ::Pastel.new
|
63
|
+
table = TTY::Table.new rows: data
|
64
|
+
pad = [ 0, 1, 0, 1 ]
|
65
|
+
rendered = table.render( :ascii, indent: 2, padding: pad ) do |r|
|
66
|
+
r.border.style = :blue
|
67
|
+
r.filter = proc do |val, _row_index, col_index|
|
68
|
+
col_index.zero? ? pastel.blue( val ) : pastel.white( val )
|
69
|
+
end
|
70
|
+
end
|
71
|
+
puts "\n #{rendered}\n\n"
|
72
|
+
end
|
73
|
+
|
55
74
|
# ---------------------------------------------------------------------
|
56
75
|
# Help
|
57
76
|
# ---------------------------------------------------------------------
|
@@ -80,6 +99,8 @@ module Gloo
|
|
80
99
|
count - Count the number of children objects in the container.
|
81
100
|
The result is put in <it>.
|
82
101
|
delete_children - Delete all children objects from the container.
|
102
|
+
show_key_value_tbl - Show a table with key (name) and values
|
103
|
+
for all children in the container.
|
83
104
|
TEXT
|
84
105
|
end
|
85
106
|
|
data/lib/gloo/objs/cli/menu.rb
CHANGED
@@ -171,7 +171,7 @@ module Gloo
|
|
171
171
|
obj = find_child DEFAULT
|
172
172
|
return unless obj
|
173
173
|
|
174
|
-
s = Gloo::
|
174
|
+
s = Gloo::Exec::Script.new obj
|
175
175
|
s.run
|
176
176
|
end
|
177
177
|
|
@@ -193,7 +193,7 @@ module Gloo
|
|
193
193
|
script = obj.do_script
|
194
194
|
return unless script
|
195
195
|
|
196
|
-
s = Gloo::
|
196
|
+
s = Gloo::Exec::Script.new script
|
197
197
|
s.run
|
198
198
|
end
|
199
199
|
|
data/lib/gloo/objs/data/table.rb
CHANGED
@@ -15,6 +15,7 @@ module Gloo
|
|
15
15
|
KEYWORD_SHORT = 'post'.freeze
|
16
16
|
URL = 'uri'.freeze
|
17
17
|
BODY = 'body'.freeze
|
18
|
+
RESULT = 'result'.freeze
|
18
19
|
|
19
20
|
#
|
20
21
|
# The name of the object type.
|
@@ -50,13 +51,23 @@ module Gloo
|
|
50
51
|
|
51
52
|
body = find_child BODY
|
52
53
|
body.children.each do |child|
|
53
|
-
|
54
|
-
h[ child.name ] =
|
54
|
+
child_val = Gloo::Objs::Alias.resolve_alias( child )
|
55
|
+
h[ child.name ] = child_val.value
|
55
56
|
end
|
56
57
|
|
57
58
|
return h.to_json
|
58
59
|
end
|
59
60
|
|
61
|
+
#
|
62
|
+
# Set the result of the API call.
|
63
|
+
#
|
64
|
+
def update_result( data )
|
65
|
+
r = find_child RESULT
|
66
|
+
return nil unless r
|
67
|
+
|
68
|
+
r.set_value data
|
69
|
+
end
|
70
|
+
|
60
71
|
# ---------------------------------------------------------------------
|
61
72
|
# Children
|
62
73
|
# ---------------------------------------------------------------------
|
@@ -73,14 +84,8 @@ module Gloo
|
|
73
84
|
# for default configurations.
|
74
85
|
def add_default_children
|
75
86
|
fac = $engine.factory
|
76
|
-
fac.
|
77
|
-
|
78
|
-
:value => 'https://web.site/',
|
79
|
-
:parent => self } )
|
80
|
-
fac.create( { :name => 'body',
|
81
|
-
:type => 'container',
|
82
|
-
:value => nil,
|
83
|
-
:parent => self } )
|
87
|
+
fac.create_string URL, 'https://web.site/', self
|
88
|
+
fac.create_can BODY, self
|
84
89
|
end
|
85
90
|
|
86
91
|
# ---------------------------------------------------------------------
|
@@ -99,8 +104,12 @@ module Gloo
|
|
99
104
|
uri = uri_value
|
100
105
|
return unless uri
|
101
106
|
|
107
|
+
$log.debug "posting to: #{uri}"
|
108
|
+
body = self.body_as_json
|
109
|
+
$log.debug "posting body: #{body}"
|
102
110
|
use_ssl = uri.downcase.start_with?( 'https' )
|
103
|
-
Gloo::Objs::HttpPost.post_json uri,
|
111
|
+
data = Gloo::Objs::HttpPost.post_json uri, body, use_ssl
|
112
|
+
self.update_result data
|
104
113
|
end
|
105
114
|
|
106
115
|
# ---------------------------------------------------------------------
|
@@ -118,7 +127,10 @@ module Gloo
|
|
118
127
|
n.use_ssl = use_ssl
|
119
128
|
|
120
129
|
# Send the payload to the endpoint.
|
121
|
-
n.start { |http| http.request( request ) }
|
130
|
+
result = n.start { |http| http.request( request ) }
|
131
|
+
$log.debug result.code
|
132
|
+
$log.debug result.message
|
133
|
+
return result.body
|
122
134
|
end
|
123
135
|
|
124
136
|
# ---------------------------------------------------------------------
|
@@ -142,6 +154,9 @@ module Gloo
|
|
142
154
|
The URI for the HTTP Post.
|
143
155
|
body - container
|
144
156
|
Collection of parameters for the HTTP Post.
|
157
|
+
result - string - Optional parameter
|
158
|
+
The result of the request. Whatever was returned in the body
|
159
|
+
of the HTTP POST.
|
145
160
|
|
146
161
|
MESSAGES
|
147
162
|
run - Run the HTTP Post sending the body data to the
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gloo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Crane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -138,6 +138,46 @@ dependencies:
|
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: 0.8.1
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: json
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - "~>"
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '2.1'
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: 2.1.0
|
151
|
+
type: :runtime
|
152
|
+
prerelease: false
|
153
|
+
version_requirements: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - "~>"
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '2.1'
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 2.1.0
|
161
|
+
- !ruby/object:Gem::Dependency
|
162
|
+
name: openssl
|
163
|
+
requirement: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '2.1'
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: 2.1.0
|
171
|
+
type: :runtime
|
172
|
+
prerelease: false
|
173
|
+
version_requirements: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - "~>"
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '2.1'
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 2.1.0
|
141
181
|
description: A scripting languge to keep it all together.
|
142
182
|
email:
|
143
183
|
- eric.crane@mac.com
|
@@ -180,6 +220,7 @@ files:
|
|
180
220
|
- lib/gloo/core/factory.rb
|
181
221
|
- lib/gloo/core/gloo_system.rb
|
182
222
|
- lib/gloo/core/heap.rb
|
223
|
+
- lib/gloo/core/here.rb
|
183
224
|
- lib/gloo/core/it.rb
|
184
225
|
- lib/gloo/core/literal.rb
|
185
226
|
- lib/gloo/core/obj.rb
|
@@ -187,11 +228,14 @@ files:
|
|
187
228
|
- lib/gloo/core/op.rb
|
188
229
|
- lib/gloo/core/parser.rb
|
189
230
|
- lib/gloo/core/pn.rb
|
190
|
-
- lib/gloo/core/script.rb
|
191
231
|
- lib/gloo/core/tokens.rb
|
192
232
|
- lib/gloo/core/verb.rb
|
233
|
+
- lib/gloo/exec/action.rb
|
193
234
|
- lib/gloo/exec/dispatch.rb
|
235
|
+
- lib/gloo/exec/exec_env.rb
|
194
236
|
- lib/gloo/exec/runner.rb
|
237
|
+
- lib/gloo/exec/script.rb
|
238
|
+
- lib/gloo/exec/stack.rb
|
195
239
|
- lib/gloo/expr/expression.rb
|
196
240
|
- lib/gloo/expr/l_boolean.rb
|
197
241
|
- lib/gloo/expr/l_decimal.rb
|