diff --git a/lib/creek/book.rb b/lib/creek/book.rb index fae6090..1bb26e5 100644 --- a/lib/creek/book.rb +++ b/lib/creek/book.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'zip/filesystem' require 'nokogiri' require 'date' diff --git a/lib/creek/drawing.rb b/lib/creek/drawing.rb index efba81a..7847536 100644 --- a/lib/creek/drawing.rb +++ b/lib/creek/drawing.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'pathname' module Creek diff --git a/lib/creek/shared_strings.rb b/lib/creek/shared_strings.rb index 1825101..663aaf1 100644 --- a/lib/creek/shared_strings.rb +++ b/lib/creek/shared_strings.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'zip/filesystem' require 'nokogiri' diff --git a/lib/creek/sheet.rb b/lib/creek/sheet.rb index be30c51..1df94b8 100644 --- a/lib/creek/sheet.rb +++ b/lib/creek/sheet.rb @@ -99,6 +99,10 @@ def rows_generator include_meta_data=false, use_simple_rows_format=false cell_style_idx = nil @book.files.file.open(path) do |xml| prefix = '' + name_row = "row" + name_c = "c" + name_v = "v" + name_t = "t" Nokogiri::XML::Reader.from_io(xml).each do |node| if prefix.empty? && node.namespaces.any? namespace = node.namespaces.detect{|_key, uri| uri == SPREADSHEETML_URI } @@ -107,13 +111,17 @@ def rows_generator include_meta_data=false, use_simple_rows_format=false else '' end + name_row = "#{prefix}row" + name_c = "#{prefix}c" + name_v = "#{prefix}v" + name_t = "#{prefix}t" end - if node.name == "#{prefix}row" && node.node_type == opener + if node.name == name_row && node.node_type == opener row = node.attributes row['cells'] = {} cells = {} y << (include_meta_data ? row : cells) if node.self_closing? - elsif node.name == "#{prefix}row" && node.node_type == closer + elsif node.name == name_row && node.node_type == closer processed_cells = fill_in_empty_cells(cells, row['r'], cell, use_simple_rows_format) @headers = processed_cells if with_headers && row['r'] == HEADERS_ROW_NUMBER @@ -127,11 +135,11 @@ def rows_generator include_meta_data=false, use_simple_rows_format=false row['cells'] = processed_cells y << (include_meta_data ? row : processed_cells) - elsif node.name == "#{prefix}c" && node.node_type == opener + elsif node.name == name_c && node.node_type == opener cell_type = node.attributes['t'] cell_style_idx = node.attributes['s'] cell = node.attributes['r'] - elsif ["#{prefix}v", "#{prefix}t"].include?(node.name) && node.node_type == opener + elsif (node.name == name_v || node.name == name_t) && node.node_type == opener unless cell.nil? node.read cells[cell] = convert(node.value, cell_type, cell_style_idx) diff --git a/lib/creek/styles.rb b/lib/creek/styles.rb index d4681e9..016f158 100644 --- a/lib/creek/styles.rb +++ b/lib/creek/styles.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Creek class Styles attr_accessor :book diff --git a/lib/creek/styles/converter.rb b/lib/creek/styles/converter.rb index afe1eb6..62bd6d6 100644 --- a/lib/creek/styles/converter.rb +++ b/lib/creek/styles/converter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'set' module Creek diff --git a/lib/creek/styles/style_types.rb b/lib/creek/styles/style_types.rb index de0db03..df3b4d1 100644 --- a/lib/creek/styles/style_types.rb +++ b/lib/creek/styles/style_types.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # https://github.com/hmcgowan/roo/blob/master/lib/roo/excelx.rb # https://github.com/woahdae/simple_xlsx_reader/blob/master/lib/simple_xlsx_reader.rb#L231 module Creek diff --git a/lib/creek/utils.rb b/lib/creek/utils.rb index 9eef47c..af4ac90 100644 --- a/lib/creek/utils.rb +++ b/lib/creek/utils.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Creek module Utils def expand_to_rels_path(filepath) diff --git a/lib/creek/version.rb b/lib/creek/version.rb index 1d6ad28..2073d94 100644 --- a/lib/creek/version.rb +++ b/lib/creek/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Creek VERSION = "2.6.2" end