markdown_exec 1.3.1 → 1.3.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/menu.yml CHANGED
@@ -1,4 +1,4 @@
1
- # MDE - Markdown Executor (1.3.1)
1
+ # MDE - Markdown Executor (1.3.3.1)
2
2
  ---
3
3
  - :arg_name: NAME
4
4
  :compreply: false
@@ -101,6 +101,12 @@
101
101
  :long_name: pwd
102
102
  :opt_name: pwd
103
103
  :procname: val_as_bool
104
+ - :arg_name: BOOL
105
+ :default: false
106
+ :description: Display only blocks of type "bash"
107
+ :env_var: MDE_BASH_ONLY
108
+ :opt_name: bash_only
109
+ :procname: val_as_bool
104
110
  - :arg_name: INT.0-3
105
111
  :default: 1
106
112
  :description: Output display level (0 to 3 [data, +context, +info])
@@ -108,6 +114,32 @@
108
114
  :long_name: display-level
109
115
  :opt_name: display_level
110
116
  :procname: val_as_int
117
+ - :arg_name: REGEX
118
+ :default:
119
+ :description: Exclude blocks with name matching
120
+ :env_var: MDE_EXCLUDE_BY_NAME_REGEX
121
+ :opt_name: exclude_by_name_regex
122
+ :procname: val_as_str
123
+ - :arg_name: REGEX
124
+ :default:
125
+ :description: Exclude blocks with shell matching
126
+ :env_var: MDE_EXCLUDE_BY_SHELL_REGEX
127
+ :opt_name: exclude_by_shell_regex
128
+ :procname: val_as_str
129
+ - :arg_name: BOOL
130
+ :default: true
131
+ :description: Hide all blocks of type "expect"
132
+ :env_var: MDE_EXCLUDE_EXPECT_BLOCKS
133
+ :opt_name: exclude_expect_blocks
134
+ :procname: val_as_bool
135
+ - :arg_name: BOOL
136
+ :default: true
137
+ :description: |-
138
+ Exclude blocks with name matching expression " \
139
+ "`block_name_hidden_match`
140
+ :env_var: MDE_HIDE_BLOCKS_BY_NAME
141
+ :opt_name: hide_blocks_by_name
142
+ :procname: val_as_bool
111
143
  - :arg_name: INT.1-
112
144
  :default: 32
113
145
  :description: Max. items to return in list
@@ -133,6 +165,18 @@
133
165
  :env_var: MDE_MENU_BLOCKS_WITH_HEADINGS
134
166
  :opt_name: menu_blocks_with_headings
135
167
  :procname: val_as_bool
168
+ - :arg_name: BOOL
169
+ :default: true
170
+ :description: Display Exit option at top of menu
171
+ :env_var: MDE_MENU_EXIT_AT_TOP
172
+ :opt_name: menu_exit_at_top
173
+ :procname: val_as_bool
174
+ - :arg_name: BOOL
175
+ :default: true
176
+ :description: Display Exit option in menu
177
+ :env_var: MDE_MENU_WITH_EXIT
178
+ :opt_name: menu_with_exit
179
+ :procname: val_as_bool
136
180
  - :arg_name: BOOL
137
181
  :default: false
138
182
  :description: Display summary for execution
@@ -140,6 +184,12 @@
140
184
  :long_name: output-execution-summary
141
185
  :opt_name: output_execution_summary
142
186
  :procname: val_as_bool
187
+ - :arg_name: BOOL
188
+ :default: false
189
+ :description: Output saved script filename at end of execution
190
+ :env_var: MDE_OUTPUT_SAVED_SCRIPT_FILENAME
191
+ :opt_name: output_saved_script_filename
192
+ :procname: val_as_bool
143
193
  - :arg_name: BOOL
144
194
  :default: false
145
195
  :description: Display script prior to execution
@@ -206,6 +256,18 @@
206
256
  :env_var: MDE_SAVED_STDOUT_GLOB
207
257
  :opt_name: saved_stdout_glob
208
258
  :procname: val_as_str
259
+ - :arg_name: REGEX
260
+ :default:
261
+ :description: Select blocks with name matching
262
+ :env_var: MDE_SELECT_BY_NAME_REGEX
263
+ :opt_name: select_by_name_regex
264
+ :procname: val_as_str
265
+ - :arg_name: REGEX
266
+ :default:
267
+ :description: Select blocks with shell matching
268
+ :env_var: MDE_SELECT_BY_SHELL_REGEX
269
+ :opt_name: select_by_shell_regex
270
+ :procname: val_as_str
209
271
  - :default: "^[\\(\\[].*[\\)\\]]$"
210
272
  :description: Pattern for blocks to hide from user-selection
211
273
  :env_var: MDE_BLOCK_NAME_HIDDEN_MATCH
@@ -223,11 +285,11 @@
223
285
  :env_var: MDE_BLOCK_REQUIRED_SCAN
224
286
  :opt_name: block_required_scan
225
287
  :procname: val_as_str
226
- - :default: "<(?<full>(?<type>\\$)?(?<name>[A-Za-z]\\S*))"
288
+ - :default: "<(?<full>(?<type>\\$)?(?<name>[A-Za-z_\\-\\.\\w]+))"
227
289
  :env_var: MDE_BLOCK_STDIN_SCAN
228
290
  :opt_name: block_stdin_scan
229
291
  :procname: val_as_str
230
- - :default: ">(?<full>(?<type>\\$)?(?<name>[A-Za-z]\\S*))"
292
+ - :default: ">(?<full>(?<type>\\$)?(?<name>[A-Za-z_\\-\\.\\w]+))"
231
293
  :env_var: MDE_BLOCK_STDOUT_SCAN
232
294
  :opt_name: block_stdout_scan
233
295
  :procname: val_as_str
@@ -239,7 +301,7 @@
239
301
  :env_var: MDE_FENCED_START_AND_END_MATCH
240
302
  :opt_name: fenced_start_and_end_match
241
303
  :procname: val_as_str
242
- - :default: "^`{3,}(?<shell>[^`\\s]*) *(?<name>.*)$"
304
+ - :default: "^`{3,}(?<shell>[^`\\s]*) *:?(?<name>[^\\s]*) *(?<rest>.*) *$"
243
305
  :env_var: MDE_FENCED_START_EX_MATCH
244
306
  :opt_name: fenced_start_ex_match
245
307
  :procname: val_as_str
@@ -255,6 +317,10 @@
255
317
  :env_var: MDE_HEADING3_MATCH
256
318
  :opt_name: heading3_match
257
319
  :procname: val_as_str
320
+ - :default: "^ *@import (.+)$"
321
+ :env_var: MDE_IMPORT_PATTERN
322
+ :opt_name: import_pattern
323
+ :procname: val_as_str
258
324
  - :default: "*.[Mm][Dd]"
259
325
  :env_var: MDE_MD_FILENAME_GLOB
260
326
  :opt_name: md_filename_glob
@@ -1,7 +1,21 @@
1
+ #!/usr/bin/env ruby
1
2
  # frozen_string_literal: true
2
3
 
3
4
  # encoding=utf-8
4
5
 
6
+ # version 2023-10-02
7
+
8
+ require 'bundler/setup'
9
+ Bundler.require(:default)
10
+
11
+ class FalseClass
12
+ unless defined?(blank?)
13
+ def present?
14
+ true
15
+ end
16
+ end
17
+ end
18
+
5
19
  # is the value empty?
6
20
  #
7
21
  class String
@@ -22,7 +36,6 @@ class String
22
36
  end
23
37
  end
24
38
 
25
-
26
39
  # is the value a non-empty string or a binary?
27
40
  #
28
41
  # :reek:ManualDispatch ### temp
@@ -38,3 +51,33 @@ class Object
38
51
  end
39
52
  end
40
53
  end
54
+
55
+ if $PROGRAM_NAME == __FILE__
56
+ require 'minitest/autorun'
57
+
58
+ class TestStringMethods < Minitest::Test
59
+ def test_blank
60
+ assert "".blank?
61
+ assert " ".blank?
62
+ assert "\t\n\r".blank?
63
+ refute "foo".blank?
64
+ end
65
+
66
+ def test_present
67
+ assert "foo".present?
68
+ refute "".present?
69
+ end
70
+ end
71
+
72
+ class TestObjectMethods < Minitest::Test
73
+ def test_present
74
+ assert "foo".present?
75
+ refute "".present?
76
+ assert Object.new.present?
77
+ assert 123.present?
78
+ assert true.present?
79
+ assert false.present?
80
+ refute nil.present?
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ # output standard header for file load during testing
4
+ #
5
+ def spec_source(file, env_var_name = 'SPEC_DEBUG')
6
+ if (->(val) { val.nil? ? false : !(val.empty? || val == '0') })
7
+ .call(ENV.fetch(env_var_name, nil))
8
+ puts "#{env_var_name}: #{file}"
9
+ end
10
+ end
data/lib/tap.rb CHANGED
@@ -5,12 +5,44 @@
5
5
  require 'json'
6
6
  require 'yaml'
7
7
 
8
- require_relative 'env'
9
- include Env
8
+ # is the value a non-empty string or a binary?
9
+ #
10
+ # :reek:ManualDispatch ### temp
11
+ class Object
12
+ unless defined?(present?)
13
+ def present?
14
+ case self.class.to_s
15
+ when 'FalseClass', 'TrueClass'
16
+ true
17
+ else
18
+ self && (!respond_to?(:empty?) || !empty?)
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ unless defined?(Env)
25
+ # utility functions to read environment variables
26
+ #
27
+ module Env
28
+ # :reek:UtilityFunction
29
+ def env_int(name, default: 0)
30
+ return default if name.nil? || (val = ENV.fetch(name, nil)).nil?
31
+ return default if val.empty?
32
+
33
+ val.to_i
34
+ end
35
+ end
36
+ end
37
+
38
+ # rubocop:disable Metrics/ParameterLists
10
39
 
11
40
  ## application-level debug control
12
41
  #
42
+ # :reek:TooManyConstants
13
43
  module Tap
44
+ include Env
45
+
14
46
  DN = 'return'
15
47
  NONE = 0x0
16
48
  T1 = 1 # RESULT
@@ -45,6 +77,8 @@ module Tap
45
77
  $tap_enable = false
46
78
  $tap_mask = ALL2
47
79
 
80
+ # :reek:BooleanParameter
81
+ # :reek:ControlParameter
48
82
  def tap_config(enable: true, envvar: nil, value: nil)
49
83
  $tap_enable = false
50
84
  if envvar
@@ -59,39 +93,69 @@ module Tap
59
93
  end
60
94
  # puts "$tap_enable: #{$tap_enable}"
61
95
  # puts "$tap_mask: #{$tap_mask.to_s(2)}"
96
+ self
62
97
  end
63
98
 
64
- def tap_inspect(name_ = nil, caller0: nil, mask: TDD, name: DN, source: nil, type: nil)
99
+ # :reek:ControlParameter
100
+ # :reek:LongParameterList
101
+ def tap_inspect(name_ = nil, caller_first: nil, mask: TDD, name: DN, source: nil,
102
+ type: nil)
65
103
  return self unless $tap_enable
66
104
  return self unless (mask & $tap_mask).positive?
67
105
 
68
106
  fn = CVT.fetch(type, CVT[:else])
69
107
  outs = []
70
- outs.push("#{source}") if source
71
- outs.push("#{(caller0 || caller[0]).scan(/in `?(\S+)'$/)[0][0]}()") # if (mask & $tap_mask & TP).positive?
72
- outs.push("#{name_ || name}: #{method(fn).call}") # if (mask & $tap_mask & TD).positive?
73
- puts outs.join(' ') if outs.length.positive?
108
+ outs.push(source.to_s) if source.present?
74
109
 
110
+ vs = (caller_first || caller[0]).scan(/in `?(\S+)'$/).fetch(0, []).fetch(0, '')
111
+ outs.push("#{vs}()") if vs.present?
112
+
113
+ outs.push(tap_named_value(name_ || name, method(fn).call))
114
+
115
+ $stdout.puts(outs.join(' ')) if outs.length.positive?
75
116
  self
76
117
  end
77
118
 
78
119
  def tap_print(mask: TDD)
120
+ return self unless $tap_enable
79
121
  return self unless (mask & $tap_mask).positive?
80
122
 
81
- print self
123
+ $stdout.print self
124
+ self
82
125
  end
83
126
 
84
- def tap_puts(name_ = nil, caller0: nil, mask: TDD, name: nil, type: nil)
85
- # return self unless (mask & $tap_mask).positive?
127
+ def tap_pry
128
+ return self unless $tap_enable
86
129
 
87
- if (name1 = name_ || name).present?
88
- puts "#{name1}: #{self}"
89
- else
90
- puts self
91
- end
130
+ binding.pry
131
+ self
132
+ end
133
+
134
+ # :reek:ControlParameter
135
+ def tap_puts(name_ = nil, mask: TDD, name: nil)
136
+ return self unless $tap_enable
137
+ return self unless (mask & $tap_mask).positive?
138
+
139
+ $stdout.puts tap_named_value(name_ || name, self)
140
+ self
141
+ end
142
+
143
+ # :reek:ControlParameter
144
+ # :reek:LongParameterList
145
+ def tap_yaml(name_ = nil, caller_first: nil, mask: TDD, name: DN, source: nil)
146
+ tap_inspect name_, caller_first: (caller_first || caller[0]),
147
+ mask: mask, name: name, source: source, type: :yaml
92
148
  end
93
149
 
94
- def tap_yaml(name_ = nil, caller0: nil, mask: TDD, name: DN, source: nil)
95
- tap_inspect name_, caller0: (caller0 || caller[0]), mask: mask, name: name, source: source, type: :yaml
150
+ private
151
+
152
+ def tap_named_value(name, value)
153
+ if name.present?
154
+ "#{name}: #{value}"
155
+ else
156
+ value.to_s
157
+ end
96
158
  end
97
159
  end
160
+
161
+ # rubocop:enable Metrics/ParameterLists
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown_exec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fareed Stevenson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-29 00:00:00.000000000 Z
11
+ date: 2023-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
@@ -110,15 +110,17 @@ files:
110
110
  - bin/setup
111
111
  - bin/tab_completion.sh
112
112
  - bin/tab_completion.sh.erb
113
+ - lib/cached_nested_file_reader.rb
113
114
  - lib/cli.rb
114
115
  - lib/colorize.rb
115
116
  - lib/env.rb
117
+ - lib/env_opts.rb
116
118
  - lib/environment_opt_parse.rb
117
- - lib/globfiles.rb
118
119
  - lib/markdown_exec.rb
119
120
  - lib/markdown_exec/version.rb
120
121
  - lib/menu.yml
121
122
  - lib/object_present.rb
123
+ - lib/rspec_helpers.rb
122
124
  - lib/shared.rb
123
125
  - lib/tap.rb
124
126
  homepage: https://rubygems.org/gems/markdown_exec
data/lib/globfiles.rb DELETED
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # encoding=utf-8
4
-
5
- # require 'json'
6
- # require 'yaml'
7
-
8
- # require_relative 'env'
9
- # include Env
10
-
11
- ## directory listing of saved files matching glob
12
- #
13
- class Globfiles
14
- def initialize(folder, glob)
15
- @folder = folder
16
- @glob = glob
17
- end
18
-
19
- def list_all
20
- Dir.glob(File.join(@folder, @glob)).tap_inspect
21
- end
22
-
23
- ## single most recent item
24
- #
25
- def most_recent(arr = nil)
26
- arr = list_all if arr.nil?
27
- return if arr.count < 1
28
-
29
- arr.max.tap_inspect
30
- end
31
-
32
- ## multiple recent items
33
- #
34
- def most_recent_list(list_count, arr = nil)
35
- arr = list_all if arr.nil?
36
- return if (ac = arr.count) < 1
37
-
38
- arr.sort[-[ac, list_count].min..].reverse.tap_inspect
39
- end
40
- end # class Globfiles