gloo 0.4.0 → 0.5.4
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/.DS_Store +0 -0
 - data/.rubocop.yml +1 -1
 - data/Gemfile.lock +84 -81
 - data/Rakefile +1 -0
 - data/gloo.gemspec +4 -1
 - data/lib/gloo/app/engine.rb +48 -3
 - data/lib/gloo/app/info.rb +1 -1
 - data/lib/gloo/app/settings.rb +12 -5
 - data/lib/gloo/convert/string_to_datetime.rb +21 -0
 - data/lib/gloo/convert/string_to_decimal.rb +20 -0
 - data/lib/gloo/convert/string_to_integer.rb +20 -0
 - data/lib/gloo/core/event_manager.rb +2 -6
 - data/lib/gloo/core/factory.rb +60 -3
 - data/lib/gloo/core/gloo_system.rb +72 -0
 - data/lib/gloo/core/obj.rb +50 -1
 - data/lib/gloo/core/parser.rb +3 -1
 - data/lib/gloo/core/pn.rb +3 -2
 - data/lib/gloo/exec/dispatch.rb +30 -0
 - data/lib/gloo/exec/runner.rb +43 -0
 - data/lib/gloo/expr/expression.rb +1 -0
 - data/lib/gloo/expr/l_decimal.rb +34 -0
 - data/lib/gloo/expr/op_div.rb +2 -0
 - data/lib/gloo/expr/op_minus.rb +2 -0
 - data/lib/gloo/expr/op_mult.rb +2 -0
 - data/lib/gloo/expr/op_plus.rb +2 -0
 - data/lib/gloo/objs/basic/alias.rb +111 -0
 - data/lib/gloo/objs/basic/container.rb +32 -1
 - data/lib/gloo/objs/basic/decimal.rb +96 -0
 - data/lib/gloo/objs/basic/integer.rb +5 -0
 - data/lib/gloo/objs/basic/string.rb +9 -1
 - data/lib/gloo/objs/basic/text.rb +27 -2
 - data/lib/gloo/objs/cli/banner.rb +137 -0
 - data/lib/gloo/objs/cli/bar.rb +141 -0
 - data/lib/gloo/objs/cli/colorize.rb +1 -1
 - data/lib/gloo/objs/cli/menu.rb +236 -0
 - data/lib/gloo/objs/cli/menu_item.rb +128 -0
 - data/lib/gloo/objs/cli/pastel.rb +120 -0
 - data/lib/gloo/objs/cli/prompt.rb +19 -11
 - data/lib/gloo/objs/cli/select.rb +153 -0
 - data/lib/gloo/objs/ctrl/each.rb +45 -16
 - data/lib/gloo/objs/ctrl/repeat.rb +129 -0
 - data/lib/gloo/objs/data/markdown.rb +109 -0
 - data/lib/gloo/objs/data/table.rb +168 -0
 - data/lib/gloo/objs/dt/date.rb +72 -0
 - data/lib/gloo/objs/dt/datetime.rb +84 -0
 - data/lib/gloo/objs/dt/time.rb +72 -0
 - data/lib/gloo/objs/ror/erb.rb +1 -0
 - data/lib/gloo/objs/system/file_handle.rb +50 -1
 - data/lib/gloo/objs/web/http_get.rb +24 -4
 - data/lib/gloo/objs/web/http_post.rb +27 -11
 - data/lib/gloo/objs/web/json.rb +155 -0
 - data/lib/gloo/objs/web/uri.rb +160 -0
 - data/lib/gloo/persist/file_loader.rb +17 -6
 - data/lib/gloo/persist/line_splitter.rb +7 -2
 - data/lib/gloo/persist/persist_man.rb +37 -13
 - data/lib/gloo/verbs/cls.rb +67 -0
 - data/lib/gloo/verbs/help.rb +9 -0
 - data/lib/gloo/verbs/if.rb +1 -0
 - data/lib/gloo/verbs/load.rb +3 -2
 - data/lib/gloo/verbs/move.rb +128 -0
 - data/lib/gloo/verbs/run.rb +21 -7
 - data/lib/gloo/verbs/tell.rb +1 -1
 - data/lib/gloo/verbs/unless.rb +1 -0
 - data/lib/gloo/verbs/wait.rb +73 -0
 - metadata +76 -5
 - data/lib/gloo/core/runner.rb +0 -26
 
| 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Author::    Eric Crane  (mailto:eric.crane@mac.com)
         
     | 
| 
      
 2 
     | 
    
         
            +
            # Copyright:: Copyright (c) 202 Eric Crane.  All rights reserved.
         
     | 
| 
      
 3 
     | 
    
         
            +
            #
         
     | 
| 
      
 4 
     | 
    
         
            +
            # Conversion tool:  String to Integer.
         
     | 
| 
      
 5 
     | 
    
         
            +
            #
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            module Gloo
         
     | 
| 
      
 8 
     | 
    
         
            +
              module Convert
         
     | 
| 
      
 9 
     | 
    
         
            +
                class StringToInteger
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  #
         
     | 
| 
      
 12 
     | 
    
         
            +
                  # Convert the given string value to an integer.
         
     | 
| 
      
 13 
     | 
    
         
            +
                  #
         
     | 
| 
      
 14 
     | 
    
         
            +
                  def convert( value )
         
     | 
| 
      
 15 
     | 
    
         
            +
                    return value.to_i
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -22,9 +22,7 @@ module Gloo 
     | 
|
| 
       22 
22 
     | 
    
         
             
                    return unless obj || in_heap
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
                    arr = Gloo::Core::ObjFinder.by_name 'on_load', obj
         
     | 
| 
       25 
     | 
    
         
            -
                    arr.each  
     | 
| 
       26 
     | 
    
         
            -
                      o.send_message 'run' if o.can_receive_message? 'run'
         
     | 
| 
       27 
     | 
    
         
            -
                    end
         
     | 
| 
      
 25 
     | 
    
         
            +
                    arr.each { |o| Gloo::Exec::Dispatch.message 'run', o }
         
     | 
| 
       28 
26 
     | 
    
         
             
                  end
         
     | 
| 
       29 
27 
     | 
    
         | 
| 
       30 
28 
     | 
    
         
             
                  #
         
     | 
| 
         @@ -34,9 +32,7 @@ module Gloo 
     | 
|
| 
       34 
32 
     | 
    
         
             
                    return unless obj
         
     | 
| 
       35 
33 
     | 
    
         | 
| 
       36 
34 
     | 
    
         
             
                    arr = Gloo::Core::ObjFinder.by_name 'on_unload', obj
         
     | 
| 
       37 
     | 
    
         
            -
                    arr.each  
     | 
| 
       38 
     | 
    
         
            -
                      o.send_message 'run' if o.can_receive_message? 'run'
         
     | 
| 
       39 
     | 
    
         
            -
                    end
         
     | 
| 
      
 35 
     | 
    
         
            +
                    arr.each { |o| Gloo::Exec::Dispatch.message 'run', o }
         
     | 
| 
       40 
36 
     | 
    
         
             
                  end
         
     | 
| 
       41 
37 
     | 
    
         | 
| 
       42 
38 
     | 
    
         
             
                end
         
     | 
    
        data/lib/gloo/core/factory.rb
    CHANGED
    
    | 
         @@ -23,7 +23,20 @@ module Gloo 
     | 
|
| 
       23 
23 
     | 
    
         
             
                  #    Factory Helpers
         
     | 
| 
       24 
24 
     | 
    
         
             
                  # ---------------------------------------------------------------------
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
                  # 
     | 
| 
      
 26 
     | 
    
         
            +
                  #
         
     | 
| 
      
 27 
     | 
    
         
            +
                  # Helper shortcut to create a string child object.
         
     | 
| 
      
 28 
     | 
    
         
            +
                  #
         
     | 
| 
      
 29 
     | 
    
         
            +
                  def create_untyped( name, value, parent )
         
     | 
| 
      
 30 
     | 
    
         
            +
                    params = { :name => name,
         
     | 
| 
      
 31 
     | 
    
         
            +
                               :type => 'untyped',
         
     | 
| 
      
 32 
     | 
    
         
            +
                               :value => value,
         
     | 
| 
      
 33 
     | 
    
         
            +
                               :parent => parent }
         
     | 
| 
      
 34 
     | 
    
         
            +
                    create params
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  #
         
     | 
| 
      
 38 
     | 
    
         
            +
                  # Helper shortcut to create a string child object.
         
     | 
| 
      
 39 
     | 
    
         
            +
                  #
         
     | 
| 
       27 
40 
     | 
    
         
             
                  def create_string( name, value, parent )
         
     | 
| 
       28 
41 
     | 
    
         
             
                    params = { :name => name,
         
     | 
| 
       29 
42 
     | 
    
         
             
                               :type => 'string',
         
     | 
| 
         @@ -32,6 +45,50 @@ module Gloo 
     | 
|
| 
       32 
45 
     | 
    
         
             
                    create params
         
     | 
| 
       33 
46 
     | 
    
         
             
                  end
         
     | 
| 
       34 
47 
     | 
    
         | 
| 
      
 48 
     | 
    
         
            +
                  #
         
     | 
| 
      
 49 
     | 
    
         
            +
                  # Helper shortcut to create an integer child object.
         
     | 
| 
      
 50 
     | 
    
         
            +
                  #
         
     | 
| 
      
 51 
     | 
    
         
            +
                  def create_int( name, value, parent )
         
     | 
| 
      
 52 
     | 
    
         
            +
                    params = { :name => name,
         
     | 
| 
      
 53 
     | 
    
         
            +
                               :type => 'integer',
         
     | 
| 
      
 54 
     | 
    
         
            +
                               :value => value,
         
     | 
| 
      
 55 
     | 
    
         
            +
                               :parent => parent }
         
     | 
| 
      
 56 
     | 
    
         
            +
                    create params
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                  #
         
     | 
| 
      
 60 
     | 
    
         
            +
                  # Helper shortcut to create a boolean child object.
         
     | 
| 
      
 61 
     | 
    
         
            +
                  #
         
     | 
| 
      
 62 
     | 
    
         
            +
                  def create_bool( name, value, parent )
         
     | 
| 
      
 63 
     | 
    
         
            +
                    params = { :name => name,
         
     | 
| 
      
 64 
     | 
    
         
            +
                               :type => 'boolean',
         
     | 
| 
      
 65 
     | 
    
         
            +
                               :value => value,
         
     | 
| 
      
 66 
     | 
    
         
            +
                               :parent => parent }
         
     | 
| 
      
 67 
     | 
    
         
            +
                    create params
         
     | 
| 
      
 68 
     | 
    
         
            +
                  end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                  #
         
     | 
| 
      
 71 
     | 
    
         
            +
                  # Helper shortcut to create a container child object.
         
     | 
| 
      
 72 
     | 
    
         
            +
                  #
         
     | 
| 
      
 73 
     | 
    
         
            +
                  def create_can( name, parent )
         
     | 
| 
      
 74 
     | 
    
         
            +
                    params = { :name => name,
         
     | 
| 
      
 75 
     | 
    
         
            +
                               :type => 'container',
         
     | 
| 
      
 76 
     | 
    
         
            +
                               :value => nil,
         
     | 
| 
      
 77 
     | 
    
         
            +
                               :parent => parent }
         
     | 
| 
      
 78 
     | 
    
         
            +
                    create params
         
     | 
| 
      
 79 
     | 
    
         
            +
                  end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                  #
         
     | 
| 
      
 82 
     | 
    
         
            +
                  # Helper shortcut to create a script child object.
         
     | 
| 
      
 83 
     | 
    
         
            +
                  #
         
     | 
| 
      
 84 
     | 
    
         
            +
                  def create_script( name, value, parent )
         
     | 
| 
      
 85 
     | 
    
         
            +
                    params = { :name => name,
         
     | 
| 
      
 86 
     | 
    
         
            +
                               :type => 'script',
         
     | 
| 
      
 87 
     | 
    
         
            +
                               :value => value,
         
     | 
| 
      
 88 
     | 
    
         
            +
                               :parent => parent }
         
     | 
| 
      
 89 
     | 
    
         
            +
                    create params
         
     | 
| 
      
 90 
     | 
    
         
            +
                  end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
       35 
92 
     | 
    
         
             
                  # ---------------------------------------------------------------------
         
     | 
| 
       36 
93 
     | 
    
         
             
                  #    Object Factory
         
     | 
| 
       37 
94 
     | 
    
         
             
                  # ---------------------------------------------------------------------
         
     | 
| 
         @@ -60,11 +117,11 @@ module Gloo 
     | 
|
| 
       60 
117 
     | 
    
         
             
                    end
         
     | 
| 
       61 
118 
     | 
    
         | 
| 
       62 
119 
     | 
    
         
             
                    if pn.exists? && params[ :squash_duplicates ]
         
     | 
| 
       63 
     | 
    
         
            -
                      $log.debug "Updating existing object: #{ 
     | 
| 
      
 120 
     | 
    
         
            +
                      $log.debug "Updating existing object: #{obj_name}"
         
     | 
| 
       64 
121 
     | 
    
         
             
                      return self.update_existing pn, params[ :value ]
         
     | 
| 
       65 
122 
     | 
    
         
             
                    end
         
     | 
| 
       66 
123 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
                    $log.debug "Creating new object: #{ 
     | 
| 
      
 124 
     | 
    
         
            +
                    $log.debug "Creating new object: #{obj_name}"
         
     | 
| 
       68 
125 
     | 
    
         
             
                    return create_new obj_name, params[ :value ], objtype, parent
         
     | 
| 
       69 
126 
     | 
    
         
             
                  end
         
     | 
| 
       70 
127 
     | 
    
         | 
| 
         @@ -6,6 +6,7 @@ 
     | 
|
| 
       6 
6 
     | 
    
         
             
            # system level variables and functions.  But it is not
         
     | 
| 
       7 
7 
     | 
    
         
             
            # actually an object in the normal sense of the word.
         
     | 
| 
       8 
8 
     | 
    
         
             
            #
         
     | 
| 
      
 9 
     | 
    
         
            +
            require 'tty-platform'
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
            module Gloo
         
     | 
| 
       11 
12 
     | 
    
         
             
              module Core
         
     | 
| 
         @@ -180,6 +181,77 @@ module Gloo 
     | 
|
| 
       180 
181 
     | 
    
         
             
                    return $settings.log_path
         
     | 
| 
       181 
182 
     | 
    
         
             
                  end
         
     | 
| 
       182 
183 
     | 
    
         | 
| 
      
 184 
     | 
    
         
            +
                  # ---------------------------------------------------------------------
         
     | 
| 
      
 185 
     | 
    
         
            +
                  #    Screen Messages
         
     | 
| 
      
 186 
     | 
    
         
            +
                  # ---------------------------------------------------------------------
         
     | 
| 
      
 187 
     | 
    
         
            +
             
     | 
| 
      
 188 
     | 
    
         
            +
                  # Get the number of lines on screen.
         
     | 
| 
      
 189 
     | 
    
         
            +
                  def msg_screen_lines
         
     | 
| 
      
 190 
     | 
    
         
            +
                    return Gloo::App::Settings.lines
         
     | 
| 
      
 191 
     | 
    
         
            +
                  end
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
                  # Get the number of columns on screen.
         
     | 
| 
      
 194 
     | 
    
         
            +
                  def msg_screen_cols
         
     | 
| 
      
 195 
     | 
    
         
            +
                    return Gloo::App::Settings.cols
         
     | 
| 
      
 196 
     | 
    
         
            +
                  end
         
     | 
| 
      
 197 
     | 
    
         
            +
             
     | 
| 
      
 198 
     | 
    
         
            +
                  # ---------------------------------------------------------------------
         
     | 
| 
      
 199 
     | 
    
         
            +
                  #    Platform Messages
         
     | 
| 
      
 200 
     | 
    
         
            +
                  # ---------------------------------------------------------------------
         
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
                  # Get the platform CPU
         
     | 
| 
      
 203 
     | 
    
         
            +
                  def msg_platform_cpu
         
     | 
| 
      
 204 
     | 
    
         
            +
                    platform = TTY::Platform.new
         
     | 
| 
      
 205 
     | 
    
         
            +
                    return platform.cpu
         
     | 
| 
      
 206 
     | 
    
         
            +
                  end
         
     | 
| 
      
 207 
     | 
    
         
            +
             
     | 
| 
      
 208 
     | 
    
         
            +
                  # Get the platform Operating System
         
     | 
| 
      
 209 
     | 
    
         
            +
                  def msg_platform_os
         
     | 
| 
      
 210 
     | 
    
         
            +
                    platform = TTY::Platform.new
         
     | 
| 
      
 211 
     | 
    
         
            +
                    return platform.os
         
     | 
| 
      
 212 
     | 
    
         
            +
                  end
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
      
 214 
     | 
    
         
            +
                  # Get the platform version
         
     | 
| 
      
 215 
     | 
    
         
            +
                  def msg_platform_version
         
     | 
| 
      
 216 
     | 
    
         
            +
                    platform = TTY::Platform.new
         
     | 
| 
      
 217 
     | 
    
         
            +
                    return platform.version
         
     | 
| 
      
 218 
     | 
    
         
            +
                  end
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
                  # Is the platform Windows?
         
     | 
| 
      
 221 
     | 
    
         
            +
                  def msg_platform_windows?
         
     | 
| 
      
 222 
     | 
    
         
            +
                    platform = TTY::Platform.new
         
     | 
| 
      
 223 
     | 
    
         
            +
                    return platform.windows?
         
     | 
| 
      
 224 
     | 
    
         
            +
                  end
         
     | 
| 
      
 225 
     | 
    
         
            +
             
     | 
| 
      
 226 
     | 
    
         
            +
                  # Is the platform Unix?
         
     | 
| 
      
 227 
     | 
    
         
            +
                  def msg_platform_unix?
         
     | 
| 
      
 228 
     | 
    
         
            +
                    platform = TTY::Platform.new
         
     | 
| 
      
 229 
     | 
    
         
            +
                    return platform.unix?
         
     | 
| 
      
 230 
     | 
    
         
            +
                  end
         
     | 
| 
      
 231 
     | 
    
         
            +
             
     | 
| 
      
 232 
     | 
    
         
            +
                  # Is the platform Linux?
         
     | 
| 
      
 233 
     | 
    
         
            +
                  def msg_platform_linux?
         
     | 
| 
      
 234 
     | 
    
         
            +
                    platform = TTY::Platform.new
         
     | 
| 
      
 235 
     | 
    
         
            +
                    return platform.linux?
         
     | 
| 
      
 236 
     | 
    
         
            +
                  end
         
     | 
| 
      
 237 
     | 
    
         
            +
             
     | 
| 
      
 238 
     | 
    
         
            +
                  # Is the platform Mac?
         
     | 
| 
      
 239 
     | 
    
         
            +
                  def msg_platform_mac?
         
     | 
| 
      
 240 
     | 
    
         
            +
                    platform = TTY::Platform.new
         
     | 
| 
      
 241 
     | 
    
         
            +
                    return platform.mac?
         
     | 
| 
      
 242 
     | 
    
         
            +
                  end
         
     | 
| 
      
 243 
     | 
    
         
            +
             
     | 
| 
      
 244 
     | 
    
         
            +
                  #
         
     | 
| 
      
 245 
     | 
    
         
            +
                  # Get the command to open a file on this platform.
         
     | 
| 
      
 246 
     | 
    
         
            +
                  #
         
     | 
| 
      
 247 
     | 
    
         
            +
                  def self.open_for_platform
         
     | 
| 
      
 248 
     | 
    
         
            +
                    platform = TTY::Platform.new
         
     | 
| 
      
 249 
     | 
    
         
            +
                    return 'open' if platform.mac?
         
     | 
| 
      
 250 
     | 
    
         
            +
                    return 'xdg-open' if platform.linux?
         
     | 
| 
      
 251 
     | 
    
         
            +
             
     | 
| 
      
 252 
     | 
    
         
            +
                    return nil
         
     | 
| 
      
 253 
     | 
    
         
            +
                  end
         
     | 
| 
      
 254 
     | 
    
         
            +
             
     | 
| 
       183 
255 
     | 
    
         
             
                end
         
     | 
| 
       184 
256 
     | 
    
         
             
              end
         
     | 
| 
       185 
257 
     | 
    
         
             
            end
         
     | 
    
        data/lib/gloo/core/obj.rb
    CHANGED
    
    | 
         @@ -60,6 +60,19 @@ module Gloo 
     | 
|
| 
       60 
60 
     | 
    
         
             
                    true
         
     | 
| 
       61 
61 
     | 
    
         
             
                  end
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
      
 63 
     | 
    
         
            +
                  #
         
     | 
| 
      
 64 
     | 
    
         
            +
                  # Get the path and name to this object.
         
     | 
| 
      
 65 
     | 
    
         
            +
                  #
         
     | 
| 
      
 66 
     | 
    
         
            +
                  def pn
         
     | 
| 
      
 67 
     | 
    
         
            +
                    str = self.name
         
     | 
| 
      
 68 
     | 
    
         
            +
                    p = self.parent
         
     | 
| 
      
 69 
     | 
    
         
            +
                    while p && !p.root?
         
     | 
| 
      
 70 
     | 
    
         
            +
                      str = "#{p.name}.#{str}"
         
     | 
| 
      
 71 
     | 
    
         
            +
                      p = p.parent
         
     | 
| 
      
 72 
     | 
    
         
            +
                    end
         
     | 
| 
      
 73 
     | 
    
         
            +
                    return str
         
     | 
| 
      
 74 
     | 
    
         
            +
                  end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
       63 
76 
     | 
    
         
             
                  # ---------------------------------------------------------------------
         
     | 
| 
       64 
77 
     | 
    
         
             
                  #    Value
         
     | 
| 
       65 
78 
     | 
    
         
             
                  # ---------------------------------------------------------------------
         
     | 
| 
         @@ -113,6 +126,21 @@ module Gloo 
     | 
|
| 
       113 
126 
     | 
    
         
             
                  #    Children
         
     | 
| 
       114 
127 
     | 
    
         
             
                  # ---------------------------------------------------------------------
         
     | 
| 
       115 
128 
     | 
    
         | 
| 
      
 129 
     | 
    
         
            +
                  #
         
     | 
| 
      
 130 
     | 
    
         
            +
                  # Find a child of the given name.
         
     | 
| 
      
 131 
     | 
    
         
            +
                  # If found, return it.  If not found create it.
         
     | 
| 
      
 132 
     | 
    
         
            +
                  #
         
     | 
| 
      
 133 
     | 
    
         
            +
                  def find_add_child( name, type )
         
     | 
| 
      
 134 
     | 
    
         
            +
                    child = self.find_child( name )
         
     | 
| 
      
 135 
     | 
    
         
            +
                    return child if child
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
                    params = { :name => name,
         
     | 
| 
      
 138 
     | 
    
         
            +
                               :type => type,
         
     | 
| 
      
 139 
     | 
    
         
            +
                               :value => nil,
         
     | 
| 
      
 140 
     | 
    
         
            +
                               :parent => self }
         
     | 
| 
      
 141 
     | 
    
         
            +
                    return $engine.factory.create params
         
     | 
| 
      
 142 
     | 
    
         
            +
                  end
         
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
       116 
144 
     | 
    
         
             
                  # Add a child object to the container.
         
     | 
| 
       117 
145 
     | 
    
         
             
                  def add_child( obj )
         
     | 
| 
       118 
146 
     | 
    
         
             
                    @children << obj
         
     | 
| 
         @@ -134,13 +162,34 @@ module Gloo 
     | 
|
| 
       134 
162 
     | 
    
         | 
| 
       135 
163 
     | 
    
         
             
                  # Find a child object with the given name.
         
     | 
| 
       136 
164 
     | 
    
         
             
                  def find_child( name )
         
     | 
| 
      
 165 
     | 
    
         
            +
                    if name.end_with?( Gloo::Objs::Alias::ALIAS_REFERENCE )
         
     | 
| 
      
 166 
     | 
    
         
            +
                      name = name[ 0..-2 ]
         
     | 
| 
      
 167 
     | 
    
         
            +
                    end
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
       137 
169 
     | 
    
         
             
                    @children.each do |o|
         
     | 
| 
       138 
170 
     | 
    
         
             
                      return o if name.downcase == o.name.downcase
         
     | 
| 
       139 
171 
     | 
    
         
             
                    end
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
                    if self.type_display == Gloo::Objs::Alias.typename
         
     | 
| 
      
 174 
     | 
    
         
            +
                      ln = Gloo::Core::Pn.new( self.value )
         
     | 
| 
      
 175 
     | 
    
         
            +
                      redirect = ln.resolve
         
     | 
| 
      
 176 
     | 
    
         
            +
                      return redirect.find_child( name )
         
     | 
| 
      
 177 
     | 
    
         
            +
                    end
         
     | 
| 
       140 
178 
     | 
    
         
             
                    return nil
         
     | 
| 
       141 
179 
     | 
    
         
             
                  end
         
     | 
| 
       142 
180 
     | 
    
         | 
| 
      
 181 
     | 
    
         
            +
                  #
         
     | 
| 
      
 182 
     | 
    
         
            +
                  # Delete all children from the container.
         
     | 
| 
      
 183 
     | 
    
         
            +
                  #
         
     | 
| 
      
 184 
     | 
    
         
            +
                  def delete_children
         
     | 
| 
      
 185 
     | 
    
         
            +
                    @children.reverse.each do |o|
         
     | 
| 
      
 186 
     | 
    
         
            +
                      self.remove_child o
         
     | 
| 
      
 187 
     | 
    
         
            +
                    end
         
     | 
| 
      
 188 
     | 
    
         
            +
                  end
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
                  #
         
     | 
| 
       143 
191 
     | 
    
         
             
                  # Remove the object from the children collection.
         
     | 
| 
      
 192 
     | 
    
         
            +
                  #
         
     | 
| 
       144 
193 
     | 
    
         
             
                  def remove_child( obj )
         
     | 
| 
       145 
194 
     | 
    
         
             
                    @children.delete obj
         
     | 
| 
       146 
195 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -167,7 +216,7 @@ module Gloo 
     | 
|
| 
       167 
216 
     | 
    
         
             
                  # Get a list of message names that this object receives.
         
     | 
| 
       168 
217 
     | 
    
         
             
                  #
         
     | 
| 
       169 
218 
     | 
    
         
             
                  def self.messages
         
     | 
| 
       170 
     | 
    
         
            -
                    return [ 
     | 
| 
      
 219 
     | 
    
         
            +
                    return %w[unload]
         
     | 
| 
       171 
220 
     | 
    
         
             
                  end
         
     | 
| 
       172 
221 
     | 
    
         | 
| 
       173 
222 
     | 
    
         
             
                  #
         
     | 
    
        data/lib/gloo/core/parser.rb
    CHANGED
    
    
    
        data/lib/gloo/core/pn.rb
    CHANGED
    
    | 
         @@ -69,7 +69,7 @@ module Gloo 
     | 
|
| 
       69 
69 
     | 
    
         | 
| 
       70 
70 
     | 
    
         
             
                  # Set the object pathname to the given value.
         
     | 
| 
       71 
71 
     | 
    
         
             
                  def set_to( value )
         
     | 
| 
       72 
     | 
    
         
            -
                    @src = value. 
     | 
| 
      
 72 
     | 
    
         
            +
                    @src = value.nil? ? nil : value.strip
         
     | 
| 
       73 
73 
     | 
    
         
             
                    @elements = @src.nil? ? [] : @src.split( '.' )
         
     | 
| 
       74 
74 
     | 
    
         
             
                  end
         
     | 
| 
       75 
75 
     | 
    
         | 
| 
         @@ -141,7 +141,8 @@ module Gloo 
     | 
|
| 
       141 
141 
     | 
    
         
             
                    parent = self.get_parent
         
     | 
| 
       142 
142 
     | 
    
         
             
                    return nil unless parent
         
     | 
| 
       143 
143 
     | 
    
         | 
| 
       144 
     | 
    
         
            -
                     
     | 
| 
      
 144 
     | 
    
         
            +
                    obj = parent.find_child( self.name )
         
     | 
| 
      
 145 
     | 
    
         
            +
                    return Gloo::Objs::Alias.resolve_alias( obj, self.src )
         
     | 
| 
       145 
146 
     | 
    
         
             
                  end
         
     | 
| 
       146 
147 
     | 
    
         | 
| 
       147 
148 
     | 
    
         
             
                end
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Author::    Eric Crane  (mailto:eric.crane@mac.com)
         
     | 
| 
      
 2 
     | 
    
         
            +
            # Copyright:: Copyright (c) 2020 Eric Crane.  All rights reserved.
         
     | 
| 
      
 3 
     | 
    
         
            +
            #
         
     | 
| 
      
 4 
     | 
    
         
            +
            # Central Message Dispatch.
         
     | 
| 
      
 5 
     | 
    
         
            +
            # Responsible for sending message to objects.
         
     | 
| 
      
 6 
     | 
    
         
            +
            # All object messaging goes through here so we can uniformly
         
     | 
| 
      
 7 
     | 
    
         
            +
            # manage things like checking to make sure object can
         
     | 
| 
      
 8 
     | 
    
         
            +
            # receive the messages sent, handling errors, etc.
         
     | 
| 
      
 9 
     | 
    
         
            +
            #
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            module Gloo
         
     | 
| 
      
 12 
     | 
    
         
            +
              module Exec
         
     | 
| 
      
 13 
     | 
    
         
            +
                class Dispatch
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  #
         
     | 
| 
      
 16 
     | 
    
         
            +
                  # Dispatch the given message to the given object.
         
     | 
| 
      
 17 
     | 
    
         
            +
                  #
         
     | 
| 
      
 18 
     | 
    
         
            +
                  def self.message( msg, to_obj, params = nil )
         
     | 
| 
      
 19 
     | 
    
         
            +
                    $log.debug "----- Sending message #{msg} to #{to_obj.name}"
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                    if to_obj.can_receive_message? msg
         
     | 
| 
      
 22 
     | 
    
         
            +
                      to_obj.send_message msg, params
         
     | 
| 
      
 23 
     | 
    
         
            +
                    else
         
     | 
| 
      
 24 
     | 
    
         
            +
                      $log.warn "Object #{to_obj.name} does not respond to #{msg}"
         
     | 
| 
      
 25 
     | 
    
         
            +
                    end
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,43 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
                    verb&.run
         
     | 
| 
      
 22 
     | 
    
         
            +
                    $engine.heap.error.clear_if_no_errors
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  #
         
     | 
| 
      
 26 
     | 
    
         
            +
                  # Send 'run' message to the object.
         
     | 
| 
      
 27 
     | 
    
         
            +
                  # Resolve the path_name and then send the run message.
         
     | 
| 
      
 28 
     | 
    
         
            +
                  #
         
     | 
| 
      
 29 
     | 
    
         
            +
                  def self.run( path_name )
         
     | 
| 
      
 30 
     | 
    
         
            +
                    $log.debug "**** Running script at #{path_name}"
         
     | 
| 
      
 31 
     | 
    
         
            +
                    pn = Gloo::Core::Pn.new path_name
         
     | 
| 
      
 32 
     | 
    
         
            +
                    o = pn.resolve
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                    if o
         
     | 
| 
      
 35 
     | 
    
         
            +
                      o.send_message 'run'
         
     | 
| 
      
 36 
     | 
    
         
            +
                    else
         
     | 
| 
      
 37 
     | 
    
         
            +
                      $log.error "Could not send message to object.  Bad path: #{path_name}"
         
     | 
| 
      
 38 
     | 
    
         
            +
                    end
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/gloo/expr/expression.rb
    CHANGED
    
    | 
         @@ -85,6 +85,7 @@ module Gloo 
     | 
|
| 
       85 
85 
     | 
    
         
             
                    return LBoolean.new( token ) if LBoolean.boolean?( token )
         
     | 
| 
       86 
86 
     | 
    
         
             
                    return LInteger.new( token ) if LInteger.integer?( token )
         
     | 
| 
       87 
87 
     | 
    
         
             
                    return LString.new( token ) if LString.string?( token )
         
     | 
| 
      
 88 
     | 
    
         
            +
                    return LDecimal.new( token ) if LDecimal.decimal?( token )
         
     | 
| 
       88 
89 
     | 
    
         | 
| 
       89 
90 
     | 
    
         
             
                    # last chance: an Object reference
         
     | 
| 
       90 
91 
     | 
    
         
             
                    return Gloo::Core::Pn.new( token )
         
     | 
| 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 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 
     | 
    
         
            +
                  # Set the value, converting to an integer.
         
     | 
| 
      
 22 
     | 
    
         
            +
                  def set_value( value )
         
     | 
| 
      
 23 
     | 
    
         
            +
                    value = value.to_s if value.is_a? Numeric
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                    @value = value.to_f
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  def to_s
         
     | 
| 
      
 29 
     | 
    
         
            +
                    return self.value.to_s
         
     | 
| 
      
 30 
     | 
    
         
            +
                  end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     |