Skip to content

Commit

Permalink
Fix indentation in generated plugin version file
Browse files Browse the repository at this point in the history
The `plugin/create.rb` tests that passed a block to the `#create_plugin`
helper method weren't executing properly, as the blocks weren't actually
called.

When they were re-enabled, test that checked `version.rb` was failing,
with extra blank lines inserted between the code.
  • Loading branch information
gma committed Jan 16, 2025
1 parent 433a723 commit 98116a2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.19.0 (Unreleased)

* Fix whitespace in version.rb when generating new plugins. (Graham Ashton)

## 0.18.0 (19 November 2024)

* Update Sinatra to 4.1, to fix a vulnerability.
Expand Down
6 changes: 3 additions & 3 deletions lib/nesta/commands/plugin/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ def module_name
def nested_module_definition_with_version
indent_with = ' '

lines = module_names.map { |name| "module #{name}\n" }
lines = module_names.map { |name| "module #{name}" }
indent_levels = 0.upto(module_names.size - 1).to_a

lines << "VERSION = '0.1.0'\n"
lines << "VERSION = '0.1.0'"
indent_levels << module_names.size

(module_names.size - 1).downto(0).each do |indent_level|
lines << "end\n"
lines << 'end'
indent_levels << indent_level
end

Expand Down
2 changes: 1 addition & 1 deletion templates/plugins/lib/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Nesta
module Plugin
<%= nested_module_definition_with_version -%>
<%= nested_module_definition_with_version %>
end
end
1 change: 1 addition & 0 deletions test/integration/commands/plugin/create_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def create_plugin(&block)
Dir.chdir(working_directory) do
command = Nesta::Commands::Plugin::Create.new(plugin_name)
command.execute(process_stub)
block.call
end
end

Expand Down

0 comments on commit 98116a2

Please sign in to comment.