table_format 0.0.7 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab7231e5b7852690cc4f5bccd459ca4e68667aac565963c3d2869e3354babeb9
4
- data.tar.gz: 976478a8e59a479fe702a23fb6567ada4a927eeda98b4f5fb75169c8f9a746a7
3
+ metadata.gz: 81a9dcbc3604388174a753a45576b298e6829a52252c569d6305c54038995d5b
4
+ data.tar.gz: 5cc7171b9e825bdbf83e8fe5a8650e3372287dbd815ad4b000e17dd7b7cf6303
5
5
  SHA512:
6
- metadata.gz: 88571616e3d9fb6e4bd066c7b60b76774235bff0fd65c97d593a3ce114704cae44ba14f8038465208ef4722568c8f44f8863aeae3ddce097f9528f5201c43471
7
- data.tar.gz: 7319e86e2349b73d7ba5d708899328fc47d219d03054868e1de8be5be4b2dec1c5e93ea25232521f5ad4e9c711712b9624b2b0a1d544bc1773d09cf97ebf1ac5
6
+ metadata.gz: 90613bd4d7ac0fc82907f007364d6dc1e541dc04b89b5cc66e3daa9f83f1d18bb088af19595a1ba5dc647e8a43d4d27aecbe28275213a1d7fdfb03ee22051990
7
+ data.tar.gz: 51bd2542a57f58469784800f79bd6468e2287d590779ea137299d467c7f5f5d07f3d4c69fb5353b8e39e67bbf9e14147f9f302f0f4fc053dec9b21e6b3fbdaa2
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  /*.gem
2
2
  /*.html
3
3
  /Gemfile.lock
4
+ *.ruby-version
data/.travis.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.5
3
+ - 2.6
data/README.org CHANGED
@@ -19,6 +19,32 @@ tp Object.constants.grep(/RUBY_/).map { |e| [e, Object.const_get(e)] }.to_h
19
19
  # >> | RUBY_ENGINE_VERSION | 2.5.0 |
20
20
  # >> | RUBY_COPYRIGHT | ruby - Copyright (C) 1993-2017 Yukihiro Matsumoto |
21
21
  # >> |---------------------+------------------------------------------------------------|
22
+ #+END_SRC
23
+
24
+ In the case of Rails
25
+
26
+ #+BEGIN_SRC ruby
27
+ class ApplicationController < ActionController::Base
28
+ if Rails.env.development?
29
+ before_action do
30
+ logger.debug params.to_unsafe_h.to_t(truncate: 40)
31
+ end
32
+ end
33
+ end
34
+ #+END_SRC
35
+
36
+ #+BEGIN_SRC shell
37
+ % cat log/development.log
38
+ Started POST "/api/xy_master/time_records" for ::1 at 2021-11-18 13:52:25 +0900
39
+ Processing by Api::XyMaster::TimeRecordsController#create as JSON
40
+ Parameters: (snip)
41
+ |-------------+---------------------------------------------|
42
+ | scope_key | scope_today |
43
+ | time_record | {"rule_key"=>"rule100t", "spent_sec"=>0,... |
44
+ | format | json |
45
+ | controller | api/xy_master/time_records |
46
+ | action | create |
47
+ |-------------+---------------------------------------------|
22
48
  #+END_SRC
23
49
 
24
50
  ** Installation
@@ -3,36 +3,36 @@ require 'active_support/core_ext/kernel/concern'
3
3
  module TableFormat
4
4
  concern :ActiveRecord do
5
5
  class_methods do
6
- def to_t(**options)
7
- TableFormat.generate(all.collect(&:attributes), **options)
6
+ def to_t(options = {})
7
+ TableFormat.generate(all.collect(&:attributes), options)
8
8
  end
9
9
  end
10
10
 
11
- def to_t(**options)
12
- TableFormat.generate(attributes, **options)
11
+ def to_t(options = {})
12
+ TableFormat.generate(attributes, options)
13
13
  end
14
14
  end
15
15
 
16
16
  concern :ActiveRecordResult do
17
- def to_t(**options)
18
- TableFormat.generate(collect(&:to_h), **options)
17
+ def to_t(options = {})
18
+ TableFormat.generate(collect(&:to_h), options)
19
19
  end
20
20
  end
21
21
  end
22
22
 
23
23
  Object.class_eval do
24
- def to_t(**options)
24
+ def to_t(options = {})
25
25
  case
26
26
  when respond_to?(:to_a)
27
27
  if false
28
28
  if to_a.first.respond_to?(:attributes)
29
- return to_a.collect(&:attributes).to_t(**options)
29
+ return to_a.collect(&:attributes).to_t(options)
30
30
  end
31
31
  end
32
32
 
33
- to_a.to_t(**options)
33
+ to_a.to_t(options)
34
34
  when respond_to?(:to_h)
35
- to_h.to_t(**options)
35
+ to_h.to_t(options)
36
36
  else
37
37
  TableFormat.generate([{self.class.name => self}], **{header: false}.merge(options))
38
38
  end
@@ -42,33 +42,33 @@ end
42
42
  Kernel.class_eval do
43
43
  private
44
44
 
45
- def tp(object, **options)
45
+ def tp(object, options = {})
46
46
  object.tap do
47
- table_format(object, **options).display
47
+ table_format(object, options).display
48
48
  end
49
49
  end
50
50
 
51
- def table_format(object, **options)
52
- object.to_t(**options)
51
+ def table_format(object, options = {})
52
+ object.to_t(options)
53
53
  end
54
54
  end
55
55
 
56
56
  Array.class_eval do
57
- def to_t(**options)
58
- TableFormat.generate(self, **options)
57
+ def to_t(options = {})
58
+ TableFormat.generate(self, options)
59
59
  end
60
60
  end
61
61
 
62
62
  Hash.class_eval do
63
- def to_t(**options)
64
- TableFormat.generate(self, **options)
63
+ def to_t(options = {})
64
+ TableFormat.generate(self, options)
65
65
  end
66
66
  end
67
67
 
68
68
  [Symbol, String, Numeric].each do |klass|
69
69
  klass.class_eval do
70
- def to_t(**options)
71
- TableFormat.generate([{self.class.name => self}], **{header: false}.merge(options))
70
+ def to_t(options = {})
71
+ TableFormat.generate([{self.class.name => self}], {header: false}.merge(options))
72
72
  end
73
73
  end
74
74
  end
@@ -1,4 +1,12 @@
1
1
  # frozen_string_literal: true
2
+
3
+ # Workaround of:
4
+ # uninitialized constant ActiveSupport::XmlMini::IsolatedExecutionState
5
+ begin
6
+ require 'active_support/isolated_execution_state'
7
+ rescue LoadError
8
+ end
9
+
2
10
  require 'active_support/core_ext/string' # for blank?
3
11
  require 'active_support/core_ext/class/attribute' # for class_attribute
4
12
  require 'kconv'
@@ -19,12 +27,12 @@ module TableFormat
19
27
  }
20
28
  end
21
29
 
22
- def self.generate(*args, **options)
23
- Generator.new(*args, **options).generate
30
+ def self.generate(rows, options = {})
31
+ Generator.new(rows, options).generate
24
32
  end
25
33
 
26
34
  class Generator
27
- def initialize(rows, **options)
35
+ def initialize(rows, options = {})
28
36
  @options = TableFormat.default_options.merge(options)
29
37
 
30
38
  if @options[:markdown]
@@ -6,7 +6,7 @@ module TableFormat
6
6
  ::ActiveRecord::Result.include TableFormat::ActiveRecordResult
7
7
 
8
8
  ::ActiveRecord::Relation.class_eval do
9
- def to_t(**options)
9
+ def to_t(options = {})
10
10
  TableFormat.generate(to_a.collect(&:attributes), options)
11
11
  end
12
12
  end
@@ -1,3 +1,3 @@
1
1
  module TableFormat
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.11'
3
3
  end
data/lib/table_format.rb CHANGED
@@ -11,7 +11,7 @@ else
11
11
  ::ActiveRecord::Result.include(TableFormat::ActiveRecordResult)
12
12
 
13
13
  ::ActiveRecord::Relation.class_eval do
14
- def to_t(**options)
14
+ def to_t(options = {})
15
15
  TableFormat.generate(to_a.collect(&:attributes), options)
16
16
  end
17
17
  end
data/table_format.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_dependency 'activesupport'
23
23
 
24
- spec.add_development_dependency 'bundler', '~> 1.3'
24
+ spec.add_development_dependency 'bundler'
25
25
  spec.add_development_dependency 'rake'
26
26
  spec.add_development_dependency 'rspec'
27
27
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_format
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - akicho8
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-05 00:00:00.000000000 Z
11
+ date: 2022-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.3'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -128,7 +128,7 @@ files:
128
128
  homepage: https://github.com/akicho8/table_format
129
129
  licenses: []
130
130
  metadata: {}
131
- post_install_message:
131
+ post_install_message:
132
132
  rdoc_options:
133
133
  - "--line-numbers"
134
134
  - "--inline-source"
@@ -148,8 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  requirements: []
151
- rubygems_version: 3.1.2
152
- signing_key:
151
+ rubygems_version: 3.3.4
152
+ signing_key:
153
153
  specification_version: 4
154
154
  summary: TableFormat shows text table like emacs org-table for easy reading.
155
155
  test_files: