markdown_exec 1.3.8 → 1.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +41 -2
- data/Gemfile +1 -0
- data/Gemfile.lock +5 -1
- data/Rakefile +11 -7
- data/bin/colorize_env_vars.sh +7 -0
- data/bin/tab_completion.sh +19 -19
- data/examples/duplicate_block.md +10 -0
- data/examples/import0.md +8 -0
- data/examples/import1.md +10 -0
- data/examples/include.md +12 -0
- data/examples/infile_config.md +10 -0
- data/examples/linked1.md +28 -0
- data/examples/linked2.md +28 -0
- data/examples/opts.md +13 -0
- data/examples/pass-through.md +14 -0
- data/examples/plant.md +23 -0
- data/examples/port.md +23 -0
- data/examples/vars.md +20 -0
- data/examples/wrap.md +33 -0
- data/lib/block_types.rb +5 -0
- data/lib/cached_nested_file_reader.rb +0 -1
- data/lib/colorize.rb +37 -23
- data/lib/fcb.rb +12 -30
- data/lib/filter.rb +13 -9
- data/lib/markdown_exec/version.rb +1 -1
- data/lib/markdown_exec.rb +488 -249
- data/lib/mdoc.rb +73 -53
- data/lib/menu.src.yml +323 -267
- data/lib/menu.yml +324 -268
- metadata +17 -6
- data/lib/env_opts.rb +0 -242
- data/lib/markdown_block_manager.rb +0 -64
- data/lib/menu_options.rb +0 -0
- data/lib/menu_options.yml +0 -0
data/lib/fcb.rb
CHANGED
@@ -18,7 +18,9 @@ module MarkdownExec
|
|
18
18
|
body: nil,
|
19
19
|
call: nil,
|
20
20
|
headings: [],
|
21
|
+
dname: nil,
|
21
22
|
name: nil,
|
23
|
+
oname: nil,
|
22
24
|
reqs: [],
|
23
25
|
shell: '',
|
24
26
|
title: '',
|
@@ -27,39 +29,9 @@ module MarkdownExec
|
|
27
29
|
}.merge(options)
|
28
30
|
end
|
29
31
|
|
30
|
-
def to_h
|
31
|
-
@attrs
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_yaml
|
35
|
-
@attrs.to_yaml
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
# 2023-10-07 proposed but not functional with code
|
41
|
-
#
|
42
|
-
# def method_missing(method, *args, &block)
|
43
|
-
# method_name = method.to_s
|
44
|
-
|
45
|
-
# if method_name[-1] == '='
|
46
|
-
# @attrs[method_name.chop.to_sym] = args[0]
|
47
|
-
# elsif @attrs.key?(method_name.to_sym)
|
48
|
-
# @attrs[method_name.to_sym]
|
49
|
-
# else
|
50
|
-
# super
|
51
|
-
# end
|
52
|
-
# rescue StandardError => err
|
53
|
-
# warn(error = "ERROR ** FCB.method_missing(method: #{method_name}, *args: #{args.inspect}, &block)")
|
54
|
-
# warn err.inspect
|
55
|
-
# warn(caller[0..4])
|
56
|
-
# raise err # Here, we simply propagate the original error instead of wrapping it in a StandardError.
|
57
|
-
# end
|
58
|
-
|
59
32
|
# :reek:ManualDispatch
|
60
33
|
def method_missing(method, *args, &block)
|
61
34
|
method_name = method.to_s
|
62
|
-
|
63
35
|
if @attrs.respond_to?(method_name)
|
64
36
|
@attrs.send(method_name, *args, &block)
|
65
37
|
elsif method_name[-1] == '='
|
@@ -79,6 +51,14 @@ module MarkdownExec
|
|
79
51
|
def respond_to_missing?(method_name, _include_private = false)
|
80
52
|
@attrs.key?(method_name.to_sym) || super
|
81
53
|
end
|
54
|
+
|
55
|
+
def to_h
|
56
|
+
@attrs
|
57
|
+
end
|
58
|
+
|
59
|
+
def to_yaml
|
60
|
+
@attrs.to_yaml
|
61
|
+
end
|
82
62
|
end
|
83
63
|
end
|
84
64
|
|
@@ -92,7 +72,9 @@ if $PROGRAM_NAME == __FILE__
|
|
92
72
|
body: 'Sample body',
|
93
73
|
call: 'Sample call',
|
94
74
|
headings: %w[Header1 Header2],
|
75
|
+
dname: 'Sample name',
|
95
76
|
name: 'Sample name',
|
77
|
+
oname: 'Sample name',
|
96
78
|
reqs: %w[req1 req2],
|
97
79
|
shell: 'bash',
|
98
80
|
text: 'Sample Text',
|
data/lib/filter.rb
CHANGED
@@ -35,10 +35,10 @@ module MarkdownExec
|
|
35
35
|
wrap_name: nil
|
36
36
|
}
|
37
37
|
|
38
|
-
name = fcb.
|
38
|
+
name = fcb.oname
|
39
39
|
shell = fcb.fetch(:shell, '')
|
40
40
|
|
41
|
-
apply_name_filters(options, filters, name)
|
41
|
+
apply_name_filters(options, filters, name) #if shell == 'bash'
|
42
42
|
apply_shell_filters(options, filters, shell)
|
43
43
|
apply_other_filters(options, filters, fcb)
|
44
44
|
|
@@ -107,7 +107,7 @@ module MarkdownExec
|
|
107
107
|
# @param fcb [Hash] The fenced code block to be evaluated.
|
108
108
|
#
|
109
109
|
def self.apply_other_filters(options, filters, fcb)
|
110
|
-
name = fcb.
|
110
|
+
name = fcb.oname
|
111
111
|
shell = fcb.fetch(:shell, '')
|
112
112
|
filters[:fcb_chrome] = fcb.fetch(:chrome, false)
|
113
113
|
|
@@ -166,13 +166,17 @@ if $PROGRAM_NAME == __FILE__
|
|
166
166
|
require 'bundler/setup'
|
167
167
|
Bundler.require(:default)
|
168
168
|
|
169
|
+
require 'fcb'
|
169
170
|
require 'minitest/autorun'
|
170
171
|
|
171
172
|
module MarkdownExec
|
172
173
|
class FilterTest < Minitest::Test
|
173
174
|
def setup
|
174
175
|
@options = {}
|
175
|
-
@fcb =
|
176
|
+
@fcb = FCB.new(
|
177
|
+
dname: nil,
|
178
|
+
oname: nil
|
179
|
+
)
|
176
180
|
end
|
177
181
|
|
178
182
|
# Tests for fcb_select? method
|
@@ -191,27 +195,27 @@ if $PROGRAM_NAME == __FILE__
|
|
191
195
|
def test_hidden_name_condition
|
192
196
|
@options[:hide_blocks_by_name] = true
|
193
197
|
@options[:block_name_hidden_match] = 'hidden'
|
194
|
-
@fcb[:
|
198
|
+
@fcb[:oname] = 'hidden_block'
|
195
199
|
refute Filter.fcb_select?(@options, @fcb)
|
196
200
|
end
|
197
201
|
|
198
202
|
def test_include_name_condition
|
199
203
|
@options[:hide_blocks_by_name] = true
|
200
204
|
@options[:block_name_indlude_match] = 'include'
|
201
|
-
@fcb[:
|
205
|
+
@fcb[:oname] = 'include_block'
|
202
206
|
assert Filter.fcb_select?(@options, @fcb)
|
203
207
|
end
|
204
208
|
|
205
209
|
def test_wrap_name_condition
|
206
210
|
@options[:hide_blocks_by_name] = true
|
207
211
|
@options[:block_name_wrapper_match] = 'wrap'
|
208
|
-
@fcb[:
|
212
|
+
@fcb[:oname] = 'wrap_block'
|
209
213
|
assert Filter.fcb_select?(@options, @fcb)
|
210
214
|
end
|
211
215
|
|
212
216
|
def test_name_exclude_condition
|
213
217
|
@options[:block_name] = 'test'
|
214
|
-
@fcb[:
|
218
|
+
@fcb[:oname] = 'sample'
|
215
219
|
refute Filter.fcb_select?(@options, @fcb)
|
216
220
|
end
|
217
221
|
|
@@ -223,7 +227,7 @@ if $PROGRAM_NAME == __FILE__
|
|
223
227
|
|
224
228
|
def test_name_select_condition
|
225
229
|
@options[:select_by_name_regex] = 'select'
|
226
|
-
@fcb[:
|
230
|
+
@fcb[:oname] = 'select_this'
|
227
231
|
assert Filter.fcb_select?(@options, @fcb)
|
228
232
|
end
|
229
233
|
|