lib/fcb.rb in markdown_exec-2.5.0 vs lib/fcb.rb in markdown_exec-2.6.0
- old
+ new
@@ -62,11 +62,12 @@
# @return [Object] The modified functional code block with updated
# summary attributes.
def for_menu!(
block_calls_scan: @delegate_object[:block_calls_scan],
block_name_match: @delegate_object[:block_name_match],
- block_name_nick_match: @delegate_object[:block_name_nick_match]
+ block_name_nick_match: @delegate_object[:block_name_nick_match],
+ id: ''
)
call = @attrs[:call] = @attrs[:start_line]&.match(
Regexp.new(block_calls_scan)
)&.fetch(1, nil)
titlexcall = call ? @attrs[:title].sub("%#{call}", '') : @attrs[:title]
@@ -81,11 +82,11 @@
block_name_match
)
bm && bm[1] ? bm[:title] : titlexcall
end
@attrs[:title] = @attrs[:oname] = oname
-
+ @attrs[:id] = id
@attrs[:dname] = HashDelegator.indent_all_lines(
(yield oname, BLOCK_TYPE_COLOR_OPTIONS[@attrs[:type]]),
@attrs[:indent]
)
end
@@ -105,21 +106,14 @@
# :reek:ManualDispatch
def method_missing(method, *args, &block)
method_name = method.to_s
if @attrs.respond_to?(method_name)
-if method_name == 'fetch'
- ww args[0]
-end
@attrs.send(method_name, *args, &block)
elsif method_name[-1] == '='
-# ww caller.take(3) if method_name == 'label='
-ww method_name
@attrs[method_name.chop.to_sym] = args[0]
else
-# ww caller.take(3) if method_name == 'label'
-ww method_name
@attrs[method_name.to_sym]
end
rescue StandardError => err
warn("ERROR ** FCB.method_missing(method: #{method_name}," \
" *args: #{args.inspect}, &block)")
@@ -156,23 +150,25 @@
def to_yaml
@attrs.to_yaml
end
- # Expand in body and dname
- def variable_expansion!(pattern, replacement_dictionary)
+ # Expand variables in `dname` and `body` attributes
+ def expand_variables_in_attributes!(pattern, replacements)
### update name, nickname, title, label ???
- @attrs[:dname] = @attrs[:dname].gsub(pattern) { |match|
- replacement_dictionary[match]
- }
+
+ # Replace variables in `dname` using the replacements dictionary
+ @attrs[:dname] = @attrs[:dname].gsub(pattern) do |match|
+ replacements[match]
+ end
+
+ # Replace variables in each line of `body` if `body` is present
if @attrs[:body]
@attrs[:body] = @attrs[:body].map do |line|
if line.empty?
line
else
- line.gsub(pattern) do |match|
- replacement_dictionary[match]
- end
+ line.gsub(pattern) { |match| replacements[match] }
end
end
end
end
end