markdown-tables 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/markdown-tables.rb +18 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 32106fcf23ba3591f4330de1e9a6e1f4b45712371c23719a975a513fe1cd1940
|
4
|
+
data.tar.gz: 6a4199314024cf80d5babf546e6057118b56198eab7f634f7fe84730b4cc5efb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0bb9614c538cb22d194ab93f224d33becc20187fd93d490827e5f9180e89031f88b435b491716e13cbdda51366f7d49bd856cd31939c24ab34cac822332dd48
|
7
|
+
data.tar.gz: 30d151838b13904c1528eca4bde980e8bad49cf58f90d0c1e208cbbd9a5801c2e4ebc67c5754a8a3ec9381b80a2b9793252e8887e47f4647177b2a661fabac06
|
data/lib/markdown-tables.rb
CHANGED
@@ -81,23 +81,32 @@ class MarkdownTables
|
|
81
81
|
private_class_method def self.validate(labels, data, align, is_rows)
|
82
82
|
if labels.class != Array
|
83
83
|
raise('labels must be an array')
|
84
|
-
|
84
|
+
end
|
85
|
+
if data.class != Array || data.any? {|datum| datum.class != Array}
|
85
86
|
raise('data must be a two-dimensional array')
|
86
|
-
|
87
|
+
end
|
88
|
+
if labels.empty?
|
87
89
|
raise('No column labels given')
|
88
|
-
|
90
|
+
end
|
91
|
+
if data.all? {|datum| datum.empty?}
|
89
92
|
raise('No cells given')
|
90
|
-
|
93
|
+
end
|
94
|
+
if labels.any? {|label| !label.respond_to?(:to_s)}
|
91
95
|
raise('One or more column labels cannot be made into a string')
|
92
|
-
|
96
|
+
end
|
97
|
+
if data.any? {|datum| datum.any? {|cell| !cell.respond_to?(:to_s)}}
|
93
98
|
raise('One or more cells cannot be made into a string')
|
94
|
-
|
99
|
+
end
|
100
|
+
if ![String, Array].include?(align.class)
|
95
101
|
raise('align must be a string or array')
|
96
|
-
|
102
|
+
end
|
103
|
+
if align.class == Array && align.any? {|val| val.class != String}
|
97
104
|
raise('One or more align values is not a string')
|
98
|
-
|
105
|
+
end
|
106
|
+
if !is_rows && data.length > labels.length
|
99
107
|
raise('Too many data columns given')
|
100
|
-
|
108
|
+
end
|
109
|
+
if is_rows && data.any? {|row| row.length > labels.length}
|
101
110
|
raise('One or more rows has too many cells')
|
102
111
|
end
|
103
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdown-tables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris de Graaf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: chrisadegraaf@gmail.com
|
@@ -37,7 +37,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
37
|
version: '0'
|
38
38
|
requirements: []
|
39
39
|
rubyforge_project:
|
40
|
-
rubygems_version: 2.6
|
40
|
+
rubygems_version: 2.7.6
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: Utilities for creating and displaying Markdown tables in Ruby
|