Skip to content

Commit e0b3861

Browse files
committed
Append the array contents, not the array itself
Without this, lines becomes: ``` [ ..., "<!-- SCHEMA_DEV: TEMPLATE #{key} - begin -->\n", "<!-- These lines are auto-inserted from a schema_dev template -->\n", [ "template line 1\n", "template line 2\n", ... ], "\n", "<!-- SCHEMA_DEV: TEMPLATE #{key} - end -->\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: ``` [ ..., "<!-- SCHEMA_DEV: TEMPLATE #{key} - begin -->\n", "<!-- These lines are auto-inserted from a schema_dev template -->\n", "template line 1\n", "template line 2\n", ..., "\n", "<!-- SCHEMA_DEV: TEMPLATE #{key} - end -->\n", ... ] ```
1 parent 014d579 commit e0b3861

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/schema_dev/readme.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def sub_template(template, lines)
5858
replace_block(lines, %r{^\s*<!-- SCHEMA_DEV: TEMPLATE #{key}}) do |contents|
5959
contents << "<!-- SCHEMA_DEV: TEMPLATE #{key} - begin -->\n"
6060
contents << "<!-- These lines are auto-inserted from a schema_dev template -->\n"
61-
contents << template.readlines
61+
contents.concat template.readlines
6262
contents << "\n"
6363
contents << "<!-- SCHEMA_DEV: TEMPLATE #{key} - end -->\n"
6464
end

0 commit comments

Comments
 (0)