Skip to content
Open
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: ruby
rvm:
- 1.9.3
- 2.0.0
- 3.0.0
5 changes: 2 additions & 3 deletions lib/collmex/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -95,4 +95,3 @@ def self.stringify_currency(data)
require "collmex/api/sales_order_get"
require "collmex/api/accbal_get"
require "collmex/api/accbal"

7 changes: 3 additions & 4 deletions lib/collmex/api/line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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
Expand All @@ -79,4 +79,3 @@ def to_h


end

2 changes: 1 addition & 1 deletion lib/collmex/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down