table_format 0.0.16 → 0.0.17

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: f00e1e8399327b1651abb33fa72c06400843fd3e04aae71ac36fef66b3f2e2ef
4
- data.tar.gz: f0379b5f92615fcb0215eb04a73260448461a08fef2accea59c0832d38145846
3
+ metadata.gz: d2752df2f0db0f5d84573bbd952c30da482384ef3395fbfb2f08ef1010b967c9
4
+ data.tar.gz: 20bc0d54d2be430b9dafe22e3039c7daf7bd7b728e3f08f4e2462994fae4e310
5
5
  SHA512:
6
- metadata.gz: fb056ac12dcb67bd0c69f90c0154d261c99b04d3095b6975e4136b8348f925dc96bc91edb53eaa204fe2342e4bf76bc064207d4ab3b08af3e4aa2b12185450d3
7
- data.tar.gz: 92d165bf8fb20f2b6d30bc39e570cfe9e4618f48216dc79383d2ba4891149d40461cb55eb3ddb26b7510893bd48f9a1a1812b559a3883e171d71687d4529897b
6
+ metadata.gz: 92d56845f4dba68f76c81489e8d28227ffcd07b305b9bb2be8ef6d38ef7a125777a0cf8184079d76d7689577fdb348531f5955a692c974108b4f153102f0e129
7
+ data.tar.gz: 03a01a0ff5655cebf11bcd8e36e11711d14bd778c4060a84646fb10cbfb67107e0bad3efe84d9794131275207748f6ac9b413c418cc526f39e37804c7ecefa73
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in advanced_annotate_models.gemspec
3
+ # Specify your gem"s dependencies in advanced_annotate_models.gemspec
4
4
  gemspec
data/README.org CHANGED
@@ -67,7 +67,7 @@ $ bundle install
67
67
  *** Array of hash
68
68
 
69
69
  #+BEGIN_SRC ruby
70
- tp [{id: 1, name: 'alice'}, {id: 2, name: 'bob'}]
70
+ tp [{id: 1, name: "alice"}, {id: 2, name: "bob"}]
71
71
  # >> |----+-------|
72
72
  # >> | id | name |
73
73
  # >> |----+-------|
@@ -79,7 +79,7 @@ tp [{id: 1, name: 'alice'}, {id: 2, name: 'bob'}]
79
79
  *** Hash
80
80
 
81
81
  #+BEGIN_SRC ruby
82
- tp({id: 1, name: 'alice'})
82
+ tp({id: 1, name: "alice"})
83
83
  # >> |------+-------|
84
84
  # >> | id | 1 |
85
85
  # >> | name | alice |
@@ -99,7 +99,7 @@ tp [:alice, :bob]
99
99
  *** ActiveRecord or Mongoid
100
100
 
101
101
  #+BEGIN_SRC ruby
102
- ['alice', 'bob'].each { |e| User.create!(name: e) }
102
+ ["alice", "bob"].each { |e| User.create!(name: e) }
103
103
  #+END_SRC
104
104
 
105
105
  #+BEGIN_SRC ruby
@@ -132,7 +132,7 @@ tp User.first
132
132
  **** ActiveRecord::Result
133
133
 
134
134
  #+BEGIN_SRC ruby
135
- tp ActiveRecord::Base.connection.select_all('SELECT * FROM users')
135
+ tp ActiveRecord::Base.connection.select_all("SELECT * FROM users")
136
136
  # >> |----+-------|
137
137
  # >> | id | name |
138
138
  # >> |----+-------|
@@ -146,7 +146,7 @@ tp ActiveRecord::Base.connection.select_all('SELECT * FROM users')
146
146
  Use to_t method.
147
147
 
148
148
  #+BEGIN_SRC ruby
149
- puts [{id: 1, name: 'alice'}, {id: 2, name: 'bob'}].to_t
149
+ puts [{id: 1, name: "alice"}, {id: 2, name: "bob"}].to_t
150
150
  # >> |----+-------|
151
151
  # >> | id | name |
152
152
  # >> |----+-------|
@@ -165,7 +165,7 @@ tp 1
165
165
  # >> | 1 |
166
166
  # >> |---|
167
167
 
168
- tp 1, intersection_both: '+'
168
+ tp 1, intersection_both: "+"
169
169
  # >> +---+
170
170
  # >> | 1 |
171
171
  # >> +---+
@@ -173,10 +173,10 @@ tp 1, intersection_both: '+'
173
173
 
174
174
  *** Markdown format example
175
175
 
176
- =markdown: true= has the same meaning as =intersection: '|', cover: false=
176
+ =markdown: true= has the same meaning as =intersection: "|", cover: false=
177
177
 
178
178
  #+BEGIN_SRC ruby
179
- tp [{id: 1, name: 'alice'}, {id: 2, name: 'bob'}], markdown: true
179
+ tp [{id: 1, name: "alice"}, {id: 2, name: "bob"}], markdown: true
180
180
  # >> | id | name |
181
181
  # >> |----|-------|
182
182
  # >> | 1 | alice |
@@ -184,7 +184,7 @@ tp [{id: 1, name: 'alice'}, {id: 2, name: 'bob'}], markdown: true
184
184
  #+END_SRC
185
185
 
186
186
  #+BEGIN_SRC ruby
187
- tp [{id: 1, name: 'alice'}, {id: 2, name: 'bob'}], intersection: '|', cover: false
187
+ tp [{id: 1, name: "alice"}, {id: 2, name: "bob"}], intersection: "|", cover: false
188
188
  # >> | id | name |
189
189
  # >> |----|-------|
190
190
  # >> | 1 | alice |
@@ -212,7 +212,7 @@ tp 1
212
212
  # >> | 1 |
213
213
  # >> |---|
214
214
 
215
- TableFormat.default_options[:intersection_both] = '+'
215
+ TableFormat.default_options[:intersection_both] = "+"
216
216
 
217
217
  tp 1
218
218
  # >> +---+
@@ -1,15 +1,15 @@
1
- $LOAD_PATH << '../lib'
2
- require 'table_format'
1
+ $LOAD_PATH << "../lib"
2
+ require "table_format"
3
3
 
4
4
  tp :ok
5
- tp 'foo'
5
+ tp "foo"
6
6
  tp :foo
7
7
  tp [:alice, :bob]
8
- tp({id: 1, name: 'alice'})
9
- tp [{id: 1, name: 'alice'}, {id: 2, name: 'bob'}]
10
- puts [{id: 1, name: 'alice'}, {id: 2, name: 'bob'}].to_t
11
- puts [{'a': ['a']}].to_t
12
- puts [{'a': {'a': 1}}].to_t
8
+ tp({id: 1, name: "alice"})
9
+ tp [{id: 1, name: "alice"}, {id: 2, name: "bob"}]
10
+ puts [{id: 1, name: "alice"}, {id: 2, name: "bob"}].to_t
11
+ puts [{"a": ["a"]}].to_t
12
+ puts [{"a": {"a": 1}}].to_t
13
13
  # >> |----|
14
14
  # >> | ok |
15
15
  # >> |----|
@@ -1,10 +1,10 @@
1
- $LOAD_PATH << '../lib'
2
- require 'active_record'
3
- require 'table_format'
1
+ $LOAD_PATH << "../lib"
2
+ require "active_record"
3
+ require "table_format"
4
4
 
5
5
  # tp ::ActiveRecord::Result.ancestors
6
6
 
7
- ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
7
+ ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
8
8
  ActiveRecord::Migration.verbose = false
9
9
  ActiveRecord::Schema.define do
10
10
  create_table :users do |t|
@@ -15,7 +15,7 @@ end
15
15
  class User < ActiveRecord::Base
16
16
  end
17
17
 
18
- ['alice', 'bob', 'carol'].each { |e| User.create!(name: e) }
18
+ ["alice", "bob", "carol"].each { |e| User.create!(name: e) }
19
19
 
20
20
  tp User.limit(2)
21
21
 
@@ -26,9 +26,9 @@ p User.limit(1).class.name # => "ActiveRecord::Relation"
26
26
  tp User.limit(1)
27
27
  puts table_format(User.limit(1))
28
28
 
29
- tp ActiveRecord::Base.connection.select_all('SELECT * FROM users')
30
- tp ActiveRecord::Base.connection.select_one('SELECT * FROM users')
31
- tp ActiveRecord::Base.connection.select_value('SELECT 1 + 2')
29
+ tp ActiveRecord::Base.connection.select_all("SELECT * FROM users")
30
+ tp ActiveRecord::Base.connection.select_one("SELECT * FROM users")
31
+ tp ActiveRecord::Base.connection.select_value("SELECT 1 + 2")
32
32
 
33
33
  puts User.first.to_t
34
34
 
@@ -1,10 +1,10 @@
1
- $LOAD_PATH << '../lib'
2
- require 'table_format'
1
+ $LOAD_PATH << "../lib"
2
+ require "table_format"
3
3
 
4
- tp 1, intersection_both: '+'
4
+ tp 1, intersection_both: "+"
5
5
 
6
6
  tp TableFormat.default_options
7
- TableFormat.default_options.update(intersection_both: '+')
7
+ TableFormat.default_options.update(intersection_both: "+")
8
8
  tp TableFormat.default_options
9
9
 
10
10
  # >> +---+
@@ -1,10 +1,10 @@
1
- $LOAD_PATH << '../lib'
2
- require 'active_record'
3
- require 'mongoid'
4
- require 'table_format'
1
+ $LOAD_PATH << "../lib"
2
+ require "active_record"
3
+ require "mongoid"
4
+ require "table_format"
5
5
 
6
6
  Mongo::Logger.logger.level = Logger::INFO
7
- Mongoid::Config.connect_to('test')
7
+ Mongoid::Config.connect_to("test")
8
8
  Mongoid::Clients.default.database.drop
9
9
 
10
10
  class User
@@ -12,7 +12,7 @@ class User
12
12
  field :name, type: String
13
13
  end
14
14
 
15
- ['alice', 'bob', 'carol'].each { |e| User.create!(name: e) }
15
+ ["alice", "bob", "carol"].each { |e| User.create!(name: e) }
16
16
 
17
17
  tp User
18
18
  tp User.first
@@ -1,21 +1,21 @@
1
- $LOAD_PATH << '../lib'
2
- require 'table_format'
1
+ $LOAD_PATH << "../lib"
2
+ require "table_format"
3
3
 
4
4
  array = [
5
- {id: 1, name: 'alice' },
6
- {id: 2, name: 'bob' },
5
+ {id: 1, name: "alice" },
6
+ {id: 2, name: "bob" },
7
7
  ]
8
8
 
9
9
  # tp with options
10
- tp array, intersection: '|', cover: false
10
+ tp array, intersection: "|", cover: false
11
11
 
12
12
  # to_t with options
13
- array.to_t(intersection: '|', cover: false) # => "| id | name |\n|----|-------|\n| 1 | alice |\n| 2 | bob |\n"
13
+ array.to_t(intersection: "|", cover: false) # => "| id | name |\n|----|-------|\n| 1 | alice |\n| 2 | bob |\n"
14
14
 
15
15
  puts
16
16
 
17
17
  # set global options
18
- TableFormat.default_options.update(intersection: '|', cover: false)
18
+ TableFormat.default_options.update(intersection: "|", cover: false)
19
19
  tp array
20
20
 
21
21
  ######################################## markdown option
@@ -1,5 +1,5 @@
1
- $LOAD_PATH << '../lib'
2
- require 'table_format'
1
+ $LOAD_PATH << "../lib"
2
+ require "table_format"
3
3
 
4
4
  tp [
5
5
  {id: 1, name: "foo\nbar" },
@@ -1,5 +1,5 @@
1
- $LOAD_PATH << '../lib'
2
- require 'table_format'
1
+ $LOAD_PATH << "../lib"
2
+ require "table_format"
3
3
 
4
4
  TableFormat.default_options.update(truncate: 2)
5
5
 
@@ -1,5 +1,5 @@
1
- $LOAD_PATH << '../lib'
2
- require 'table_format'
1
+ $LOAD_PATH << "../lib"
2
+ require "table_format"
3
3
 
4
4
  tp "♡"
5
5
  # >> |----|
@@ -1,6 +1,6 @@
1
- $LOAD_PATH << '../lib'
2
- require 'table_format'
3
- require 'ostruct'
1
+ $LOAD_PATH << "../lib"
2
+ require "table_format"
3
+ require "ostruct"
4
4
 
5
5
  class C1
6
6
  extend Enumerable
@@ -1,5 +1,5 @@
1
- $LOAD_PATH << '../lib'
2
- require 'table_format'
1
+ $LOAD_PATH << "../lib"
2
+ require "table_format"
3
3
 
4
4
  require "active_support/logger"
5
5
 
@@ -1,5 +1,5 @@
1
- $LOAD_PATH << '../lib'
2
- require 'table_format'
1
+ $LOAD_PATH << "../lib"
2
+ require "table_format"
3
3
 
4
4
  tp "ア"
5
5
  # >> |---|
@@ -1,5 +1,4 @@
1
- require 'active_support'
2
- require 'active_support/core_ext/kernel/concern'
1
+ require "active_support/core_ext/kernel/concern"
3
2
 
4
3
  module TableFormat
5
4
  concern :ActiveRecord do
@@ -1,23 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support'
4
- require 'active_support/core_ext/object/blank' # for blank?
5
- require 'active_support/core_ext/class/attribute' # for class_attribute
6
- require 'kconv'
3
+ require "active_support/core_ext/object/blank" # for blank?
4
+ require "active_support/core_ext/module/attribute_accessors" # for class_attribute
5
+ require "kconv"
7
6
 
8
7
  module TableFormat
9
8
  mattr_accessor :default_options do
10
9
  {
11
- markdown: false, # Same as {intersection: '|', :cover: false}
12
- header: nil,
13
- cover: true,
14
- vertical: '|',
15
- intersection: '+',
16
- intersection_both: '|',
17
- horizon: '-',
18
- padding: ' ',
19
- truncate: 256,
20
- in_code: Kconv::UTF8,
10
+ :markdown => false, # Same as {intersection: "|", :cover: false}
11
+ :header => nil,
12
+ :cover => true,
13
+ :vertical => "|",
14
+ :intersection => "+",
15
+ :intersection_both => "|",
16
+ :horizon => "-",
17
+ :padding => " ",
18
+ :truncate => 256,
19
+ :in_code => Kconv::UTF8,
21
20
  }
22
21
  end
23
22
 
@@ -34,7 +33,7 @@ module TableFormat
34
33
  @options = TableFormat.default_options.merge(options)
35
34
 
36
35
  if @options[:markdown]
37
- @options[:intersection] = '|'
36
+ @options[:intersection] = "|"
38
37
  @options[:cover] = false
39
38
  end
40
39
 
@@ -44,7 +43,7 @@ module TableFormat
44
43
 
45
44
  def generate
46
45
  if @rows.blank?
47
- return ''
46
+ return ""
48
47
  end
49
48
 
50
49
  pre_processes.each do |e|
@@ -145,9 +144,9 @@ module TableFormat
145
144
  align = (@options[:align] || {}).fetch(all_columns[i]) do
146
145
  Float(value) && :right rescue :left
147
146
  end
148
- space = ' ' * (column_widths[i] - str_width(value))
149
- lspace = ''
150
- rspace = ''
147
+ space = " " * (column_widths[i] - str_width(value))
148
+ lspace = ""
149
+ rspace = ""
151
150
  if align == :right
152
151
  lspace = space
153
152
  else
@@ -183,10 +182,10 @@ module TableFormat
183
182
  header: false,
184
183
  process: -> e {
185
184
  e.collect do |k, v|
186
- {'(key)' => k.to_s, '(value)' => v.to_s}
185
+ {"(key)" => k.to_s, "(value)" => v.to_s}
187
186
  end
188
187
  },
189
- align: {'(key)' => :right, '(value)' => :left},
188
+ align: {"(key)" => :right, "(value)" => :left},
190
189
  },
191
190
 
192
191
  # Array of Hash
@@ -202,7 +201,7 @@ module TableFormat
202
201
  header: false,
203
202
  process: -> e {
204
203
  e.collect do |v|
205
- {'(array_element)' => v}
204
+ {"(array_element)" => v}
206
205
  end
207
206
  },
208
207
  },
@@ -216,7 +215,7 @@ module TableFormat
216
215
  if v.kind_of? Hash
217
216
  v
218
217
  else
219
- {'(array_element)' => v}
218
+ {"(array_element)" => v}
220
219
  end
221
220
  end
222
221
  },
@@ -228,9 +227,9 @@ end
228
227
 
229
228
  if $0 == __FILE__
230
229
  rows = [
231
- {id: 1, name: 'alice', description: '0123456789'},
232
- {id: 2, name: 'bob', description: 'あいうえお'},
233
- {id: 3, name: 'carol'},
230
+ { id: 1, name: "alice", description: "0123456789" },
231
+ { id: 2, name: "bob", description: "あいうえお" },
232
+ { id: 3, name: "carol" },
234
233
  ]
235
234
  print TableFormat.generate({a: []})
236
235
  print TableFormat.generate([])
@@ -1,6 +1,6 @@
1
1
  module TableFormat
2
2
  class Railtie < Rails::Railtie
3
- initializer 'table_format' do
3
+ initializer "table_format" do
4
4
  ActiveSupport.on_load(:active_record) do
5
5
  include TableFormat::ActiveRecord
6
6
  ::ActiveRecord::Result.include TableFormat::ActiveRecordResult
@@ -1,3 +1,3 @@
1
1
  module TableFormat
2
- VERSION = '0.0.16'
2
+ VERSION = "0.0.17"
3
3
  end
data/lib/table_format.rb CHANGED
@@ -1,21 +1,22 @@
1
- require 'table_format/version'
2
- require 'table_format/generator'
3
- require 'table_format/core_ext'
1
+ require "table_format/version"
2
+ require "table_format/generator"
3
+ require "table_format/core_ext"
4
4
 
5
5
  if defined?(Rails)
6
- require 'table_format/railtie'
6
+ require "table_format/railtie"
7
7
  else
8
8
  if defined?(ActiveSupport)
9
- ActiveSupport.on_load(:active_record) do
10
- include TableFormat::ActiveRecord
11
- ::ActiveRecord::Result.include(TableFormat::ActiveRecordResult)
9
+ if ActiveSupport.respond_to?(:on_load)
10
+ ActiveSupport.on_load(:active_record) do
11
+ include TableFormat::ActiveRecord
12
+ ::ActiveRecord::Result.include(TableFormat::ActiveRecordResult)
12
13
 
13
- ::ActiveRecord::Relation.class_eval do
14
- def to_t(options = {})
15
- TableFormat.generate(to_a.collect(&:attributes), options)
14
+ ::ActiveRecord::Relation.class_eval do
15
+ def to_t(options = {})
16
+ TableFormat.generate(to_a.collect(&:attributes), options)
17
+ end
16
18
  end
17
19
  end
18
-
19
20
  end
20
21
  end
21
22
  if defined?(Mongoid::Document)
@@ -1,8 +1,8 @@
1
- require_relative 'spec_helper'
2
- require 'active_record'
1
+ require_relative "spec_helper"
2
+ require "active_record"
3
3
 
4
4
  ActiveRecord::Base.send(:include, TableFormat::ActiveRecord)
5
- ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
5
+ ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
6
6
  ActiveRecord::Migration.verbose = false
7
7
 
8
8
  ActiveRecord::Schema.define do
@@ -35,7 +35,7 @@ EOT
35
35
  |------+---|
36
36
  EOT
37
37
 
38
- ActiveRecord::Base.connection.select_all('select * from users').to_t.should == <<~EOT
38
+ ActiveRecord::Base.connection.select_all("select * from users").to_t.should == <<~EOT
39
39
  |----+------|
40
40
  | id | name |
41
41
  |----+------|
@@ -1,8 +1,8 @@
1
- require_relative 'spec_helper'
1
+ require_relative "spec_helper"
2
2
 
3
3
  describe TableFormat do
4
- require 'tempfile'
5
- require 'active_support/testing/stream'
4
+ require "tempfile"
5
+ require "active_support/testing/stream"
6
6
  include ActiveSupport::Testing::Stream
7
7
 
8
8
  it do
@@ -13,12 +13,12 @@ describe TableFormat do
13
13
  EOT
14
14
  end
15
15
 
16
- it 'result is like p method' do
16
+ it "result is like p method" do
17
17
  v = Object.new
18
18
  quietly { tp v }.should == v
19
19
  end
20
20
 
21
- it 'tp with options' do
21
+ it "tp with options" do
22
22
  capture(:stdout) { tp({id: 123}, truncate: 1) }.should == <<~EOT
23
23
  |------+------|
24
24
  | i... | 1... |
@@ -26,7 +26,7 @@ describe TableFormat do
26
26
  EOT
27
27
  end
28
28
 
29
- it 'hankaku katakana' do
29
+ it "hankaku katakana" do
30
30
  capture(:stdout) { tp("ア") }.should == <<~EOT
31
31
  |---|
32
32
  | ア |
data/spec/object_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require_relative 'spec_helper'
1
+ require_relative "spec_helper"
2
2
  require "ostruct"
3
3
 
4
4
  describe TableFormat do
@@ -60,10 +60,10 @@ EOT
60
60
  EOT
61
61
 
62
62
  C4.to_t.should == <<~EOT
63
- |-----------------------------------|
64
- | #<OpenStruct attributes={:id=>1}> |
65
- | #<OpenStruct attributes={:id=>2}> |
66
- |-----------------------------------|
63
+ |----------------------------------|
64
+ | #<OpenStruct attributes={id: 1}> |
65
+ | #<OpenStruct attributes={id: 2}> |
66
+ |----------------------------------|
67
67
  EOT
68
68
  end
69
69
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
- require 'table_format'
1
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
2
+ require "table_format"
3
3
 
4
4
  RSpec.configure do |config|
5
5
  config.expect_with :rspec do |c|
@@ -1,19 +1,19 @@
1
- require_relative 'spec_helper'
1
+ require_relative "spec_helper"
2
2
 
3
3
  describe TableFormat do
4
4
  before do
5
5
  @rows = [
6
- {id: 1, name: 'alice', description: '0123456789'},
7
- {id: 2, name: 'bob', description: 'あいうえお'},
8
- {id: 3, name: 'bob'},
6
+ {id: 1, name: "alice", description: "0123456789"},
7
+ {id: 2, name: "bob", description: "あいうえお"},
8
+ {id: 3, name: "bob"},
9
9
  ]
10
10
  end
11
11
 
12
- it 'empty array' do
13
- TableFormat.generate([]).should == ''
12
+ it "empty array" do
13
+ TableFormat.generate([]).should == ""
14
14
  end
15
15
 
16
- it 'default' do
16
+ it "default" do
17
17
  TableFormat.generate(@rows).should == <<~EOT
18
18
  |----+-------+-------------|
19
19
  | id | name | description |
@@ -25,7 +25,7 @@ describe TableFormat do
25
25
  EOT
26
26
  end
27
27
 
28
- it 'header: false' do
28
+ it "header: false" do
29
29
  TableFormat.generate(@rows, header: false).should == <<~EOT
30
30
  |---+-------+------------|
31
31
  | 1 | alice | 0123456789 |
@@ -35,8 +35,8 @@ EOT
35
35
  EOT
36
36
  end
37
37
 
38
- it 'padding disable' do
39
- TableFormat.generate(@rows, padding: '').should == <<~EOT
38
+ it "padding disable" do
39
+ TableFormat.generate(@rows, padding: "").should == <<~EOT
40
40
  |--+-----+-----------|
41
41
  |id|name |description|
42
42
  |--+-----+-----------|
@@ -47,8 +47,8 @@ EOT
47
47
  EOT
48
48
  end
49
49
 
50
- it 'markdown format' do
51
- TableFormat.generate(@rows, intersection: '|', cover: false).should == <<~EOT
50
+ it "markdown format" do
51
+ TableFormat.generate(@rows, intersection: "|", cover: false).should == <<~EOT
52
52
  | id | name | description |
53
53
  |----|-------|-------------|
54
54
  | 1 | alice | 0123456789 |
@@ -65,15 +65,15 @@ EOT
65
65
  EOT
66
66
  end
67
67
 
68
- it 'Convert line breaks to \n' do
69
- TableFormat.generate(["a\nb"]).should == <<~'EOT'
68
+ it "Convert line breaks to \n" do
69
+ TableFormat.generate(['a\nb']).should == <<~'EOT'
70
70
  |------|
71
71
  | a\nb |
72
72
  |------|
73
73
  EOT
74
74
  end
75
75
 
76
- it 'truncate' do
76
+ it "truncate" do
77
77
  TableFormat.generate(["0123"], truncate: 2).should == <<~EOT
78
78
  |-------|
79
79
  | 01... |
@@ -81,8 +81,8 @@ EOT
81
81
  EOT
82
82
  end
83
83
 
84
- describe 'various to_t' do
85
- it 'hash array' do
84
+ describe "various to_t" do
85
+ it "hash array" do
86
86
  [{a: 1}].to_t.should == <<~EOT
87
87
  |---|
88
88
  | a |
@@ -92,7 +92,7 @@ EOT
92
92
  EOT
93
93
  end
94
94
 
95
- it 'Hash' do
95
+ it "Hash" do
96
96
  {a: 1}.to_t.should == <<~EOT
97
97
  |---+---|
98
98
  | a | 1 |
@@ -100,8 +100,8 @@ EOT
100
100
  EOT
101
101
  end
102
102
 
103
- it 'String Array' do
104
- ['a', 'b'].to_t.should == <<~EOT
103
+ it "String Array" do
104
+ ["a", "b"].to_t.should == <<~EOT
105
105
  |---|
106
106
  | a |
107
107
  | b |
@@ -109,7 +109,7 @@ EOT
109
109
  EOT
110
110
  end
111
111
 
112
- it 'Struct' do
112
+ it "Struct" do
113
113
  Struct.new(:a, :b).new(1, 2).to_h.to_t.should == <<~EOT
114
114
  |---+---|
115
115
  | a | 1 |
@@ -118,9 +118,9 @@ EOT
118
118
  EOT
119
119
  end
120
120
 
121
- it 'Others' do
121
+ it "Others" do
122
122
  1.to_t.should be_present
123
- '1'.to_t.should be_present
123
+ "1".to_t.should be_present
124
124
  Module.new.should be_present
125
125
  {[:a] => []}.to_t.should == <<~EOT
126
126
  |------+----|
@@ -129,8 +129,8 @@ EOT
129
129
  EOT
130
130
  end
131
131
 
132
- it 'Array of hashes and width is correct even when value is array' do
133
- TableFormat.generate([{'a' => ['a']}]).should == <<~EOT
132
+ it "Array of hashes and width is correct even when value is array" do
133
+ TableFormat.generate([{"a" => ["a"]}]).should == <<~EOT
134
134
  |-------|
135
135
  | a |
136
136
  |-------|
@@ -139,7 +139,7 @@ EOT
139
139
  EOT
140
140
  end
141
141
 
142
- it 'Array containing Hash and others' do
142
+ it "Array containing Hash and others" do
143
143
  TableFormat.generate([["a", "b"], {"c" => "d"}]).should == <<~EOT
144
144
  |-----------------+---|
145
145
  | (array_element) | c |
@@ -151,7 +151,7 @@ EOT
151
151
  end
152
152
  end
153
153
 
154
- it 'emoji' do
154
+ it "emoji" do
155
155
  "♡".to_t.should == <<~EOT
156
156
  |----|
157
157
  | ♡ |
@@ -159,3 +159,5 @@ EOT
159
159
  EOT
160
160
  end
161
161
  end
162
+ # ~> -:1:in `require_relative': cannot load such file -- /Users/ikeda/src/table_format/spec_helper (LoadError)
163
+ # ~> from -:1:in `<main>'
data/table_format.gemspec CHANGED
@@ -1,30 +1,32 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'table_format/version'
4
+ require "table_format/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = 'table_format'
7
+ spec.name = "table_format"
8
8
  spec.version = TableFormat::VERSION
9
- spec.author = 'akicho8'
10
- spec.email = 'akicho8@gmail.com'
11
- spec.homepage = 'https://github.com/akicho8/table_format'
12
- spec.summary = 'TableFormat shows text table like emacs org-table for easy reading.'
13
- spec.description = 'TableFormat shows text table like emacs org-table for easy reading.'
9
+ spec.author = "akicho8"
10
+ spec.email = "akicho8@gmail.com"
11
+ spec.homepage = "https://github.com/akicho8/table_format"
12
+ spec.summary = "TableFormat shows text table like emacs org-table for easy reading."
13
+ spec.description = "TableFormat shows text table like emacs org-table for easy reading."
14
14
  spec.platform = Gem::Platform::RUBY
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ['lib']
20
- spec.rdoc_options = ['--line-numbers', '--inline-source', '--charset=UTF-8', '--diagram', '--image-format=jpg']
19
+ spec.require_paths = ["lib"]
20
+ spec.rdoc_options = ["--line-numbers", "--inline-source", "--charset=UTF-8", "--diagram", "--image-format=jpg"]
21
21
 
22
- spec.add_dependency 'activesupport'
22
+ spec.add_dependency "activesupport"
23
+ spec.add_dependency "nkf"
23
24
 
24
- spec.add_development_dependency 'bundler'
25
- spec.add_development_dependency 'rake'
26
- spec.add_development_dependency 'rspec'
25
+ spec.add_development_dependency "bundler"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec"
27
28
 
28
- spec.add_development_dependency 'activerecord'
29
- spec.add_development_dependency 'sqlite3'
29
+ spec.add_development_dependency "activerecord"
30
+ spec.add_development_dependency "sqlite3"
31
+ spec.add_development_dependency "ostruct"
30
32
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_format
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - akicho8
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-10-17 00:00:00.000000000 Z
10
+ date: 2025-03-25 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -24,6 +23,20 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: nkf
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
27
40
  - !ruby/object:Gem::Dependency
28
41
  name: bundler
29
42
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +107,20 @@ dependencies:
94
107
  - - ">="
95
108
  - !ruby/object:Gem::Version
96
109
  version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: ostruct
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
97
124
  description: TableFormat shows text table like emacs org-table for easy reading.
98
125
  email: akicho8@gmail.com
99
126
  executables: []
@@ -113,7 +140,7 @@ files:
113
140
  - examples/0150_line_break.rb
114
141
  - examples/0160_truncate.rb
115
142
  - examples/0170_emoji.rb
116
- - examples/0180_object.rb
143
+ - examples/0180_object_spec.rb
117
144
  - examples/0190_table_print.rb
118
145
  - examples/0200_hankaku_katakana.rb
119
146
  - lib/table_format.rb
@@ -130,7 +157,6 @@ files:
130
157
  homepage: https://github.com/akicho8/table_format
131
158
  licenses: []
132
159
  metadata: {}
133
- post_install_message:
134
160
  rdoc_options:
135
161
  - "--line-numbers"
136
162
  - "--inline-source"
@@ -150,8 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
176
  - !ruby/object:Gem::Version
151
177
  version: '0'
152
178
  requirements: []
153
- rubygems_version: 3.4.12
154
- signing_key:
179
+ rubygems_version: 3.6.6
155
180
  specification_version: 4
156
181
  summary: TableFormat shows text table like emacs org-table for easy reading.
157
182
  test_files: