gloo 0.8.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.gitignore +2 -1
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/LICENSE.txt +1 -1
  7. data/gloo.gemspec +12 -4
  8. data/lib/VERSION +1 -1
  9. data/lib/dependencies.rb +4 -4
  10. data/lib/gloo/app/info.rb +3 -1
  11. data/lib/gloo/app/log.rb +1 -29
  12. data/lib/gloo/app/platform.rb +142 -0
  13. data/lib/gloo/objs/cli/banner.rb +2 -2
  14. data/lib/gloo/objs/cli/bar.rb +4 -4
  15. data/lib/gloo/objs/cli/colorize.rb +3 -3
  16. data/lib/gloo/objs/cli/confirm.rb +3 -3
  17. data/lib/gloo/objs/cli/menu.rb +9 -9
  18. data/lib/gloo/objs/cli/menu_item.rb +2 -2
  19. data/lib/gloo/objs/cli/pastel.rb +2 -2
  20. data/lib/gloo/objs/cli/prompt.rb +4 -4
  21. data/lib/gloo/objs/cli/select.rb +4 -4
  22. data/lib/gloo/objs/data/mysql.rb +9 -9
  23. data/lib/gloo/objs/data/sqlite.rb +10 -10
  24. data/lib/gloo/objs/dev/git.rb +7 -7
  25. data/lib/gloo/objs/dev/stats.rb +8 -5
  26. data/lib/gloo/objs/snd/play.rb +1 -1
  27. data/lib/gloo/objs/snd/say.rb +2 -2
  28. data/lib/gloo/objs/system/file_handle.rb +9 -9
  29. data/lib/gloo/objs/system/ssh_exec.rb +3 -3
  30. data/lib/gloo/objs/system/system.rb +2 -2
  31. data/lib/gloo/verbs/alert.rb +7 -7
  32. data/lib/gloo/verbs/beep.rb +1 -1
  33. data/lib/gloo/verbs/cls.rb +2 -2
  34. data/lib/gloo/verbs/help.rb +7 -189
  35. data/lib/gloo/verbs/version.rb +3 -3
  36. data/lib/gloo.rb +5 -1
  37. data/lib/run.rb +5 -1
  38. metadata +41 -177
  39. data/Gemfile.lock +0 -171
  40. data/lib/gloo/app/args.rb +0 -112
  41. data/lib/gloo/app/engine.rb +0 -230
  42. data/lib/gloo/app/help.rb +0 -156
  43. data/lib/gloo/app/mode.rb +0 -27
  44. data/lib/gloo/app/settings.rb +0 -186
  45. data/lib/gloo/convert/converter.rb +0 -35
  46. data/lib/gloo/convert/string_to_datetime.rb +0 -21
  47. data/lib/gloo/convert/string_to_decimal.rb +0 -20
  48. data/lib/gloo/convert/string_to_integer.rb +0 -20
  49. data/lib/gloo/core/baseo.rb +0 -30
  50. data/lib/gloo/core/dictionary.rb +0 -181
  51. data/lib/gloo/core/error.rb +0 -61
  52. data/lib/gloo/core/event_manager.rb +0 -44
  53. data/lib/gloo/core/factory.rb +0 -210
  54. data/lib/gloo/core/gloo_system.rb +0 -266
  55. data/lib/gloo/core/heap.rb +0 -52
  56. data/lib/gloo/core/here.rb +0 -36
  57. data/lib/gloo/core/it.rb +0 -36
  58. data/lib/gloo/core/literal.rb +0 -30
  59. data/lib/gloo/core/obj.rb +0 -303
  60. data/lib/gloo/core/obj_finder.rb +0 -30
  61. data/lib/gloo/core/op.rb +0 -40
  62. data/lib/gloo/core/parser.rb +0 -59
  63. data/lib/gloo/core/pn.rb +0 -188
  64. data/lib/gloo/core/tokens.rb +0 -165
  65. data/lib/gloo/core/verb.rb +0 -86
  66. data/lib/gloo/exec/action.rb +0 -48
  67. data/lib/gloo/exec/dispatch.rb +0 -40
  68. data/lib/gloo/exec/exec_env.rb +0 -74
  69. data/lib/gloo/exec/runner.rb +0 -45
  70. data/lib/gloo/exec/script.rb +0 -49
  71. data/lib/gloo/exec/stack.rb +0 -78
  72. data/lib/gloo/expr/expression.rb +0 -118
  73. data/lib/gloo/expr/l_boolean.rb +0 -36
  74. data/lib/gloo/expr/l_decimal.rb +0 -39
  75. data/lib/gloo/expr/l_integer.rb +0 -37
  76. data/lib/gloo/expr/l_string.rb +0 -58
  77. data/lib/gloo/expr/op_div.rb +0 -22
  78. data/lib/gloo/expr/op_minus.rb +0 -22
  79. data/lib/gloo/expr/op_mult.rb +0 -22
  80. data/lib/gloo/expr/op_plus.rb +0 -24
  81. data/lib/gloo/help/app/application.txt +0 -22
  82. data/lib/gloo/help/app/configuration.txt +0 -7
  83. data/lib/gloo/help/app/default_help.txt +0 -14
  84. data/lib/gloo/help/app/logging.txt +0 -16
  85. data/lib/gloo/help/core/color.txt +0 -31
  86. data/lib/gloo/help/core/error.txt +0 -33
  87. data/lib/gloo/help/core/events.txt +0 -21
  88. data/lib/gloo/help/core/gloo_system.txt +0 -57
  89. data/lib/gloo/help/core/here.txt +0 -30
  90. data/lib/gloo/help/core/it.txt +0 -23
  91. data/lib/gloo/help/core/ops.txt +0 -16
  92. data/lib/gloo/help/core/pathname.txt +0 -29
  93. data/lib/gloo/help/objs/basic/alias.txt +0 -36
  94. data/lib/gloo/help/objs/basic/boolean.txt +0 -28
  95. data/lib/gloo/help/objs/basic/container.txt +0 -33
  96. data/lib/gloo/help/objs/basic/decimal.txt +0 -28
  97. data/lib/gloo/help/objs/basic/integer.txt +0 -27
  98. data/lib/gloo/help/objs/basic/script.txt +0 -29
  99. data/lib/gloo/help/objs/basic/string.txt +0 -28
  100. data/lib/gloo/help/objs/basic/text.txt +0 -27
  101. data/lib/gloo/help/objs/basic/untyped.txt +0 -22
  102. data/lib/gloo/help/objs/cli/banner.txt +0 -49
  103. data/lib/gloo/help/objs/cli/bar.txt +0 -37
  104. data/lib/gloo/help/objs/cli/colorize.txt +0 -33
  105. data/lib/gloo/help/objs/cli/confirm.txt +0 -26
  106. data/lib/gloo/help/objs/cli/menu.txt +0 -44
  107. data/lib/gloo/help/objs/cli/menu_item.txt +0 -26
  108. data/lib/gloo/help/objs/cli/pastel.txt +0 -43
  109. data/lib/gloo/help/objs/cli/prompt.txt +0 -27
  110. data/lib/gloo/help/objs/cli/select.txt +0 -34
  111. data/lib/gloo/help/objs/ctrl/each.txt +0 -48
  112. data/lib/gloo/help/objs/ctrl/repeat.txt +0 -38
  113. data/lib/gloo/help/objs/data/markdown.txt +0 -25
  114. data/lib/gloo/help/objs/data/mysql.txt +0 -40
  115. data/lib/gloo/help/objs/data/query.txt +0 -37
  116. data/lib/gloo/help/objs/data/sqlite.txt +0 -26
  117. data/lib/gloo/help/objs/data/table.txt +0 -46
  118. data/lib/gloo/help/objs/dev/git_repo.txt +0 -36
  119. data/lib/gloo/help/objs/dev/stats.txt +0 -36
  120. data/lib/gloo/help/objs/dt/date.txt +0 -23
  121. data/lib/gloo/help/objs/dt/datetime.txt +0 -24
  122. data/lib/gloo/help/objs/dt/time.txt +0 -23
  123. data/lib/gloo/help/objs/ror/erb.txt +0 -37
  124. data/lib/gloo/help/objs/ror/eval.txt +0 -24
  125. data/lib/gloo/help/objs/snd/play.txt +0 -23
  126. data/lib/gloo/help/objs/snd/say.txt +0 -28
  127. data/lib/gloo/help/objs/system/file.txt +0 -48
  128. data/lib/gloo/help/objs/system/ssh_exec.txt +0 -30
  129. data/lib/gloo/help/objs/system/system.txt +0 -32
  130. data/lib/gloo/help/objs/web/http_get.txt +0 -35
  131. data/lib/gloo/help/objs/web/http_post.txt +0 -34
  132. data/lib/gloo/help/objs/web/json.txt +0 -34
  133. data/lib/gloo/help/objs/web/slack.txt +0 -33
  134. data/lib/gloo/help/objs/web/teams.txt +0 -30
  135. data/lib/gloo/help/objs/web/uri.txt +0 -38
  136. data/lib/gloo/help/verbs/alert.txt +0 -33
  137. data/lib/gloo/help/verbs/beep.txt +0 -25
  138. data/lib/gloo/help/verbs/cls.txt +0 -24
  139. data/lib/gloo/help/verbs/context.txt +0 -43
  140. data/lib/gloo/help/verbs/create.txt +0 -33
  141. data/lib/gloo/help/verbs/execute.txt +0 -27
  142. data/lib/gloo/help/verbs/help.txt +0 -34
  143. data/lib/gloo/help/verbs/if.txt +0 -37
  144. data/lib/gloo/help/verbs/list.txt +0 -34
  145. data/lib/gloo/help/verbs/load.txt +0 -38
  146. data/lib/gloo/help/verbs/move.txt +0 -42
  147. data/lib/gloo/help/verbs/put.txt +0 -38
  148. data/lib/gloo/help/verbs/quit.txt +0 -25
  149. data/lib/gloo/help/verbs/run.txt +0 -41
  150. data/lib/gloo/help/verbs/save.txt +0 -26
  151. data/lib/gloo/help/verbs/show.txt +0 -30
  152. data/lib/gloo/help/verbs/tell.txt +0 -34
  153. data/lib/gloo/help/verbs/unless.txt +0 -38
  154. data/lib/gloo/help/verbs/version.txt +0 -32
  155. data/lib/gloo/help/verbs/wait.txt +0 -29
  156. data/lib/gloo/objs/basic/alias.rb +0 -78
  157. data/lib/gloo/objs/basic/boolean.rb +0 -120
  158. data/lib/gloo/objs/basic/container.rb +0 -76
  159. data/lib/gloo/objs/basic/decimal.rb +0 -76
  160. data/lib/gloo/objs/basic/integer.rb +0 -73
  161. data/lib/gloo/objs/basic/script.rb +0 -99
  162. data/lib/gloo/objs/basic/string.rb +0 -77
  163. data/lib/gloo/objs/basic/text.rb +0 -87
  164. data/lib/gloo/objs/basic/untyped.rb +0 -41
  165. data/lib/gloo/objs/ctrl/each.rb +0 -279
  166. data/lib/gloo/objs/ctrl/repeat.rb +0 -108
  167. data/lib/gloo/objs/data/markdown.rb +0 -84
  168. data/lib/gloo/objs/data/query.rb +0 -176
  169. data/lib/gloo/objs/data/table.rb +0 -140
  170. data/lib/gloo/objs/dt/date.rb +0 -50
  171. data/lib/gloo/objs/dt/datetime.rb +0 -62
  172. data/lib/gloo/objs/dt/time.rb +0 -50
  173. data/lib/gloo/objs/ror/erb.rb +0 -116
  174. data/lib/gloo/objs/ror/eval.rb +0 -107
  175. data/lib/gloo/objs/web/http_get.rb +0 -159
  176. data/lib/gloo/objs/web/http_post.rb +0 -183
  177. data/lib/gloo/objs/web/json.rb +0 -135
  178. data/lib/gloo/objs/web/slack.rb +0 -130
  179. data/lib/gloo/objs/web/teams.rb +0 -117
  180. data/lib/gloo/objs/web/uri.rb +0 -148
  181. data/lib/gloo/persist/file_loader.rb +0 -191
  182. data/lib/gloo/persist/file_saver.rb +0 -49
  183. data/lib/gloo/persist/file_storage.rb +0 -45
  184. data/lib/gloo/persist/line_splitter.rb +0 -81
  185. data/lib/gloo/persist/persist_man.rb +0 -120
  186. data/lib/gloo/utils/format.rb +0 -21
  187. data/lib/gloo/utils/stats.rb +0 -205
  188. data/lib/gloo/utils/words.rb +0 -19
  189. data/lib/gloo/verbs/context.rb +0 -62
  190. data/lib/gloo/verbs/create.rb +0 -68
  191. data/lib/gloo/verbs/execute.rb +0 -56
  192. data/lib/gloo/verbs/if.rb +0 -92
  193. data/lib/gloo/verbs/list.rb +0 -98
  194. data/lib/gloo/verbs/load.rb +0 -45
  195. data/lib/gloo/verbs/move.rb +0 -89
  196. data/lib/gloo/verbs/put.rb +0 -94
  197. data/lib/gloo/verbs/quit.rb +0 -40
  198. data/lib/gloo/verbs/run.rb +0 -75
  199. data/lib/gloo/verbs/save.rb +0 -39
  200. data/lib/gloo/verbs/show.rb +0 -64
  201. data/lib/gloo/verbs/tell.rb +0 -79
  202. data/lib/gloo/verbs/unless.rb +0 -92
  203. data/lib/gloo/verbs/wait.rb +0 -42
@@ -1,108 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # A looping construct...do something x times.
5
- #
6
-
7
- module Gloo
8
- module Objs
9
- class Repeat < Gloo::Core::Obj
10
-
11
- KEYWORD = 'repeat'.freeze
12
- KEYWORD_SHORT = 'repeat'.freeze
13
- TIMES = 'times'.freeze
14
- INDEX = 'index'.freeze
15
- DO = 'do'.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 times
36
- o = find_child TIMES
37
- return o ? o.value : 0
38
- end
39
-
40
- #
41
- # Run the do script once.
42
- #
43
- def run_do
44
- o = find_child DO
45
- return unless o
46
-
47
- Gloo::Exec::Dispatch.message 'run', o
48
- end
49
-
50
- #
51
- # Set the index of the current iteration.
52
- #
53
- def set_index( index )
54
- o = find_child INDEX
55
- return unless o
56
-
57
- o.set_value index
58
- end
59
-
60
- # ---------------------------------------------------------------------
61
- # Children
62
- # ---------------------------------------------------------------------
63
-
64
- #
65
- # Does this object have children to add when an object
66
- # is created in interactive mode?
67
- # This does not apply during obj load, etc.
68
- #
69
- def add_children_on_create?
70
- return true
71
- end
72
-
73
- #
74
- # Add children to this object.
75
- # This is used by containers to add children needed
76
- # for default configurations.
77
- #
78
- def add_default_children
79
- fac = $engine.factory
80
- fac.create_int TIMES, 0, self
81
- fac.create_int INDEX, 0, self
82
- fac.create_script DO, '', self
83
- end
84
-
85
- # ---------------------------------------------------------------------
86
- # Messages
87
- # ---------------------------------------------------------------------
88
-
89
- #
90
- # Get a list of message names that this object receives.
91
- #
92
- def self.messages
93
- return super + [ 'run' ]
94
- end
95
-
96
- #
97
- # Run the repeat loop.
98
- #
99
- def msg_run
100
- times.times do |index|
101
- set_index index
102
- run_do
103
- end
104
- end
105
-
106
- end
107
- end
108
- end
@@ -1,84 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # Markdown data.
5
- #
6
- require 'tty-markdown'
7
- require 'tty-pager'
8
-
9
- module Gloo
10
- module Objs
11
- class Markdown < Gloo::Core::Obj
12
-
13
- KEYWORD = 'markdown'.freeze
14
- KEYWORD_SHORT = 'md'.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
- self.value = new_value.to_s
35
- end
36
-
37
- #
38
- # Does this object support multi-line values?
39
- # Initially only true for scripts.
40
- #
41
- def multiline_value?
42
- return false
43
- end
44
-
45
- #
46
- # Get the number of lines of text.
47
- #
48
- def line_count
49
- return value.split( "\n" ).count
50
- end
51
-
52
- # ---------------------------------------------------------------------
53
- # Messages
54
- # ---------------------------------------------------------------------
55
-
56
- #
57
- # Get a list of message names that this object receives.
58
- #
59
- def self.messages
60
- return super + %w[show page]
61
- end
62
-
63
- #
64
- # Show the markdown data in the terminal.
65
- #
66
- def msg_show
67
- puts TTY::Markdown.parse self.value
68
- end
69
-
70
- #
71
- # Show the markdown data in the terminal, paginated.
72
- #
73
- def msg_page
74
- return unless self.value
75
-
76
- md = TTY::Markdown.parse self.value
77
- # pager = TTY::Pager::SystemPager.new command: 'less -R'
78
- pager = TTY::Pager.new
79
- pager.page( md )
80
- end
81
-
82
- end
83
- end
84
- end
@@ -1,176 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # A SQL database query.
5
- # Relies on a database connection object.
6
- #
7
-
8
- module Gloo
9
- module Objs
10
- class Query < Gloo::Core::Obj
11
-
12
- KEYWORD = 'query'.freeze
13
- KEYWORD_SHORT = 'sql'.freeze
14
-
15
- DB = 'database'.freeze
16
- SQL = 'sql'.freeze
17
- RESULT = 'result'.freeze
18
- PARAMS = 'params'.freeze
19
-
20
- DB_MISSING_ERR = 'The database connection is missing!'.freeze
21
-
22
- #
23
- # The name of the object type.
24
- #
25
- def self.typename
26
- return KEYWORD
27
- end
28
-
29
- #
30
- # The short name of the object type.
31
- #
32
- def self.short_typename
33
- return KEYWORD_SHORT
34
- end
35
-
36
- # ---------------------------------------------------------------------
37
- # Children
38
- # ---------------------------------------------------------------------
39
-
40
- #
41
- # Does this object have children to add when an object
42
- # is created in interactive mode?
43
- # This does not apply during obj load, etc.
44
- #
45
- def add_children_on_create?
46
- return true
47
- end
48
-
49
- #
50
- # Add children to this object.
51
- # This is used by containers to add children needed
52
- # for default configurations.
53
- #
54
- def add_default_children
55
- fac = $engine.factory
56
- fac.create_alias DB, nil, self
57
- fac.create_string SQL, nil, self
58
- fac.create_can RESULT, self
59
- end
60
-
61
- # ---------------------------------------------------------------------
62
- # Messages
63
- # ---------------------------------------------------------------------
64
-
65
- #
66
- # Get a list of message names that this object receives.
67
- #
68
- def self.messages
69
- return super + [ 'run' ]
70
- end
71
-
72
- #
73
- # SSH to the host and execute the command, then update result.
74
- #
75
- def msg_run
76
- db = db_obj
77
- unless db
78
- $engine.err DB_MISSING_ERR
79
- return
80
- end
81
-
82
- result = db.query( sql_value, param_array )
83
- process_result result
84
- end
85
-
86
- # ---------------------------------------------------------------------
87
- # Private functions
88
- # ---------------------------------------------------------------------
89
-
90
- private
91
-
92
- #
93
- # Get the database connection.
94
- #
95
- def db_obj
96
- o = find_child DB
97
- return Gloo::Objs::Alias.resolve_alias( o )
98
- end
99
-
100
- #
101
- # Get the SQL from the child object.
102
- # Returns nil if there is none.
103
- #
104
- def sql_value
105
- o = find_child SQL
106
- return nil unless o
107
-
108
- return o.value
109
- end
110
-
111
- #
112
- # Do something with the result of the SQL Query call.
113
- # If there's a result container, we'll create objects in it.
114
- # If not, we'll just show the output in the console.
115
- #
116
- def process_result( data )
117
- r = find_child RESULT
118
- if r
119
- update_result_contaier data
120
- else
121
- show_result data
122
- end
123
- end
124
-
125
- #
126
- # Get the arrya of parameters.
127
- # If there is no PARAM container of if it is empty,
128
- # we'll return a nil value.
129
- #
130
- def param_array
131
- o = find_child PARAMS
132
- return nil unless o
133
-
134
- return nil if o.child_count.zero?
135
-
136
- params = []
137
- o.children.each do |p|
138
- params << p.value
139
- end
140
-
141
- return params
142
- end
143
-
144
- #
145
- # Show the result of the query in the console.
146
- #
147
- def show_result( data )
148
- return if data.nil?
149
-
150
- data.each_with_index do |row, i|
151
- # Show header for the first row
152
- puts row.map { |k, _| k }.join( " \t " ).white if i.zero?
153
-
154
- # Show the row data
155
- puts row.map { |_, v| v }.join( " \t " )
156
- end
157
- end
158
-
159
- #
160
- # Update the result container with the data from the query.
161
- #
162
- def update_result_contaier( data )
163
- r = find_child RESULT
164
- r = Gloo::Objs::Alias.resolve_alias( r )
165
- data.each_with_index do |row, i|
166
- can = r.find_add_child( i.to_s, 'can' )
167
- row.each do |k, v|
168
- o = can.find_add_child( k, 'untyped' )
169
- o.set_value v
170
- end
171
- end
172
- end
173
-
174
- end
175
- end
176
- end
@@ -1,140 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # A data table.
5
- # The table container headers and data.
6
- #
7
- require 'tty-table'
8
- require 'pastel'
9
-
10
- module Gloo
11
- module Objs
12
- class Table < Gloo::Core::Obj
13
-
14
- KEYWORD = 'table'.freeze
15
- KEYWORD_SHORT = 'tbl'.freeze
16
- HEADERS = 'headers'.freeze
17
- DATA = 'data'.freeze
18
-
19
- #
20
- # The name of the object type.
21
- #
22
- def self.typename
23
- return KEYWORD
24
- end
25
-
26
- #
27
- # The short name of the object type.
28
- #
29
- def self.short_typename
30
- return KEYWORD_SHORT
31
- end
32
-
33
- #
34
- # Get the list of headers.
35
- # Returns nil if there is none.
36
- #
37
- def headers
38
- o = find_child HEADERS
39
- return [] unless o
40
-
41
- return o.children.map( &:value )
42
- end
43
-
44
- #
45
- # Get the list of column names.
46
- # Returns nil if there is none.
47
- #
48
- def columns
49
- o = find_child HEADERS
50
- return [] unless o
51
-
52
- return o.children.map( &:name )
53
- end
54
-
55
- #
56
- # Get the list of data elements.
57
- #
58
- def data
59
- o = find_child DATA
60
- return [] unless o
61
-
62
- o = Gloo::Objs::Alias.resolve_alias( o )
63
- cols = self.columns
64
- return o.children.map do |e|
65
- cols.map { |h| e.find_child( h ).value }
66
- end
67
- end
68
-
69
- # ---------------------------------------------------------------------
70
- # Children
71
- # ---------------------------------------------------------------------
72
-
73
- #
74
- # Does this object have children to add when an object
75
- # is created in interactive mode?
76
- # This does not apply during obj load, etc.
77
- #
78
- def add_children_on_create?
79
- return true
80
- end
81
-
82
- #
83
- # Add children to this object.
84
- # This is used by containers to add children needed
85
- # for default configurations.
86
- #
87
- def add_default_children
88
- fac = $engine.factory
89
- fac.create_can HEADERS, self
90
- fac.create_can DATA, self
91
- end
92
-
93
- # ---------------------------------------------------------------------
94
- # Messages
95
- # ---------------------------------------------------------------------
96
-
97
- #
98
- # Get a list of message names that this object receives.
99
- #
100
- def self.messages
101
- return super + %w[show]
102
- end
103
-
104
- #
105
- # Show the table in the CLI.
106
- #
107
- def msg_show
108
- title = self.value
109
- Gloo::Objs::Table.show headers, data, title
110
- end
111
-
112
- # ---------------------------------------------------------------------
113
- # Static table helper
114
- # ---------------------------------------------------------------------
115
-
116
- #
117
- # Show the given table data.
118
- #
119
- def self.show( headers, data, title = nil )
120
- pastel = ::Pastel.new
121
- table = TTY::Table.new headers, data
122
- pad = [ 0, 1, 0, 1 ]
123
- rendered = table.render( :ascii, indent: 2, padding: pad ) do |r|
124
- r.border.style = :blue
125
- r.filter = proc do |val, row_index, _col_index|
126
- # col_index % 2 == 1 ? pastel.red.on_green(val) : val
127
- if row_index.zero?
128
- pastel.blue( val )
129
- else
130
- row_index.odd? ? pastel.white( val ) : pastel.yellow( val )
131
- end
132
- end
133
- end
134
- puts "\n#{title.white}"
135
- puts "#{rendered}\n\n"
136
- end
137
-
138
- end
139
- end
140
- end
@@ -1,50 +0,0 @@
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
-
14
- #
15
- # The name of the object type.
16
- #
17
- def self.typename
18
- return KEYWORD
19
- end
20
-
21
- #
22
- # The short name of the object type.
23
- #
24
- def self.short_typename
25
- return KEYWORD_SHORT
26
- end
27
-
28
- # ---------------------------------------------------------------------
29
- # Messages
30
- # ---------------------------------------------------------------------
31
-
32
- #
33
- # Get a list of message names that this object receives.
34
- #
35
- def self.messages
36
- return super + %w[now]
37
- end
38
-
39
- #
40
- # Set to the current date.
41
- #
42
- def msg_now
43
- t = DateTime.now.strftime( '%Y.%m.%d' )
44
- self.value = t
45
- $engine.heap.it.set_to t
46
- end
47
-
48
- end
49
- end
50
- end
@@ -1,62 +0,0 @@
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
- module Gloo
8
- module Objs
9
- class Datetime < Gloo::Core::Obj
10
-
11
- KEYWORD = 'datetime'.freeze
12
- KEYWORD_SHORT = 'dt'.freeze
13
-
14
- #
15
- # The name of the object type.
16
- #
17
- def self.typename
18
- return KEYWORD
19
- end
20
-
21
- #
22
- # The short name of the object type.
23
- #
24
- def self.short_typename
25
- return KEYWORD_SHORT
26
- end
27
-
28
- #
29
- # Set the value with any necessary type conversions.
30
- #
31
- def set_value( new_value )
32
- unless new_value.is_a? DateTime
33
- self.value = $engine.converter.convert( new_value, 'DateTime', nil )
34
- return
35
- end
36
-
37
- self.value = new_value
38
- end
39
-
40
- # ---------------------------------------------------------------------
41
- # Messages
42
- # ---------------------------------------------------------------------
43
-
44
- #
45
- # Get a list of message names that this object receives.
46
- #
47
- def self.messages
48
- return super + %w[now]
49
- end
50
-
51
- #
52
- # Set to the current date and time.
53
- #
54
- def msg_now
55
- t = DateTime.now.strftime( '%Y.%m.%d %I:%M:%S %P' )
56
- self.value = t
57
- $engine.heap.it.set_to t
58
- end
59
-
60
- end
61
- end
62
- end
@@ -1,50 +0,0 @@
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
-
14
- #
15
- # The name of the object type.
16
- #
17
- def self.typename
18
- return KEYWORD
19
- end
20
-
21
- #
22
- # The short name of the object type.
23
- #
24
- def self.short_typename
25
- return KEYWORD_SHORT
26
- end
27
-
28
- # ---------------------------------------------------------------------
29
- # Messages
30
- # ---------------------------------------------------------------------
31
-
32
- #
33
- # Get a list of message names that this object receives.
34
- #
35
- def self.messages
36
- return super + %w[now]
37
- end
38
-
39
- #
40
- # Set to the current time.
41
- #
42
- def msg_now
43
- t = DateTime.now.strftime( '%I:%M:%S %P' )
44
- self.value = t
45
- $engine.heap.it.set_to t
46
- end
47
-
48
- end
49
- end
50
- end