mrtable 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +4 -0
- data/lib/mrtable/version.rb +1 -1
- data/lib/mrtable.rb +34 -1
- data/mrtable.gemspec +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d93194f7e7851b05c61792e0823c3db016f52845
|
4
|
+
data.tar.gz: e1d7c78cc51c22a384cd4f4d074fca0cb84623c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35121c86b9a27f76a68b31220caa3d81cff9b4d7b7981169772a478402d87e0b534c4d284f74ba2377d862d3d92fd633775a7b0569e8649a315ba674aef7d981
|
7
|
+
data.tar.gz: f5368f5e2d589c594e6494b717211542fb5fb6177d419f07549a35df79407789444a2cd27e495444b6b14b023d8492d67bb495d9af2d125f058685345b703e28
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 sonota88
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
data/lib/mrtable/version.rb
CHANGED
data/lib/mrtable.rb
CHANGED
@@ -46,6 +46,32 @@ module Mrtable
|
|
46
46
|
min_len = 3
|
47
47
|
maxlens.map { |len| [len, min_len].max }
|
48
48
|
end
|
49
|
+
|
50
|
+
def complement(val)
|
51
|
+
num_cols_max = [
|
52
|
+
@header_cols.size,
|
53
|
+
@rows.map { |cols| cols.size }.max
|
54
|
+
].max
|
55
|
+
|
56
|
+
new_header_cols = Mrtable.complement_cols(
|
57
|
+
@header_cols, num_cols_max, val)
|
58
|
+
|
59
|
+
new_rows = @rows.map { |cols|
|
60
|
+
Mrtable.complement_cols(cols, num_cols_max, val)
|
61
|
+
}
|
62
|
+
|
63
|
+
Table.new new_header_cols, new_rows
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.complement_cols(cols, num_cols_max, val)
|
68
|
+
(0...num_cols_max).map { |ci|
|
69
|
+
if ci < cols.size
|
70
|
+
cols[ci]
|
71
|
+
else
|
72
|
+
val
|
73
|
+
end
|
74
|
+
}
|
49
75
|
end
|
50
76
|
|
51
77
|
def self.int?(s)
|
@@ -167,7 +193,7 @@ module Mrtable
|
|
167
193
|
cols
|
168
194
|
end
|
169
195
|
|
170
|
-
def self.parse(text)
|
196
|
+
def self.parse(text, opts = {})
|
171
197
|
lines = text.split(/\r?\n/)
|
172
198
|
lines2 = lines.reject { |line|
|
173
199
|
/^\s*$/ =~ line ||
|
@@ -186,6 +212,13 @@ module Mrtable
|
|
186
212
|
parse_col col
|
187
213
|
}
|
188
214
|
|
215
|
+
if opts.has_key? :complement
|
216
|
+
unless opts[:complement].is_a? String or opts[:complement].nil?
|
217
|
+
raise "opts[:complement] must be String or nil"
|
218
|
+
end
|
219
|
+
parsed = parsed.complement opts[:complement]
|
220
|
+
end
|
221
|
+
|
189
222
|
{
|
190
223
|
:header_cols => parsed.header_cols,
|
191
224
|
:rows => parsed.rows
|
data/mrtable.gemspec
CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.summary = %q{machine readable table}
|
13
13
|
spec.description = %q{machine readable table}
|
14
14
|
spec.homepage = "https://github.com/sonota88/mrtable"
|
15
|
+
spec.license = "MIT"
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
18
|
f.match(%r{^(test|spec|features)/})
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mrtable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sonota88
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -62,13 +62,15 @@ files:
|
|
62
62
|
- ".gitignore"
|
63
63
|
- CHANGELOG.md
|
64
64
|
- Gemfile
|
65
|
+
- LICENSE.txt
|
65
66
|
- README.md
|
66
67
|
- Rakefile
|
67
68
|
- lib/mrtable.rb
|
68
69
|
- lib/mrtable/version.rb
|
69
70
|
- mrtable.gemspec
|
70
71
|
homepage: https://github.com/sonota88/mrtable
|
71
|
-
licenses:
|
72
|
+
licenses:
|
73
|
+
- MIT
|
72
74
|
metadata: {}
|
73
75
|
post_install_message:
|
74
76
|
rdoc_options: []
|