Skip to content

Commit

Permalink
rubocop autocorrections
Browse files Browse the repository at this point in the history
  • Loading branch information
infused committed May 2, 2024
1 parent 7fcc4d6 commit cbc5bda
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/dbf/column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class NameError < StandardError
M: ColumnType::Memo,
B: ColumnType::Double,
G: ColumnType::General,
'+'.to_sym => ColumnType::SignedLong2
:+ => ColumnType::SignedLong2
}
# rubocop:enable Style/MutableConstant
TYPE_CAST_CLASS.default = ColumnType::String
Expand Down
4 changes: 1 addition & 3 deletions lib/dbf/database/foxpro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ def extract_dbc_data # :nodoc:
end
end

Hash[
data.values.map { |v| [v[:name], v[:fields]] }
]
data.values.to_h { |v| [v[:name], v[:fields]] }
end

def process_table(record, data)
Expand Down
2 changes: 1 addition & 1 deletion lib/dbf/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def [](name)
#
# @return [Hash]
def attributes
@attributes ||= Hash[column_names.zip(to_a)]
@attributes ||= column_names.zip(to_a).to_h
end

# Do all search parameters match?
Expand Down
6 changes: 2 additions & 4 deletions spec/dbf/encoding_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# encoding: utf-8

require 'spec_helper'

RSpec.describe 'default encoding' do
Expand All @@ -16,7 +14,7 @@
end

it 'encodes column names' do
expect(table.column_names).to eq ['ШАР', 'ПЛОЩА']
expect(table.column_names).to eq %w[ШАР ПЛОЩА]
end

it 'encodes record values' do
Expand All @@ -38,7 +36,7 @@
end

it 'encodes column names' do
expect(table.column_names).to eq ['RN', 'NAME']
expect(table.column_names).to eq %w[RN NAME]
end

it 'encodes record values' do
Expand Down
6 changes: 3 additions & 3 deletions spec/dbf/file_formats_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
end

specify 'records should be instances of DBF::Record' do
expect(table).to all be_kind_of(DBF::Record)
expect(table).to all be_a(DBF::Record)
end

specify 'record count should be the same as reported in the header' do
Expand All @@ -31,7 +31,7 @@

specify 'column lengths should be instances of Integer' do
table.columns.each do |column|
expect(column.length).to be_kind_of(Integer)
expect(column.length).to be_a(Integer)
end
end

Expand All @@ -43,7 +43,7 @@

specify 'column decimals should be instances of Integer' do
table.columns.each do |column|
expect(column.decimal).to be_kind_of(Integer)
expect(column.decimal).to be_a(Integer)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/dbf/record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@

describe 'when other does not have attributes' do
it 'returns false' do
expect((record == instance_double('DBF::Record'))).to be_falsey
expect((record == instance_double(DBF::Record))).to be_falsey
end
end

describe 'if other attributes match' do
let(:attributes) { {x: 1, y: 2} }
let(:other) { instance_double('DBF::Record', attributes: attributes) }
let(:other) { instance_double(DBF::Record, attributes: attributes) }

before do
allow(record).to receive(:attributes).and_return(attributes)
Expand Down
2 changes: 1 addition & 1 deletion spec/dbf/table_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
before { table.to_csv('test.csv') }

it 'creates a custom csv file' do
expect(File).to be_exist('test.csv')
expect(File).to exist('test.csv')
end
end
end
Expand Down

0 comments on commit cbc5bda

Please sign in to comment.