gloo 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20774ab083e3f97894367f2e5ab0ede6ae65edeb72e8153af73df130da3a728c
4
- data.tar.gz: 9225ba79729353ed2a21966dfdf380ad1d6b081615895d6bef1eec83720d428b
3
+ metadata.gz: 458df803a19ddb0ef29a942b8257e00723b1554d25ff11776d2d5cc170fd9535
4
+ data.tar.gz: 6ae7b1768becdb52bb251b5c1bc0aaa5329caf34327fcd9a3a1ea9ac1ceed658
5
5
  SHA512:
6
- metadata.gz: 1c4d53f40b31c60a0d32f45bf5ab8a3a6489325f34fb4f488333a3fdc5c67b876b13bd7cf9ad7daa388124386ba866033b5c96357d6621239f9b02e466db13c4
7
- data.tar.gz: c3326a3b85ca3996cf5a0ecee1dbf4d49ada7f8ae37815bdfa053ba9c593bf1a01e508870ebff7b263e159d48472a37c874baddba78d2dfce52ba1aabe9dee99
6
+ metadata.gz: 8de984642bca19eb20c8ad2d171729d980adde59a7c768b0f1ecdff90fa0e15283a64b1d9fee318ba3deb4148e06e38b419b957aad08774ccaa491f47241db7f
7
+ data.tar.gz: 53edc86be0a517dd71230b11f58a83874cb2598a4f846e690646f4d5400bde5481c6be4ace40e19a0ed9e6e60433fd38b9c9b358cce843d43e48c8227e32221c
data/lib/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.2.0
data/lib/gloo/app/log.rb CHANGED
@@ -26,6 +26,7 @@ module Gloo
26
26
  def initialize( engine, quiet=true )
27
27
  @engine = engine
28
28
  @quite = quiet
29
+ @debug = engine.settings.debug
29
30
 
30
31
  create_logger
31
32
 
@@ -60,6 +61,8 @@ module Gloo
60
61
  # Write a debug message to the log.
61
62
  #
62
63
  def debug( msg )
64
+ return unless @debug
65
+
63
66
  @logger.debug msg
64
67
  end
65
68
 
@@ -12,7 +12,7 @@ module Gloo
12
12
 
13
13
  attr_reader :user_root, :log_path,
14
14
  :config_path, :project_path,
15
- :start_with, :list_indent, :tmp_path,
15
+ :start_with, :list_indent, :list_levels, :tmp_path,
16
16
  :debug_path, :debug
17
17
 
18
18
  #
@@ -33,51 +33,28 @@ module Gloo
33
33
  # Can be seen in app with 'help settings'
34
34
  #
35
35
  def show
36
- puts "\nApplication Settings:"
37
- puts ' Startup with: ' + @start_with
38
- puts ' Indent in Listing: ' + @list_indent.to_s
39
- puts ' Screen Lines: ' + Gloo::App::Settings.lines( @engine ).to_s
40
- puts ' Page Size: ' + Gloo::App::Settings.page_size( @engine ).to_s
41
- puts ''
36
+ puts "\n Application Settings:".blue
37
+ puts ' Startup with: '.yellow + @start_with.white
38
+ puts ' Indent in Listing: '.yellow + @list_indent.to_s.white
39
+ puts ' List Levels: '.yellow + @list_levels.to_s.white
40
+ puts ' Debug? '.yellow + @debug.to_s.white
41
+ puts ' Screen Lines: '.yellow + Gloo::App::Settings.lines( @engine ).to_s.white
42
+ puts ' Page Size: '.yellow + Gloo::App::Settings.page_size( @engine ).to_s.white
42
43
  self.show_paths
43
- puts ''
44
44
  end
45
-
45
+
46
46
  #
47
47
  # Show path settings
48
48
  #
49
49
  def show_paths
50
- puts ' User Root Path is here: ' + @user_root
51
- puts ' Projects Path: ' + @project_path
52
- puts ' Tmp Path: ' + @tmp_path
53
- puts ' Debug Path: ' + @debug_path
50
+ puts "\n Application Paths:".blue
51
+ puts ' User Root Path is here: '.yellow + @user_root.white
52
+ puts ' Projects Path: '.yellow + @project_path.white
53
+ puts ' Tmp Path: '.yellow + @tmp_path.white
54
+ puts ' Debug Path: '.yellow + @debug_path.white
55
+ puts "\n"
54
56
  end
55
57
 
56
- # #
57
- # # Show the current application settings.
58
- # # Can be seen in app with 'help settings'
59
- # #
60
- # def show
61
- # puts "\nApplication Settings:".blue
62
- # puts ' Startup with: '.yellow + @start_with.white
63
- # puts ' Indent in Listing: '.yellow + @list_indent.to_s.white
64
- # puts ' Screen Lines: '.yellow + Gloo::App::Settings.lines.to_s.white
65
- # puts ' Page Size: '.yellow + Gloo::App::Settings.page_size.to_s.white
66
- # puts ''
67
- # self.show_paths
68
- # puts ''
69
- # end
70
- #
71
- # #
72
- # # Show path settings
73
- # #
74
- # def show_paths
75
- # puts ' User Root Path is here: '.yellow + @user_root.white
76
- # puts ' Projects Path: '.yellow + @project_path.white
77
- # puts ' Tmp Path: '.yellow + @tmp_path.white
78
- # puts ' Debug Path: '.yellow + @debug_path.white
79
- # end
80
-
81
58
  #
82
59
  # Get the number of vertical lines on screen.
83
60
  #
@@ -162,6 +139,7 @@ module Gloo
162
139
 
163
140
  @start_with = settings[ 'gloo' ][ 'start_with' ]
164
141
  @list_indent = settings[ 'gloo' ][ 'list_indent' ]
142
+ @list_levels = settings[ 'gloo' ][ 'list_levels' ]
165
143
 
166
144
  @debug = settings[ 'gloo' ][ 'debug' ]
167
145
  end
@@ -191,7 +169,8 @@ module Gloo
191
169
  gloo:
192
170
  project_path: #{projects}
193
171
  start_with:
194
- list_indent: 1
172
+ list_indent: 2
173
+ list_levels: 3
195
174
  debug: false
196
175
  TEXT
197
176
  return str
@@ -14,24 +14,29 @@ module Gloo
14
14
  HELP_NOT_FOUND_ERR = 'Help command could not be found:'.freeze
15
15
 
16
16
  DISPATCH = {
17
+ s: 'show_settings',
17
18
  settings: 'show_settings',
18
- keywords: 'show_keywords',
19
19
  verb: 'show_verbs',
20
20
  verbs: 'show_verbs',
21
21
  v: 'show_verbs',
22
+ o: 'show_objs',
22
23
  obj: 'show_objs',
23
24
  object: 'show_objs',
24
- objects: 'show_objs',
25
- o: 'show_objs',
26
- topics: 'show_topics'
25
+ objects: 'show_objs'
27
26
  }.freeze
28
27
 
29
28
  #
30
29
  # Run the verb.
31
30
  #
32
31
  def run
33
- data = "\n For documentation use the gloo website. \n\n"
34
- @engine.log.show data
32
+ opts = @tokens.second if @tokens
33
+ opts = opts.strip.downcase if opts
34
+
35
+ if opts
36
+ dispatch opts
37
+ else
38
+ show_default_help
39
+ end
35
40
  end
36
41
 
37
42
  #
@@ -77,6 +82,105 @@ module Gloo
77
82
  @engine.dictionary.show_keywords
78
83
  end
79
84
 
85
+ #
86
+ # Show default help.
87
+ # No parameters were given.
88
+ #
89
+ def show_default_help
90
+ data = "\n"
91
+ data << " Help Options:\n"
92
+ data << " ? objects (obj, o) \n"
93
+ data << " ? verbs (v) \n"
94
+ data << " ? settings (s) \n"
95
+ data << "\n For detailed documentation use the gloo website. \n"
96
+ data << "\n https://gloo.ecrane.us/doc/. \n\n"
97
+ @engine.log.show data
98
+ end
99
+
100
+ #
101
+ # Dispatch the help to the right place.
102
+ #
103
+ def dispatch( opts )
104
+ # return if dispatch_help_page( opts )
105
+
106
+ @engine.log.debug 'looking for help topic'
107
+ cmd = DISPATCH[ opts.to_sym ]
108
+ if cmd
109
+ @engine.log.debug 'found help command'
110
+ send cmd
111
+ else
112
+ report_help_error opts
113
+ end
114
+ end
115
+
116
+ #
117
+ # Show application settings.
118
+ #
119
+ def show_settings
120
+ @engine.settings.show
121
+ end
122
+
123
+ #
124
+ # Report an error with the inline help.
125
+ #
126
+ def report_help_error( opts )
127
+ @engine.err "#{HELP_NOT_FOUND_ERR} '#{opts}'"
128
+ end
129
+
130
+ #
131
+ # List the verbs
132
+ #
133
+ def show_verbs
134
+ data = "\n"
135
+ data << " Verbs (shortcut, name)\n".blue
136
+ data << "#{get_verbs}\n\n"
137
+ @engine.log.show data
138
+ end
139
+
140
+ #
141
+ # List the object types
142
+ #
143
+ def show_objs
144
+ data = "\n"
145
+ data << " Objects \n".blue
146
+ data << "#{get_objects}\n\n"
147
+ @engine.log.show data
148
+ end
149
+
150
+ #
151
+ # Get the text for the list of verbs.
152
+ #
153
+ def get_verbs
154
+ str = ''
155
+ verbs = @engine.dictionary.get_verbs.sort_by( &:keyword )
156
+ verbs.each_with_index do |v, i|
157
+ cut = v.keyword_shortcut.ljust( 5, ' ' ).yellow
158
+ name = v.keyword.ljust( 20, ' ' ).white
159
+ str << " #{cut} #{name} \n"
160
+ end
161
+
162
+ return str
163
+ end
164
+
165
+ #
166
+ # Get the text for the list of objects.
167
+ #
168
+ def get_objects
169
+ str = ''
170
+ objs = @engine.dictionary.get_obj_types.sort_by( &:typename )
171
+ objs.each_with_index do |o, i|
172
+ if o.short_typename != o.typename
173
+ short = "(#{o.short_typename})".yellow
174
+ name = "#{o.typename.white} #{short}"
175
+ else
176
+ name = o.typename.white
177
+ end
178
+ str << " #{name.ljust( 30, ' ' )}\n"
179
+ end
180
+
181
+ return str
182
+ end
183
+
80
184
  end
81
185
  end
82
186
  end
@@ -18,9 +18,11 @@ module Gloo
18
18
  def run
19
19
  levels = determine_levels
20
20
  target = self.determine_target
21
+ indent = self.determine_indent
22
+
21
23
  obj = target.resolve
22
24
  if obj
23
- show_target( obj, levels )
25
+ show_target( obj, levels, indent )
24
26
  else
25
27
  @engine.err "#{TARGET_MISSING_ERR} #{target}"
26
28
  end
@@ -63,7 +65,7 @@ module Gloo
63
65
  return if levels.zero?
64
66
 
65
67
  obj.children.each do |o|
66
- show_target( o, levels - 1, "#{indent} " )
68
+ show_target( o, levels - 1, "#{indent}#{determine_indent}" )
67
69
  end
68
70
  end
69
71
 
@@ -72,12 +74,17 @@ module Gloo
72
74
  #
73
75
  def show_obj( obj, indent = ' ' )
74
76
  if obj.multiline_value? && obj.value_is_array?
75
- @engine.log.show "#{indent}#{obj.name} [#{obj.type_display}] :"
77
+ str = "#{indent}#{obj.name}".white
78
+ str << " [#{obj.type_display}] : ".yellow
79
+ @engine.log.show str
76
80
  obj.value.each do |line|
77
81
  @engine.log.show "#{indent} #{line}"
78
82
  end
79
83
  else
80
- @engine.log.show "#{indent}#{obj.name} [#{obj.type_display}] : #{obj.value}"
84
+ str = "#{indent}#{obj.name}".white
85
+ str << " [#{obj.type_display}] : ".yellow
86
+ str << "#{obj.value}"
87
+ @engine.log.show str
81
88
  end
82
89
  end
83
90
 
@@ -86,13 +93,27 @@ module Gloo
86
93
  #
87
94
  def determine_levels
88
95
  # Check settings for the default value.
89
- levels = @engine.settings.list_indent
96
+ levels = @engine.settings.list_levels
90
97
  return levels if levels
91
98
 
92
99
  # Last chance: use the default
93
100
  return 1
94
101
  end
95
102
 
103
+ #
104
+ # Determine the level of indentation in the outline.
105
+ #
106
+ def determine_indent
107
+ # Check settings for the default value.
108
+ indent = @engine.settings.list_indent
109
+ if indent
110
+ return ( ' ' * indent )
111
+ end
112
+
113
+ # Last chance: use the default
114
+ return 2
115
+ end
116
+
96
117
  end
97
118
  end
98
119
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gloo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Crane
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-24 00:00:00.000000000 Z
11
+ date: 2023-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler