From e0b3861834a6dcef8d2c10df52a5797e247ad24f Mon Sep 17 00:00:00 2001 From: Samuel Cochran Date: Sat, 9 Dec 2023 14:13:37 +1100 Subject: [PATCH] Append the array contents, not the array itself Without this, lines becomes: ``` [ ..., "\n", "\n", [ "template line 1\n", "template line 2\n", ... ], "\n", "\n", ... ] ``` Then subsequent replacements fail because they choke on the array in the middle. Like: ``` .../schema_dev-4.2.0/lib/schema_dev/readme.rb:68:in `!~': undefined method `=~' for ["As usual:\n", "\n", "```ruby\n", "gem \"<%= gem_name %>\" # in a Gemfile\n", "gem.add_dependency \"<%= gem_name %>\" # in a .gemspec\n", "```\n"]:Array (NoMethodError) before = lines.take_while { |line| line !~ pattern } ^^ from .../schema_dev-4.2.0/lib/schema_dev/readme.rb:68:in `block in replace_block' ``` After this change: ``` [ ..., "\n", "\n", "template line 1\n", "template line 2\n", ..., "\n", "\n", ... ] ``` --- lib/schema_dev/readme.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/schema_dev/readme.rb b/lib/schema_dev/readme.rb index 254705e..09f4521 100644 --- a/lib/schema_dev/readme.rb +++ b/lib/schema_dev/readme.rb @@ -58,7 +58,7 @@ def sub_template(template, lines) replace_block(lines, %r{^\s*\n" contents << "\n" - contents << template.readlines + contents.concat template.readlines contents << "\n" contents << "\n" end