gloo-lang 0.9.5 → 0.9.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d19934c8b9f0ae7c4b7770b353555c19c4acb4b755775222e14cde8aa1a4bbee
4
- data.tar.gz: b88f21b0a86cf71b92fcc3fe8c018884109b83293e54db266bb17cef5111e7c0
3
+ metadata.gz: dd3e269694e1c7aef191b9fcd1bae34b29932fc2215f90f372cfd5d5d2748bc0
4
+ data.tar.gz: 7976911ab79e1679c1940e43217f4c8fc533bab59fbf2a71b857ee4a7aeefed2
5
5
  SHA512:
6
- metadata.gz: f3475c8c03da31aa4a05feb948b10a89a3b0fae818800ef14329c5028add3e5a788f3a6e7fff7b21c762c53fb67619ffa875dd6586044373110316e78c494480
7
- data.tar.gz: 27d759c5e86633db59786a3a7db230c4f26c2e54d94a3d339af759983799fd6a4dccb21b84f0dd4cd8de80f1f3a46650c0d3bb283cee246ce95f5cca439ace4e
6
+ metadata.gz: f9be9692d331f3767e78efc2e9a5fcb5d826e11429240cf77ae9d134a41408b2fbed7a144b54a6ba8291619ddc4bb108cecf3743deb53f96e425018937d8fc28
7
+ data.tar.gz: b29cc45d25aa4472d8112caaf08c20deccf245c9f3a0e3392e102a558e4c13daba147b9077d057d9fb67b847bc04e0ffdd5642292376857bacf1cf33896473ae
data/Gemfile.lock CHANGED
@@ -1,11 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gloo-lang (0.9.4)
4
+ gloo-lang (0.9.7)
5
5
  chronic (~> 0.10, >= 0.10.2)
6
6
  json (~> 2.1, >= 2.1.0)
7
7
  net-ssh (~> 6.1, >= 6.1.0)
8
8
  openssl (~> 2.1, >= 2.1.0)
9
+ tty-platform (~> 0.3, >= 0.3.0)
9
10
 
10
11
  GEM
11
12
  remote: https://rubygems.org/
@@ -37,6 +38,7 @@ GEM
37
38
  rubocop-ast (1.16.0)
38
39
  parser (>= 3.1.1.0)
39
40
  ruby-progressbar (1.11.0)
41
+ tty-platform (0.3.0)
40
42
  unicode-display_width (2.1.0)
41
43
 
42
44
  PLATFORMS
data/lib/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.5
1
+ 0.9.8
@@ -19,12 +19,14 @@ module GlooLang
19
19
  #
20
20
  # Set up the engine with basic elements.
21
21
  #
22
- def initialize( params = [], platform=nil )
22
+ def initialize( params = [], platform=Platform, log=Log )
23
23
  $engine = self
24
24
  @args = Args.new( params )
25
25
  $settings = Settings.new( ENV[ 'GLOO_ENV' ] )
26
- $log = Log.new( @args.quiet? )
27
- @platform = platform ? platform : Platform.new
26
+
27
+ $log = log.new( @args.quiet? )
28
+ @platform = platform.new
29
+
28
30
  $log.debug 'engine intialized...'
29
31
  end
30
32
 
@@ -4,8 +4,6 @@
4
4
  # Application Logging wrapper.
5
5
  #
6
6
  require 'active_support'
7
- require 'colorize'
8
- require 'colorized_string'
9
7
 
10
8
  module GlooLang
11
9
  module App
@@ -18,11 +16,11 @@ module GlooLang
18
16
  # If quiet is true, then message are written to the log
19
17
  # but not to the console.
20
18
  #
21
- def initialize( quiet )
19
+ def initialize( quiet=true )
22
20
  f = File.join( $settings.log_path, 'gloo.log' )
23
21
  @logger = Logger.new( f )
24
22
  @logger.level = Logger::DEBUG
25
- @quiet = quiet
23
+ @quite = quiet
26
24
  end
27
25
 
28
26
  #
@@ -45,7 +43,7 @@ module GlooLang
45
43
  #
46
44
  def info( msg )
47
45
  @logger.info msg
48
- puts msg.blue unless @quiet
46
+ puts msg unless @quiet
49
47
  end
50
48
 
51
49
  #
@@ -54,7 +52,7 @@ module GlooLang
54
52
  #
55
53
  def warn( msg )
56
54
  @logger.warn msg
57
- puts msg.yellow unless @quiet
55
+ puts msg unless @quiet
58
56
  end
59
57
 
60
58
  #
@@ -68,11 +66,11 @@ module GlooLang
68
66
  if ex
69
67
  @logger.error ex.message
70
68
  @logger.error ex.backtrace
71
- puts msg.red unless @quiet
72
- puts ex.message.red unless @quiet
69
+ puts msg unless @quiet
70
+ puts ex.message unless @quiet
73
71
  puts ex.backtrace unless @quiet
74
72
  else
75
- puts msg.red unless @quiet
73
+ puts msg unless @quiet
76
74
  end
77
75
  end
78
76
 
@@ -5,7 +5,6 @@
5
5
  #
6
6
 
7
7
  require 'yaml'
8
- require 'colorize'
9
8
 
10
9
  module GlooLang
11
10
  module App
@@ -47,11 +46,11 @@ module GlooLang
47
46
  # Can be seen in app with 'help settings'
48
47
  #
49
48
  def show
50
- puts "\nApplication Settings:".blue
51
- puts ' Startup with: '.yellow + @start_with.white
52
- puts ' Indent in Listing: '.yellow + @list_indent.to_s.white
53
- puts ' Screen Lines: '.yellow + GlooLang::App::Settings.lines.to_s.white
54
- puts ' Page Size: '.yellow + GlooLang::App::Settings.page_size.to_s.white
49
+ puts "\nApplication Settings:"
50
+ puts ' Startup with: ' + @start_with
51
+ puts ' Indent in Listing: ' + @list_indent.to_s
52
+ puts ' Screen Lines: ' + GlooLang::App::Settings.lines.to_s
53
+ puts ' Page Size: ' + GlooLang::App::Settings.page_size.to_s
55
54
  puts ''
56
55
  self.show_paths
57
56
  puts ''
@@ -61,12 +60,37 @@ module GlooLang
61
60
  # Show path settings
62
61
  #
63
62
  def show_paths
64
- puts ' User Root Path is here: '.yellow + @user_root.white
65
- puts ' Projects Path: '.yellow + @project_path.white
66
- puts ' Tmp Path: '.yellow + @tmp_path.white
67
- puts ' Debug Path: '.yellow + @debug_path.white
63
+ puts ' User Root Path is here: ' + @user_root
64
+ puts ' Projects Path: ' + @project_path
65
+ puts ' Tmp Path: ' + @tmp_path
66
+ puts ' Debug Path: ' + @debug_path
68
67
  end
69
68
 
69
+ # #
70
+ # # Show the current application settings.
71
+ # # Can be seen in app with 'help settings'
72
+ # #
73
+ # def show
74
+ # puts "\nApplication Settings:".blue
75
+ # puts ' Startup with: '.yellow + @start_with.white
76
+ # puts ' Indent in Listing: '.yellow + @list_indent.to_s.white
77
+ # puts ' Screen Lines: '.yellow + GlooLang::App::Settings.lines.to_s.white
78
+ # puts ' Page Size: '.yellow + GlooLang::App::Settings.page_size.to_s.white
79
+ # puts ''
80
+ # self.show_paths
81
+ # puts ''
82
+ # end
83
+ #
84
+ # #
85
+ # # Show path settings
86
+ # #
87
+ # def show_paths
88
+ # puts ' User Root Path is here: '.yellow + @user_root.white
89
+ # puts ' Projects Path: '.yellow + @project_path.white
90
+ # puts ' Tmp Path: '.yellow + @tmp_path.white
91
+ # puts ' Debug Path: '.yellow + @debug_path.white
92
+ # end
93
+
70
94
  #
71
95
  # Get the number of vertical lines on screen.
72
96
  #
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # Show a single object's value.
5
5
  #
6
- require 'colorized_string'
6
+ # require 'colorized_string'
7
7
 
8
8
  module GlooLang
9
9
  module Verbs
@@ -54,7 +54,8 @@ module GlooLang
54
54
  expr = GlooLang::Expr::Expression.new( @params.tokens )
55
55
  val = expr.evaluate
56
56
  color = val.to_sym
57
- return ColorizedString[ str.to_s ].colorize( color )
57
+ # return ColorizedString[ str.to_s ].colorize( color )
58
+ return str.to_s
58
59
  end
59
60
  return str
60
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gloo-lang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Crane
@@ -309,9 +309,7 @@ files:
309
309
  - lib/gloo_lang/objs/ctrl/each.rb
310
310
  - lib/gloo_lang/objs/ctrl/repeat.rb
311
311
  - lib/gloo_lang/objs/data/markdown.rb
312
- - lib/gloo_lang/objs/data/mysql.rb
313
312
  - lib/gloo_lang/objs/data/query.rb
314
- - lib/gloo_lang/objs/data/sqlite.rb
315
313
  - lib/gloo_lang/objs/data/table.rb
316
314
  - lib/gloo_lang/objs/dt/date.rb
317
315
  - lib/gloo_lang/objs/dt/datetime.rb
@@ -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 GlooLang
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( 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( 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( 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( 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
@@ -1,159 +0,0 @@
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 GlooLang
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