diff --git a/.rubocop.yml b/.rubocop.yml index 5586e337..720c828a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -16,3 +16,5 @@ Style/RescueStandardError: Enabled: false Style/DateTime: Enabled: false +AllCops: + TargetRubyVersion: 2.6 diff --git a/lib/hanami/entity/schema.rb b/lib/hanami/entity/schema.rb index 7f41e788..3edd8b90 100644 --- a/lib/hanami/entity/schema.rb +++ b/lib/hanami/entity/schema.rb @@ -169,7 +169,7 @@ def initialize(type = nil, &blk) raise LocalJumpError unless block_given? @attributes, @schema = Dsl.build(type, &blk) - @attributes = Hash[@attributes.map { |k, _| [k, true] }] + @attributes = @attributes.transform_values { |_| true } freeze end diff --git a/lib/hanami/model/migrator/sqlite_adapter.rb b/lib/hanami/model/migrator/sqlite_adapter.rb index 9bcf83df..3ee4f0b5 100644 --- a/lib/hanami/model/migrator/sqlite_adapter.rb +++ b/lib/hanami/model/migrator/sqlite_adapter.rb @@ -108,16 +108,14 @@ def load_structure # def dump_migrations_data execute "sqlite3 #{escape(path)} .dump" do |stdout| - begin - contents = stdout.read.split($INPUT_RECORD_SEPARATOR) - contents = contents.grep(/^INSERT INTO "?#{migrations_table}"?/) - - ::File.open(schema, ::File::CREAT | ::File::BINARY | ::File::WRONLY | ::File::APPEND) do |file| - file.write(contents.join($INPUT_RECORD_SEPARATOR)) - end - rescue => exception - raise MigrationError.new(exception.message) + contents = stdout.read.split($INPUT_RECORD_SEPARATOR) + contents = contents.grep(/^INSERT INTO "?#{migrations_table}"?/) + + ::File.open(schema, ::File::CREAT | ::File::BINARY | ::File::WRONLY | ::File::APPEND) do |file| + file.write(contents.join($INPUT_RECORD_SEPARATOR)) end + rescue => exception + raise MigrationError.new(exception.message) end end end diff --git a/lib/hanami/model/sql/entity/schema.rb b/lib/hanami/model/sql/entity/schema.rb index eb8a2f52..9219dc24 100644 --- a/lib/hanami/model/sql/entity/schema.rb +++ b/lib/hanami/model/sql/entity/schema.rb @@ -36,7 +36,7 @@ class Schema < Hanami::Entity::Schema def initialize(registry, relation, mapping) attributes = build(registry, relation, mapping) @schema = Types::Coercible::Hash.schema(attributes) - @attributes = Hash[attributes.map { |k, _| [k, true] }] + @attributes = attributes.transform_values { |_| true } freeze end