Skip to content

Commit 6c2d4ae

Browse files
committed
fixes
1 parent f0bd4fd commit 6c2d4ae

File tree

9 files changed

+29
-27
lines changed

9 files changed

+29
-27
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ gem "dry-system", github: "dry-rb/dry-system", branch: "main"
2020

2121
gem "rack"
2222

23-
# gem "mysql2"
23+
gem "mysql2"
2424
gem "pg"
2525
gem "sqlite3"
2626

lib/hanami/cli/commands/app/db/migrate.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Migrate < DB::Command
1212
option :gateway, required: false, desc: "Use database for gateway"
1313
option :target, desc: "Target migration number", aliases: ["-t"]
1414
option :dump, required: false, type: :boolean, default: true,
15-
desc: "Dump the database structure after migrating"
15+
desc: "Dump the database structure after migrating"
1616

1717
def call(target: nil, app: false, slice: nil, gateway: nil, dump: true, command_exit: method(:exit), **)
1818
databases(app: app, slice: slice, gateway: gateway).each do |database|

lib/hanami/cli/commands/app/db/utils/postgres.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ def schema_migrations_sql_dump
5858
migrations_sql = super
5959
return unless migrations_sql
6060

61+
6162
search_path = gateway.connection
6263
.fetch("SHOW search_path").to_a.first
6364
.fetch(:search_path)
6465

65-
"SET search_path TO #{search_path};\n\n" << migrations_sql
66+
+"SET search_path TO #{search_path};\n\n" << migrations_sql
6667
end
6768

6869
private

lib/hanami/cli/commands/app/db/utils/sqlite.rb

+8-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def exec_create_command
3838
def exec_drop_command
3939
begin
4040
File.unlink(file_path) if exists?
41-
rescue StandardError => e
41+
rescue => e
4242
# Mimic a system_call result
4343
return Failure.new(e.message)
4444
end
@@ -76,11 +76,13 @@ def name
7676
private
7777

7878
def file_path
79-
@file_path ||= if File.absolute_path?(name)
80-
name
81-
else
82-
slice.app.root.join(name).to_s
83-
end
79+
@file_path ||= begin
80+
if File.absolute_path?(name)
81+
name
82+
else
83+
slice.app.root.join(name).to_s
84+
end
85+
end
8486
end
8587
end
8688
end

lib/hanami/cli/commands/app/generate/action.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ def call(
106106
raise InvalidActionNameError.new(name)
107107
end
108108

109-
generator.call(app.namespace, controller, action, url, http, format, skip_view, skip_route, slice,
110-
context: context)
109+
generator.call(app.namespace, controller, action, url, http, format, skip_view, skip_route, slice, context: context)
111110
end
112111

113112
# rubocop:enable Metrics/ParameterLists

lib/hanami/cli/commands/app/generate/slice.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ class Slice < App::Command
2929
# @since 2.2.0
3030
# @api private
3131
option :skip_db,
32-
type: :flag,
33-
required: false,
34-
default: SKIP_DB_DEFAULT,
35-
desc: "Skip database"
32+
type: :flag,
33+
required: false,
34+
default: SKIP_DB_DEFAULT,
35+
desc: "Skip database"
3636
# @since 2.2.0
3737
# @api private
3838
option :skip_route,
39-
type: :flag,
40-
required: false,
41-
default: DEFAULT_SKIP_ROUTE,
42-
desc: "Skip route generation"
39+
type: :flag,
40+
required: false,
41+
default: DEFAULT_SKIP_ROUTE,
42+
desc: "Skip route generation"
4343

4444
example [
4545
"admin # Admin slice (/admin URL prefix)",

lib/hanami/cli/commands/app/install.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Install < Command
3939
def initialize(
4040
fs:,
4141
bundler: CLI::Bundler.new(fs: fs),
42-
**_opts
42+
**opts
4343
)
4444
@bundler = bundler
4545
end

lib/hanami/cli/commands/gem/new.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def initialize(
110110
@system_call = system_call
111111
end
112112

113-
# rubocop:disable Metrics/AbcSize
113+
# rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
114114

115115
# @since 2.0.0
116116
# @api private
@@ -162,7 +162,7 @@ def call(
162162
end
163163
end
164164
end
165-
# rubocop:enable Metrics/AbcSize
165+
# rubocop:enable Metrics/AbcSize, Metrics/PerceivedComplexity
166166

167167
private
168168

spec/unit/hanami/cli/commands/app/db/prepare_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ class Comments < Hanami::DB::Relation
291291
expect(output).to include_in_order(
292292
"database #{POSTGRES_BASE_DB_NAME}_app created",
293293
"database #{POSTGRES_BASE_DB_NAME}_app migrated",
294-
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql",
294+
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql",
295295
"seed data loaded from config/db/seeds.rb",
296296
)
297297
expect(output).not_to include "#{POSTGRES_BASE_DB_NAME}_main"
@@ -310,7 +310,7 @@ class Comments < Hanami::DB::Relation
310310
expect(output).to include_in_order(
311311
"database #{POSTGRES_BASE_DB_NAME}_main created",
312312
"database #{POSTGRES_BASE_DB_NAME}_main migrated",
313-
"#{POSTGRES_BASE_DB_NAME}_main structure dumped to slices/main/config/db/structure.sql",
313+
"#{POSTGRES_BASE_DB_NAME}_main structure dumped to slices/main/config/db/structure.sql",
314314
"seed data loaded from slices/main/config/db/seeds.rb"
315315
)
316316
expect(output).not_to include "#{POSTGRES_BASE_DB_NAME}_app"
@@ -349,7 +349,7 @@ class Comments < Hanami::DB::Relation
349349
expect(output).to include_in_order(
350350
"database #{POSTGRES_BASE_DB_NAME}_app created",
351351
"database #{POSTGRES_BASE_DB_NAME}_app migrated",
352-
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql",
352+
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql",
353353
"seed data loaded from config/db/seeds.rb",
354354
)
355355
end
@@ -377,7 +377,7 @@ class Comments < Hanami::DB::Relation
377377
expect(output).to include_in_order(
378378
"database #{POSTGRES_BASE_DB_NAME}_app created", # TODO: it would be good not to include this
379379
"database #{POSTGRES_BASE_DB_NAME}_app migrated",
380-
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql",
380+
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql",
381381
"seed data loaded from config/db/seeds.rb",
382382
)
383383
end
@@ -405,7 +405,7 @@ class Comments < Hanami::DB::Relation
405405
expect(output).to include_in_order(
406406
"database #{POSTGRES_BASE_DB_NAME}_app created", # TODO: it would be good not to include this
407407
"database #{POSTGRES_BASE_DB_NAME}_app migrated",
408-
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql"
408+
"#{POSTGRES_BASE_DB_NAME}_app structure dumped to config/db/structure.sql"
409409
)
410410
expect(output).not_to include "seed data loaded from config/db/seeds.rb"
411411
end

0 commit comments

Comments
 (0)