gloo 0.4.0 → 0.5.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 (67) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.rubocop.yml +1 -1
  4. data/Gemfile.lock +80 -81
  5. data/Rakefile +1 -0
  6. data/gloo.gemspec +2 -1
  7. data/lib/gloo/app/engine.rb +48 -3
  8. data/lib/gloo/app/info.rb +1 -1
  9. data/lib/gloo/app/settings.rb +12 -5
  10. data/lib/gloo/convert/string_to_datetime.rb +21 -0
  11. data/lib/gloo/convert/string_to_decimal.rb +20 -0
  12. data/lib/gloo/convert/string_to_integer.rb +20 -0
  13. data/lib/gloo/core/event_manager.rb +2 -6
  14. data/lib/gloo/core/factory.rb +58 -1
  15. data/lib/gloo/core/gloo_system.rb +72 -0
  16. data/lib/gloo/core/obj.rb +50 -1
  17. data/lib/gloo/core/parser.rb +3 -1
  18. data/lib/gloo/core/pn.rb +3 -2
  19. data/lib/gloo/exec/dispatch.rb +30 -0
  20. data/lib/gloo/exec/runner.rb +43 -0
  21. data/lib/gloo/expr/expression.rb +1 -0
  22. data/lib/gloo/expr/l_decimal.rb +34 -0
  23. data/lib/gloo/expr/op_div.rb +2 -0
  24. data/lib/gloo/expr/op_minus.rb +2 -0
  25. data/lib/gloo/expr/op_mult.rb +2 -0
  26. data/lib/gloo/expr/op_plus.rb +2 -0
  27. data/lib/gloo/objs/basic/alias.rb +111 -0
  28. data/lib/gloo/objs/basic/container.rb +11 -1
  29. data/lib/gloo/objs/basic/decimal.rb +96 -0
  30. data/lib/gloo/objs/basic/integer.rb +5 -0
  31. data/lib/gloo/objs/basic/string.rb +9 -1
  32. data/lib/gloo/objs/basic/text.rb +27 -2
  33. data/lib/gloo/objs/cli/banner.rb +137 -0
  34. data/lib/gloo/objs/cli/bar.rb +141 -0
  35. data/lib/gloo/objs/cli/colorize.rb +1 -1
  36. data/lib/gloo/objs/cli/menu.rb +236 -0
  37. data/lib/gloo/objs/cli/menu_item.rb +128 -0
  38. data/lib/gloo/objs/cli/pastel.rb +120 -0
  39. data/lib/gloo/objs/cli/prompt.rb +19 -11
  40. data/lib/gloo/objs/cli/select.rb +153 -0
  41. data/lib/gloo/objs/ctrl/each.rb +45 -16
  42. data/lib/gloo/objs/ctrl/repeat.rb +129 -0
  43. data/lib/gloo/objs/data/markdown.rb +109 -0
  44. data/lib/gloo/objs/data/table.rb +168 -0
  45. data/lib/gloo/objs/dt/date.rb +72 -0
  46. data/lib/gloo/objs/dt/datetime.rb +84 -0
  47. data/lib/gloo/objs/dt/time.rb +72 -0
  48. data/lib/gloo/objs/ror/erb.rb +1 -0
  49. data/lib/gloo/objs/system/file_handle.rb +50 -1
  50. data/lib/gloo/objs/web/http_get.rb +24 -4
  51. data/lib/gloo/objs/web/http_post.rb +1 -0
  52. data/lib/gloo/objs/web/json.rb +155 -0
  53. data/lib/gloo/objs/web/uri.rb +160 -0
  54. data/lib/gloo/persist/file_loader.rb +17 -6
  55. data/lib/gloo/persist/line_splitter.rb +7 -2
  56. data/lib/gloo/persist/persist_man.rb +37 -13
  57. data/lib/gloo/verbs/cls.rb +67 -0
  58. data/lib/gloo/verbs/help.rb +9 -0
  59. data/lib/gloo/verbs/if.rb +1 -0
  60. data/lib/gloo/verbs/load.rb +3 -2
  61. data/lib/gloo/verbs/move.rb +128 -0
  62. data/lib/gloo/verbs/run.rb +21 -7
  63. data/lib/gloo/verbs/tell.rb +1 -1
  64. data/lib/gloo/verbs/unless.rb +1 -0
  65. data/lib/gloo/verbs/wait.rb +73 -0
  66. metadata +36 -5
  67. data/lib/gloo/core/runner.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19496a960895aafa43d063747006006f73974b35932d46e2b6e16348f94ebd12
4
- data.tar.gz: ea5df8220074a3d6d9b2e9316696287fe9176f22bcbbd6ca6f0ae3f1108cf983
3
+ metadata.gz: 19cd2f8b1438d4d9dab2b0bdcd66fe01784b8bb161accff80d1911f89c813ad3
4
+ data.tar.gz: b90953b0ebbfe6b776e87ec4dfade2344a61d3e1a5f6522d0b5d8131f9864fce
5
5
  SHA512:
6
- metadata.gz: 98f6ed2211824bbc5af791b32b1c2a55e5bc70dd91c6fe2440a2820324f2143c39860f89d458787dfba7405eb79f5dcd25f961b2cc9944350347e12d2daa60b6
7
- data.tar.gz: ac15204c8c19dc59c87335da8d491436f540976bfba1d2304e38493ec07ba733005333e19f00a26753d4b83c30a86ef5e6764747663562a11787be68cb2c02b0
6
+ metadata.gz: 904fb7abfb42e1032c6fd51d37ef7b5e7ce072f003ca399693601b0c330da73fb4add837ef5ecf02754325f8dcffd34f8d2305e5fc415674c6f8c21444d36f3d
7
+ data.tar.gz: da4e24cec3300ce53327788013401b3e9228201d3e04e3a7a4d401788a4f708b0cc4959bcbb738d939ad152de700a53455e16293d396c56652bf3292b717656d
Binary file
@@ -56,7 +56,7 @@ Naming/MethodParameterName:
56
56
  Metrics/PerceivedComplexity:
57
57
  Max: 10 # default value is 7
58
58
  Metrics/ClassLength:
59
- Max: 137 # default is 100
59
+ Max: 157 # default is 100
60
60
  Metrics/AbcSize:
61
61
  Max: 37 # default is 15
62
62
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gloo (0.4.0)
4
+ gloo (0.5.0)
5
5
  activesupport (~> 5.2, >= 5.2.4.3)
6
6
  chronic (~> 0.10, >= 0.10.2)
7
7
  colorize (~> 0.8, >= 0.8.1)
@@ -17,114 +17,113 @@ GEM
17
17
  tzinfo (~> 1.1)
18
18
  chronic (0.10.2)
19
19
  colorize (0.8.1)
20
- concurrent-ruby (1.1.4)
21
- diff-lcs (1.3)
22
- equatable (0.5.0)
23
- i18n (1.3.0)
20
+ concurrent-ruby (1.1.7)
21
+ diff-lcs (1.4.4)
22
+ equatable (0.6.1)
23
+ i18n (1.8.5)
24
24
  concurrent-ruby (~> 1.0)
25
25
  kramdown (1.16.2)
26
26
  minitest (5.11.3)
27
- necromancer (0.4.0)
28
- pastel (0.7.2)
29
- equatable (~> 0.5.0)
30
- tty-color (~> 0.4.0)
31
- rake (10.5.0)
32
- rouge (3.3.0)
33
- strings (0.1.4)
34
- strings-ansi (~> 0.1.0)
35
- unicode-display_width (~> 1.4.0)
36
- unicode_utils (~> 1.4.0)
27
+ necromancer (0.5.1)
28
+ pastel (0.7.4)
29
+ equatable (~> 0.6)
30
+ tty-color (~> 0.5)
31
+ rake (13.0.1)
32
+ rouge (3.22.0)
33
+ strings (0.1.8)
34
+ strings-ansi (~> 0.1)
35
+ unicode-display_width (~> 1.5)
36
+ unicode_utils (~> 1.4)
37
37
  strings-ansi (0.1.0)
38
38
  thor (0.20.3)
39
39
  thread_safe (0.3.6)
40
- timers (4.2.0)
41
- tty (0.9.1)
40
+ tty (0.10.0)
42
41
  bundler (~> 1.16, < 2.0)
43
42
  equatable (~> 0.5)
44
43
  pastel (~> 0.7.2)
45
44
  thor (~> 0.20.0)
46
- tty-box (~> 0.3.0)
47
- tty-color (~> 0.4)
48
- tty-command (~> 0.8.0)
49
- tty-config (~> 0.3.0)
50
- tty-cursor (~> 0.6)
51
- tty-editor (~> 0.5.0)
52
- tty-file (~> 0.7.0)
53
- tty-font (~> 0.2.0)
54
- tty-markdown (~> 0.5.0)
55
- tty-pager (~> 0.12.0)
56
- tty-pie (~> 0.1.0)
57
- tty-platform (~> 0.2.0)
58
- tty-progressbar (~> 0.16.0)
59
- tty-prompt (~> 0.18.0)
60
- tty-screen (~> 0.6)
61
- tty-spinner (~> 0.9.0)
62
- tty-table (~> 0.10.0)
63
- tty-tree (~> 0.2.0)
45
+ tty-box (~> 0.4.1)
46
+ tty-color (~> 0.5)
47
+ tty-command (~> 0.9.0)
48
+ tty-config (~> 0.3.2)
49
+ tty-cursor (~> 0.7)
50
+ tty-editor (~> 0.5)
51
+ tty-file (~> 0.8.0)
52
+ tty-font (~> 0.4.0)
53
+ tty-logger (~> 0.2.0)
54
+ tty-markdown (~> 0.6.0)
55
+ tty-pager (~> 0.12)
56
+ tty-pie (~> 0.3.0)
57
+ tty-platform (~> 0.2)
58
+ tty-progressbar (~> 0.17)
59
+ tty-prompt (~> 0.19)
60
+ tty-screen (~> 0.7)
61
+ tty-spinner (~> 0.9)
62
+ tty-table (~> 0.11.0)
63
+ tty-tree (~> 0.3)
64
64
  tty-which (~> 0.4)
65
- tty-box (0.3.0)
65
+ tty-box (0.4.1)
66
66
  pastel (~> 0.7.2)
67
- strings (~> 0.1.4)
68
- tty-cursor (~> 0.6.0)
69
- tty-color (0.4.3)
70
- tty-command (0.8.2)
67
+ strings (~> 0.1.6)
68
+ tty-cursor (~> 0.7)
69
+ tty-color (0.5.2)
70
+ tty-command (0.9.0)
71
71
  pastel (~> 0.7.0)
72
- tty-config (0.3.0)
73
- tty-cursor (0.6.0)
74
- tty-editor (0.5.0)
75
- tty-prompt (~> 0.18)
72
+ tty-config (0.3.2)
73
+ tty-cursor (0.7.1)
74
+ tty-editor (0.5.1)
75
+ tty-prompt (~> 0.19)
76
76
  tty-which (~> 0.4)
77
- tty-file (0.7.0)
77
+ tty-file (0.8.0)
78
78
  diff-lcs (~> 1.3)
79
79
  pastel (~> 0.7.2)
80
80
  tty-prompt (~> 0.18)
81
- tty-font (0.2.0)
82
- tty-markdown (0.5.0)
81
+ tty-font (0.4.0)
82
+ tty-logger (0.2.0)
83
+ pastel (~> 0.7.0)
84
+ tty-markdown (0.6.0)
83
85
  kramdown (~> 1.16.2)
84
86
  pastel (~> 0.7.2)
85
87
  rouge (~> 3.3)
86
88
  strings (~> 0.1.4)
87
89
  tty-color (~> 0.4)
88
90
  tty-screen (~> 0.6)
89
- tty-pager (0.12.0)
90
- strings (~> 0.1.4)
91
- tty-screen (~> 0.6)
92
- tty-which (~> 0.4)
93
- tty-pie (0.1.0)
94
- pastel (~> 0.7.2)
95
- tty-cursor (~> 0.6.0)
96
- tty-platform (0.2.0)
97
- tty-progressbar (0.16.0)
91
+ tty-pager (0.13.0)
92
+ strings (~> 0.1.8)
93
+ tty-screen (~> 0.8)
94
+ tty-pie (0.3.0)
95
+ pastel (~> 0.7.3)
96
+ tty-cursor (~> 0.7)
97
+ tty-platform (0.3.0)
98
+ tty-progressbar (0.17.0)
98
99
  strings-ansi (~> 0.1.0)
99
- tty-cursor (~> 0.6.0)
100
- tty-screen (~> 0.6.4)
101
- unicode-display_width (~> 1.3)
102
- tty-prompt (0.18.1)
103
- necromancer (~> 0.4.0)
100
+ tty-cursor (~> 0.7)
101
+ tty-screen (~> 0.7)
102
+ unicode-display_width (~> 1.6)
103
+ tty-prompt (0.21.0)
104
+ necromancer (~> 0.5.0)
104
105
  pastel (~> 0.7.0)
105
- timers (~> 4.0)
106
- tty-cursor (~> 0.6.0)
107
- tty-reader (~> 0.5.0)
108
- tty-reader (0.5.0)
109
- tty-cursor (~> 0.6.0)
110
- tty-screen (~> 0.6.4)
106
+ tty-reader (~> 0.7.0)
107
+ tty-reader (0.7.0)
108
+ tty-cursor (~> 0.7)
109
+ tty-screen (~> 0.7)
111
110
  wisper (~> 2.0.0)
112
- tty-screen (0.6.5)
113
- tty-spinner (0.9.0)
114
- tty-cursor (~> 0.6.0)
115
- tty-table (0.10.0)
116
- equatable (~> 0.5.0)
117
- necromancer (~> 0.4.0)
111
+ tty-screen (0.8.1)
112
+ tty-spinner (0.9.3)
113
+ tty-cursor (~> 0.7)
114
+ tty-table (0.11.0)
115
+ equatable (~> 0.6)
116
+ necromancer (~> 0.5)
118
117
  pastel (~> 0.7.2)
119
- strings (~> 0.1.0)
120
- tty-screen (~> 0.6.4)
121
- tty-tree (0.2.0)
122
- tty-which (0.4.0)
123
- tzinfo (1.2.5)
118
+ strings (~> 0.1.5)
119
+ tty-screen (~> 0.7)
120
+ tty-tree (0.4.0)
121
+ tty-which (0.4.2)
122
+ tzinfo (1.2.7)
124
123
  thread_safe (~> 0.1)
125
- unicode-display_width (1.4.1)
124
+ unicode-display_width (1.7.0)
126
125
  unicode_utils (1.4.0)
127
- wisper (2.0.0)
126
+ wisper (2.0.1)
128
127
 
129
128
  PLATFORMS
130
129
  ruby
@@ -133,7 +132,7 @@ DEPENDENCIES
133
132
  bundler (~> 1.16)
134
133
  gloo!
135
134
  minitest (~> 5.0)
136
- rake (~> 10.0)
135
+ rake (~> 13.0, >= 13.0.1)
137
136
 
138
137
  BUNDLED WITH
139
138
  1.16.2
data/Rakefile CHANGED
@@ -4,6 +4,7 @@ require 'rake/testtask'
4
4
  Rake::TestTask.new(:test) do |t|
5
5
  ENV[ 'GLOO_ENV' ] = 'TEST'
6
6
 
7
+ t.warning = false
7
8
  t.libs << 'test'
8
9
  t.libs << 'lib'
9
10
  t.test_files = FileList['test/**/*_test.rb']
@@ -29,7 +29,8 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_development_dependency 'bundler', '~> 1.16'
31
31
  spec.add_development_dependency 'minitest', '~> 5.0'
32
- spec.add_development_dependency 'rake', '~> 10.0'
32
+ # spec.add_development_dependency 'rake', '~> 10.0'
33
+ spec.add_development_dependency "rake", '~> 13.0', '>= 13.0.1'
33
34
 
34
35
  spec.add_dependency "activesupport", '~> 5.2', ">= 5.2.4.3"
35
36
  # spec.add_dependency 'activesupport', '~> 5.2', '>= 5.2.1'
@@ -44,6 +44,10 @@ module Gloo
44
44
  run_mode
45
45
  end
46
46
 
47
+ # ---------------------------------------------------------------------
48
+ # Run
49
+ # ---------------------------------------------------------------------
50
+
47
51
  # Run the selected mode.
48
52
  def run_mode
49
53
  if @mode == Mode::VERSION
@@ -94,7 +98,7 @@ module Gloo
94
98
  d = dt.strftime( '%Y.%m.%d' )
95
99
  t = dt.strftime( '%I:%M:%S' )
96
100
 
97
- @last_cmd = $prompt.ask( "#{d.yellow} #{t.white} >" )
101
+ @last_cmd = $prompt.ask( "#{'gloo'.blue} #{d.yellow} #{t.white} >" )
98
102
  end
99
103
 
100
104
  # Is the last command entered blank?
@@ -118,8 +122,7 @@ module Gloo
118
122
  return
119
123
  end
120
124
 
121
- @immediate = @parser.parse_immediate @last_cmd
122
- Gloo::Core::Runner.go( @immediate ) if @immediate
125
+ @parser.run @last_cmd
123
126
  end
124
127
 
125
128
  # Request the engine to stop running.
@@ -132,6 +135,10 @@ module Gloo
132
135
  $log.debug 'quitting...'
133
136
  end
134
137
 
138
+ # ---------------------------------------------------------------------
139
+ # Helpers
140
+ # ---------------------------------------------------------------------
141
+
135
142
  # Show the version information and then quit.
136
143
  def run_version
137
144
  puts Info.display_title unless @args.quiet?
@@ -149,15 +156,53 @@ module Gloo
149
156
 
150
157
  # Clear the screen.
151
158
  def clear_screen
159
+ @cursor ||= TTY::Cursor
152
160
  print @cursor.clear_screen
153
161
  print @cursor.move_to( 0, 0 )
154
162
  end
155
163
 
164
+ # ---------------------------------------------------------------------
165
+ # Error Handling
166
+ # ---------------------------------------------------------------------
167
+
168
+ #
156
169
  # Did the last command result in an error?
170
+ #
157
171
  def error?
158
172
  return !@heap.error.value.nil?
159
173
  end
160
174
 
175
+ #
176
+ # Report an error.
177
+ # Write it to the log and set the heap error value.
178
+ #
179
+ def err( msg )
180
+ $log.error msg
181
+ self.heap.error.set_to msg
182
+ end
183
+
184
+ # ---------------------------------------------------------------------
185
+ # Convert
186
+ # ---------------------------------------------------------------------
187
+
188
+ #
189
+ # Convert the given value to the specified type,
190
+ # or if no conversion is available, revert to default.
191
+ #
192
+ def convert( value, to_type, default = nil )
193
+ begin
194
+ name = "Gloo::Convert::#{value.class}To#{to_type}"
195
+ clazz = name.split( '::' ).inject( Object ) { |o, c| o.const_get c }
196
+ o = clazz.new
197
+ return o.convert( value )
198
+ rescue => e
199
+ $log.error e.message
200
+ $engine.heap.error.set_to e.message
201
+ end
202
+
203
+ return default
204
+ end
205
+
161
206
  end
162
207
  end
163
208
  end
@@ -8,7 +8,7 @@ module Gloo
8
8
  module App
9
9
  class Info
10
10
 
11
- VERSION = '0.4.0'.freeze
11
+ VERSION = '0.5.0'.freeze
12
12
  APP_NAME = 'Gloo'.freeze
13
13
 
14
14
  # Get the application display title.
@@ -13,7 +13,7 @@ module Gloo
13
13
  class Settings
14
14
 
15
15
  attr_reader :user_root, :log_path, :config_path, :project_path
16
- attr_reader :start_with, :list_indent
16
+ attr_reader :start_with, :list_indent, :tmp_path
17
17
 
18
18
  # Load setting from the yml file.
19
19
  def initialize( mode )
@@ -55,6 +55,9 @@ module Gloo
55
55
 
56
56
  @config_path = File.join( @user_root, 'config' )
57
57
  Dir.mkdir( @config_path ) unless File.exist?( @config_path )
58
+
59
+ @tmp_path = File.join( @user_root, 'tmp' )
60
+ Dir.mkdir( @tmp_path ) unless File.exist?( @tmp_path )
58
61
  end
59
62
 
60
63
  # Initialize the user settings for the currently
@@ -91,16 +94,20 @@ module Gloo
91
94
  return str
92
95
  end
93
96
 
97
+ #
94
98
  # Show the current application settings.
99
+ # Can be seen in app with 'help settings'
100
+ #
95
101
  def show
96
102
  puts "\nApplication Settings:".blue
97
103
  puts ' User Root Path is here: '.yellow + @user_root.white
98
- puts ' Projects directory: '.yellow + @projects.white
104
+ puts ' Projects directory: '.yellow + @project_path.white
105
+ puts ' Tmp directory: '.yellow + @tmp_path.white
99
106
  puts ' Startup with: '.yellow + @start_with.white
100
- puts ' Indent in Listing: '.yellow + @list_indent.white
107
+ puts ' Indent in Listing: '.yellow + @list_indent.to_s.white
101
108
  puts ''
102
- puts ' Screen Lines: '.yellow + Settings.lines.to_s.white
103
- puts ' Page Size: '.yellow + Settings.page_size.to_s.white
109
+ puts ' Screen Lines: '.yellow + Gloo::App::Settings.lines.to_s.white
110
+ puts ' Page Size: '.yellow + Gloo::App::Settings.page_size.to_s.white
104
111
  puts ''
105
112
  end
106
113
 
@@ -0,0 +1,21 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 202 Eric Crane. All rights reserved.
3
+ #
4
+ # Conversion tool: String to Date Time.
5
+ #
6
+ require 'chronic'
7
+
8
+ module Gloo
9
+ module Convert
10
+ class StringToDateTime
11
+
12
+ #
13
+ # Convert the given string value to a date and time.
14
+ #
15
+ def convert( value )
16
+ return Chronic.parse( value )
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 202 Eric Crane. All rights reserved.
3
+ #
4
+ # Conversion tool: String to Decimal.
5
+ #
6
+
7
+ module Gloo
8
+ module Convert
9
+ class StringToDecimal
10
+
11
+ #
12
+ # Convert the given string value to an integer.
13
+ #
14
+ def convert( value )
15
+ return value.to_f
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # Author:: Eric Crane (mailto:eric.crane@mac.com)
2
+ # Copyright:: Copyright (c) 202 Eric Crane. All rights reserved.
3
+ #
4
+ # Conversion tool: String to Integer.
5
+ #
6
+
7
+ module Gloo
8
+ module Convert
9
+ class StringToInteger
10
+
11
+ #
12
+ # Convert the given string value to an integer.
13
+ #
14
+ def convert( value )
15
+ return value.to_i
16
+ end
17
+
18
+ end
19
+ end
20
+ end