Skip to content

Commit

Permalink
Support newlines in .shot files
Browse files Browse the repository at this point in the history
Closes #101
  • Loading branch information
miharekar committed Feb 2, 2024
1 parent 866ff86 commit dd59c45
Show file tree
Hide file tree
Showing 3 changed files with 577 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/models/parsers/decent_tcl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def parse

EXTRA_DATA_CAPTURE.each do |name|
define_method(:"extract_setting_#{name}") do |data|
@extra[name] = handle_array(data).force_encoding("UTF-8")
@extra[name] = handle_array(data, smart_separator: true).force_encoding("UTF-8")
end
end

Expand Down Expand Up @@ -73,9 +73,11 @@ def extract_profile(data)
nil
end

def handle_array(data)
def handle_array(data, smart_separator: false)
return data unless data.is_a?(Array)

separator = smart_separator && data.first.is_a?(Array) ? "\n" : " "

data.map do |line|
next line unless line.is_a?(Array)

Expand All @@ -97,7 +99,7 @@ def handle_array(data)
end

line.join(" ")
end.join(" ")
end.join(separator)
end
end
end
Loading

0 comments on commit dd59c45

Please sign in to comment.