tablesmith 0.6.0 → 0.6.2

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: e3c75c62ab94384c394373d395134e52bbb21e4e94f8cc94646f450ada1f9678
4
- data.tar.gz: 9aa2c83212ca484555bd5f7344e38e0ddc7b603315e2f976ff29e6054bb571bb
3
+ metadata.gz: e087948276046a5d4ca9af901465ce4afe11c627acd172b1be29d6a46e018672
4
+ data.tar.gz: 1f366c3de38e86d801d38a8f1356fa76f11d6b71eb5b5d1c8df59331be3dafcc
5
5
  SHA512:
6
- metadata.gz: f0b940e2db92a0941ed25daaf81f501bec3d13964e1769f4d582a2966d76674ab151b6576010929ee2028f01e02e9fbdd10de0e526e7a7c0d26680f31193b1ee
7
- data.tar.gz: 949d1f0e968bb9f4c8315508e755ba596736e9cb68dc037f5c06bbce3303e2062ac235e942f32b44a8ca9943b2961a42846270847dab18cb3a1b62a0e3ae32d1
6
+ metadata.gz: b2f5bd5a0c206007be448a651aaf9de768615d526640c0bf3edd760b3e369303da06554aa18cc304faaf4d2940a9dfa824a25a0bbba06f4273e2b6680fb785a2
7
+ data.tar.gz: effe9b8dcfaa3d1f747006aa05af31d4eb92586af0ab358a17e36ece76b019cc2698178af52a98bd219b3366af1e8051c7c0a012b915fa7da33793bb314e82ad
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tablesmith
4
- VERSION = '0.6.0'
4
+ VERSION = '0.6.2'
5
5
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
+ # rubocop:disable Rails/SkipsModelValidations
5
6
  describe 'ActiveRecordSource' do
6
7
  it 'outputs text table of multiple ActiveRecords' do
7
8
  a = Person.new.tap { |c| c.first_name = 'A' }
@@ -360,3 +361,4 @@ describe 'ActiveRecordSource' do
360
361
  end
361
362
  end
362
363
  end
364
+ # rubocop:enable Rails/SkipsModelValidations
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tablesmith
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrismo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-21 00:00:00.000000000 Z
11
+ date: 2020-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: text-table
@@ -136,6 +136,34 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-performance
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop-rails
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
139
167
  - !ruby/object:Gem::Dependency
140
168
  name: simplecov
141
169
  requirement: !ruby/object:Gem::Requirement
@@ -167,26 +195,10 @@ dependencies:
167
195
  description: Minimal console table
168
196
  email:
169
197
  - chrismo@clabs.org
170
- executables:
171
- - console
198
+ executables: []
172
199
  extensions: []
173
200
  extra_rdoc_files: []
174
201
  files:
175
- - ".gitignore"
176
- - ".rspec"
177
- - ".rubocop.yml"
178
- - ".ruby-version"
179
- - ".travis.yml"
180
- - Appraisals
181
- - Gemfile
182
- - LICENSE
183
- - README.md
184
- - Rakefile
185
- - bin/console
186
- - gemfiles/activerecord_4.gemfile
187
- - gemfiles/activerecord_5.1.gemfile
188
- - gemfiles/activerecord_5.2.gemfile
189
- - gemfiles/activerecord_6.0.gemfile
190
202
  - lib/tablesmith.rb
191
203
  - lib/tablesmith/active_record_source.rb
192
204
  - lib/tablesmith/array_rows_source.rb
@@ -203,7 +215,6 @@ files:
203
215
  - spec/hash_table_spec.rb
204
216
  - spec/spec_helper.rb
205
217
  - spec/table_spec.rb
206
- - tablesmith.gemspec
207
218
  homepage: http://github.com/livingsocial/tablesmith
208
219
  licenses: []
209
220
  metadata: {}
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- .bundle/
2
- .idea/
3
- bin/
4
- pkg/
5
- Gemfile.lock
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --backtrace
2
- --color
@@ -1,124 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.3
3
-
4
- Layout/ClassStructure:
5
- Enabled: true
6
- Categories:
7
- module_inclusion:
8
- - include
9
- - prepend
10
- - extend
11
- association:
12
- - has_many
13
- - has_one
14
- - belongs_to
15
- - has_and_belongs_to_many
16
- validations:
17
- - validate
18
- - validates_inclusion_of
19
- - validates_presence_of
20
- callbacks:
21
- - before_initialize
22
- - before_validation
23
- - before_save
24
- - before_create
25
- - before_update
26
- - before_destroy
27
- - after_save
28
- - after_create
29
- - after_validation
30
- - after_initialize
31
- - after_update
32
- - after_destroy
33
- enums:
34
- - enum
35
- scopes:
36
- - scope
37
- ExpectedOrder:
38
- - association
39
- - module_inclusion
40
- - validations
41
- - constants
42
- - enums
43
- - callbacks
44
- - scopes
45
- - public_class_methods
46
- - initializer
47
- - public_methods
48
- - protected_methods
49
- - private_methods
50
-
51
- Layout/DotPosition:
52
- EnforcedStyle: trailing
53
-
54
- Layout/SpaceInsideHashLiteralBraces:
55
- Enabled: false
56
-
57
- Lint/Void:
58
- Exclude:
59
- - 'spec/**'
60
-
61
- Metrics:
62
- Enabled: true
63
-
64
- Metrics/AbcSize:
65
- Max: 20
66
-
67
- Metrics/BlockLength:
68
- Exclude:
69
- - 'Rakefile'
70
- - '**/*.rake'
71
- - 'spec/**/*.rb'
72
- - 'test/**/*.rb'
73
- ExcludedMethods: ['included', 'namespace']
74
-
75
- Metrics/ClassLength:
76
- Exclude:
77
- - 'Rakefile'
78
- - 'spec/**/*.rb'
79
- - 'test/**/*.rb'
80
-
81
- Metrics/LineLength:
82
- Enabled: false
83
- Max: 120
84
- AllowHeredoc: true
85
- AllowURI: true
86
- URISchemes: http, https
87
-
88
- Metrics/MethodLength:
89
- CountComments: false # count full line comments?
90
- Max: 15
91
-
92
- Naming/UncommunicativeMethodParamName:
93
- Enabled: false
94
-
95
- Rails/Date:
96
- Enabled: true
97
- EnforcedStyle: flexible
98
-
99
- Rails/RefuteMethods:
100
- Enabled: true
101
-
102
- Rails/TimeZone:
103
- Enabled: true
104
- EnforcedStyle: flexible
105
-
106
- Style/ClassAndModuleChildren:
107
- Enabled: false
108
-
109
- Style/Documentation:
110
- Enabled: false
111
-
112
- Style/DocumentationMethod:
113
- Enabled: false
114
-
115
- Style/FrozenStringLiteralComment:
116
- EnforcedStyle: when_needed
117
- Enabled: true
118
-
119
- # Technically this performs better, and I got no problem with it.
120
- Style/ParallelAssignment:
121
- Enabled: false
122
-
123
- Style/WhenThen:
124
- Enabled: true
@@ -1 +0,0 @@
1
- 2.6.5
@@ -1,22 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 2.4.6
5
- - 2.5.5
6
- - 2.6.5
7
- - 2.7.0
8
-
9
- gemfile:
10
- - gemfiles/activerecord_4.gemfile
11
- - gemfiles/activerecord_5.1.gemfile
12
- - gemfiles/activerecord_5.2.gemfile
13
- - gemfiles/activerecord_6.0.gemfile
14
-
15
- before_install: gem install bundler -v 2.1.2
16
-
17
- jobs:
18
- exclude:
19
- - rvm: 2.4.6
20
- gemfile: gemfiles/activerecord_6.0.gemfile
21
- - rvm: 2.7.0
22
- gemfile: gemfiles/activerecord_4.gemfile
data/Appraisals DELETED
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- appraise 'activerecord-4' do
4
- gem 'activerecord', '~> 4.0'
5
- gem 'sqlite3', '~> 1.3.6'
6
- end
7
-
8
- appraise 'activerecord-5.1' do
9
- gem 'activerecord', '~> 5.1.0'
10
- gem 'sqlite3', '~> 1.4'
11
- end
12
-
13
- appraise 'activerecord-5.2' do
14
- gem 'activerecord', '~> 5.2.0'
15
- gem 'sqlite3', '~> 1.4'
16
- end
17
-
18
- appraise 'activerecord-6.0' do
19
- gem 'activerecord', '~> 6.0.0'
20
- gem 'sqlite3', '~> 1.4'
21
- end
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in tablesmith.gemspec
6
- gemspec
data/LICENSE DELETED
@@ -1,19 +0,0 @@
1
- Copyright (c) 2012-2015 LivingSocial, Inc.
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- SOFTWARE.
data/README.md DELETED
@@ -1,148 +0,0 @@
1
- [![Build Status](https://travis-ci.org/livingsocial/tablesmith.svg?branch=master)](https://travis-ci.org/livingsocial/tablesmith)
2
-
3
- # Tablesmith
4
-
5
- Drop-in gem for console tables for Array, Hash, and ActiveRecord.
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- gem 'tablesmith'
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install tablesmith
20
-
21
- ## Usage
22
-
23
- ### In irb or pry
24
-
25
- ```
26
- require 'tablesmith'
27
-
28
- > [[:foo, :bar], [1,3]].to_table
29
- => +-----+-----+
30
- | foo | bar |
31
- +-----+-----+
32
- | 1 | 3 |
33
- +-----+-----+
34
-
35
- > {a: 1, b: 2}.to_table
36
- => +---+---+
37
- | a | b |
38
- +---+---+
39
- | 1 | 2 |
40
- +---+---+
41
-
42
- > t = [{date: '1/1/2020', amt: 35}, {date: '1/2/2020', amt: 80}].to_table
43
- => +----------+-----+
44
- | date | amt |
45
- +----------+-----+
46
- | 1/1/2020 | 35 |
47
- | 1/2/2020 | 80 |
48
- +----------+-----+
49
-
50
- > # Table delegates to Array, all Array methods are available.
51
- > t.select! { |h| h[:amt] > 40 }
52
- => [{:date=>"1/2/2020", :amt=>80}]
53
-
54
- > t
55
- => +----------+-----+
56
- | date | amt |
57
- +----------+-----+
58
- | 1/2/2020 | 80 |
59
- +----------+-----+
60
-
61
-
62
- > p1 = Person.create(first_name: 'chrismo', custom_attributes: { instrument: 'piano', style: 'jazz' })
63
- => #<Person:0x00007fac3eb406a8 id: 1, first_name: "chrismo", last_name: nil, age: nil, custom_attributes: {:instrument=>"piano", :style=>"jazz"}>
64
- > p2 = Person.create(first_name: 'romer', custom_attributes: { hobby: 'games' })
65
- => #<Person:0x00007fac3ebcbb68 id: 2, first_name: "romer", last_name: nil, age: nil, custom_attributes: {:hobby=>"games"}>
66
- > batch = [p1, p2].to_table
67
- => +----+------------+-----------+-----+--------+------------+--------+
68
- | person | custom_attributes |
69
- +----+------------+-----------+-----+--------+------------+--------+
70
- | id | first_name | last_name | age | hobby | instrument | style |
71
- +----+------------+-----------+-----+--------+------------+--------+
72
- | 1 | chrismo | | | | piano | jazz |
73
- | 2 | romer | | | games | | |
74
- +----+------------+-----------+-----+--------+------------+--------+
75
- ```
76
-
77
- ### In a Script
78
-
79
- `puts` won't work because of how Kernel#puts has special case code for Arrays.
80
- Tablesmith::Table subclasses Array, so it can't cope with puts. Try to remember
81
- to use `print` instead.
82
-
83
- ```ruby
84
- require 'tablesmith'
85
-
86
- print [{date: '1/1/2020', amt: 35}, {date: '1/2/2020', amt: 80}].to_table
87
- ```
88
-
89
- ### CSV Support
90
- ```
91
- > puts [{date: '1/1/2020', amt: 35}, {date: '1/2/2020', amt: 80}].to_table.to_csv
92
- date,amt
93
- 1/1/2020,35
94
- 1/2/2020,80
95
- ```
96
-
97
- ### HTML Support
98
- ```
99
- > puts [{date: '1/1/2020', amt: 35}, {date: '1/2/2020', amt: 80}].to_table.to_html
100
- <table>
101
- <thead>
102
- <tr>
103
- <th>date</th>
104
- <th>amt</th>
105
- </tr>
106
- </thead>
107
- <tbody>
108
- <tr>
109
- <td>1/1/2020</td>
110
- <td>35</td>
111
- </tr>
112
- <tr>
113
- <td>1/2/2020</td>
114
- <td>80</td>
115
- </tr>
116
- </tbody>
117
- </table>
118
- ```
119
-
120
- ## Troubleshooting
121
-
122
- If you ever get a default inspection output in a console for a table, an
123
- exception has likely occurred and been caught by IRB or Pry. Call
124
- `.to_table.to_s` to see what the exception is.
125
-
126
- ```
127
- [1] pry(main)> [1, [2, 3]].to_table
128
- => #<Tablesmith::Table:0x3fc083e14294>
129
- [2] pry(main)> [1, [2, 3]].to_table.to_s
130
- IndexError: element size differs (2 should be 1)
131
- from /Users/chrismo/.bundle/ruby/2.6.0/gems/text-table-1.2.4/lib/text-table/table.rb:157:in `transpose'
132
- ```
133
-
134
- ## Why Not #{other_gem}?
135
-
136
- Happy to learn about something else already out there, but I have struggled to
137
- find something that doesn't require some sort of setup. I want drop-in
138
- ready-to-go table output for Arrays, Hashes, and ActiveRecord objects.
139
-
140
- Here's a quick list of other gems that I've tried out that are awesome and do
141
- much more than what Tablesmith does, but don't seem to specialize in what I
142
- want:
143
-
144
- - [text-table](https://github.com/aptinio/text-table) _Tablesmith uses text-table underneath_
145
- - [Hirb](https://github.com/cldwalker/hirb) _Hirb is cool, and pretty close to what I want_
146
- - [table_print](http://tableprintgem.com/)
147
- - [awesome_print](https://github.com/awesome-print/awesome_print)
148
- - [tabulo](https://github.com/matt-harvey/tabulo)
data/Rakefile DELETED
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rspec/core/rake_task'
4
- require 'bundler/gem_tasks'
5
-
6
- FileList['tasks/*.rake'].each(&method(:load))
7
-
8
- task default: :spec
9
-
10
- desc 'Run the specs.'
11
- RSpec::Core::RakeTask.new do |t|
12
- t.pattern = '*_spec.rb'
13
- end
14
-
15
- require 'rubocop/rake_task'
16
-
17
- RuboCop::RakeTask.new(:rubocop)
18
-
19
- task default: :rubocop
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file was generated by Appraisal
4
-
5
- source 'https://rubygems.org'
6
-
7
- gem 'activerecord', '~> 4.0'
8
- gem 'sqlite3', '~> 1.3.6'
9
-
10
- gemspec path: '../'
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file was generated by Appraisal
4
-
5
- source 'https://rubygems.org'
6
-
7
- gem 'activerecord', '~> 5.1.0'
8
- gem 'sqlite3', '~> 1.4'
9
-
10
- gemspec path: '../'
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file was generated by Appraisal
4
-
5
- source 'https://rubygems.org'
6
-
7
- gem 'activerecord', '~> 5.2.0'
8
- gem 'sqlite3', '~> 1.4'
9
-
10
- gemspec path: '../'
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file was generated by Appraisal
4
-
5
- source 'https://rubygems.org'
6
-
7
- gem 'activerecord', '~> 6.0.0'
8
- gem 'sqlite3', '~> 1.4'
9
-
10
- gemspec path: '../'
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'tablesmith/version'
6
-
7
- Gem::Specification.new do |gem|
8
- gem.name = 'tablesmith'
9
- gem.version = Tablesmith::VERSION
10
- gem.authors = ['chrismo']
11
- gem.email = ['chrismo@clabs.org']
12
- gem.description = 'Minimal console table'
13
- gem.summary = 'Minimal console table'
14
- gem.homepage = 'http://github.com/livingsocial/tablesmith'
15
-
16
- gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
- gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
18
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
- gem.require_paths = ['lib']
20
-
21
- gem.add_dependency 'text-table'
22
-
23
- gem.add_development_dependency 'activerecord', '~> 4.0'
24
- gem.add_development_dependency 'appraisal'
25
- gem.add_development_dependency 'bundler', '~> 2.1'
26
- gem.add_development_dependency 'pry'
27
- gem.add_development_dependency 'rake', '>= 12.3.3'
28
- gem.add_development_dependency 'rspec', '~> 3.0'
29
- gem.add_development_dependency 'rubocop'
30
- gem.add_development_dependency 'rubocop_lineup'
31
- gem.add_development_dependency 'simplecov'
32
- gem.add_development_dependency 'sqlite3', '~> 1.3.6'
33
- end