gloo 1.4.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.gitignore +1 -0
  4. data/gloo.gemspec +0 -2
  5. data/lib/VERSION +1 -1
  6. data/lib/dependencies.rb +4 -4
  7. data/lib/gloo/app/args.rb +112 -0
  8. data/lib/gloo/app/engine.rb +247 -0
  9. data/lib/gloo/app/engine_context.rb +25 -0
  10. data/lib/gloo/app/info.rb +20 -3
  11. data/lib/gloo/app/log.rb +73 -1
  12. data/lib/gloo/app/mode.rb +27 -0
  13. data/lib/gloo/app/platform.rb +8 -1
  14. data/lib/gloo/app/settings.rb +202 -0
  15. data/lib/gloo/convert/converter.rb +42 -0
  16. data/lib/gloo/convert/string_to_date.rb +21 -0
  17. data/lib/gloo/convert/string_to_datetime.rb +21 -0
  18. data/lib/gloo/convert/string_to_decimal.rb +20 -0
  19. data/lib/gloo/convert/string_to_integer.rb +20 -0
  20. data/lib/gloo/convert/string_to_time.rb +21 -0
  21. data/lib/gloo/core/baseo.rb +31 -0
  22. data/lib/gloo/core/dictionary.rb +245 -0
  23. data/lib/gloo/core/error.rb +61 -0
  24. data/lib/gloo/core/event_manager.rb +45 -0
  25. data/lib/gloo/core/factory.rb +211 -0
  26. data/lib/gloo/core/gloo_system.rb +267 -0
  27. data/lib/gloo/core/heap.rb +53 -0
  28. data/lib/gloo/core/here.rb +36 -0
  29. data/lib/gloo/core/it.rb +36 -0
  30. data/lib/gloo/core/literal.rb +30 -0
  31. data/lib/gloo/core/obj.rb +318 -0
  32. data/lib/gloo/core/obj_finder.rb +30 -0
  33. data/lib/gloo/core/op.rb +40 -0
  34. data/lib/gloo/core/parser.rb +60 -0
  35. data/lib/gloo/core/pn.rb +212 -0
  36. data/lib/gloo/core/tokens.rb +165 -0
  37. data/lib/gloo/core/verb.rb +87 -0
  38. data/lib/gloo/exec/action.rb +48 -0
  39. data/lib/gloo/exec/dispatch.rb +40 -0
  40. data/lib/gloo/exec/exec_env.rb +75 -0
  41. data/lib/gloo/exec/runner.rb +45 -0
  42. data/lib/gloo/exec/script.rb +50 -0
  43. data/lib/gloo/exec/stack.rb +79 -0
  44. data/lib/gloo/expr/expression.rb +119 -0
  45. data/lib/gloo/expr/l_boolean.rb +36 -0
  46. data/lib/gloo/expr/l_decimal.rb +39 -0
  47. data/lib/gloo/expr/l_integer.rb +37 -0
  48. data/lib/gloo/expr/l_string.rb +58 -0
  49. data/lib/gloo/expr/op_div.rb +22 -0
  50. data/lib/gloo/expr/op_minus.rb +22 -0
  51. data/lib/gloo/expr/op_mult.rb +22 -0
  52. data/lib/gloo/expr/op_plus.rb +24 -0
  53. data/lib/gloo/objs/basic/alias.rb +78 -0
  54. data/lib/gloo/objs/basic/boolean.rb +120 -0
  55. data/lib/gloo/objs/basic/container.rb +65 -0
  56. data/lib/gloo/objs/basic/decimal.rb +76 -0
  57. data/lib/gloo/objs/basic/integer.rb +73 -0
  58. data/lib/gloo/objs/basic/script.rb +99 -0
  59. data/lib/gloo/objs/basic/string.rb +77 -0
  60. data/lib/gloo/objs/basic/text.rb +79 -0
  61. data/lib/gloo/objs/basic/untyped.rb +41 -0
  62. data/lib/gloo/objs/cli/banner.rb +1 -1
  63. data/lib/gloo/objs/cli/bar.rb +3 -3
  64. data/lib/gloo/objs/cli/colorize.rb +1 -1
  65. data/lib/gloo/objs/cli/confirm.rb +1 -1
  66. data/lib/gloo/objs/cli/menu.rb +6 -6
  67. data/lib/gloo/objs/cli/menu_item.rb +1 -1
  68. data/lib/gloo/objs/cli/pastel.rb +1 -1
  69. data/lib/gloo/objs/cli/prompt.rb +1 -1
  70. data/lib/gloo/objs/cli/select.rb +2 -2
  71. data/lib/gloo/objs/ctrl/each.rb +279 -0
  72. data/lib/gloo/objs/ctrl/repeat.rb +108 -0
  73. data/lib/gloo/objs/data/markdown.rb +79 -0
  74. data/lib/gloo/objs/data/mysql.rb +5 -5
  75. data/lib/gloo/objs/data/query.rb +4 -4
  76. data/lib/gloo/objs/data/sqlite.rb +1 -1
  77. data/lib/gloo/objs/data/table.rb +112 -0
  78. data/lib/gloo/objs/dev/git.rb +2 -2
  79. data/lib/gloo/objs/dev/stats.rb +4 -4
  80. data/lib/gloo/objs/dt/date.rb +65 -0
  81. data/lib/gloo/objs/dt/datetime.rb +120 -0
  82. data/lib/gloo/objs/dt/dt_tools.rb +100 -0
  83. data/lib/gloo/objs/dt/time.rb +65 -0
  84. data/lib/gloo/objs/ror/erb.rb +116 -0
  85. data/lib/gloo/objs/ror/eval.rb +107 -0
  86. data/lib/gloo/objs/snd/play.rb +1 -1
  87. data/lib/gloo/objs/snd/say.rb +1 -1
  88. data/lib/gloo/objs/system/file_handle.rb +4 -4
  89. data/lib/gloo/objs/system/ssh_exec.rb +1 -1
  90. data/lib/gloo/objs/system/system.rb +1 -1
  91. data/lib/gloo/objs/web/http_get.rb +159 -0
  92. data/lib/gloo/objs/web/http_post.rb +183 -0
  93. data/lib/gloo/objs/web/json.rb +135 -0
  94. data/lib/gloo/objs/web/slack.rb +130 -0
  95. data/lib/gloo/objs/web/teams.rb +117 -0
  96. data/lib/gloo/objs/web/uri.rb +148 -0
  97. data/lib/gloo/persist/disc_mech.rb +87 -0
  98. data/lib/gloo/persist/file_loader.rb +193 -0
  99. data/lib/gloo/persist/file_saver.rb +51 -0
  100. data/lib/gloo/persist/file_storage.rb +46 -0
  101. data/lib/gloo/persist/line_splitter.rb +81 -0
  102. data/lib/gloo/persist/persist_man.rb +153 -0
  103. data/lib/gloo/utils/format.rb +21 -0
  104. data/lib/gloo/utils/stats.rb +206 -0
  105. data/lib/gloo/utils/words.rb +19 -0
  106. data/lib/gloo/verbs/alert.rb +2 -2
  107. data/lib/gloo/verbs/beep.rb +1 -1
  108. data/lib/gloo/verbs/cls.rb +1 -1
  109. data/lib/gloo/verbs/context.rb +62 -0
  110. data/lib/gloo/verbs/create.rb +68 -0
  111. data/lib/gloo/verbs/execute.rb +56 -0
  112. data/lib/gloo/verbs/files.rb +49 -0
  113. data/lib/gloo/verbs/help.rb +1 -1
  114. data/lib/gloo/verbs/if.rb +92 -0
  115. data/lib/gloo/verbs/list.rb +98 -0
  116. data/lib/gloo/verbs/load.rb +45 -0
  117. data/lib/gloo/verbs/move.rb +89 -0
  118. data/lib/gloo/verbs/put.rb +94 -0
  119. data/lib/gloo/verbs/quit.rb +40 -0
  120. data/lib/gloo/verbs/reload.rb +43 -0
  121. data/lib/gloo/verbs/run.rb +75 -0
  122. data/lib/gloo/verbs/save.rb +39 -0
  123. data/lib/gloo/verbs/show.rb +63 -0
  124. data/lib/gloo/verbs/tell.rb +80 -0
  125. data/lib/gloo/verbs/unless.rb +92 -0
  126. data/lib/gloo/verbs/unload.rb +46 -0
  127. data/lib/gloo/verbs/version.rb +3 -3
  128. data/lib/gloo/verbs/wait.rb +42 -0
  129. data/lib/gloo.rb +2 -2
  130. data/lib/run.rb +2 -2
  131. metadata +97 -22
@@ -6,7 +6,7 @@
6
6
 
7
7
  module Gloo
8
8
  module Objs
9
- class Stats < GlooLang::Core::Obj
9
+ class Stats < Gloo::Core::Obj
10
10
 
11
11
  KEYWORD = 'stats'.freeze
12
12
  KEYWORD_SHORT = 'stat'.freeze
@@ -95,7 +95,7 @@ module Gloo
95
95
  # Show all project stats.
96
96
  #
97
97
  def msg_show_all
98
- o = GlooLang::Utils::Stats.new(
98
+ o = Gloo::Utils::Stats.new(
99
99
  @engine, path_value, types_value, skip_list )
100
100
  o.show_all
101
101
  end
@@ -104,7 +104,7 @@ module Gloo
104
104
  # Show file types.
105
105
  #
106
106
  def msg_show_types
107
- o = GlooLang::Utils::Stats.new(
107
+ o = Gloo::Utils::Stats.new(
108
108
  @engine, path_value, types_value, skip_list )
109
109
  o.file_types
110
110
  end
@@ -113,7 +113,7 @@ module Gloo
113
113
  # Show busy folders: those with the most files.
114
114
  #
115
115
  def msg_show_busy_folders
116
- o = GlooLang::Utils::Stats.new(
116
+ o = Gloo::Utils::Stats.new(
117
117
  @engine, path_value, types_value, skip_list )
118
118
  o.busy_folders
119
119
  end
@@ -0,0 +1,65 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
+ #
4
+ # A Date object (does not include a time).
5
+ #
6
+
7
+ module Gloo
8
+ module Objs
9
+ class Date < Gloo::Core::Obj
10
+
11
+ KEYWORD = 'date'.freeze
12
+ KEYWORD_SHORT = 'date'.freeze
13
+ DEFAULT_FORMAT = '%Y.%m.%d'.freeze
14
+
15
+ #
16
+ # The name of the object type.
17
+ #
18
+ def self.typename
19
+ return KEYWORD
20
+ end
21
+
22
+ #
23
+ # The short name of the object type.
24
+ #
25
+ def self.short_typename
26
+ return KEYWORD_SHORT
27
+ end
28
+
29
+ #
30
+ # Set the value with any necessary type conversions.
31
+ #
32
+ def set_value( new_value )
33
+ if DtTools.is_dt_type? new_value
34
+ self.value = new_value
35
+ else
36
+ self.value = @engine.converter.convert( new_value, 'Date', nil )
37
+ end
38
+
39
+ if DtTools.is_dt_type? self.value
40
+ self.value = self.value.strftime( DEFAULT_FORMAT )
41
+ end
42
+ end
43
+
44
+ # ---------------------------------------------------------------------
45
+ # Messages
46
+ # ---------------------------------------------------------------------
47
+
48
+ #
49
+ # Get a list of message names that this object receives.
50
+ #
51
+ def self.messages
52
+ return super + %w[now]
53
+ end
54
+
55
+ #
56
+ # Set to the current date.
57
+ #
58
+ def msg_now
59
+ self.set_value( DateTime.now )
60
+ @engine.heap.it.set_to self.value
61
+ end
62
+
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,120 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
+ #
4
+ # A Date and Time object.
5
+ #
6
+ require 'active_support/all'
7
+
8
+ module Gloo
9
+ module Objs
10
+ class Datetime < Gloo::Core::Obj
11
+
12
+ KEYWORD = 'datetime'.freeze
13
+ KEYWORD_SHORT = 'dt'.freeze
14
+ DEFAULT_FORMAT = '%Y.%m.%d %I:%M:%S %P'.freeze
15
+
16
+ #
17
+ # The name of the object type.
18
+ #
19
+ def self.typename
20
+ return KEYWORD
21
+ end
22
+
23
+ #
24
+ # The short name of the object type.
25
+ #
26
+ def self.short_typename
27
+ return KEYWORD_SHORT
28
+ end
29
+
30
+ #
31
+ # Set the value with any necessary type conversions.
32
+ #
33
+ def set_value( new_value )
34
+ if DtTools.is_dt_type? new_value
35
+ self.value = new_value
36
+ else
37
+ self.value = @engine.converter.convert( new_value, 'DateTime', nil )
38
+ end
39
+
40
+ if DtTools.is_dt_type? self.value
41
+ self.value = self.value.strftime( DEFAULT_FORMAT )
42
+ end
43
+ end
44
+
45
+ # ---------------------------------------------------------------------
46
+ # Messages
47
+ # ---------------------------------------------------------------------
48
+
49
+ #
50
+ # Get a list of message names that this object receives.
51
+ #
52
+ def self.messages
53
+ return super + %w[now is_today is_future is_past is_yesterday is_tomorrow is_this_week]
54
+ end
55
+
56
+ #
57
+ # Tell the datetime to check if it is today.
58
+ #
59
+ def msg_is_today
60
+ today = DtTools.is_today?( self.value )
61
+ @engine.heap.it.set_to today
62
+ return today
63
+ end
64
+
65
+ #
66
+ # Tell the datetime to check if it is in the future.
67
+ #
68
+ def msg_is_future
69
+ today = DtTools.is_future?( self.value )
70
+ @engine.heap.it.set_to today
71
+ return today
72
+ end
73
+
74
+ #
75
+ # Tell the datetime to check if it is in the past.
76
+ #
77
+ def msg_is_past
78
+ today = DtTools.is_past?( self.value )
79
+ @engine.heap.it.set_to today
80
+ return today
81
+ end
82
+
83
+ #
84
+ # Tell the datetime to check if it is yesterday.
85
+ #
86
+ def msg_is_yesterday
87
+ today = DtTools.is_yesterday?( self.value )
88
+ @engine.heap.it.set_to today
89
+ return today
90
+ end
91
+
92
+ #
93
+ # Tell the datetime to check if it is tomorrow.
94
+ #
95
+ def msg_is_tomorrow
96
+ today = DtTools.is_tomorrow?( self.value )
97
+ @engine.heap.it.set_to today
98
+ return today
99
+ end
100
+
101
+ #
102
+ # Tell the datetime to check if it is this week.
103
+ #
104
+ def msg_is_this_week
105
+ today = DtTools.is_this_week?( self.value )
106
+ @engine.heap.it.set_to today
107
+ return today
108
+ end
109
+
110
+ #
111
+ # Set to the current date and time.
112
+ #
113
+ def msg_now
114
+ self.set_value( DateTime.now )
115
+ @engine.heap.it.set_to self.value
116
+ end
117
+
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,100 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
+ #
4
+ # A Date and Time object.
5
+ #
6
+
7
+ class DtTools
8
+
9
+ # ---------------------------------------------------------------------
10
+ # Type helpers
11
+ # ---------------------------------------------------------------------
12
+
13
+ #
14
+ # Is the given object a base Date Time object?
15
+ # True for DateTime and Time
16
+ #
17
+ def self.is_dt_type? obj
18
+ return true if obj.is_a? ::DateTime
19
+ return true if obj.is_a? ::Time
20
+ return false
21
+ end
22
+
23
+ # ---------------------------------------------------------------------
24
+ # Language helpers
25
+ # ---------------------------------------------------------------------
26
+
27
+ #
28
+ # Get the beginning of the week.
29
+ #
30
+ def self.beginning_of_week
31
+ return Time.now.beginning_of_week( start_day = :sunday )
32
+ end
33
+
34
+ #
35
+ # Is the date in the next 10 days?
36
+ #
37
+ def self.in_next_ten_days?( dt )
38
+ return false if DtTools.is_past?( dt )
39
+ dt < 10.days.from_now.end_of_day
40
+ end
41
+
42
+ #
43
+ # Is the date in the past?
44
+ #
45
+ def self.is_past?( dt )
46
+ dt < Time.now.beginning_of_day
47
+ end
48
+
49
+ #
50
+ # Is the date in the future?
51
+ #
52
+ def self.is_future?( dt )
53
+ dt > Time.now.end_of_day
54
+ end
55
+
56
+ #
57
+ # Is the given date today?
58
+ #
59
+ def self.is_today?( dt )
60
+ return false if dt.blank?
61
+ dt = Chronic.parse( dt ) if dt.is_a? String
62
+ return false if dt <= ::Time.now.beginning_of_day
63
+ return false if dt >= ::Time.now.end_of_day
64
+ return true
65
+ end
66
+
67
+ #
68
+ # Is the given date tomorrow?
69
+ #
70
+ def self.is_tomorrow?( dt )
71
+ return false if dt.blank?
72
+ dt = Chronic.parse( dt ) if dt.is_a? String
73
+ return false if dt <= ( ::Time.now.beginning_of_day + 1.day )
74
+ return false if dt >= ( ::Time.now.end_of_day + 1.day )
75
+ return true
76
+ end
77
+
78
+ #
79
+ # Is the given date yesterday?
80
+ #
81
+ def self.is_yesterday?( dt )
82
+ return false if dt.blank?
83
+ dt = Chronic.parse( dt ) if dt.is_a? String
84
+ return false if dt <= ( ::Time.now.beginning_of_day - 1.day )
85
+ return false if dt >= ( ::Time.now.end_of_day - 1.day )
86
+ return true
87
+ end
88
+
89
+ #
90
+ # Is the given date this week?
91
+ #
92
+ def self.is_this_week?( dt )
93
+ return false if dt.blank?
94
+ dt = Chronic.parse( dt ) if dt.is_a?( String )
95
+ return false if dt <= ::Time.now.beginning_of_week( start_day = :sunday )
96
+ return false if dt >= ::Time.now.end_of_week( start_day = :sunday )
97
+ return true
98
+ end
99
+
100
+ end
@@ -0,0 +1,65 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
+ #
4
+ # A Time object (does not include a date).
5
+ #
6
+
7
+ module Gloo
8
+ module Objs
9
+ class Time < Gloo::Core::Obj
10
+
11
+ KEYWORD = 'time'.freeze
12
+ KEYWORD_SHORT = 'time'.freeze
13
+ DEFAULT_FORMAT = '%I:%M:%S %P'.freeze
14
+
15
+ #
16
+ # The name of the object type.
17
+ #
18
+ def self.typename
19
+ return KEYWORD
20
+ end
21
+
22
+ #
23
+ # The short name of the object type.
24
+ #
25
+ def self.short_typename
26
+ return KEYWORD_SHORT
27
+ end
28
+
29
+ #
30
+ # Set the value with any necessary type conversions.
31
+ #
32
+ def set_value( new_value )
33
+ if DtTools.is_dt_type? new_value
34
+ self.value = new_value
35
+ else
36
+ self.value = @engine.converter.convert( new_value, 'Time', nil )
37
+ end
38
+
39
+ if DtTools.is_dt_type? self.value
40
+ self.value = self.value.strftime( DEFAULT_FORMAT )
41
+ end
42
+ end
43
+
44
+ # ---------------------------------------------------------------------
45
+ # Messages
46
+ # ---------------------------------------------------------------------
47
+
48
+ #
49
+ # Get a list of message names that this object receives.
50
+ #
51
+ def self.messages
52
+ return super + %w[now]
53
+ end
54
+
55
+ #
56
+ # Set to the current time.
57
+ #
58
+ def msg_now
59
+ self.set_value( DateTime.now )
60
+ @engine.heap.it.set_to self.value
61
+ end
62
+
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,116 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
+ #
4
+ # An object that evaluate a ruby statement.
5
+ #
6
+ require 'erb'
7
+
8
+ module Gloo
9
+ module Objs
10
+ class Erb < Gloo::Core::Obj
11
+
12
+ KEYWORD = 'erb'.freeze
13
+ KEYWORD_SHORT = 'erb'.freeze
14
+ TEMPLATE = 'template'.freeze
15
+ PARAMS = 'params'.freeze
16
+ RESULT = 'result'.freeze
17
+
18
+ #
19
+ # The name of the object type.
20
+ #
21
+ def self.typename
22
+ return KEYWORD
23
+ end
24
+
25
+ #
26
+ # The short name of the object type.
27
+ #
28
+ def self.short_typename
29
+ return KEYWORD_SHORT
30
+ end
31
+
32
+ #
33
+ # Get the ERB template.
34
+ #
35
+ def template_value
36
+ tmpl = find_child TEMPLATE
37
+ return nil unless tmpl
38
+
39
+ return tmpl.value
40
+ end
41
+
42
+ #
43
+ # Set the result of the ERB template conversion.
44
+ #
45
+ def set_result( data )
46
+ r = find_child RESULT
47
+ return nil unless r
48
+
49
+ r.set_value data
50
+ end
51
+
52
+ #
53
+ # Get a hash with parameters for the ERB render.
54
+ #
55
+ def param_hash
56
+ h = {}
57
+
58
+ body = find_child PARAMS
59
+ body.children.each do |child|
60
+ child = Gloo::Objs::Alias.resolve_alias( @engine, child )
61
+ h[ child.name ] = child.value
62
+ end
63
+
64
+ return h
65
+ end
66
+
67
+ # ---------------------------------------------------------------------
68
+ # Children
69
+ # ---------------------------------------------------------------------
70
+
71
+ #
72
+ # Does this object have children to add when an object
73
+ # is created in interactive mode?
74
+ # This does not apply during obj load, etc.
75
+ #
76
+ def add_children_on_create?
77
+ return true
78
+ end
79
+
80
+ #
81
+ # Add children to this object.
82
+ # This is used by containers to add children needed
83
+ # for default configurations.
84
+ #
85
+ def add_default_children
86
+ fac = @engine.factory
87
+ fac.create_text TEMPLATE, '', self
88
+ fac.create_can PARAMS, self
89
+ fac.create_text RESULT, '', self
90
+ end
91
+
92
+ # ---------------------------------------------------------------------
93
+ # Messages
94
+ # ---------------------------------------------------------------------
95
+
96
+ #
97
+ # Get a list of message names that this object receives.
98
+ #
99
+ def self.messages
100
+ return super + [ 'run' ]
101
+ end
102
+
103
+ #
104
+ # Run the ERB template conversion.
105
+ #
106
+ def msg_run
107
+ tmpl = template_value
108
+ return unless tmpl
109
+
110
+ render = ERB.new( tmpl )
111
+ set_result render.result_with_hash( param_hash )
112
+ end
113
+
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,107 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
+ #
4
+ # An object that evaluate a ruby statement.
5
+ #
6
+
7
+ module Gloo
8
+ module Objs
9
+ class Eval < Gloo::Core::Obj
10
+
11
+ KEYWORD = 'eval'.freeze
12
+ KEYWORD_SHORT = 'ruby'.freeze
13
+ CMD = 'command'.freeze
14
+ DEFAULT_CMD = '1+2'.freeze
15
+ RESULT = 'result'.freeze
16
+
17
+ #
18
+ # The name of the object type.
19
+ #
20
+ def self.typename
21
+ return KEYWORD
22
+ end
23
+
24
+ #
25
+ # The short name of the object type.
26
+ #
27
+ def self.short_typename
28
+ return KEYWORD_SHORT
29
+ end
30
+
31
+ #
32
+ # Get the URI from the child object.
33
+ # Returns nil if there is none.
34
+ #
35
+ def cmd_value
36
+ cmd = find_child CMD
37
+ return nil unless cmd
38
+
39
+ return cmd.value
40
+ end
41
+
42
+ #
43
+ # Set the result of the system call.
44
+ #
45
+ def set_result( data )
46
+ r = find_child RESULT
47
+ return nil unless r
48
+
49
+ r.set_value data
50
+ end
51
+
52
+ # ---------------------------------------------------------------------
53
+ # Children
54
+ # ---------------------------------------------------------------------
55
+
56
+ #
57
+ # Does this object have children to add when an object
58
+ # is created in interactive mode?
59
+ # This does not apply during obj load, etc.
60
+ #
61
+ def add_children_on_create?
62
+ return true
63
+ end
64
+
65
+ #
66
+ # Add children to this object.
67
+ # This is used by containers to add children needed
68
+ # for default configurations.
69
+ #
70
+ def add_default_children
71
+ fac = @engine.factory
72
+ fac.create_string CMD, DEFAULT_CMD, self
73
+ fac.create_string RESULT, nil, self
74
+ end
75
+
76
+ # ---------------------------------------------------------------------
77
+ # Messages
78
+ # ---------------------------------------------------------------------
79
+
80
+ #
81
+ # Get a list of message names that this object receives.
82
+ #
83
+ def self.messages
84
+ return super + [ 'run' ]
85
+ end
86
+
87
+ #
88
+ # Run the command and evaluate the expression.
89
+ #
90
+ def msg_run
91
+ cmd = cmd_value
92
+ return unless cmd
93
+
94
+ begin
95
+ # rubocop:disable Security/Eval
96
+ result = eval cmd
97
+ # rubocop:enable Security/Eval
98
+ set_result result
99
+ @engine.heap.it.set_to result
100
+ rescue => e
101
+ @engine.err e.message
102
+ end
103
+ end
104
+
105
+ end
106
+ end
107
+ end
@@ -6,7 +6,7 @@
6
6
 
7
7
  module Gloo
8
8
  module Objs
9
- class Play < GlooLang::Core::Obj
9
+ class Play < Gloo::Core::Obj
10
10
 
11
11
  KEYWORD = 'play'.freeze
12
12
  KEYWORD_SHORT = 'play'.freeze
@@ -7,7 +7,7 @@ require 'erb'
7
7
 
8
8
  module Gloo
9
9
  module Objs
10
- class Say < GlooLang::Core::Obj
10
+ class Say < Gloo::Core::Obj
11
11
 
12
12
  KEYWORD = 'say'.freeze
13
13
  KEYWORD_SHORT = 'say'.freeze
@@ -7,7 +7,7 @@ require 'tty-pager'
7
7
 
8
8
  module Gloo
9
9
  module Objs
10
- class FileHandle < GlooLang::Core::Obj
10
+ class FileHandle < Gloo::Core::Obj
11
11
 
12
12
  KEYWORD = 'file'.freeze
13
13
  KEYWORD_SHORT = 'dir'.freeze
@@ -47,7 +47,7 @@ module Gloo
47
47
  def msg_open
48
48
  return unless value && File.exist?( value )
49
49
 
50
- cmd = GlooLang::Core::GlooSystem.open_for_platform
50
+ cmd = Gloo::Core::GlooSystem.open_for_platform
51
51
  cmd_with_param = "#{cmd} \"#{value}\""
52
52
  `#{cmd_with_param}`
53
53
  end
@@ -79,7 +79,7 @@ module Gloo
79
79
 
80
80
  data = File.read( value )
81
81
  if @params&.token_count&.positive?
82
- pn = GlooLang::Core::Pn.new( @engine, @params.first )
82
+ pn = Gloo::Core::Pn.new( @engine, @params.first )
83
83
  o = pn.resolve
84
84
  o.set_value data
85
85
  else
@@ -95,7 +95,7 @@ module Gloo
95
95
  return unless value
96
96
 
97
97
  if @params&.token_count&.positive?
98
- expr = GlooLang::Expr::Expression.new( @engine, @params.tokens )
98
+ expr = Gloo::Expr::Expression.new( @engine, @params.tokens )
99
99
  data = expr.evaluate
100
100
  end
101
101
  File.write( value, data )
@@ -7,7 +7,7 @@ require 'net/ssh'
7
7
 
8
8
  module Gloo
9
9
  module Objs
10
- class SshExec < GlooLang::Core::Obj
10
+ class SshExec < Gloo::Core::Obj
11
11
 
12
12
  KEYWORD = 'ssh_exec'.freeze
13
13
  KEYWORD_SHORT = 'ssh'.freeze
@@ -6,7 +6,7 @@
6
6
 
7
7
  module Gloo
8
8
  module Objs
9
- class System < GlooLang::Core::Obj
9
+ class System < Gloo::Core::Obj
10
10
 
11
11
  KEYWORD = 'system'.freeze
12
12
  KEYWORD_SHORT = 'sys'.freeze