kosi 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -1
- data/.rspec +2 -2
- data/.rubocop.yml +11 -11
- data/.travis.yml +8 -8
- data/Gemfile +12 -12
- data/README.md +2 -1
- data/Rakefile +8 -8
- data/kosi.gemspec +28 -28
- data/lib/kosi.rb +13 -13
- data/lib/kosi/align.rb +33 -33
- data/lib/kosi/char_option.rb +17 -17
- data/lib/kosi/connector_char.rb +26 -26
- data/lib/kosi/header.rb +18 -18
- data/lib/kosi/horizontal_border_char.rb +26 -26
- data/lib/kosi/options.rb +15 -15
- data/lib/kosi/separate_each_row.rb +15 -15
- data/lib/kosi/validators.rb +3 -3
- data/lib/kosi/validators/each_array_length_validator.rb +21 -21
- data/lib/kosi/validators/row_type_validator.rb +19 -19
- data/lib/kosi/version.rb +4 -4
- data/lib/kosi/vertical_border_char.rb +26 -26
- data/lib/table.rb +149 -138
- data/spec/kosi/align_spec.rb +77 -77
- data/spec/kosi/connector_char_spec.rb +59 -59
- data/spec/kosi/header_spec.rb +93 -93
- data/spec/kosi/horizontal_border_char_spec.rb +59 -59
- data/spec/kosi/separate_each_row_spec.rb +55 -55
- data/spec/kosi/validators/each_array_length_validator_spec.rb +56 -56
- data/spec/kosi/validators/row_type_validator_spec.rb +51 -51
- data/spec/kosi/vertical_border_char_spec.rb +59 -59
- data/spec/spec_helper.rb +16 -16
- data/spec/table_spec.rb +145 -134
- metadata +2 -3
- data/README.html +0 -273
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81b6af7fc9f98bd40c313d725b1108bad80aca5c
|
4
|
+
data.tar.gz: d325142941f583225c85f82391f6bc1fc2f98094
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36da7e4271b166b40c978c95688c4683103c06f7ff494eabe3c2072eb72ac2bfbb7cae37c39cdc0eb1458523be66a64be84e29000467303c0f85628c3315ccb5
|
7
|
+
data.tar.gz: c34bf70484a25916f44b920548a845ba6e77b87fad82b27f50340c7500c794cc07101ab187e54bddee4073421ef743e0ff9fe70780afe8cb44ba7e178a1d2b28
|
data/.coveralls.yml
CHANGED
@@ -1 +1 @@
|
|
1
|
-
service_name: travis-ci
|
1
|
+
service_name: travis-ci
|
data/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
--color
|
2
|
-
--format progress
|
1
|
+
--color
|
2
|
+
--format progress
|
data/.rubocop.yml
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
AllCops:
|
2
|
-
Exclude:
|
3
|
-
- !ruby/regexp /spec\/*\.rb$/
|
4
|
-
|
5
|
-
AsciiComments:
|
6
|
-
Enabled: false
|
7
|
-
|
8
|
-
RegexpLiteral:
|
9
|
-
MaxSlashes: 0
|
10
|
-
|
11
|
-
ClassLength:
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- !ruby/regexp /spec\/*\.rb$/
|
4
|
+
|
5
|
+
AsciiComments:
|
6
|
+
Enabled: false
|
7
|
+
|
8
|
+
RegexpLiteral:
|
9
|
+
MaxSlashes: 0
|
10
|
+
|
11
|
+
ClassLength:
|
12
12
|
Max: 150
|
data/.travis.yml
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
language: ruby
|
2
|
-
before_install:
|
3
|
-
- gem update --system 2.1.11
|
4
|
-
- gem --version
|
5
|
-
rvm:
|
6
|
-
- 1.9.3
|
7
|
-
- 2.0.0
|
8
|
-
- 2.1
|
1
|
+
language: ruby
|
2
|
+
before_install:
|
3
|
+
- gem update --system 2.1.11
|
4
|
+
- gem --version
|
5
|
+
rvm:
|
6
|
+
- 1.9.3
|
7
|
+
- 2.0.0
|
8
|
+
- 2.1
|
data/Gemfile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gemspec
|
4
|
-
gem "rspec", "~> 2.14.1"
|
5
|
-
gem "thor", "~> 0.18.1"
|
6
|
-
gem "simplecov", "~> 0.8.2"
|
7
|
-
gem "activesupport", "~> 4.0.1"
|
8
|
-
gem "activemodel", "~> 4.0.2"
|
9
|
-
gem "tudu", "~> 0.0.4"
|
10
|
-
group :test do
|
11
|
-
gem 'coveralls', require: false
|
12
|
-
end
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
gem "rspec", "~> 2.14.1"
|
5
|
+
gem "thor", "~> 0.18.1"
|
6
|
+
gem "simplecov", "~> 0.8.2"
|
7
|
+
gem "activesupport", "~> 4.0.1"
|
8
|
+
gem "activemodel", "~> 4.0.2"
|
9
|
+
gem "tudu", "~> 0.0.4"
|
10
|
+
group :test do
|
11
|
+
gem 'coveralls', require: false
|
12
|
+
end
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'bundler/gem_tasks'
|
2
|
-
require 'rspec/core'
|
3
|
-
require 'rspec/core/rake_task'
|
4
|
-
task default: [:spec]
|
5
|
-
|
6
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
7
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
8
|
-
end
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
task default: [:spec]
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
7
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
8
|
+
end
|
data/kosi.gemspec
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'kosi/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'kosi'
|
8
|
-
spec.version = Kosi::VERSION
|
9
|
-
spec.authors = ['tbpgr']
|
10
|
-
spec.email = ['tbpgr@tbpgr.jp']
|
11
|
-
spec.summary = %q(terminal table format for japanese)
|
12
|
-
spec.description = %q(terminal table format for japanese)
|
13
|
-
spec.homepage = 'https://github.com/tbpgr/kosi'
|
14
|
-
spec.license = 'MIT'
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ['lib']
|
20
|
-
|
21
|
-
spec.add_runtime_dependency 'activesupport', '~> 4.0.1'
|
22
|
-
spec.add_runtime_dependency 'activemodel', '~> 4.0.2'
|
23
|
-
|
24
|
-
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
|
-
spec.add_development_dependency 'rake'
|
26
|
-
spec.add_development_dependency 'rspec', '~> 2.14.1'
|
27
|
-
spec.add_development_dependency 'simplecov', '~> 0.8.2'
|
28
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'kosi/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'kosi'
|
8
|
+
spec.version = Kosi::VERSION
|
9
|
+
spec.authors = ['tbpgr']
|
10
|
+
spec.email = ['tbpgr@tbpgr.jp']
|
11
|
+
spec.summary = %q(terminal table format for japanese)
|
12
|
+
spec.description = %q(terminal table format for japanese)
|
13
|
+
spec.homepage = 'https://github.com/tbpgr/kosi'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'activesupport', '~> 4.0.1'
|
22
|
+
spec.add_runtime_dependency 'activemodel', '~> 4.0.2'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 2.14.1'
|
27
|
+
spec.add_development_dependency 'simplecov', '~> 0.8.2'
|
28
|
+
end
|
data/lib/kosi.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'kosi/align'
|
3
|
-
require 'kosi/connector_char'
|
4
|
-
require 'kosi/header'
|
5
|
-
require 'kosi/horizontal_border_char'
|
6
|
-
require 'kosi/options'
|
7
|
-
require 'kosi/separate_each_row'
|
8
|
-
require 'kosi/vertical_border_char'
|
9
|
-
require 'table'
|
10
|
-
|
11
|
-
# TableFormat for Terminal(Use Japanese Charactors)
|
12
|
-
module Kosi
|
13
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'kosi/align'
|
3
|
+
require 'kosi/connector_char'
|
4
|
+
require 'kosi/header'
|
5
|
+
require 'kosi/horizontal_border_char'
|
6
|
+
require 'kosi/options'
|
7
|
+
require 'kosi/separate_each_row'
|
8
|
+
require 'kosi/vertical_border_char'
|
9
|
+
require 'table'
|
10
|
+
|
11
|
+
# TableFormat for Terminal(Use Japanese Charactors)
|
12
|
+
module Kosi
|
13
|
+
end
|
data/lib/kosi/align.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'kosi/options'
|
3
|
-
|
4
|
-
# TableFormat for Terminal(Use Japanese Charactors)
|
5
|
-
module Kosi
|
6
|
-
# Align
|
7
|
-
class Align
|
8
|
-
attr_reader :value
|
9
|
-
# Align Type
|
10
|
-
module TYPE
|
11
|
-
CENTER = :center
|
12
|
-
RIGHT = :right
|
13
|
-
LEFT = :left
|
14
|
-
DEFAULT = LEFT
|
15
|
-
end
|
16
|
-
|
17
|
-
def initialize(options)
|
18
|
-
@value = options[OptionKeys::ALIGN] || TYPE::DEFAULT
|
19
|
-
end
|
20
|
-
|
21
|
-
def apply(text, max_value, diff)
|
22
|
-
pos = max_value - diff
|
23
|
-
case @value
|
24
|
-
when TYPE::CENTER
|
25
|
-
text.center(pos)
|
26
|
-
when TYPE::RIGHT
|
27
|
-
text.rjust(pos)
|
28
|
-
when TYPE::LEFT
|
29
|
-
text.ljust(pos)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'kosi/options'
|
3
|
+
|
4
|
+
# TableFormat for Terminal(Use Japanese Charactors)
|
5
|
+
module Kosi
|
6
|
+
# Align
|
7
|
+
class Align
|
8
|
+
attr_reader :value
|
9
|
+
# Align Type
|
10
|
+
module TYPE
|
11
|
+
CENTER = :center
|
12
|
+
RIGHT = :right
|
13
|
+
LEFT = :left
|
14
|
+
DEFAULT = LEFT
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(options)
|
18
|
+
@value = options[OptionKeys::ALIGN] || TYPE::DEFAULT
|
19
|
+
end
|
20
|
+
|
21
|
+
def apply(text, max_value, diff)
|
22
|
+
pos = max_value - diff
|
23
|
+
case @value
|
24
|
+
when TYPE::CENTER
|
25
|
+
text.center(pos)
|
26
|
+
when TYPE::RIGHT
|
27
|
+
text.rjust(pos)
|
28
|
+
when TYPE::LEFT
|
29
|
+
text.ljust(pos)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/kosi/char_option.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
require 'kosi/options'
|
2
|
-
|
3
|
-
# TableFormat for Terminal(Use Japanese Charactors)
|
4
|
-
module Kosi
|
5
|
-
# CharOption
|
6
|
-
class CharOption
|
7
|
-
attr_reader :value
|
8
|
-
|
9
|
-
def initialize(options)
|
10
|
-
@value = String(options[key])
|
11
|
-
@value = default if @value.empty?
|
12
|
-
unless @value.size == 1
|
13
|
-
fail ArgumentError, format(invalid_char_msg, @value.size, @value)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
1
|
+
require 'kosi/options'
|
2
|
+
|
3
|
+
# TableFormat for Terminal(Use Japanese Charactors)
|
4
|
+
module Kosi
|
5
|
+
# CharOption
|
6
|
+
class CharOption
|
7
|
+
attr_reader :value
|
8
|
+
|
9
|
+
def initialize(options)
|
10
|
+
@value = String(options[key])
|
11
|
+
@value = default if @value.empty?
|
12
|
+
unless @value.size == 1
|
13
|
+
fail ArgumentError, format(invalid_char_msg, @value.size, @value)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/kosi/connector_char.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
require 'kosi/options'
|
2
|
-
require 'kosi/char_option'
|
3
|
-
|
4
|
-
# TableFormat for Terminal(Use Japanese Charactors)
|
5
|
-
module Kosi
|
6
|
-
# ConnectorChar
|
7
|
-
class ConnectorChar < CharOption
|
8
|
-
DEFAULT = '+'
|
9
|
-
INVALID_CHAR_MSG = \
|
10
|
-
'connector char must be 1 length(%d) char %s'
|
11
|
-
|
12
|
-
def default
|
13
|
-
DEFAULT
|
14
|
-
end
|
15
|
-
|
16
|
-
def key
|
17
|
-
OptionKeys::CONNECTOR_CHAR
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def invalid_char_msg
|
23
|
-
INVALID_CHAR_MSG
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
1
|
+
require 'kosi/options'
|
2
|
+
require 'kosi/char_option'
|
3
|
+
|
4
|
+
# TableFormat for Terminal(Use Japanese Charactors)
|
5
|
+
module Kosi
|
6
|
+
# ConnectorChar
|
7
|
+
class ConnectorChar < CharOption
|
8
|
+
DEFAULT = '+'
|
9
|
+
INVALID_CHAR_MSG = \
|
10
|
+
'connector char must be 1 length(%d) char %s'
|
11
|
+
|
12
|
+
def default
|
13
|
+
DEFAULT
|
14
|
+
end
|
15
|
+
|
16
|
+
def key
|
17
|
+
OptionKeys::CONNECTOR_CHAR
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def invalid_char_msg
|
23
|
+
INVALID_CHAR_MSG
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/kosi/header.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'kosi/options'
|
3
|
-
|
4
|
-
# TableFormat for Terminal(Use Japanese Charactors)
|
5
|
-
module Kosi
|
6
|
-
# Header
|
7
|
-
class Header
|
8
|
-
attr_reader :value
|
9
|
-
|
10
|
-
def initialize(options)
|
11
|
-
@value = options[OptionKeys::HEADER]
|
12
|
-
end
|
13
|
-
|
14
|
-
def empty?
|
15
|
-
@value.nil?
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'kosi/options'
|
3
|
+
|
4
|
+
# TableFormat for Terminal(Use Japanese Charactors)
|
5
|
+
module Kosi
|
6
|
+
# Header
|
7
|
+
class Header
|
8
|
+
attr_reader :value
|
9
|
+
|
10
|
+
def initialize(options)
|
11
|
+
@value = options[OptionKeys::HEADER]
|
12
|
+
end
|
13
|
+
|
14
|
+
def empty?
|
15
|
+
@value.nil?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
require 'kosi/options'
|
2
|
-
require 'kosi/char_option'
|
3
|
-
|
4
|
-
# TableFormat for Terminal(Use Japanese Charactors)
|
5
|
-
module Kosi
|
6
|
-
# HorizontalBorderChar
|
7
|
-
class HorizontalBorderChar < CharOption
|
8
|
-
DEFAULT = '-'
|
9
|
-
INVALID_CHAR_MSG = \
|
10
|
-
'horizontal_border_char must be 1 length(%d) char %s'
|
11
|
-
|
12
|
-
def default
|
13
|
-
DEFAULT
|
14
|
-
end
|
15
|
-
|
16
|
-
def key
|
17
|
-
OptionKeys::HORIZONTAL_BORDER_CHAR
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def invalid_char_msg
|
23
|
-
INVALID_CHAR_MSG
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
1
|
+
require 'kosi/options'
|
2
|
+
require 'kosi/char_option'
|
3
|
+
|
4
|
+
# TableFormat for Terminal(Use Japanese Charactors)
|
5
|
+
module Kosi
|
6
|
+
# HorizontalBorderChar
|
7
|
+
class HorizontalBorderChar < CharOption
|
8
|
+
DEFAULT = '-'
|
9
|
+
INVALID_CHAR_MSG = \
|
10
|
+
'horizontal_border_char must be 1 length(%d) char %s'
|
11
|
+
|
12
|
+
def default
|
13
|
+
DEFAULT
|
14
|
+
end
|
15
|
+
|
16
|
+
def key
|
17
|
+
OptionKeys::HORIZONTAL_BORDER_CHAR
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def invalid_char_msg
|
23
|
+
INVALID_CHAR_MSG
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|