Skip to content

Commit ca0c2ce

Browse files
committed
Format generated Ruby hashes with spaces inside braces
1 parent 0e0b309 commit ca0c2ce

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

‎CLAUDE.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
## Design and style
1010
- Include `# frozen_string_literal: true` in Ruby files.
11+
- Always put spaces inside nonempty Ruby hash braces, including generated code: `{ post: model }`. Keep empty hashes as `{}`.
1112
- Use small Ruby blocks and explicit requires; keep classes in an application module.
1213
- Configure an absolute root and namespace, then call `App.boot!` after defining the app.
1314
- Controllers own data access, authorization, attribute assignment, and explicit multi-record transactions.

‎lib/mk_framework/generator/templates/README.md.erb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Each action has its own controller and handler.
1212
| DELETE | `/<%= config.resource %>/:id` | delete |
1313

1414
Create returns 201; the other actions return 200. Index returns
15-
`{<%= config.resource %>: [...]}`; member actions return `{<%= config.model_name %>: {...}}`,
15+
`{ <%= config.resource %>: [...] }`; member actions return `{ <%= config.model_name %>: { ... } }`,
1616
including the deleted record for DELETE. Missing records return 404.
1717

1818
## Setup

‎lib/mk_framework/generator/templates/handler.rb.erb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ module <%= config.namespace %>
77
r.response.status = 201
88
<% end -%>
99
<% if action == 'index' -%>
10-
{<%= config.resource %>: model.map { |record| record.slice(*<%= config.model_class %>.public_attributes_list) }}
10+
{ <%= config.resource %>: model.map { |record| record.slice(*<%= config.model_class %>.public_attributes_list) } }
1111
<% else -%>
12-
{<%= config.model_name %>: model.slice(*<%= config.model_class %>.public_attributes_list)}
12+
{ <%= config.model_name %>: model.slice(*<%= config.model_class %>.public_attributes_list) }
1313
<% end -%>
1414
end
1515
end

‎lib/mk_framework/generator/templates/request_spec.rb.erb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ RSpec.describe '<%= config.model_class %> CRUD' do
5757
expect(JSON.parse(response.body).fetch('<%= config.model_name %>')).to eq(record)
5858
end
5959

60-
<% updated_value = {'string' => 'Updated', 'text' => 'Updated text', 'integer' => 2, 'float' => 2.5, 'boolean' => true, 'date' => '2027-02-03', 'datetime' => '2027-02-03T14:30:00Z'}.fetch(config.fields.first[:type]) -%>
60+
<% updated_value = { 'string' => 'Updated', 'text' => 'Updated text', 'integer' => 2, 'float' => 2.5, 'boolean' => true, 'date' => '2027-02-03', 'datetime' => '2027-02-03T14:30:00Z' }.fetch(config.fields.first[:type]) -%>
6161
%w[patch put].each do |verb|
6262
it "updates permitted fields with #{verb.upcase}, preserving omitted fields and the ID" do
6363
record = create_record
64-
changes = {'<%= config.fields.first[:name] %>' => <%= updated_value.inspect %>, 'id' => 999}
64+
changes = { '<%= config.fields.first[:name] %>' => <%= updated_value.inspect %>, 'id' => 999 }
6565
response = client.public_send(verb, "/<%= config.resource %>/#{record.fetch('id')}",
6666
input: JSON.generate(changes), 'CONTENT_TYPE' => 'application/json')
6767
expect(response.status).to eq(200)

0 commit comments

Comments
 (0)