ttable 0.0.1 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f5aa789decb21c44678b0b5865b3b7d0f17ae10
4
- data.tar.gz: cac976ca917be93b636c1150ce3d96f0055d7229
3
+ metadata.gz: ee884467d48100b295bd4d3d5b9ca21a651d1ad8
4
+ data.tar.gz: c2c5fd97bfbe4014b47e19a5c4d2bfd76da0c68f
5
5
  SHA512:
6
- metadata.gz: 1dd66ff78816eee695535e8197bd24eeb8fac2b265cfa911cdf21084f00b74f12232e1394b75aaec6da5ad73780859ccf5e81040da66472c6b21a3497944c1e7
7
- data.tar.gz: 354d25c974938f4b63f3bc8ea3ccf3dd329f219a830a1dd9a8f604a16c3616b33f80a9c3ed17cbeda6ce570aa0eb63e89d05636f8472273401f4854c001029db
6
+ metadata.gz: 21fc5f06070be22a6785e9c616176f2d0d07a53c1eec7d01f879e65a1f2c6bd5ed242c55fc3bd45a1857e37d049d8422851987d8d0fc369c90d4653c1c8c42a8
7
+ data.tar.gz: 702dcf5e24dd764d30b926cf7fad809e18ab62147fd44c9ed28cc60db81a43964370e6d0ff8cb58d90a5100af85261d02fc07752b0a864e14b96bec5096ccb3d
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script: bundle exec rspec
data/Gemfile CHANGED
@@ -6,5 +6,6 @@ group :development, :test do
6
6
  gem 'rspec', '~> 2.12.0'
7
7
  gem 'guard'
8
8
  gem 'guard-rspec'
9
+ gem 'simplecov', require: false
10
+ gem 'coveralls', require: false
9
11
  end
10
-
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # ttable
2
2
 
3
+ [![Code Climate](https://codeclimate.com/github/forresty/ttable/badges/gpa.svg)](https://codeclimate.com/github/forresty/ttable)
4
+ [![Coverage Status](https://img.shields.io/coveralls/forresty/ttable.svg)](https://coveralls.io/r/forresty/ttable)
5
+ [![Build Status](https://travis-ci.org/forresty/ttable.svg?branch=master)](https://travis-ci.org/forresty/ttable)
6
+
3
7
  See it in action:
4
8
 
5
9
  ![screenshot.png](screenshot.png)
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
1
  require "bundler/gem_tasks"
2
-
@@ -4,13 +4,22 @@ require "gemoji"
4
4
 
5
5
  class String
6
6
  def twidth
7
- # ❤️ is 2 characters
8
- result = -3 * scan('❤️').size
7
+ result = 0
8
+
9
+ # 4 code point emoji
10
+ %w{ ☺️ ❤️ }.each do |c|
11
+ result += -3 * scan(c).size
12
+ end
13
+
14
+ # 3 code point emoji
15
+ %w{ ♍️ }.each do |c|
16
+ result += -2 * scan(c).size
17
+ end
9
18
 
10
19
  chars.inject(result) do |result, c|
11
20
  if c.ord <= 126
12
21
  result += 1
13
- elsif %w{ • é · ♪ … ω ˊ ˋ }.include?(c)
22
+ elsif %w{ ě ì • é · ♪ … ω ˊ ˋ √ “ ” ☻ }.include?(c)
14
23
  result += 1
15
24
  elsif Emoji.find_by_unicode(c)
16
25
  result += 1
@@ -31,6 +40,8 @@ end
31
40
 
32
41
  module Terminal
33
42
  class Table
43
+ VERSION = '0.0.2'
44
+
34
45
  attr_accessor :rows
35
46
  attr_accessor :headings
36
47
  attr_accessor :column_widths
@@ -52,7 +63,7 @@ module Terminal
52
63
 
53
64
  if @headings.count > 0
54
65
  (0...@headings.size).each do |col|
55
- @column_widths[col] = [@column_widths[col], @headings[col].twidth].max
66
+ @column_widths[col] = [@column_widths[col] || 0, @headings[col].twidth].max
56
67
  end
57
68
  end
58
69
  end
@@ -1 +1,7 @@
1
+ require "simplecov"
2
+ SimpleCov.start
3
+
4
+ require "coveralls"
5
+ Coveralls.wear!
6
+
1
7
  require "ttable"
@@ -1,7 +1,80 @@
1
+ # coding: utf-8
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  module Terminal
4
6
  describe Table do
5
7
  it { should respond_to :to_s }
8
+
9
+ describe '#to_s' do
10
+ context 'when empty' do
11
+ subject { Table.new }
12
+ its(:to_s) { should == "++\n++\n" }
13
+ end
14
+
15
+ context 'when only heading' do
16
+ subject { Table.new { |t| t.headings = %w{ head } } }
17
+ its(:to_s) { should == "+------+\n| head |\n+------+\n+------+\n" }
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ describe String do
24
+ describe '#twidth' do
25
+ context 'C' do
26
+ subject { 'C' }
27
+ its(:twidth) { should == 2 }
28
+ end
29
+
30
+ context 'ě' do
31
+ subject { 'ě' }
32
+ its(:twidth) { should == 1 }
33
+ end
34
+
35
+ context 'l' do
36
+ subject { 'l' }
37
+ its(:twidth) { should == 2 }
38
+ end
39
+
40
+ context 'ì' do
41
+ subject { 'ì' }
42
+ its(:twidth) { should == 1 }
43
+ end
44
+
45
+ context '☺️' do
46
+ subject { '☺️' }
47
+ its(:twidth) { should == 1 }
48
+ end
49
+
50
+ context '❤️' do
51
+ subject { '❤️' }
52
+ its(:twidth) { should == 1 }
53
+ end
54
+
55
+ context '√' do
56
+ subject { '√' }
57
+ its(:twidth) { should == 1 }
58
+ end
59
+
60
+ context '”' do
61
+ subject { '”' }
62
+ its(:twidth) { should == 1 }
63
+ end
64
+
65
+ context '“' do
66
+ subject { '“' }
67
+ its(:twidth) { should == 1 }
68
+ end
69
+
70
+ context '♍️' do
71
+ subject { '♍️' }
72
+ its(:twidth) { should == 1 }
73
+ end
74
+
75
+ context '☻' do
76
+ subject { '☻' }
77
+ its(:twidth) { should == 1 }
78
+ end
6
79
  end
7
80
  end
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'ttable/version'
4
+ require 'terminal/table'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "ttable"
8
- spec.version = Ttable::VERSION
8
+ spec.version = Terminal::Table::VERSION
9
9
  spec.authors = ["Forrest Ye"]
10
10
  spec.email = ["afu@forresty.com"]
11
11
  spec.summary = %q{Terminal Table with @2x width character support}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ttable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Forrest Ye
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-23 00:00:00.000000000 Z
11
+ date: 2014-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -61,6 +61,7 @@ extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
63
  - .gitignore
64
+ - .travis.yml
64
65
  - Gemfile
65
66
  - Guardfile
66
67
  - LICENSE.txt
@@ -69,7 +70,6 @@ files:
69
70
  - bin/ttable
70
71
  - lib/terminal/table.rb
71
72
  - lib/ttable.rb
72
- - lib/ttable/version.rb
73
73
  - screenshot.png
74
74
  - spec/spec_helper.rb
75
75
  - spec/terminal/table_spec.rb
@@ -1,3 +0,0 @@
1
- module Ttable
2
- VERSION = "0.0.1"
3
- end