gloo 0.8.0 → 1.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 (125) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/Gemfile.lock +32 -28
  4. data/LICENSE.txt +1 -1
  5. data/gloo.gemspec +11 -6
  6. data/lib/VERSION +1 -1
  7. data/lib/dependencies.rb +4 -4
  8. data/lib/gloo/app/info.rb +3 -1
  9. data/lib/gloo/app/log.rb +1 -29
  10. data/lib/gloo/app/platform.rb +142 -0
  11. data/lib/gloo/objs/cli/banner.rb +2 -2
  12. data/lib/gloo/objs/cli/bar.rb +4 -4
  13. data/lib/gloo/objs/cli/colorize.rb +3 -3
  14. data/lib/gloo/objs/cli/confirm.rb +3 -3
  15. data/lib/gloo/objs/cli/menu.rb +9 -9
  16. data/lib/gloo/objs/cli/menu_item.rb +2 -2
  17. data/lib/gloo/objs/cli/pastel.rb +2 -2
  18. data/lib/gloo/objs/cli/prompt.rb +4 -4
  19. data/lib/gloo/objs/cli/select.rb +4 -4
  20. data/lib/gloo/objs/dev/git.rb +7 -7
  21. data/lib/gloo/objs/dev/stats.rb +8 -5
  22. data/lib/gloo/objs/snd/play.rb +1 -1
  23. data/lib/gloo/objs/snd/say.rb +2 -2
  24. data/lib/gloo/objs/system/file_handle.rb +9 -9
  25. data/lib/gloo/objs/system/ssh_exec.rb +3 -3
  26. data/lib/gloo/objs/system/system.rb +2 -2
  27. data/lib/gloo/verbs/alert.rb +7 -7
  28. data/lib/gloo/verbs/beep.rb +1 -1
  29. data/lib/gloo/verbs/cls.rb +2 -2
  30. data/lib/gloo.rb +5 -1
  31. data/lib/run.rb +5 -1
  32. metadata +39 -145
  33. data/lib/gloo/app/args.rb +0 -112
  34. data/lib/gloo/app/engine.rb +0 -230
  35. data/lib/gloo/app/help.rb +0 -156
  36. data/lib/gloo/app/mode.rb +0 -27
  37. data/lib/gloo/app/settings.rb +0 -186
  38. data/lib/gloo/convert/converter.rb +0 -35
  39. data/lib/gloo/convert/string_to_datetime.rb +0 -21
  40. data/lib/gloo/convert/string_to_decimal.rb +0 -20
  41. data/lib/gloo/convert/string_to_integer.rb +0 -20
  42. data/lib/gloo/core/baseo.rb +0 -30
  43. data/lib/gloo/core/dictionary.rb +0 -181
  44. data/lib/gloo/core/error.rb +0 -61
  45. data/lib/gloo/core/event_manager.rb +0 -44
  46. data/lib/gloo/core/factory.rb +0 -210
  47. data/lib/gloo/core/gloo_system.rb +0 -266
  48. data/lib/gloo/core/heap.rb +0 -52
  49. data/lib/gloo/core/here.rb +0 -36
  50. data/lib/gloo/core/it.rb +0 -36
  51. data/lib/gloo/core/literal.rb +0 -30
  52. data/lib/gloo/core/obj.rb +0 -303
  53. data/lib/gloo/core/obj_finder.rb +0 -30
  54. data/lib/gloo/core/op.rb +0 -40
  55. data/lib/gloo/core/parser.rb +0 -59
  56. data/lib/gloo/core/pn.rb +0 -188
  57. data/lib/gloo/core/tokens.rb +0 -165
  58. data/lib/gloo/core/verb.rb +0 -86
  59. data/lib/gloo/exec/action.rb +0 -48
  60. data/lib/gloo/exec/dispatch.rb +0 -40
  61. data/lib/gloo/exec/exec_env.rb +0 -74
  62. data/lib/gloo/exec/runner.rb +0 -45
  63. data/lib/gloo/exec/script.rb +0 -49
  64. data/lib/gloo/exec/stack.rb +0 -78
  65. data/lib/gloo/expr/expression.rb +0 -118
  66. data/lib/gloo/expr/l_boolean.rb +0 -36
  67. data/lib/gloo/expr/l_decimal.rb +0 -39
  68. data/lib/gloo/expr/l_integer.rb +0 -37
  69. data/lib/gloo/expr/l_string.rb +0 -58
  70. data/lib/gloo/expr/op_div.rb +0 -22
  71. data/lib/gloo/expr/op_minus.rb +0 -22
  72. data/lib/gloo/expr/op_mult.rb +0 -22
  73. data/lib/gloo/expr/op_plus.rb +0 -24
  74. data/lib/gloo/objs/basic/alias.rb +0 -78
  75. data/lib/gloo/objs/basic/boolean.rb +0 -120
  76. data/lib/gloo/objs/basic/container.rb +0 -76
  77. data/lib/gloo/objs/basic/decimal.rb +0 -76
  78. data/lib/gloo/objs/basic/integer.rb +0 -73
  79. data/lib/gloo/objs/basic/script.rb +0 -99
  80. data/lib/gloo/objs/basic/string.rb +0 -77
  81. data/lib/gloo/objs/basic/text.rb +0 -87
  82. data/lib/gloo/objs/basic/untyped.rb +0 -41
  83. data/lib/gloo/objs/ctrl/each.rb +0 -279
  84. data/lib/gloo/objs/ctrl/repeat.rb +0 -108
  85. data/lib/gloo/objs/data/markdown.rb +0 -84
  86. data/lib/gloo/objs/data/mysql.rb +0 -192
  87. data/lib/gloo/objs/data/query.rb +0 -176
  88. data/lib/gloo/objs/data/sqlite.rb +0 -159
  89. data/lib/gloo/objs/data/table.rb +0 -140
  90. data/lib/gloo/objs/dt/date.rb +0 -50
  91. data/lib/gloo/objs/dt/datetime.rb +0 -62
  92. data/lib/gloo/objs/dt/time.rb +0 -50
  93. data/lib/gloo/objs/ror/erb.rb +0 -116
  94. data/lib/gloo/objs/ror/eval.rb +0 -107
  95. data/lib/gloo/objs/web/http_get.rb +0 -159
  96. data/lib/gloo/objs/web/http_post.rb +0 -183
  97. data/lib/gloo/objs/web/json.rb +0 -135
  98. data/lib/gloo/objs/web/slack.rb +0 -130
  99. data/lib/gloo/objs/web/teams.rb +0 -117
  100. data/lib/gloo/objs/web/uri.rb +0 -148
  101. data/lib/gloo/persist/file_loader.rb +0 -191
  102. data/lib/gloo/persist/file_saver.rb +0 -49
  103. data/lib/gloo/persist/file_storage.rb +0 -45
  104. data/lib/gloo/persist/line_splitter.rb +0 -81
  105. data/lib/gloo/persist/persist_man.rb +0 -120
  106. data/lib/gloo/utils/format.rb +0 -21
  107. data/lib/gloo/utils/stats.rb +0 -205
  108. data/lib/gloo/utils/words.rb +0 -19
  109. data/lib/gloo/verbs/context.rb +0 -62
  110. data/lib/gloo/verbs/create.rb +0 -68
  111. data/lib/gloo/verbs/execute.rb +0 -56
  112. data/lib/gloo/verbs/help.rb +0 -264
  113. data/lib/gloo/verbs/if.rb +0 -92
  114. data/lib/gloo/verbs/list.rb +0 -98
  115. data/lib/gloo/verbs/load.rb +0 -45
  116. data/lib/gloo/verbs/move.rb +0 -89
  117. data/lib/gloo/verbs/put.rb +0 -94
  118. data/lib/gloo/verbs/quit.rb +0 -40
  119. data/lib/gloo/verbs/run.rb +0 -75
  120. data/lib/gloo/verbs/save.rb +0 -39
  121. data/lib/gloo/verbs/show.rb +0 -64
  122. data/lib/gloo/verbs/tell.rb +0 -79
  123. data/lib/gloo/verbs/unless.rb +0 -92
  124. data/lib/gloo/verbs/version.rb +0 -37
  125. data/lib/gloo/verbs/wait.rb +0 -42
@@ -1,279 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
- #
4
- # A looping construct...do something for each whatever in something.
5
- # This object has several possible uses:
6
- # - each word in a string
7
- # - each line in a string
8
- # - each file in a directory
9
- # - each git repo in a directory
10
- #
11
-
12
- module Gloo
13
- module Objs
14
- class Each < Gloo::Core::Obj
15
-
16
- KEYWORD = 'each'.freeze
17
- KEYWORD_SHORT = 'each'.freeze
18
- CHILD = 'child'.freeze
19
- WORD = 'word'.freeze
20
- LINE = 'line'.freeze
21
- FILE = 'file'.freeze
22
- REPO = 'repo'.freeze
23
- IN = 'IN'.freeze
24
- DO = 'do'.freeze
25
-
26
- #
27
- # The name of the object type.
28
- #
29
- def self.typename
30
- return KEYWORD
31
- end
32
-
33
- #
34
- # The short name of the object type.
35
- #
36
- def self.short_typename
37
- return KEYWORD_SHORT
38
- end
39
-
40
- #
41
- # Get the URI from the child object.
42
- # Returns nil if there is none.
43
- #
44
- def in_value
45
- o = find_child IN
46
- return o ? o.value : nil
47
- end
48
-
49
- #
50
- # Run the do script once.
51
- #
52
- def run_do
53
- o = find_child DO
54
- return unless o
55
-
56
- Gloo::Exec::Dispatch.message 'run', o
57
- end
58
-
59
- # ---------------------------------------------------------------------
60
- # Children
61
- # ---------------------------------------------------------------------
62
-
63
- #
64
- # Does this object have children to add when an object
65
- # is created in interactive mode?
66
- # This does not apply during obj load, etc.
67
- #
68
- def add_children_on_create?
69
- return true
70
- end
71
-
72
- #
73
- # Add children to this object.
74
- # This is used by containers to add children needed
75
- # for default configurations.
76
- #
77
- def add_default_children
78
- fac = $engine.factory
79
- fac.create_string WORD, '', self
80
- fac.create_string IN, '', self
81
- fac.create_script DO, '', self
82
- end
83
-
84
- # ---------------------------------------------------------------------
85
- # Messages
86
- # ---------------------------------------------------------------------
87
-
88
- #
89
- # Get a list of message names that this object receives.
90
- #
91
- def self.messages
92
- return super + [ 'run' ]
93
- end
94
-
95
- # Run the system command.
96
- def msg_run
97
- if each_child?
98
- run_each_child
99
- elsif each_word?
100
- run_each_word
101
- elsif each_line?
102
- run_each_line
103
- elsif each_repo?
104
- run_each_repo
105
- end
106
- end
107
-
108
- # ---------------------------------------------------------------------
109
- # Child Object
110
- # ---------------------------------------------------------------------
111
-
112
- #
113
- # Is it set up to run for each word?
114
- # If there is a child object by the name "word"
115
- # then we will loop for each word in the string.
116
- #
117
- def each_child?
118
- return true if contains_child? CHILD
119
-
120
- return false
121
- end
122
-
123
- #
124
- # Run for each word.
125
- #
126
- def run_each_child
127
- o = find_child IN
128
- return unless o
129
-
130
- o = Gloo::Objs::Alias.resolve_alias( o )
131
- o.children.each do |child|
132
- set_child child
133
- run_do
134
- end
135
- end
136
-
137
- #
138
- # Set the child alias.
139
- #
140
- def set_child( obj )
141
- o = find_child CHILD
142
- return unless o
143
-
144
- o.set_value obj.pn
145
- end
146
-
147
- # ---------------------------------------------------------------------
148
- # Word
149
- # ---------------------------------------------------------------------
150
-
151
- #
152
- # Is it set up to run for each word?
153
- # If there is a child object by the name "word"
154
- # then we will loop for each word in the string.
155
- #
156
- def each_word?
157
- return true if find_child WORD
158
-
159
- return false
160
- end
161
-
162
- #
163
- # Run for each word.
164
- #
165
- def run_each_word
166
- str = in_value
167
- return unless str
168
-
169
- str.split( ' ' ).each do |word|
170
- set_word word
171
- run_do
172
- end
173
- end
174
-
175
- #
176
- # Set the value of the word.
177
- #
178
- def set_word( word )
179
- o = find_child WORD
180
- return unless o
181
-
182
- o.set_value word
183
- end
184
-
185
- # ---------------------------------------------------------------------
186
- # Line
187
- # ---------------------------------------------------------------------
188
-
189
- #
190
- # Is it set up to run for each line?
191
- # If there is a child object by the name "line"
192
- # then we will loop for each line in the string.
193
- #
194
- def each_line?
195
- return true if find_child LINE
196
-
197
- return false
198
- end
199
-
200
- #
201
- # Run for each line.
202
- #
203
- def run_each_line
204
- str = in_value
205
- return unless str
206
-
207
- str.each_line do |line|
208
- set_line line
209
- run_do
210
- end
211
- end
212
-
213
- #
214
- # Set the value of the word.
215
- #
216
- def set_line( line )
217
- o = find_child LINE
218
- return unless o
219
-
220
- o.set_value line
221
- end
222
-
223
- # ---------------------------------------------------------------------
224
- # Git Repo
225
- # ---------------------------------------------------------------------
226
-
227
- #
228
- # Is it set up to run for each git repo?
229
- # If there is a child object by the name "repo"
230
- # then we will loop for each repo in the directory.
231
- #
232
- def each_repo?
233
- return true if find_child REPO
234
-
235
- return false
236
- end
237
-
238
- #
239
- # Find all git projects in a path.
240
- #
241
- def find_all_git_projects( path )
242
- path.children.collect do |f|
243
- if f.directory? && ( File.basename( f ) == '.git' )
244
- File.dirname( f )
245
- elsif f.directory?
246
- find_all_git_projects( f )
247
- end
248
- end.flatten.compact
249
- end
250
-
251
- #
252
- # Run for each line.
253
- #
254
- def run_each_repo
255
- path = in_value
256
- return unless path
257
-
258
- path = Pathname.new( path )
259
- repos = find_all_git_projects( path )
260
- repos.each do |o|
261
- set_repo o
262
- run_do
263
- end
264
- end
265
-
266
- #
267
- # Set the value of the repo.
268
- # This is a path to the repo.
269
- #
270
- def set_repo( path )
271
- o = find_child REPO
272
- return unless o
273
-
274
- o.set_value path
275
- end
276
-
277
- end
278
- end
279
- end
@@ -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,192 +0,0 @@
1
- # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
- # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
- #
4
- # A MySQL database connection.
5
- #
6
- #
7
- # https://github.com/brianmario/mysql2
8
- # https://www.rubydoc.info/gems/mysql2/0.2.3/Mysql2/Client
9
- #
10
- # Connection Parameters
11
- # user = opts[:username]
12
- # pass = opts[:password]
13
- # host = opts[:host] || 'localhost'
14
- # port = opts[:port] || 3306
15
- # database = opts[:database]
16
- # socket = opts[:socket]
17
- # flags = opts[:flags] || 0
18
- #
19
- require 'mysql2'
20
-
21
- module Gloo
22
- module Objs
23
- class Mysql < Gloo::Core::Obj
24
-
25
- KEYWORD = 'mysql'.freeze
26
- KEYWORD_SHORT = 'mysql'.freeze
27
-
28
- HOST = 'host'.freeze
29
- DB = 'database'.freeze
30
- USER = 'username'.freeze
31
- PASSWD = 'password'.freeze
32
-
33
- #
34
- # The name of the object type.
35
- #
36
- def self.typename
37
- return KEYWORD
38
- end
39
-
40
- #
41
- # The short name of the object type.
42
- #
43
- def self.short_typename
44
- return KEYWORD_SHORT
45
- end
46
-
47
- # ---------------------------------------------------------------------
48
- # Children
49
- # ---------------------------------------------------------------------
50
-
51
- #
52
- # Does this object have children to add when an object
53
- # is created in interactive mode?
54
- # This does not apply during obj load, etc.
55
- #
56
- def add_children_on_create?
57
- return true
58
- end
59
-
60
- #
61
- # Add children to this object.
62
- # This is used by containers to add children needed
63
- # for default configurations.
64
- #
65
- def add_default_children
66
- fac = $engine.factory
67
- fac.create_string HOST, nil, self
68
- fac.create_string DB, nil, self
69
- fac.create_string USER, nil, self
70
- fac.create_string PASSWD, nil, self
71
- end
72
-
73
- # ---------------------------------------------------------------------
74
- # Messages
75
- # ---------------------------------------------------------------------
76
-
77
- #
78
- # Get a list of message names that this object receives.
79
- #
80
- def self.messages
81
- return super + [ 'verify' ]
82
- end
83
-
84
- #
85
- # SSH to the host and execute the command, then update result.
86
- #
87
- def msg_verify
88
- return unless connects?
89
-
90
- $engine.heap.it.set_to true
91
- end
92
-
93
- # ---------------------------------------------------------------------
94
- # DB functions (all database connections)
95
- # ---------------------------------------------------------------------
96
-
97
- #
98
- # Open a connection and execute the SQL statement.
99
- # Return the resulting data.
100
- #
101
- def query( sql, params = nil )
102
- h = {
103
- host: host_value,
104
- database: db_value,
105
- username: user_value,
106
- password: passwd_value
107
- }
108
- client = Mysql2::Client.new( h )
109
- return client.query( sql ) unless params
110
-
111
- pst = client.prepare( sql )
112
- return pst.execute( *params )
113
- end
114
-
115
- # ---------------------------------------------------------------------
116
- # Private functions
117
- # ---------------------------------------------------------------------
118
-
119
- private
120
-
121
- #
122
- # Get the host from the child object.
123
- # Returns nil if there is none.
124
- #
125
- def host_value
126
- o = find_child HOST
127
- return nil unless o
128
-
129
- o = Gloo::Objs::Alias.resolve_alias( o )
130
- return o.value
131
- end
132
-
133
- #
134
- # Get the Database name from the child object.
135
- # Returns nil if there is none.
136
- #
137
- def db_value
138
- o = find_child DB
139
- return nil unless o
140
-
141
- o = Gloo::Objs::Alias.resolve_alias( o )
142
- return o.value
143
- end
144
-
145
- #
146
- # Get the Username from the child object.
147
- # Returns nil if there is none.
148
- #
149
- def user_value
150
- o = find_child USER
151
- return nil unless o
152
-
153
- o = Gloo::Objs::Alias.resolve_alias( o )
154
- return o.value
155
- end
156
-
157
- #
158
- # Get the Password name from the child object.
159
- # Returns nil if there is none.
160
- #
161
- def passwd_value
162
- o = find_child PASSWD
163
- return nil unless o
164
-
165
- o = Gloo::Objs::Alias.resolve_alias( o )
166
- return o.value
167
- end
168
-
169
- #
170
- # Try the connection and make sure it works.
171
- # Returns true if we can establish a connection.
172
- #
173
- def connects?
174
- begin
175
- h = {
176
- host: host_value,
177
- database: db_value,
178
- username: user_value,
179
- password: passwd_value
180
- }
181
- Mysql2::Client.new( h )
182
- rescue => e
183
- $engine.err e.message
184
- $engine.heap.it.set_to false
185
- return false
186
- end
187
- return true
188
- end
189
-
190
- end
191
- end
192
- end