gloo-lang 0.9.8 → 0.9.11
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 +14 -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 -25
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d059c3cd65790c4b384540889583e122d31f67369df848c74768839aeff6192
|
4
|
+
data.tar.gz: 9ba8cc80b297965dbd73d91902f81629b7753e1e19db00afe7f975cb1ba2da38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b5ccb5f2c17fd4d2a1bb692fcfafbc8fa463d0a25c38a4db7174b1a0616b3f0b2fa039674336f45dd537f557133dee40bd3514ce930c07ffe33a0a9a66404a2
|
7
|
+
data.tar.gz: f78caa4e197479a56d91a7782ebbac77067897a3275a9ff6ccae2ee8473c8d30277b1cc49c0e90be55f1531716c36c5662eab3157cbf38cc65e7006a626ba379
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gloo-lang (0.9.
|
4
|
+
gloo-lang (0.9.10)
|
5
|
+
activesupport (~> 6.1, >= 6.1.4.6)
|
5
6
|
chronic (~> 0.10, >= 0.10.2)
|
6
7
|
json (~> 2.1, >= 2.1.0)
|
7
8
|
net-ssh (~> 6.1, >= 6.1.0)
|
@@ -11,8 +12,17 @@ PATH
|
|
11
12
|
GEM
|
12
13
|
remote: https://rubygems.org/
|
13
14
|
specs:
|
15
|
+
activesupport (6.1.5)
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
i18n (>= 1.6, < 2)
|
18
|
+
minitest (>= 5.1)
|
19
|
+
tzinfo (~> 2.0)
|
20
|
+
zeitwerk (~> 2.3)
|
14
21
|
ast (2.4.2)
|
15
22
|
chronic (0.10.2)
|
23
|
+
concurrent-ruby (1.1.10)
|
24
|
+
i18n (1.10.0)
|
25
|
+
concurrent-ruby (~> 1.0)
|
16
26
|
ipaddr (1.2.4)
|
17
27
|
json (2.6.1)
|
18
28
|
minitest (5.15.0)
|
@@ -39,7 +49,10 @@ GEM
|
|
39
49
|
parser (>= 3.1.1.0)
|
40
50
|
ruby-progressbar (1.11.0)
|
41
51
|
tty-platform (0.3.0)
|
52
|
+
tzinfo (2.0.4)
|
53
|
+
concurrent-ruby (~> 1.0)
|
42
54
|
unicode-display_width (2.1.0)
|
55
|
+
zeitwerk (2.5.4)
|
43
56
|
|
44
57
|
PLATFORMS
|
45
58
|
x86_64-darwin-21
|
data/gloo-lang.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
28
28
|
spec.add_development_dependency "rake", '~> 13.0', '>= 13.0.1'
|
29
29
|
|
30
|
-
|
30
|
+
spec.add_dependency "activesupport", '~> 6.1', ">= 6.1.4.6"
|
31
31
|
spec.add_dependency 'chronic', '~> 0.10', '>= 0.10.2'
|
32
32
|
spec.add_dependency 'json', '~> 2.1', '>= 2.1.0'
|
33
33
|
spec.add_dependency 'openssl', '~> 2.1', '>= 2.1.0'
|
data/lib/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.11
|
data/lib/gloo_lang/app/args.rb
CHANGED
@@ -19,7 +19,8 @@ module GlooLang
|
|
19
19
|
#
|
20
20
|
# Create arguments and setup.
|
21
21
|
#
|
22
|
-
def initialize( params = [] )
|
22
|
+
def initialize( engine, params = [] )
|
23
|
+
@engine = engine
|
23
24
|
@switches = []
|
24
25
|
@files = []
|
25
26
|
|
@@ -84,7 +85,7 @@ module GlooLang
|
|
84
85
|
else
|
85
86
|
Mode.default_mode
|
86
87
|
end
|
87
|
-
|
88
|
+
@engine.log.debug "running in #{mode} mode"
|
88
89
|
|
89
90
|
return mode
|
90
91
|
end
|
data/lib/gloo_lang/app/engine.rb
CHANGED
@@ -11,6 +11,7 @@ module GlooLang
|
|
11
11
|
module App
|
12
12
|
class Engine
|
13
13
|
|
14
|
+
attr_reader :settings, :log
|
14
15
|
attr_reader :args, :mode, :running, :platform,
|
15
16
|
:dictionary, :parser, :heap, :factory
|
16
17
|
attr_accessor :last_cmd, :persist_man, :event_manager,
|
@@ -19,15 +20,14 @@ module GlooLang
|
|
19
20
|
#
|
20
21
|
# Set up the engine with basic elements.
|
21
22
|
#
|
22
|
-
def initialize(
|
23
|
-
|
24
|
-
@
|
25
|
-
$settings = Settings.new( ENV[ 'GLOO_ENV' ] )
|
23
|
+
def initialize( context )
|
24
|
+
@args = Args.new( self, context.params )
|
25
|
+
@settings = Settings.new( self, context.user_root )
|
26
26
|
|
27
|
-
|
28
|
-
@platform = platform
|
27
|
+
@log = Log.new( self, @args.quiet? )
|
28
|
+
@platform = context.platform
|
29
29
|
|
30
|
-
|
30
|
+
@log.debug 'engine intialized...'
|
31
31
|
end
|
32
32
|
|
33
33
|
#
|
@@ -35,24 +35,24 @@ module GlooLang
|
|
35
35
|
# Load object and verb definitions and setup engine elements.
|
36
36
|
#
|
37
37
|
def start
|
38
|
-
|
39
|
-
|
38
|
+
@log.debug 'starting the engine...'
|
39
|
+
@log.debug Info.display_title
|
40
40
|
@mode = @args.detect_mode
|
41
41
|
@running = true
|
42
42
|
|
43
|
-
@dictionary = GlooLang::Core::Dictionary.
|
44
|
-
@dictionary.init
|
45
|
-
@parser = GlooLang::Core::Parser.new
|
46
|
-
@heap = GlooLang::Core::Heap.new
|
47
|
-
@factory = GlooLang::Core::Factory.new
|
48
|
-
@persist_man = GlooLang::Persist::PersistMan.new
|
49
|
-
@event_manager = GlooLang::Core::EventManager.new
|
43
|
+
@dictionary = GlooLang::Core::Dictionary.get
|
50
44
|
|
51
|
-
@
|
52
|
-
@
|
53
|
-
@
|
45
|
+
@parser = GlooLang::Core::Parser.new( self )
|
46
|
+
@heap = GlooLang::Core::Heap.new( self )
|
47
|
+
@factory = GlooLang::Core::Factory.new( self )
|
48
|
+
@persist_man = GlooLang::Persist::PersistMan.new( self )
|
49
|
+
@event_manager = GlooLang::Core::EventManager.new( self )
|
54
50
|
|
55
|
-
|
51
|
+
@exec_env = GlooLang::Exec::ExecEnv.new( self )
|
52
|
+
@help = GlooLang::App::Help.new( self )
|
53
|
+
@converter = GlooLang::Convert::Converter.new( self )
|
54
|
+
|
55
|
+
@log.debug 'the engine has started'
|
56
56
|
run_mode
|
57
57
|
end
|
58
58
|
|
@@ -64,7 +64,7 @@ module GlooLang
|
|
64
64
|
# Run gloo in the selected mode.
|
65
65
|
#
|
66
66
|
def run_mode
|
67
|
-
|
67
|
+
@log.debug "running gloo in #{@mode} mode"
|
68
68
|
|
69
69
|
if @mode == Mode::VERSION
|
70
70
|
run_version
|
@@ -107,7 +107,7 @@ module GlooLang
|
|
107
107
|
# Get the setting for the start_with file and open it.
|
108
108
|
#
|
109
109
|
def open_start_file
|
110
|
-
name =
|
110
|
+
name = @settings.start_with
|
111
111
|
@persist_man.load( name ) if name
|
112
112
|
end
|
113
113
|
|
@@ -154,7 +154,7 @@ module GlooLang
|
|
154
154
|
# Do any clean up and quit.
|
155
155
|
#
|
156
156
|
def quit
|
157
|
-
|
157
|
+
@log.debug 'quitting...'
|
158
158
|
end
|
159
159
|
|
160
160
|
# ---------------------------------------------------------------------
|
@@ -193,8 +193,8 @@ module GlooLang
|
|
193
193
|
# Write it to the log and set the heap error value.
|
194
194
|
#
|
195
195
|
def err( msg )
|
196
|
-
|
197
|
-
|
196
|
+
@log.error msg
|
197
|
+
@heap.error.set_to msg
|
198
198
|
end
|
199
199
|
|
200
200
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2022 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# The context (parameters) for the Gloo Script Engine.
|
5
|
+
#
|
6
|
+
|
7
|
+
module GlooLang
|
8
|
+
module App
|
9
|
+
class EngineContext
|
10
|
+
|
11
|
+
attr_accessor :params, :platform, :log, :user_root
|
12
|
+
|
13
|
+
#
|
14
|
+
# Create the context, supplying defaults where relevant.
|
15
|
+
#
|
16
|
+
def initialize( params = [], platform=nil, log=nil, user_root=nil )
|
17
|
+
@params = params
|
18
|
+
@platform = platform ? platform : Platform.new
|
19
|
+
@log = log ? log : Log
|
20
|
+
@user_root = user_root
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/gloo_lang/app/help.rb
CHANGED
@@ -16,7 +16,8 @@ module GlooLang
|
|
16
16
|
# Set up the help system.
|
17
17
|
# We won't load help topics until we know we need them.
|
18
18
|
#
|
19
|
-
def initialize
|
19
|
+
def initialize( engine )
|
20
|
+
@engine = engine
|
20
21
|
@topics = nil
|
21
22
|
end
|
22
23
|
|
@@ -25,7 +26,7 @@ module GlooLang
|
|
25
26
|
# This is the what is shown when help is run from the CLI.
|
26
27
|
#
|
27
28
|
def show_app_help
|
28
|
-
puts Info.display_title unless
|
29
|
+
puts Info.display_title unless @engine.args.quiet?
|
29
30
|
self.show_topic APPLICATION
|
30
31
|
end
|
31
32
|
|
@@ -54,21 +55,21 @@ module GlooLang
|
|
54
55
|
# screen, it won't paginate.
|
55
56
|
#
|
56
57
|
def page_topic( topic )
|
57
|
-
return if
|
58
|
+
return if @engine.args.quiet?
|
58
59
|
|
59
60
|
data = self.get_topic_data( topic )
|
60
|
-
page = data.lines.count > Settings.page_size
|
61
|
-
|
61
|
+
page = data.lines.count > Settings.page_size( @engine )
|
62
|
+
@engine.platform.show( data, topic_is_md?( topic ), page )
|
62
63
|
end
|
63
64
|
|
64
65
|
#
|
65
66
|
# Show a help topic.
|
66
67
|
#
|
67
68
|
def show_topic( topic )
|
68
|
-
return if
|
69
|
+
return if @engine.args.quiet?
|
69
70
|
|
70
71
|
data = self.get_topic_data( topic )
|
71
|
-
|
72
|
+
@engine.platform.show( data, topic_is_md?( topic ), false )
|
72
73
|
end
|
73
74
|
|
74
75
|
#
|
@@ -92,7 +93,7 @@ module GlooLang
|
|
92
93
|
return if @topics
|
93
94
|
|
94
95
|
@topics = {}
|
95
|
-
|
96
|
+
@engine.log.debug 'loading help file index...'
|
96
97
|
|
97
98
|
pn = File.dirname( File.absolute_path( __FILE__ ) )
|
98
99
|
pn = File.dirname( pn )
|
@@ -109,7 +110,7 @@ module GlooLang
|
|
109
110
|
@topics[ key ] = md_file
|
110
111
|
end
|
111
112
|
|
112
|
-
|
113
|
+
@engine.log.debug "Found #{@topics.count} help files"
|
113
114
|
end
|
114
115
|
|
115
116
|
end
|
data/lib/gloo_lang/app/log.rb
CHANGED
@@ -9,15 +9,17 @@ module GlooLang
|
|
9
9
|
module App
|
10
10
|
class Log
|
11
11
|
|
12
|
-
|
12
|
+
attr_accessor :quiet
|
13
|
+
attr_reader :logger
|
13
14
|
|
14
15
|
#
|
15
16
|
# Set up a logger.
|
16
17
|
# If quiet is true, then message are written to the log
|
17
18
|
# but not to the console.
|
18
19
|
#
|
19
|
-
def initialize( quiet=true )
|
20
|
-
|
20
|
+
def initialize( engine, quiet=true )
|
21
|
+
@engine = engine
|
22
|
+
f = File.join( @engine.settings.log_path, 'gloo.log' )
|
21
23
|
@logger = Logger.new( f )
|
22
24
|
@logger.level = Logger::DEBUG
|
23
25
|
@quite = quiet
|
@@ -10,37 +10,24 @@ module GlooLang
|
|
10
10
|
module App
|
11
11
|
class Settings
|
12
12
|
|
13
|
-
attr_reader :user_root, :log_path,
|
14
|
-
|
15
|
-
|
13
|
+
attr_reader :user_root, :log_path,
|
14
|
+
:config_path, :project_path,
|
15
|
+
:start_with, :list_indent, :tmp_path,
|
16
|
+
:debug_path, :debug
|
16
17
|
|
17
18
|
#
|
18
19
|
# Load setting from the yml file.
|
19
20
|
# The mode parameter is used to determine if we are running in TEST.
|
20
21
|
#
|
21
|
-
def initialize(
|
22
|
-
@
|
23
|
-
|
22
|
+
def initialize( engine, root=nil )
|
23
|
+
@engine = engine
|
24
|
+
# @mode = mode
|
25
|
+
init_root( root )
|
26
|
+
|
24
27
|
init_path_settings
|
25
28
|
init_user_settings
|
26
29
|
end
|
27
30
|
|
28
|
-
#
|
29
|
-
# Are we in test mode?
|
30
|
-
#
|
31
|
-
def in_test_mode?
|
32
|
-
return @mode == 'TEST'
|
33
|
-
end
|
34
|
-
|
35
|
-
#
|
36
|
-
# Get the project path for the current mode.
|
37
|
-
#
|
38
|
-
def project_path_for_mode( settings )
|
39
|
-
return File.join( @user_root, 'projects' ) if in_test_mode?
|
40
|
-
|
41
|
-
return settings[ 'gloo' ][ 'project_path' ]
|
42
|
-
end
|
43
|
-
|
44
31
|
#
|
45
32
|
# Show the current application settings.
|
46
33
|
# Can be seen in app with 'help settings'
|
@@ -49,8 +36,8 @@ module GlooLang
|
|
49
36
|
puts "\nApplication Settings:"
|
50
37
|
puts ' Startup with: ' + @start_with
|
51
38
|
puts ' Indent in Listing: ' + @list_indent.to_s
|
52
|
-
puts ' Screen Lines: ' + GlooLang::App::Settings.lines.to_s
|
53
|
-
puts ' Page Size: ' + GlooLang::App::Settings.page_size.to_s
|
39
|
+
puts ' Screen Lines: ' + GlooLang::App::Settings.lines( @engine ).to_s
|
40
|
+
puts ' Page Size: ' + GlooLang::App::Settings.page_size( @engine ).to_s
|
54
41
|
puts ''
|
55
42
|
self.show_paths
|
56
43
|
puts ''
|
@@ -94,23 +81,23 @@ module GlooLang
|
|
94
81
|
#
|
95
82
|
# Get the number of vertical lines on screen.
|
96
83
|
#
|
97
|
-
def self.lines
|
98
|
-
|
84
|
+
def self.lines engine
|
85
|
+
engine.platform.lines
|
99
86
|
end
|
100
87
|
|
101
88
|
#
|
102
89
|
# Get the number of horizontal columns on screen.
|
103
90
|
#
|
104
|
-
def self.cols
|
105
|
-
|
91
|
+
def self.cols engine
|
92
|
+
engine.platform.cols
|
106
93
|
end
|
107
94
|
|
108
95
|
#
|
109
96
|
# Get the default page size.
|
110
97
|
# This is the number of lines of text we can show.
|
111
98
|
#
|
112
|
-
def self.page_size
|
113
|
-
Settings.lines - 3
|
99
|
+
def self.page_size engine
|
100
|
+
Settings.lines( engine ) - 3
|
114
101
|
end
|
115
102
|
|
116
103
|
#
|
@@ -129,12 +116,14 @@ module GlooLang
|
|
129
116
|
#
|
130
117
|
# Initialize gloo's root path.
|
131
118
|
#
|
132
|
-
def init_root
|
133
|
-
if
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
119
|
+
def init_root root
|
120
|
+
if root
|
121
|
+
@user_root = root
|
122
|
+
# if in_test_mode?
|
123
|
+
# path = File.dirname( File.dirname( File.absolute_path( __FILE__ ) ) )
|
124
|
+
# path = File.dirname( File.dirname( path ) )
|
125
|
+
# path = File.join( path, 'test', 'gloo' )
|
126
|
+
# @user_root = path
|
138
127
|
else
|
139
128
|
@user_root = File.join( Dir.home, 'gloo' )
|
140
129
|
end
|
@@ -166,7 +155,11 @@ module GlooLang
|
|
166
155
|
def init_user_settings
|
167
156
|
settings = get_settings
|
168
157
|
|
169
|
-
@project_path =
|
158
|
+
@project_path = settings[ 'gloo' ][ 'project_path' ]
|
159
|
+
if @project_path.blank?
|
160
|
+
@project_path = File.join( @user_root, 'projects' )
|
161
|
+
end
|
162
|
+
|
170
163
|
@start_with = settings[ 'gloo' ][ 'start_with' ]
|
171
164
|
@list_indent = settings[ 'gloo' ][ 'list_indent' ]
|
172
165
|
|
@@ -8,6 +8,13 @@ module GlooLang
|
|
8
8
|
module Convert
|
9
9
|
class Converter
|
10
10
|
|
11
|
+
#
|
12
|
+
# Initializer.
|
13
|
+
#
|
14
|
+
def initialize( engine )
|
15
|
+
@engine = engine
|
16
|
+
end
|
17
|
+
|
11
18
|
# ---------------------------------------------------------------------
|
12
19
|
# Convert
|
13
20
|
# ---------------------------------------------------------------------
|
@@ -23,8 +30,8 @@ module GlooLang
|
|
23
30
|
o = clazz.new
|
24
31
|
return o.convert( value )
|
25
32
|
rescue => e
|
26
|
-
|
27
|
-
|
33
|
+
@engine.log.error e.message
|
34
|
+
@engine.heap.error.set_to e.message
|
28
35
|
end
|
29
36
|
|
30
37
|
return default
|
data/lib/gloo_lang/core/baseo.rb
CHANGED
@@ -24,6 +24,16 @@ module GlooLang
|
|
24
24
|
@keywords = []
|
25
25
|
end
|
26
26
|
|
27
|
+
#
|
28
|
+
# Get the singleton Dictionary and Initialize
|
29
|
+
# if this is the first time.
|
30
|
+
#
|
31
|
+
def self.get
|
32
|
+
o = GlooLang::Core::Dictionary.instance
|
33
|
+
o.init if o.verbs.count == 0
|
34
|
+
return o
|
35
|
+
end
|
36
|
+
|
27
37
|
#
|
28
38
|
# Register a verb.
|
29
39
|
#
|
@@ -42,7 +52,7 @@ module GlooLang
|
|
42
52
|
# Initialize verbs and objects in the dictionary.
|
43
53
|
#
|
44
54
|
def init
|
45
|
-
|
55
|
+
# @engine.log.debug 'initializing dictionaries'
|
46
56
|
init_verbs
|
47
57
|
init_objs
|
48
58
|
end
|
@@ -140,7 +150,7 @@ module GlooLang
|
|
140
150
|
#
|
141
151
|
def add_key( keyword )
|
142
152
|
if @keywords.include?( keyword )
|
143
|
-
|
153
|
+
# @engine.log.error "duplicate keyword '#{keyword}'"
|
144
154
|
return
|
145
155
|
end
|
146
156
|
|
@@ -151,9 +161,9 @@ module GlooLang
|
|
151
161
|
# Init the list of objects.
|
152
162
|
#
|
153
163
|
def init_objs
|
154
|
-
|
164
|
+
# @engine.log.debug "initializing #{@obj_references.count} objects"
|
155
165
|
@obj_references.each do |o|
|
156
|
-
|
166
|
+
# @engine.log.debug o
|
157
167
|
@objs[ o.typename ] = o
|
158
168
|
@objs[ o.short_typename ] = o
|
159
169
|
add_key o.typename
|
@@ -165,9 +175,9 @@ module GlooLang
|
|
165
175
|
# Init the list of verbs.
|
166
176
|
#
|
167
177
|
def init_verbs
|
168
|
-
|
178
|
+
# @engine.log.debug "initializing #{@verb_references.count} verbs"
|
169
179
|
@verb_references.each do |v|
|
170
|
-
|
180
|
+
# @engine.log.debug v
|
171
181
|
@verbs[ v.keyword ] = v
|
172
182
|
@verbs[ v.keyword_shortcut ] = v
|
173
183
|
# v.send( :new ).run
|
@@ -12,8 +12,9 @@ module GlooLang
|
|
12
12
|
#
|
13
13
|
# Set up the event manager.
|
14
14
|
#
|
15
|
-
def initialize
|
16
|
-
|
15
|
+
def initialize( engine )
|
16
|
+
@engine = engine
|
17
|
+
@engine.log.debug 'event manager intialized...'
|
17
18
|
end
|
18
19
|
|
19
20
|
#
|
@@ -23,9 +24,9 @@ module GlooLang
|
|
23
24
|
def on_load( obj = nil, in_heap = false )
|
24
25
|
return unless obj || in_heap
|
25
26
|
|
26
|
-
|
27
|
-
arr = GlooLang::Core::ObjFinder.by_name 'on_load', obj
|
28
|
-
arr.each { |o| GlooLang::Exec::Dispatch.message 'run', o }
|
27
|
+
@engine.log.debug 'on_load event'
|
28
|
+
arr = GlooLang::Core::ObjFinder.by_name( @engine, 'on_load', obj )
|
29
|
+
arr.each { |o| GlooLang::Exec::Dispatch.message( @engine, 'run', o ) }
|
29
30
|
end
|
30
31
|
|
31
32
|
#
|
@@ -34,9 +35,9 @@ module GlooLang
|
|
34
35
|
def on_unload( obj )
|
35
36
|
return unless obj
|
36
37
|
|
37
|
-
|
38
|
-
arr = GlooLang::Core::ObjFinder.by_name 'on_unload', obj
|
39
|
-
arr.each { |o| GlooLang::Exec::Dispatch.message 'run', o }
|
38
|
+
@engine.log.debug 'on_unload event'
|
39
|
+
arr = GlooLang::Core::ObjFinder.by_name( @engine, 'on_unload', obj )
|
40
|
+
arr.each { |o| GlooLang::Exec::Dispatch.message( @engine, 'run', o ) }
|
40
41
|
end
|
41
42
|
|
42
43
|
end
|
@@ -15,8 +15,9 @@ module GlooLang
|
|
15
15
|
#
|
16
16
|
# Set up the object factory.
|
17
17
|
#
|
18
|
-
def initialize
|
19
|
-
|
18
|
+
def initialize( engine )
|
19
|
+
@engine = engine
|
20
|
+
@engine.log.debug 'object factory intialized...'
|
20
21
|
end
|
21
22
|
|
22
23
|
# ---------------------------------------------------------------------
|
@@ -140,7 +141,7 @@ module GlooLang
|
|
140
141
|
objtype = find_type params[ :type ]
|
141
142
|
return nil unless objtype
|
142
143
|
|
143
|
-
pn = GlooLang::Core::Pn.new params[ :name ]
|
144
|
+
pn = GlooLang::Core::Pn.new( @engine, params[ :name ] )
|
144
145
|
parent = params[ :parent ]
|
145
146
|
if parent.nil?
|
146
147
|
parent = pn.get_parent
|
@@ -150,11 +151,11 @@ module GlooLang
|
|
150
151
|
end
|
151
152
|
|
152
153
|
if pn.exists? && params[ :squash_duplicates ]
|
153
|
-
|
154
|
+
@engine.log.debug "Updating existing object: #{obj_name}"
|
154
155
|
return self.update_existing pn, params[ :value ]
|
155
156
|
end
|
156
157
|
|
157
|
-
|
158
|
+
@engine.log.debug "Creating new object: #{obj_name}"
|
158
159
|
return create_new obj_name, params[ :value ], objtype, parent
|
159
160
|
end
|
160
161
|
|
@@ -163,11 +164,11 @@ module GlooLang
|
|
163
164
|
#
|
164
165
|
def create_new( name, value, type, parent )
|
165
166
|
unless parent
|
166
|
-
|
167
|
+
@engine.log.error "Could not create object. Bad path: #{name}"
|
167
168
|
return nil
|
168
169
|
end
|
169
170
|
|
170
|
-
o = type.new
|
171
|
+
o = type.new( @engine )
|
171
172
|
o.name = name
|
172
173
|
o.set_value value
|
173
174
|
parent.add_child( o )
|
@@ -190,15 +191,15 @@ module GlooLang
|
|
190
191
|
#
|
191
192
|
def find_type( type_name )
|
192
193
|
type_name = 'untyped' if type_name.nil? || type_name.strip.empty?
|
193
|
-
t =
|
194
|
+
t = @engine.dictionary.find_obj( type_name )
|
194
195
|
|
195
196
|
if t.nil?
|
196
|
-
|
197
|
+
@engine.log.warn "Could not find type, '#{type_name}'"
|
197
198
|
return nil
|
198
199
|
end
|
199
200
|
|
200
201
|
unless t.can_create?
|
201
|
-
|
202
|
+
@engine.log.error "'#{type_name}' cannot be created."
|
202
203
|
return nil
|
203
204
|
end
|
204
205
|
|
@@ -18,7 +18,8 @@ module GlooLang
|
|
18
18
|
attr_reader :pn
|
19
19
|
|
20
20
|
# Set up the object.
|
21
|
-
def initialize( pn )
|
21
|
+
def initialize( engine, pn )
|
22
|
+
@engine = engine
|
22
23
|
@pn = pn
|
23
24
|
end
|
24
25
|
|
@@ -137,7 +138,7 @@ module GlooLang
|
|
137
138
|
o = "msg_#{msg}"
|
138
139
|
return self.public_send( o ) if self.respond_to? o
|
139
140
|
|
140
|
-
|
141
|
+
@engine.log.error "Message #{msg} not implemented"
|
141
142
|
return false
|
142
143
|
end
|
143
144
|
|
@@ -163,22 +164,22 @@ module GlooLang
|
|
163
164
|
|
164
165
|
# Get the Gloo home directory
|
165
166
|
def msg_gloo_home
|
166
|
-
return
|
167
|
+
return @engine.settings.user_root
|
167
168
|
end
|
168
169
|
|
169
170
|
# Get the Gloo configuration directory
|
170
171
|
def msg_gloo_config
|
171
|
-
return
|
172
|
+
return @engine.settings.config_path
|
172
173
|
end
|
173
174
|
|
174
175
|
# Get the Gloo projects directory
|
175
176
|
def msg_gloo_projects
|
176
|
-
return
|
177
|
+
return @engine.settings.project_path
|
177
178
|
end
|
178
179
|
|
179
180
|
# Get the Gloo log directory
|
180
181
|
def msg_gloo_log
|
181
|
-
return
|
182
|
+
return @engine.settings.log_path
|
182
183
|
end
|
183
184
|
|
184
185
|
# ---------------------------------------------------------------------
|
@@ -196,12 +197,12 @@ module GlooLang
|
|
196
197
|
|
197
198
|
# Get the number of lines on screen.
|
198
199
|
def msg_screen_lines
|
199
|
-
return GlooLang::App::Settings.lines
|
200
|
+
return GlooLang::App::Settings.lines( @engine )
|
200
201
|
end
|
201
202
|
|
202
203
|
# Get the number of columns on screen.
|
203
204
|
def msg_screen_cols
|
204
|
-
return GlooLang::App::Settings.cols
|
205
|
+
return GlooLang::App::Settings.cols( @engine )
|
205
206
|
end
|
206
207
|
|
207
208
|
# ---------------------------------------------------------------------
|