csv2md 1.1.2 → 1.1.3
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 +4 -4
- data/bin/csv2md +1 -1
- data/lib/csv2md.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 14c863a68dd0fc361df23464d60eaf4a2f1b13f3
|
|
4
|
+
data.tar.gz: 3adb1f7393c3afcf3dc4a5e99a16e8c0e08eca42
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 435f6d1c63eebf9ff37b18ac45d46e0b491b7e5375665f2b1ec2e82cfea11dc8b60f6e90779479d1e68feb7f15851b3823aec72b35151c8213eab07129a84777
|
|
7
|
+
data.tar.gz: 4cb4921b0fd9ec8c2a1de43ecb21b28b952a9a8de32fb707b0ea5306ff8be85f5abfc17a07b833b083fcdd425dc7c5dfd1b8a485be833254256b356f4ab92c51
|
data/bin/csv2md
CHANGED
data/lib/csv2md.rb
CHANGED
|
@@ -12,7 +12,7 @@ class Csv2md
|
|
|
12
12
|
def find_column_widths
|
|
13
13
|
parsed_csv.inject(Array.new(parsed_csv[0].length, 0)) do |result, line|
|
|
14
14
|
line.each_with_index do |column, i|
|
|
15
|
-
if column.length > result[i]
|
|
15
|
+
if column.to_s.length > result[i]
|
|
16
16
|
result[i] = column.length
|
|
17
17
|
end
|
|
18
18
|
end
|
|
@@ -31,7 +31,7 @@ class Csv2md
|
|
|
31
31
|
parsed_csv.each_with_index do |line, row_index|
|
|
32
32
|
line.each_with_index do |column, column_index|
|
|
33
33
|
result += "| "
|
|
34
|
-
result += column.ljust(widths[column_index] + 1, " ")
|
|
34
|
+
result += column.to_s.ljust(widths[column_index] + 1, " ")
|
|
35
35
|
if column_index == number_of_columns - 1
|
|
36
36
|
result += "|\n"
|
|
37
37
|
end
|
|
@@ -49,7 +49,7 @@ class Csv2md
|
|
|
49
49
|
|
|
50
50
|
def csv
|
|
51
51
|
result = input.split("\n").map do |line|
|
|
52
|
-
row = line.scan(/\|([^\|]
|
|
52
|
+
row = line.scan(/\|([^\|]*)\s/).flatten.map(&:strip).join(",")
|
|
53
53
|
row unless row.strip == ""
|
|
54
54
|
end.compact.join("\n")
|
|
55
55
|
result += "\n"
|