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.
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.fetch(:name, '')
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.fetch(:name, '')
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[:name] = 'hidden_block'
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[:name] = 'include_block'
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[:name] = 'wrap_block'
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[:name] = 'sample'
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[:name] = 'select_this'
230
+ @fcb[:oname] = 'select_this'
227
231
  assert Filter.fcb_select?(@options, @fcb)
228
232
  end
229
233
 
@@ -7,5 +7,5 @@ module MarkdownExec
7
7
  BIN_NAME = 'mde'
8
8
  GEM_NAME = 'markdown_exec'
9
9
  TAP_DEBUG = 'MDE_DEBUG'
10
- VERSION = '1.3.8'
10
+ VERSION = '1.3.9'
11
11
  end