terminal-table-unicode 0.1.0 → 0.1.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 +4 -4
- data/README.md +4 -10
- data/lib/terminal/table/cell.rb +1 -3
- data/lib/terminal/table/unicode/ext/string.rb +0 -17
- data/lib/terminal/table/unicode/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85dffa2fb12bbba3b8efdceea67ec82776aa3af6
|
4
|
+
data.tar.gz: 7cd63232652fac37666a5605c4af76970407de5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dbc0ba8e48d9bb0e3343b220fd737a68f2d45d2f5a3cde20ee12ecd231da3fc30fb24a78eb144cfb42fb89ac31ead04e86ea3dc2b1b52204f06f3340e39cc8e
|
7
|
+
data.tar.gz: 5009fe1aaa42ff693228fa0c1bdd99941508802f87912572609c104909965064afd4159249aabcba66d381e8a5116dd7b599f9fc9cdbd4e31e7c2918655837c1
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# terminal-table-unicode
|
2
2
|
|
3
|
-
[tj/terminal-table](https://github.com/tj/terminal-table) is
|
3
|
+
[tj/terminal-table](https://github.com/tj/terminal-table) is an awesome rubygem. But it has a probrem that can deal with [full-width unicode characters](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms#Fullwidth_form). terminal-table-unicode solved that.
|
4
4
|
I referred to [miaout17/hirb-unicode](https://github.com/miaout17/hirb-unicode).
|
5
5
|
|
6
6
|
## Installation
|
@@ -32,18 +32,12 @@ table = Terminal::Table.new :rows => rows
|
|
32
32
|
puts table
|
33
33
|
```
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
| One | 1 |
|
38
|
-
| Two | 2 |
|
39
|
-
| Three | 3 |
|
40
|
-
| よん | 4 |
|
41
|
-
+-------+---+
|
42
|
-
```
|
35
|
+

|
36
|
+
|
43
37
|
|
44
38
|
You can use with other options.
|
45
39
|
see more: [tj/terminal-table](https://github.com/tj/terminal-table)
|
46
40
|
|
47
41
|
## Contributing
|
48
42
|
|
49
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rochefort/terminal-table-unicode.
|
data/lib/terminal/table/cell.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
module Terminal
|
2
2
|
class Table
|
3
3
|
class Cell
|
4
|
-
|
5
4
|
def align(val, position, length)
|
6
5
|
# positions = { :left => :ljust, :right => :rjust, :center => :center }
|
7
|
-
positions = { :
|
6
|
+
positions = { left: :mb_ljust, right: :mb_rjust, center: :mb_center }
|
8
7
|
val.public_send(positions[position], length)
|
9
8
|
end
|
10
|
-
|
11
9
|
end
|
12
10
|
end
|
13
11
|
end
|
@@ -1,21 +1,4 @@
|
|
1
1
|
class String
|
2
|
-
def display_width(ambiguous = 1)
|
3
|
-
#codepoints.inject(0){ |a,c|
|
4
|
-
unpack('U*').inject(0){ |a,c|
|
5
|
-
width = case Unicode::DisplayWidth.codepoint(c).to_s
|
6
|
-
when *%w[F W]
|
7
|
-
2
|
8
|
-
when *%w[N Na H]
|
9
|
-
1
|
10
|
-
when *%w[A] # TODO
|
11
|
-
ambiguous
|
12
|
-
else
|
13
|
-
1
|
14
|
-
end
|
15
|
-
a + width
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
2
|
def mb_ljust(desired_width)
|
20
3
|
padding = desired_width - display_width
|
21
4
|
padding > 0 ? self + ' ' * padding : self
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terminal-table-unicode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rochefort
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: terminal-table
|
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
110
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.4.
|
111
|
+
rubygems_version: 2.4.8
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: Simple, feature rich ascii table generation library with full-width unicode
|