doctordata 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e05423d70ba06c78abea9fa5cbaa603477907e43
4
- data.tar.gz: 5b96d9dc76e7e734e94874191aa8de46ab2b472d
3
+ metadata.gz: 6b6fb1b6365be0aa5bbdb0161e49b22a0a781c5e
4
+ data.tar.gz: 00f8835784cb459c4f34c2d86ae08bb535c7a017
5
5
  SHA512:
6
- metadata.gz: 37d44d08a1fa4b2795f23fbbf51a552812e713a70c6a6350c5fcb46fdd33a3c87bf2c43a2c346c6c9068b3e3f3daba0f88cfe42b1c83f20fa8d586888b3322af
7
- data.tar.gz: 43dddd849ce6bed55e0044531cb8ca80443a89f25129fe3a4394f543559b6bba1bce8acd70f81c9ed7277089f06a6aba93398fdcffdab783651b3613ec8d22d2
6
+ metadata.gz: 40c9eb6d3fb706392666e81136702f6a2eefffced271bca997fd91a00896e65d178757d8d1ce315c222ce0b37cb3fa41d33692ca01ba1abe2f33c77c3a0c383a
7
+ data.tar.gz: fd735c4a9a64946dc20879b34c39ac1d7e982f2b8489aadb6d9b7121a43b8a694a53b7430f1922e451b41e3d51742837e845707086489dc9e0509ca992244edc
@@ -5,7 +5,7 @@ require 'roo'
5
5
  module Doctordata
6
6
  class Parser
7
7
  class << self
8
- def from_csv_table(table)
8
+ def from_csv_table(table, options = {})
9
9
  # there is much room to do performance tuning
10
10
  checked_table = table.by_col!.delete_if{ |k, v| k == nil || k == '' || k.start_with?('#') }
11
11
  checked_table.by_row!.map do |row|
@@ -49,23 +49,26 @@ module Doctordata
49
49
  end
50
50
  end
51
51
 
52
- def from_csv_path(path)
53
- table = CSV.read(path, headers: true)
54
- from_csv_table(table)
52
+ def from_csv_path(path, options = {})
53
+ json_str = File.read(path)
54
+ from_csv_str(json_str, options)
55
55
  end
56
56
 
57
- def from_csv_str(csv_str)
57
+ def from_csv_str(csv_str, options = {})
58
+ unless options[:skip_lines_number].nil?
59
+ csv_str = csv_str.lines.to_a[options[:skip_lines_number].to_i..-1].join
60
+ end
58
61
  table = CSV.parse(csv_str, :headers => true)
59
62
  from_csv_table(table)
60
63
  end
61
64
 
62
- def from_excel(file_or_path)
65
+ def from_excel(file_or_path, options = {})
63
66
  xlsx = Roo::Spreadsheet.open(file_or_path, extension: :xlsx)
64
67
  hash = {}
65
68
  xlsx.each_with_pagename do |name, sheet|
66
69
  next if name == nil || name == '' || name.start_with?('#')
67
70
  csv_str = sheet.to_csv
68
- hash[name] = from_csv_str(csv_str)
71
+ hash[name] = from_csv_str(csv_str, options)
69
72
  end
70
73
  hash
71
74
  end
@@ -1,3 +1,3 @@
1
1
  module Doctordata
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doctordata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - qsona
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-29 00:00:00.000000000 Z
11
+ date: 2017-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roo