gloo 1.0.0 → 1.2.2

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 (87) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/gloo.gemspec +7 -4
  6. data/lib/VERSION +1 -1
  7. data/lib/gloo/objs/data/mysql.rb +192 -0
  8. data/lib/gloo/objs/data/sqlite.rb +159 -0
  9. data/lib/gloo/verbs/help.rb +82 -0
  10. data/lib/gloo/verbs/version.rb +37 -0
  11. metadata +52 -82
  12. data/Gemfile.lock +0 -175
  13. data/lib/gloo/help/app/application.txt +0 -22
  14. data/lib/gloo/help/app/configuration.txt +0 -7
  15. data/lib/gloo/help/app/default_help.txt +0 -14
  16. data/lib/gloo/help/app/logging.txt +0 -16
  17. data/lib/gloo/help/core/color.txt +0 -31
  18. data/lib/gloo/help/core/error.txt +0 -33
  19. data/lib/gloo/help/core/events.txt +0 -21
  20. data/lib/gloo/help/core/gloo_system.txt +0 -57
  21. data/lib/gloo/help/core/here.txt +0 -30
  22. data/lib/gloo/help/core/it.txt +0 -23
  23. data/lib/gloo/help/core/ops.txt +0 -16
  24. data/lib/gloo/help/core/pathname.txt +0 -29
  25. data/lib/gloo/help/objs/basic/alias.txt +0 -36
  26. data/lib/gloo/help/objs/basic/boolean.txt +0 -28
  27. data/lib/gloo/help/objs/basic/container.txt +0 -33
  28. data/lib/gloo/help/objs/basic/decimal.txt +0 -28
  29. data/lib/gloo/help/objs/basic/integer.txt +0 -27
  30. data/lib/gloo/help/objs/basic/script.txt +0 -29
  31. data/lib/gloo/help/objs/basic/string.txt +0 -28
  32. data/lib/gloo/help/objs/basic/text.txt +0 -27
  33. data/lib/gloo/help/objs/basic/untyped.txt +0 -22
  34. data/lib/gloo/help/objs/cli/banner.txt +0 -49
  35. data/lib/gloo/help/objs/cli/bar.txt +0 -37
  36. data/lib/gloo/help/objs/cli/colorize.txt +0 -33
  37. data/lib/gloo/help/objs/cli/confirm.txt +0 -26
  38. data/lib/gloo/help/objs/cli/menu.txt +0 -44
  39. data/lib/gloo/help/objs/cli/menu_item.txt +0 -26
  40. data/lib/gloo/help/objs/cli/pastel.txt +0 -43
  41. data/lib/gloo/help/objs/cli/prompt.txt +0 -27
  42. data/lib/gloo/help/objs/cli/select.txt +0 -34
  43. data/lib/gloo/help/objs/ctrl/each.txt +0 -48
  44. data/lib/gloo/help/objs/ctrl/repeat.txt +0 -38
  45. data/lib/gloo/help/objs/data/markdown.txt +0 -25
  46. data/lib/gloo/help/objs/data/mysql.txt +0 -40
  47. data/lib/gloo/help/objs/data/query.txt +0 -37
  48. data/lib/gloo/help/objs/data/sqlite.txt +0 -26
  49. data/lib/gloo/help/objs/data/table.txt +0 -46
  50. data/lib/gloo/help/objs/dev/git_repo.txt +0 -36
  51. data/lib/gloo/help/objs/dev/stats.txt +0 -36
  52. data/lib/gloo/help/objs/dt/date.txt +0 -23
  53. data/lib/gloo/help/objs/dt/datetime.txt +0 -24
  54. data/lib/gloo/help/objs/dt/time.txt +0 -23
  55. data/lib/gloo/help/objs/ror/erb.txt +0 -37
  56. data/lib/gloo/help/objs/ror/eval.txt +0 -24
  57. data/lib/gloo/help/objs/snd/play.txt +0 -23
  58. data/lib/gloo/help/objs/snd/say.txt +0 -28
  59. data/lib/gloo/help/objs/system/file.txt +0 -48
  60. data/lib/gloo/help/objs/system/ssh_exec.txt +0 -30
  61. data/lib/gloo/help/objs/system/system.txt +0 -32
  62. data/lib/gloo/help/objs/web/http_get.txt +0 -35
  63. data/lib/gloo/help/objs/web/http_post.txt +0 -34
  64. data/lib/gloo/help/objs/web/json.txt +0 -34
  65. data/lib/gloo/help/objs/web/slack.txt +0 -33
  66. data/lib/gloo/help/objs/web/teams.txt +0 -30
  67. data/lib/gloo/help/objs/web/uri.txt +0 -38
  68. data/lib/gloo/help/verbs/alert.txt +0 -33
  69. data/lib/gloo/help/verbs/beep.txt +0 -25
  70. data/lib/gloo/help/verbs/cls.txt +0 -24
  71. data/lib/gloo/help/verbs/context.txt +0 -43
  72. data/lib/gloo/help/verbs/create.txt +0 -33
  73. data/lib/gloo/help/verbs/execute.txt +0 -27
  74. data/lib/gloo/help/verbs/help.txt +0 -34
  75. data/lib/gloo/help/verbs/if.txt +0 -37
  76. data/lib/gloo/help/verbs/list.txt +0 -34
  77. data/lib/gloo/help/verbs/load.txt +0 -38
  78. data/lib/gloo/help/verbs/move.txt +0 -42
  79. data/lib/gloo/help/verbs/put.txt +0 -38
  80. data/lib/gloo/help/verbs/quit.txt +0 -25
  81. data/lib/gloo/help/verbs/run.txt +0 -41
  82. data/lib/gloo/help/verbs/save.txt +0 -26
  83. data/lib/gloo/help/verbs/show.txt +0 -30
  84. data/lib/gloo/help/verbs/tell.txt +0 -34
  85. data/lib/gloo/help/verbs/unless.txt +0 -38
  86. data/lib/gloo/help/verbs/version.txt +0 -32
  87. data/lib/gloo/help/verbs/wait.txt +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be2491c8754aeb5997318b86f7a6b3f8473178c41aa4af8a36e78b4efcd662e5
4
- data.tar.gz: bd6ba3f319a58164b3ce7aed2b9a68201fde3a8220407850af1c9eacbddf9311
3
+ metadata.gz: 1b5ba7fb72c8c2c7d708feaefa39cdbf3729e8aeb406fd7cd164518efa1ae813
4
+ data.tar.gz: 463d279308f9ac258c802a79355c1b7af3df01c7dbbdc7e7a0952f17aa6e6f08
5
5
  SHA512:
6
- metadata.gz: c48baf591661121a625dea69ea38e8913e8a01beac350024e7b0844ec9564ee9645900c8ef25b0f1de49f45ea89bffeecd8266c992d3ff34461a9f713f6b819f
7
- data.tar.gz: c65e8f1c3aa5af175336ad4ea9d97fd224132c59793a58c77850985da0f90bb519370a3a86e24b4486f8defaadb6950af57983936c5c2a9c1680858e69b0c8a9
6
+ metadata.gz: ff67da493c051dfd83eab40f4e2c325e9cf541417164d9863e1bd63669907adf3ac049c326d3ab19168cb0b678b2d4bab9ec84c85a6b0818e0ec73b48cff073c
7
+ data.tar.gz: 2fab95b182a3311bb7ff6c7a0449c23b892869a7c07bf7358f8a9d80ce597ced0950d199db1688dea7e41a88609ff627407a80633033fbb4ed39b93ee32f8d98
data/.gitignore CHANGED
@@ -9,4 +9,5 @@
9
9
  *.gem
10
10
  *.log
11
11
  test/gloo/debug/*
12
- .DS_Store
12
+ Gemfile.lock
13
+ *.DS_Store
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ gloo-gem
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-3.0.2
data/gloo.gemspec CHANGED
@@ -27,14 +27,17 @@ Gem::Specification.new do |spec|
27
27
  spec.executables << 'o'
28
28
  spec.executables << 'gloo'
29
29
 
30
+ #
31
+ # tty uses an older version of bundle
32
+ #
30
33
  # spec.add_development_dependency 'bundler', '~> 2.2.22'
31
- # spec.add_development_dependency 'bundler', '~> 2.3.9'
34
+ # spec.add_development_dependency 'bundler', '~> 2.3.17'
32
35
  spec.add_development_dependency 'bundler', '~> 1.17.3'
33
36
  spec.add_development_dependency 'minitest', '~> 5.1', '>= 5.14.2'
34
37
  # spec.add_development_dependency 'rake', '~> 10.0'
35
38
  spec.add_development_dependency "rake", '~> 13.0', '>= 13.0.1'
36
39
 
37
- spec.add_dependency "gloo-lang", '~> 1.0', ">= 1.0.1"
40
+ spec.add_dependency "gloo-lang", '~> 1.1', ">= 1.2.2"
38
41
 
39
42
  spec.add_dependency "activesupport", '~> 6.1', ">= 6.1.5"
40
43
  # spec.add_dependency "activesupport", '~> 6.1', ">= 6.1.4.6"
@@ -46,6 +49,6 @@ Gem::Specification.new do |spec|
46
49
  spec.add_dependency 'json', '~> 2.1', '>= 2.1.0'
47
50
  spec.add_dependency 'openssl', '~> 2.1', '>= 2.1.0'
48
51
  spec.add_dependency 'net-ssh', '~> 6.1', '>= 6.1.0'
49
- # spec.add_dependency 'mysql2', '~> 0.5', '>= 0.5.3'
50
- # spec.add_dependency 'sqlite3', '~> 1.4', '>= 1.4.2'
52
+ spec.add_dependency 'mysql2', '~> 0.5', '>= 0.5.3'
53
+ spec.add_dependency 'sqlite3', '~> 1.4', '>= 1.4.2'
51
54
  end
data/lib/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.2.2
@@ -0,0 +1,192 @@
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 < GlooLang::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 = GlooLang::Objs::Alias.resolve_alias( @engine, 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 = GlooLang::Objs::Alias.resolve_alias( @engine, 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 = GlooLang::Objs::Alias.resolve_alias( @engine, 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 = GlooLang::Objs::Alias.resolve_alias( @engine, 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
@@ -0,0 +1,159 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
3
+ #
4
+ # A Sqlite3 database connection.
5
+ #
6
+ # https://www.rubydoc.info/gems/sqlite3/1.3.11
7
+ # https://www.devdungeon.com/content/ruby-sqlite-tutorial
8
+ #
9
+ # db.results_as_hash = true
10
+ # Set results to return as Hash object.
11
+ # This is slower but offers a huge convenience.
12
+ # Consider turning it off for high performance situations.
13
+ # Each row will have the column name as the hash key.
14
+ #
15
+ # # Alternatively, to only get one row and discard the rest,
16
+ # replace `db.query()` with `db.get_first_value()`.
17
+ #
18
+ require 'sqlite3'
19
+
20
+ module Gloo
21
+ module Objs
22
+ class Sqlite < GlooLang::Core::Obj
23
+
24
+ KEYWORD = 'sqlite'.freeze
25
+ KEYWORD_SHORT = 'sqlite'.freeze
26
+
27
+ DB = 'database'.freeze
28
+ DEFAULT_DB = 'test.db'.freeze
29
+
30
+ DB_REQUIRED_ERR = 'The database name is required!'.freeze
31
+ DB_NOT_FOUND_ERR = 'The database file was not found!'.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 DB, DEFAULT_DB, self
68
+ end
69
+
70
+ # ---------------------------------------------------------------------
71
+ # Messages
72
+ # ---------------------------------------------------------------------
73
+
74
+ #
75
+ # Get a list of message names that this object receives.
76
+ #
77
+ def self.messages
78
+ return super + [ 'verify' ]
79
+ end
80
+
81
+ #
82
+ # Verify access to the Sqlite database specified.
83
+ #
84
+ def msg_verify
85
+ name = db_value
86
+ if name.empty?
87
+ @engine.err DB_REQUIRED_ERR
88
+ @engine.heap.it.set_to false
89
+ return
90
+ end
91
+
92
+ unless File.exist? name
93
+ @engine.err DB_NOT_FOUND_ERR
94
+ @engine.heap.it.set_to false
95
+ return
96
+ end
97
+
98
+ return unless connects?
99
+
100
+ @engine.heap.it.set_to true
101
+ end
102
+
103
+ # ---------------------------------------------------------------------
104
+ # DB functions (all database connections)
105
+ # ---------------------------------------------------------------------
106
+
107
+ #
108
+ # Open a connection and execute the SQL statement.
109
+ # Return the resulting data.
110
+ #
111
+ def query( sql, params = nil )
112
+ name = db_value
113
+ unless name
114
+ @engine.err DB_REQUIRED_ERR
115
+ return
116
+ end
117
+
118
+ db = SQLite3::Database.open name
119
+ db.results_as_hash = true
120
+ return db.query( sql, params )
121
+ end
122
+
123
+ # ---------------------------------------------------------------------
124
+ # Private functions
125
+ # ---------------------------------------------------------------------
126
+
127
+ private
128
+
129
+ #
130
+ # Get the Database file from the child object.
131
+ # Returns nil if there is none.
132
+ #
133
+ def db_value
134
+ o = find_child DB
135
+ return nil unless o
136
+
137
+ return o.value
138
+ end
139
+
140
+ #
141
+ # Try the connection and make sure it works.
142
+ # Returns true if we can connect and do a query.
143
+ #
144
+ def connects?
145
+ begin
146
+ db = SQLite3::Database.open db_value
147
+ sql = "SELECT COUNT(name) FROM sqlite_master WHERE type='table'"
148
+ db.get_first_value sql
149
+ rescue => e
150
+ @engine.err e.message
151
+ @engine.heap.it.set_to false
152
+ return false
153
+ end
154
+ return true
155
+ end
156
+
157
+ end
158
+ end
159
+ end
@@ -0,0 +1,82 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
+ #
4
+ # Show the help information.
5
+ #
6
+
7
+ module Gloo
8
+ module Verbs
9
+ class Help < GlooLang::Core::Verb
10
+
11
+ KEYWORD = 'help'.freeze
12
+ KEYWORD_SHORT = '?'.freeze
13
+ DEFAULT_HELP = 'default_help'.freeze
14
+ HELP_NOT_FOUND_ERR = 'Help command could not be found:'.freeze
15
+
16
+ DISPATCH = {
17
+ settings: 'show_settings',
18
+ keywords: 'show_keywords',
19
+ verb: 'show_verbs',
20
+ verbs: 'show_verbs',
21
+ v: 'show_verbs',
22
+ obj: 'show_objs',
23
+ object: 'show_objs',
24
+ objects: 'show_objs',
25
+ o: 'show_objs',
26
+ topics: 'show_topics'
27
+ }.freeze
28
+
29
+ #
30
+ # Run the verb.
31
+ #
32
+ def run
33
+ data = "\n For documentation use the gloo website. \n\n"
34
+ @engine.log.show data
35
+ end
36
+
37
+ #
38
+ # Get the Verb's keyword.
39
+ #
40
+ def self.keyword
41
+ return KEYWORD
42
+ end
43
+
44
+ #
45
+ # Get the Verb's keyword shortcut.
46
+ #
47
+ def self.keyword_shortcut
48
+ return KEYWORD_SHORT
49
+ end
50
+
51
+ # ---------------------------------------------------------------------
52
+ # Private functions
53
+ # ---------------------------------------------------------------------
54
+
55
+ private
56
+
57
+ #
58
+ # Write output to it and show it unless we are in
59
+ # silent mode.
60
+ #
61
+ def show_output( out )
62
+ @engine.heap.it.set_to out
63
+ puts out unless @engine.args.quiet?
64
+ end
65
+
66
+ #
67
+ # Show application settings.
68
+ #
69
+ def show_settings
70
+ @engine.settings.show
71
+ end
72
+
73
+ #
74
+ # Show all keywords: verbs and objects.
75
+ #
76
+ def show_keywords
77
+ @engine.dictionary.show_keywords
78
+ end
79
+
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,37 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
3
+ #
4
+ # Show the current application version.
5
+ #
6
+
7
+ module GlooLang
8
+ module Verbs
9
+ class Version < GlooLang::Core::Verb
10
+
11
+ KEYWORD = 'version'.freeze
12
+ KEYWORD_SHORT = 'v'.freeze
13
+
14
+ #
15
+ # Run the verb.
16
+ #
17
+ def run
18
+ @engine.log.show GlooLang::App::Info.full_version
19
+ end
20
+
21
+ #
22
+ # Get the Verb's keyword.
23
+ #
24
+ def self.keyword
25
+ return KEYWORD
26
+ end
27
+
28
+ #
29
+ # Get the Verb's keyword shortcut.
30
+ #
31
+ def self.keyword_shortcut
32
+ return KEYWORD_SHORT
33
+ end
34
+
35
+ end
36
+ end
37
+ end