gloo-lang 0.9.7 → 0.9.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +16 -1
  3. data/gloo-lang.gemspec +1 -1
  4. data/lib/VERSION +1 -1
  5. data/lib/gloo_lang/app/args.rb +3 -2
  6. data/lib/gloo_lang/app/engine.rb +25 -26
  7. data/lib/gloo_lang/app/engine_context.rb +25 -0
  8. data/lib/gloo_lang/app/help.rb +10 -9
  9. data/lib/gloo_lang/app/log.rb +5 -3
  10. data/lib/gloo_lang/app/settings.rb +30 -37
  11. data/lib/gloo_lang/convert/converter.rb +9 -2
  12. data/lib/gloo_lang/core/baseo.rb +2 -1
  13. data/lib/gloo_lang/core/dictionary.rb +16 -6
  14. data/lib/gloo_lang/core/event_manager.rb +9 -8
  15. data/lib/gloo_lang/core/factory.rb +11 -10
  16. data/lib/gloo_lang/core/gloo_system.rb +9 -8
  17. data/lib/gloo_lang/core/heap.rb +5 -4
  18. data/lib/gloo_lang/core/here.rb +2 -2
  19. data/lib/gloo_lang/core/obj.rb +9 -8
  20. data/lib/gloo_lang/core/obj_finder.rb +3 -3
  21. data/lib/gloo_lang/core/parser.rb +6 -5
  22. data/lib/gloo_lang/core/pn.rb +20 -16
  23. data/lib/gloo_lang/core/verb.rb +2 -1
  24. data/lib/gloo_lang/exec/dispatch.rb +8 -8
  25. data/lib/gloo_lang/exec/exec_env.rb +7 -6
  26. data/lib/gloo_lang/exec/runner.rb +10 -10
  27. data/lib/gloo_lang/exec/script.rb +6 -5
  28. data/lib/gloo_lang/exec/stack.rb +8 -7
  29. data/lib/gloo_lang/expr/expression.rb +3 -2
  30. data/lib/gloo_lang/objs/basic/alias.rb +4 -4
  31. data/lib/gloo_lang/objs/basic/boolean.rb +3 -3
  32. data/lib/gloo_lang/objs/basic/container.rb +2 -2
  33. data/lib/gloo_lang/objs/basic/decimal.rb +3 -3
  34. data/lib/gloo_lang/objs/basic/integer.rb +3 -3
  35. data/lib/gloo_lang/objs/basic/script.rb +1 -1
  36. data/lib/gloo_lang/objs/basic/string.rb +3 -3
  37. data/lib/gloo_lang/objs/basic/text.rb +2 -2
  38. data/lib/gloo_lang/objs/ctrl/each.rb +3 -3
  39. data/lib/gloo_lang/objs/ctrl/repeat.rb +2 -2
  40. data/lib/gloo_lang/objs/data/markdown.rb +2 -2
  41. data/lib/gloo_lang/objs/data/query.rb +4 -4
  42. data/lib/gloo_lang/objs/data/table.rb +3 -3
  43. data/lib/gloo_lang/objs/dt/date.rb +1 -1
  44. data/lib/gloo_lang/objs/dt/datetime.rb +2 -2
  45. data/lib/gloo_lang/objs/dt/time.rb +1 -1
  46. data/lib/gloo_lang/objs/ror/erb.rb +2 -2
  47. data/lib/gloo_lang/objs/ror/eval.rb +3 -3
  48. data/lib/gloo_lang/objs/web/http_get.rb +3 -3
  49. data/lib/gloo_lang/objs/web/http_post.rb +8 -8
  50. data/lib/gloo_lang/objs/web/json.rb +5 -5
  51. data/lib/gloo_lang/objs/web/slack.rb +1 -1
  52. data/lib/gloo_lang/objs/web/teams.rb +1 -1
  53. data/lib/gloo_lang/objs/web/uri.rb +6 -6
  54. data/lib/gloo_lang/persist/file_loader.rb +6 -5
  55. data/lib/gloo_lang/persist/file_saver.rb +2 -1
  56. data/lib/gloo_lang/persist/file_storage.rb +6 -5
  57. data/lib/gloo_lang/persist/persist_man.rb +9 -8
  58. data/lib/gloo_lang/utils/stats.rb +5 -4
  59. data/lib/gloo_lang/verbs/context.rb +4 -4
  60. data/lib/gloo_lang/verbs/create.rb +3 -3
  61. data/lib/gloo_lang/verbs/execute.rb +4 -4
  62. data/lib/gloo_lang/verbs/help.rb +23 -23
  63. data/lib/gloo_lang/verbs/if.rb +3 -3
  64. data/lib/gloo_lang/verbs/list.rb +7 -7
  65. data/lib/gloo_lang/verbs/load.rb +3 -3
  66. data/lib/gloo_lang/verbs/move.rb +6 -6
  67. data/lib/gloo_lang/verbs/put.rb +6 -6
  68. data/lib/gloo_lang/verbs/quit.rb +1 -1
  69. data/lib/gloo_lang/verbs/run.rb +5 -5
  70. data/lib/gloo_lang/verbs/save.rb +1 -1
  71. data/lib/gloo_lang/verbs/show.rb +5 -5
  72. data/lib/gloo_lang/verbs/tell.rb +5 -4
  73. data/lib/gloo_lang/verbs/unless.rb +3 -3
  74. data/lib/gloo_lang/verbs/version.rb +1 -1
  75. data/lib/gloo_lang/verbs/wait.rb +1 -1
  76. metadata +23 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78f880bdd4bdd4c5b796b0bc6a273df959ea129075750649d8c76e1f039d916b
4
- data.tar.gz: df8cca545850962ae5151e3307ece3ff9e2cbeed1588c213326cb0ebfdb9c223
3
+ metadata.gz: 38f13cdfcec13390f7b1332f97c2d2296ba72bfa67008eaf677d04409b3f0f8a
4
+ data.tar.gz: 042cb5edc85629209f62ff2b778d29d082128eefb6ae0037d501906ebe776df3
5
5
  SHA512:
6
- metadata.gz: 3bc34b8d10b6ce580189f868834170015a9d8f5305a02fc99705788c95a852d7e593d8326c3304e4b9a2bbd85faaa4b43b44e37271ac6d7399424b7b3a5a248f
7
- data.tar.gz: 0fd7f6347b859d8a945452eaa23f63742c49db49d5c2eb102a28ab3ddee362ef210c83cbbfb004bdae848303a02e514f13318901361660c2a9ff3be6d6ebca1c
6
+ metadata.gz: bb96a66f19398aa1bfd0ca5251adbcf9740fbe8395a0e24592510a52beceb961cba107e9f7b251d266af8c691f71a9dcf17107fad85398bb0d7d7768cc7e2d49
7
+ data.tar.gz: 94b7b46fae7e2f31ae499defffddbc3e09e0fbde3004900f5ded87c6b9e841f86587414c8786f2d53bd2afc57403da1bd38fd47a9270212f245de01e5934230d
data/Gemfile.lock CHANGED
@@ -1,17 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gloo-lang (0.9.4)
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)
8
9
  openssl (~> 2.1, >= 2.1.0)
10
+ tty-platform (~> 0.3, >= 0.3.0)
9
11
 
10
12
  GEM
11
13
  remote: https://rubygems.org/
12
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)
13
21
  ast (2.4.2)
14
22
  chronic (0.10.2)
23
+ concurrent-ruby (1.1.10)
24
+ i18n (1.10.0)
25
+ concurrent-ruby (~> 1.0)
15
26
  ipaddr (1.2.4)
16
27
  json (2.6.1)
17
28
  minitest (5.15.0)
@@ -37,7 +48,11 @@ GEM
37
48
  rubocop-ast (1.16.0)
38
49
  parser (>= 3.1.1.0)
39
50
  ruby-progressbar (1.11.0)
51
+ tty-platform (0.3.0)
52
+ tzinfo (2.0.4)
53
+ concurrent-ruby (~> 1.0)
40
54
  unicode-display_width (2.1.0)
55
+ zeitwerk (2.5.4)
41
56
 
42
57
  PLATFORMS
43
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
- # spec.add_dependency "activesupport", '~> 6.1', ">= 6.1.4.6"
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.7
1
+ 0.9.10
@@ -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
- $log.debug "running in #{mode} mode"
88
+ @engine.log.debug "running in #{mode} mode"
88
89
 
89
90
  return mode
90
91
  end
@@ -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,16 +20,14 @@ module GlooLang
19
20
  #
20
21
  # Set up the engine with basic elements.
21
22
  #
22
- def initialize( params = [], platform=nil, log=nil )
23
- $engine = self
24
- @args = Args.new( params )
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
- $log = log ? log : Log.new
28
- $log.quiet = @args.quiet?
27
+ @log = Log.new( self, @args.quiet? )
28
+ @platform = context.platform
29
29
 
30
- @platform = platform ? platform : Platform.new
31
- $log.debug 'engine intialized...'
30
+ @log.debug 'engine intialized...'
32
31
  end
33
32
 
34
33
  #
@@ -36,24 +35,24 @@ module GlooLang
36
35
  # Load object and verb definitions and setup engine elements.
37
36
  #
38
37
  def start
39
- $log.debug 'starting the engine...'
40
- $log.debug Info.display_title
38
+ @log.debug 'starting the engine...'
39
+ @log.debug Info.display_title
41
40
  @mode = @args.detect_mode
42
41
  @running = true
43
42
 
44
- @dictionary = GlooLang::Core::Dictionary.instance
45
- @dictionary.init
46
- @parser = GlooLang::Core::Parser.new
47
- @heap = GlooLang::Core::Heap.new
48
- @factory = GlooLang::Core::Factory.new
49
- @persist_man = GlooLang::Persist::PersistMan.new
50
- @event_manager = GlooLang::Core::EventManager.new
43
+ @dictionary = GlooLang::Core::Dictionary.get
51
44
 
52
- @exec_env = GlooLang::Exec::ExecEnv.new
53
- @help = GlooLang::App::Help.new
54
- @converter = GlooLang::Convert::Converter.new
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 )
55
50
 
56
- $log.debug 'the engine has started'
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'
57
56
  run_mode
58
57
  end
59
58
 
@@ -65,7 +64,7 @@ module GlooLang
65
64
  # Run gloo in the selected mode.
66
65
  #
67
66
  def run_mode
68
- $log.debug "running gloo in #{@mode} mode"
67
+ @log.debug "running gloo in #{@mode} mode"
69
68
 
70
69
  if @mode == Mode::VERSION
71
70
  run_version
@@ -108,7 +107,7 @@ module GlooLang
108
107
  # Get the setting for the start_with file and open it.
109
108
  #
110
109
  def open_start_file
111
- name = $settings.start_with
110
+ name = @settings.start_with
112
111
  @persist_man.load( name ) if name
113
112
  end
114
113
 
@@ -155,7 +154,7 @@ module GlooLang
155
154
  # Do any clean up and quit.
156
155
  #
157
156
  def quit
158
- $log.debug 'quitting...'
157
+ @log.debug 'quitting...'
159
158
  end
160
159
 
161
160
  # ---------------------------------------------------------------------
@@ -194,8 +193,8 @@ module GlooLang
194
193
  # Write it to the log and set the heap error value.
195
194
  #
196
195
  def err( msg )
197
- $log.error msg
198
- self.heap.error.set_to msg
196
+ @log.error msg
197
+ @heap.error.set_to msg
199
198
  end
200
199
 
201
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.new if platform.nil?
19
+ @log = Log if log.nil?
20
+ @user_root = user_root
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -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 $engine.args.quiet?
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 $engine.args.quiet?
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
- $engine.platform.show( data, topic_is_md?( topic ), page )
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 $engine.args.quiet?
69
+ return if @engine.args.quiet?
69
70
 
70
71
  data = self.get_topic_data( topic )
71
- $engine.platform.show( data, topic_is_md?( topic ), false )
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
- $log.debug 'loading help file index...'
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
- $log.debug "Found #{@topics.count} help files"
113
+ @engine.log.debug "Found #{@topics.count} help files"
113
114
  end
114
115
 
115
116
  end
@@ -9,18 +9,20 @@ module GlooLang
9
9
  module App
10
10
  class Log
11
11
 
12
- attr_reader :logger
13
12
  attr_accessor :quiet
13
+ attr_reader :logger
14
14
 
15
15
  #
16
16
  # Set up a logger.
17
17
  # If quiet is true, then message are written to the log
18
18
  # but not to the console.
19
19
  #
20
- def initialize( quiet=true )
21
- f = File.join( $settings.log_path, 'gloo.log' )
20
+ def initialize( engine, quiet=true )
21
+ @engine = engine
22
+ f = File.join( @engine.settings.log_path, 'gloo.log' )
22
23
  @logger = Logger.new( f )
23
24
  @logger.level = Logger::DEBUG
25
+ @quite = quiet
24
26
  end
25
27
 
26
28
  #
@@ -10,37 +10,24 @@ module GlooLang
10
10
  module App
11
11
  class Settings
12
12
 
13
- attr_reader :user_root, :log_path, :config_path, :project_path,
14
- :start_with, :list_indent, :tmp_path,
15
- :debug_path, :debug
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( mode )
22
- @mode = mode
23
- init_root
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
- $engine.platform.lines
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
- $engine.platform.cols
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 in_test_mode?
134
- path = File.dirname( File.dirname( File.absolute_path( __FILE__ ) ) )
135
- path = File.dirname( File.dirname( path ) )
136
- path = File.join( path, 'test', 'gloo' )
137
- @user_root = path
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 = project_path_for_mode settings
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
- $log.error e.message
27
- $engine.heap.error.set_to e.message
33
+ @engine.log.error e.message
34
+ @engine.heap.error.set_to e.message
28
35
  end
29
36
 
30
37
  return default
@@ -14,7 +14,8 @@ module GlooLang
14
14
  NOT_IMPLEMENTED_ERR = 'Not implemented yet!'.freeze
15
15
 
16
16
  # Set up the object.
17
- def initialize
17
+ def initialize( engine )
18
+ @engine = engine
18
19
  @name = ''
19
20
  end
20
21
 
@@ -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
- $log.debug 'initializing dictionaries'
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
- $log.error "duplicate keyword '#{keyword}'"
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
- $log.debug "initializing #{@obj_references.count} objects"
164
+ # @engine.log.debug "initializing #{@obj_references.count} objects"
155
165
  @obj_references.each do |o|
156
- $log.debug o
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
- $log.debug "initializing #{@verb_references.count} verbs"
178
+ # @engine.log.debug "initializing #{@verb_references.count} verbs"
169
179
  @verb_references.each do |v|
170
- $log.debug v
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
- $log.debug 'event manager intialized...'
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
- $log.debug 'on_load event'
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
- $log.debug 'on_unload event'
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
- $log.debug 'object factory intialized...'
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
- $log.debug "Updating existing object: #{obj_name}"
154
+ @engine.log.debug "Updating existing object: #{obj_name}"
154
155
  return self.update_existing pn, params[ :value ]
155
156
  end
156
157
 
157
- $log.debug "Creating new object: #{obj_name}"
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
- $log.error "Could not create object. Bad path: #{name}"
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 = $engine.dictionary.find_obj( type_name )
194
+ t = @engine.dictionary.find_obj( type_name )
194
195
 
195
196
  if t.nil?
196
- $log.warn "Could not find type, '#{type_name}'"
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
- $log.error "'#{type_name}' cannot be created."
202
+ @engine.log.error "'#{type_name}' cannot be created."
202
203
  return nil
203
204
  end
204
205