rggen-markdown 0.15.0 → 0.16.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02b96ecb6ed9233f9a4ef82126aec770caa2f8b184e7bd9bb3ce4ac9b7186dcf
4
- data.tar.gz: 81d02c038948ab3126fcebea1ed61c47ccba20179ec982ca52f1e07d73d9c126
3
+ metadata.gz: 9e35fb93a0fc6227415ad2b8647cd127a579ab0fb98553a116e5b04a970744f4
4
+ data.tar.gz: 673b9127ce1f4e993a93e06c4cf4928f0976d68fdc3fd06f49e9f934559f4cf1
5
5
  SHA512:
6
- metadata.gz: 86e03cacf5dd362ceebd2678524f57c952ddbaa9a4a81c06b00403e2c43f121f2f07fa8962e369deac3709108963644dd9b67baf12e01c1ef50a666a1db7234a
7
- data.tar.gz: 7679c97a617d776b661efcf43f051e133a1d27daf8b891e85f9a4e55408c393b14652fa6f3608f4636f883e9cff545a75aac92c3f173395c07d7e2a906f2c7c5
6
+ metadata.gz: cae81e6fe7ed9aeda80268bccffae0799e438744a857dbfcb82b29054abef4ab43674b884018c3aa65f841e4de1d468c074f1ad6a0dbd8693e94bcd876a336fa
7
+ data.tar.gz: 137a5c107c1ce1834a1edc333e9b33c8dfdb941b8125ef5229b2fbbf655b9ed501a9d64087d61a3a9cddd792ed8000564d53002beb5de037750f868f6f9733ec
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 Taichi Ishitani
3
+ Copyright (c) 2019-2020 Taichi Ishitani
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/rggen-markdown.svg)](https://badge.fury.io/rb/rggen-markdown)
2
- [![Build Status](https://travis-ci.com/rggen/rggen-markdown.svg?branch=master)](https://travis-ci.com/rggen/rggen-markdown)
2
+ [![CI](https://github.com/rggen/rggen-markdown/workflows/CI/badge.svg)](https://github.com/rggen/rggen-markdown/actions?query=workflow%3ACI)
3
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/5bbd7d84fefb30c5ee9a/maintainability)](https://codeclimate.com/github/rggen/rggen-markdown/maintainability)
4
4
  [![codecov](https://codecov.io/gh/rggen/rggen-markdown/branch/master/graph/badge.svg)](https://codecov.io/gh/rggen/rggen-markdown)
5
5
  [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=rggen_rggen-markdown&metric=alert_status)](https://sonarcloud.io/dashboard?id=rggen_rggen-markdown)
@@ -34,7 +34,7 @@ Feedbacks, bug reports, questions and etc. are wellcome! You can post them by us
34
34
 
35
35
  ## Copyright & License
36
36
 
37
- Copyright © 2019 Taichi Ishitani. RgGen::Markdown is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
37
+ Copyright © 2019-2020 Taichi Ishitani. RgGen::Markdown is licensed under the [MIT License](https://opensource.org/licenses/MIT), see [LICENSE](LICENSE) for futher details.
38
38
 
39
39
  ## Code of Conduct
40
40
 
@@ -1,10 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ruport'
4
- require 'ruport/wiki_table_formatter'
5
-
6
3
  require_relative 'markdown/version'
7
4
  require_relative 'markdown/utility/source_file'
5
+ require_relative 'markdown/utility/table_formatter'
8
6
  require_relative 'markdown/utility'
9
7
  require_relative 'markdown/component'
10
8
  require_relative 'markdown/feature'
@@ -19,11 +19,8 @@ module RgGen
19
19
  "[#{text}](##{id})"
20
20
  end
21
21
 
22
- def table(column_names, rows)
23
- table = Ruport.Table(column_names) do |t|
24
- rows.each { |row| t << row }
25
- end
26
- table.to_markdown(io: +'').chomp
22
+ def table(labels, rows)
23
+ TableFormatter.new.format(labels, rows)
27
24
  end
28
25
  end
29
26
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RgGen
4
+ module Markdown
5
+ module Utility
6
+ class TableFormatter
7
+ include Core::Utility::CodeUtility
8
+
9
+ def format(labels, table)
10
+ code_block do |code|
11
+ build_md_lines(labels, table).each_with_index do |line, i|
12
+ code << nl if i.positive?
13
+ code << line
14
+ end
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def build_md_lines(labels, table)
21
+ lines = []
22
+ build_md_line(lines, labels)
23
+ build_md_line(lines, alignment_marks(labels.size))
24
+ table.each { |row| build_md_line(lines, row) }
25
+ lines
26
+ end
27
+
28
+ def build_md_line(lines, row)
29
+ lines <<
30
+ ['', *row]
31
+ .map(&method(:escape))
32
+ .zip(separators(row.size + 1))
33
+ .flatten
34
+ end
35
+
36
+ def escape(cell)
37
+ cell.to_s
38
+ .gsub('|', '&#124;')
39
+ .gsub("\n", '<br>')
40
+ end
41
+
42
+ def separators(size)
43
+ Array.new(size, '|')
44
+ end
45
+
46
+ def alignment_marks(size)
47
+ Array.new(size, ':--')
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RgGen
4
4
  module Markdown
5
- VERSION = '0.15.0'
5
+ VERSION = '0.16.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rggen-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taichi Ishitani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-01 00:00:00.000000000 Z
11
+ date: 2020-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: ruport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '1.7'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '1.7'
27
- - !ruby/object:Gem::Dependency
28
- name: ruport-wiki-table-formatter
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0.2'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0.2'
41
13
  - !ruby/object:Gem::Dependency
42
14
  name: bundler
43
15
  requirement: !ruby/object:Gem::Requirement
@@ -54,7 +26,7 @@ dependencies:
54
26
  version: '0'
55
27
  description: 'Markdown generator for RgGen.
56
28
 
57
- '
29
+ '
58
30
  email:
59
31
  - rggen@googlegroups.com
60
32
  executables: []
@@ -74,6 +46,7 @@ files:
74
46
  - lib/rggen/markdown/setup.rb
75
47
  - lib/rggen/markdown/utility.rb
76
48
  - lib/rggen/markdown/utility/source_file.rb
49
+ - lib/rggen/markdown/utility/table_formatter.rb
77
50
  - lib/rggen/markdown/version.rb
78
51
  homepage: https://github.com/rggen/rggen-markdown
79
52
  licenses:
@@ -91,15 +64,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
64
  requirements:
92
65
  - - ">="
93
66
  - !ruby/object:Gem::Version
94
- version: '2.3'
67
+ version: '2.4'
95
68
  required_rubygems_version: !ruby/object:Gem::Requirement
96
69
  requirements:
97
70
  - - ">="
98
71
  - !ruby/object:Gem::Version
99
72
  version: '0'
100
73
  requirements: []
101
- rubygems_version: 3.0.3
74
+ rubygems_version: 3.1.2
102
75
  signing_key:
103
76
  specification_version: 4
104
- summary: rggen-markdown-0.15.0
77
+ summary: rggen-markdown-0.16.0
105
78
  test_files: []