diff --git a/.travis.yml b/.travis.yml index 222078e..dc8f585 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: ruby rvm: - - 1.9.3 - 2.0.0 + - 3.0.0 diff --git a/lib/collmex/api.rb b/lib/collmex/api.rb index a2cea5b..925b4b4 100644 --- a/lib/collmex/api.rb +++ b/lib/collmex/api.rb @@ -20,7 +20,7 @@ def self.line_class_exists?(class_name) # from Collmex::Api::Line def self.parse_line(line) # in case the line is already an array - if line.is_a?(Array) && line.first.is_a?(String) || line.is_a?(String) && line = CSV.parse_line(line, Collmex.csv_opts) + if line.is_a?(Array) && line.first.is_a?(String) || line.is_a?(String) && line = CSV.parse_line(line, **Collmex.csv_opts) identifyer = line.first.split(/_|-/).map { |s| s.downcase.capitalize }.join if self.line_class_exists?(identifyer) Collmex::Api.const_get(identifyer).new(line) @@ -59,7 +59,7 @@ def self.parse_currency(str) end end - # given an object, convert it to a string according to the collmex api. + # given an object, convert it to a string according to the collmex api. def self.stringify(data, type) return "" if data.nil? case type @@ -95,4 +95,3 @@ def self.stringify_currency(data) require "collmex/api/sales_order_get" require "collmex/api/accbal_get" require "collmex/api/accbal" - diff --git a/lib/collmex/api/line.rb b/lib/collmex/api/line.rb index a5afed7..0b4548a 100644 --- a/lib/collmex/api/line.rb +++ b/lib/collmex/api/line.rb @@ -26,13 +26,13 @@ def self.hashify(data) hash = self.default_hash fields_spec = self.specification - if data.is_a?(Array) || data.is_a?(String) && data = CSV.parse_line(data,Collmex.csv_opts) + if data.is_a?(Array) || data.is_a?(String) && data = CSV.parse_line(data, **Collmex.csv_opts) fields_spec.each_with_index do |field_spec, index| if !data[index].nil? && !field_spec.has_key?(:fix) hash[field_spec[:name]] = Collmex::Api.parse_field(data[index], field_spec[:type]) end end - elsif data.is_a? Hash + elsif data.is_a? Hash fields_spec.each_with_index do |field_spec, index| if data.key?(field_spec[:name]) && !field_spec.has_key?(:fix) hash[field_spec[:name]] = Collmex::Api.parse_field(data[field_spec[:name]], field_spec[:type]) @@ -70,7 +70,7 @@ def to_stringified_array def to_csv - CSV.generate_line(self.to_stringified_array, Collmex.csv_opts) + CSV.generate_line(self.to_stringified_array, **Collmex.csv_opts) end def to_h @@ -79,4 +79,3 @@ def to_h end - diff --git a/lib/collmex/request.rb b/lib/collmex/request.rb index 7f80619..9878378 100644 --- a/lib/collmex/request.rb +++ b/lib/collmex/request.rb @@ -82,7 +82,7 @@ def execute @raw_response[:string] = response.body.encode("UTF-8") begin - @raw_response[:array] = CSV.parse(@raw_response[:string], Collmex.csv_opts) + @raw_response[:array] = CSV.parse(@raw_response[:string], **Collmex.csv_opts) rescue => e STDERR.puts "CSV.parse failed with string: #{@raw_response[:string]}" if self.debug raise e