Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ Style/MultilineBlockChain:
Metrics/ParameterLists:
Max: 10

### Naming

Naming/UncommunicativeMethodParamName:
AllowedNames:
- db
- str

### RSpec --------------------------------------------------------------

RSpec/MessageSpies:
Expand Down
3 changes: 2 additions & 1 deletion daru-io.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
lib = File.expand_path('../lib', __FILE__)

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'daru/io/version'

Expand Down
2 changes: 2 additions & 0 deletions lib/daru/io/exporters/excel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ def write(path)

def process_offsets
@row_offset = @header ? 1 : 0
# rubocop:disable Naming/MemoizedInstanceVariableName
@col_offset = 0 unless @index
@col_offset ||= @dataframe.index.is_a?(Daru::MultiIndex) ? @dataframe.index.width : 1
# rubocop:enable Naming/MemoizedInstanceVariableName
end

def write_headers
Expand Down
2 changes: 1 addition & 1 deletion lib/daru/io/importers/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def initialize
# @example Reading from a website url file
# instance = Daru::IO::Importers::HTML.read('http://www.moneycontrol.com/')
def read(path)
@file_data = Nokogiri.parse(open(path).read)
@file_data = Nokogiri.parse(File.open(path).read)
self
end

Expand Down
10 changes: 5 additions & 5 deletions lib/daru/io/importers/plaintext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ def process_row(row,empty)
end
end

def try_string_to_number(s)
case s
def try_string_to_number(str)
case str
when INT_PATTERN
s.to_i
str.to_i
when FLOAT_PATTERN
s.tr(',', '.').to_f
str.tr(',', '.').to_f
else
s
str
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/daru/io/exporters/csv_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

RSpec.describe Daru::IO::Exporters::CSV do
subject { File.open(tempfile.path, &:readline).chomp.split(',', -1) }

Expand Down Expand Up @@ -48,7 +49,7 @@
end

context 'writes into .csv.gz format' do
subject { Zlib::GzipReader.new(open(tempfile.path)).read.split("\n") }
subject { Zlib::GzipReader.new(File.open(tempfile.path)).read.split("\n") }

let(:opts) { {compression: :gzip} }
let(:filename) { 'test.csv.gz' }
Expand Down