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 +4 -4
- data/lib/doctordata.rb +10 -7
- data/lib/doctordata/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b6fb1b6365be0aa5bbdb0161e49b22a0a781c5e
|
4
|
+
data.tar.gz: 00f8835784cb459c4f34c2d86ae08bb535c7a017
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40c9eb6d3fb706392666e81136702f6a2eefffced271bca997fd91a00896e65d178757d8d1ce315c222ce0b37cb3fa41d33692ca01ba1abe2f33c77c3a0c383a
|
7
|
+
data.tar.gz: fd735c4a9a64946dc20879b34c39ac1d7e982f2b8489aadb6d9b7121a43b8a694a53b7430f1922e451b41e3d51742837e845707086489dc9e0509ca992244edc
|
data/lib/doctordata.rb
CHANGED
@@ -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
|
-
|
54
|
-
|
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
|
data/lib/doctordata/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: roo
|