tabulo 0.6.3 → 1.0.0

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: 6756f8ae92c219bb324358e9046e86ec756d3923
4
- data.tar.gz: de3d6bedfcbea40b81d607d00ca07be75e4277a5
3
+ metadata.gz: 5a910d751c5f088a4cd7c5fbae68747885c15038
4
+ data.tar.gz: b5c7538803ec163bbad593eec5f45604fc58fb0a
5
5
  SHA512:
6
- metadata.gz: b5f10a9d672d15083bf96cb7d6f5e8a21030e98318fc13cd98d82ec9c22f5d83ea25d65cb792273c5840db056b7b6a0a961d71676a10bac430f5f874517521b6
7
- data.tar.gz: c46bcc143a0447af136aab26c7dc960b1c4f53afdf72e27a57522428dab7d936ccc95cd8b2a4bbe19726100fd28de4547f978ed1280be9a491bc88bc9a18547d
6
+ metadata.gz: d1362c34d1d078488ced0b4f7cefc0fb697eb7b8de6602e27a3a406efb65f81a955bdf17f6f075a9df998b4b5db771e1b3c6e57781773dc9c06033fba9d1bf4c
7
+ data.tar.gz: bdb51c2747da845b04dfac1bf49f4c3320f1dc1eacd306a4d96596fca17a54738dab88714771dca96a0d1158a57fc21e66c07fbae09f7d6299c6045b9cd226b1
@@ -5,4 +5,4 @@ rvm:
5
5
  - 2.2.6
6
6
  - 2.3.3
7
7
  - 2.4.0
8
- before_install: gem install bundler -v 1.14.6
8
+ before_install: gem install bundler -v 1.15.1
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ### v1.0.0
4
+
5
+ * Decision to release stable version!
6
+ * Minor implementation and documentation tweaks.
7
+
3
8
  ### v0.6.3
4
9
 
5
10
  * Throw an exception if column labels are not unique.
data/README.md CHANGED
@@ -86,7 +86,7 @@ end
86
86
  Or equivalently:
87
87
 
88
88
  ```ruby
89
- table = Tabulo::Table.new([1, 2, 5], columns: %i(itself even? odd?))
89
+ table = Tabulo::Table.new([1, 2, 5], columns: %i[itself even? odd?])
90
90
  ```
91
91
 
92
92
  ```
@@ -161,7 +161,7 @@ If you want to set the default column width for all columns of the table to some
161
161
  than 12, use the `column_width` option when initializing the table:
162
162
 
163
163
  ```ruby
164
- table = Tabulo::Table.new([1, 2], columns: %i(itself even?), column_width: 6)
164
+ table = Tabulo::Table.new([1, 2], columns: %i[itself even?], column_width: 6)
165
165
  ```
166
166
 
167
167
  ```
@@ -183,7 +183,7 @@ itself, so that each column is just wide enough for its header and contents (plu
183
183
  of padding):
184
184
 
185
185
  ```ruby
186
- table = Tabulo::Table.new([1, 2], columns: %i(itself even?))
186
+ table = Tabulo::Table.new([1, 2], columns: %i[itself even?])
187
187
  table.shrinkwrap!
188
188
  ```
189
189
 
@@ -199,14 +199,14 @@ table.shrinkwrap!
199
199
  The `shrinkwrap!` method returns the table itself, so you can "wrap-and-print" in one go:
200
200
 
201
201
  ```ruby
202
- puts Tabulo::Table.new([1, 2], columns: %i(itself even?)).shrinkwrap!
202
+ puts Tabulo::Table.new([1, 2], columns: %i[itself even?]).shrinkwrap!
203
203
  ```
204
204
 
205
205
  <a name="max-table-width"></a>
206
206
  You can place an upper limit on the total width of the table when shrinkwrapping:
207
207
 
208
208
  ```ruby
209
- puts Tabulo::Table.new([1, 2], columns: %i(itself even?)).shrinkwrap!(max_table_width: 17)
209
+ puts Tabulo::Table.new([1, 2], columns: %i[itself even?]).shrinkwrap!(max_table_width: 17)
210
210
  ```
211
211
 
212
212
  ```
@@ -242,7 +242,7 @@ required:
242
242
  ```ruby
243
243
  table = Tabulo::Table.new(
244
244
  ["hello", "abcdefghijklmnopqrstuvwxyz"],
245
- columns: %i(itself length)
245
+ columns: %i[itself length]
246
246
  )
247
247
  ```
248
248
 
@@ -267,7 +267,7 @@ outputted cell content to show that truncation has occurred:
267
267
  table = Tabulo::Table.new(
268
268
  ["hello", "abcdefghijklmnopqrstuvwxyz"],
269
269
  wrap_body_cells_to: 1,
270
- columns: %i(itself length)
270
+ columns: %i[itself length]
271
271
  )
272
272
  ```
273
273
 
@@ -325,7 +325,7 @@ at table that's taller than your terminal.
325
325
  E.g.:
326
326
 
327
327
  ```ruby
328
- table = Tabulo::Table.new(1..10, columns: %i(itself even?), header_frequency: 5)
328
+ table = Tabulo::Table.new(1..10, columns: %i[itself even?], header_frequency: 5)
329
329
  ```
330
330
 
331
331
  ```
@@ -397,11 +397,11 @@ License](http://opensource.org/licenses/MIT).
397
397
  [Dependency Status]: https://gemnasium.com/matt-harvey/tabulo
398
398
  [Coverage Status]: https://coveralls.io/r/matt-harvey/tabulo
399
399
  [Code Climate]: https://codeclimate.com/github/matt-harvey/tabulo
400
- [Documentation]: http://www.rubydoc.info/github/matt-harvey/tabulo
400
+ [Documentation]: http://www.rubydoc.info/gems/tabulo/1.0.0
401
401
 
402
402
  [GV img]: https://img.shields.io/gem/v/tabulo.svg?style=plastic
403
403
  [BS img]: https://img.shields.io/travis/matt-harvey/tabulo.svg?style=plastic
404
404
  [DS img]: https://img.shields.io/gemnasium/matt-harvey/tabulo.svg?style=plastic
405
405
  [CS img]: https://img.shields.io/coveralls/matt-harvey/tabulo.svg?style=plastic
406
406
  [CC img]: https://img.shields.io/codeclimate/github/matt-harvey/tabulo.svg?style=plastic
407
- [DC img]: https://img.shields.io/badge/docs-latest-blue.svg?style=plastic
407
+ [DC img]: https://img.shields.io/badge/docs-v1.0.0-blue.svg?style=plastic
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.3
1
+ 1.0.0
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-cayman
@@ -22,7 +22,7 @@ module Tabulo
22
22
  # cell.class # => Fixnum, => FalseClass
23
23
  # end
24
24
  def each
25
- @table.column_registry.each do |label, column|
25
+ @table.column_registry.each do |_, column|
26
26
  yield column.body_cell_value(@source)
27
27
  end
28
28
  end
@@ -152,7 +152,7 @@ module Tabulo
152
152
 
153
153
  # @return [String] an "ASCII" graphical representation of the Table column headers.
154
154
  def formatted_header
155
- cells = column_registry.map { |label, column| column.header_subcells }
155
+ cells = column_registry.map { |_, column| column.header_subcells }
156
156
  format_row(cells, @wrap_header_cells_to)
157
157
  end
158
158
 
@@ -165,7 +165,7 @@ module Tabulo
165
165
  # end
166
166
  #
167
167
  def horizontal_rule
168
- inner = column_registry.map do |label, column|
168
+ inner = column_registry.map do |_, column|
169
169
  surround(column.horizontal_rule, HORIZONTAL_RULE_CHARACTER)
170
170
  end
171
171
  surround_join(inner, CORNER_CHARACTER)
@@ -199,25 +199,21 @@ module Tabulo
199
199
  # @return [Table] the Table itself
200
200
  def shrinkwrap!(max_table_width: nil)
201
201
  return self if column_registry.none?
202
+ columns = column_registry.values
202
203
 
203
- wrapped_width = -> (str) { str.split($/).map(&:length).max || 1 }
204
-
205
- column_registry.each do |label, column|
206
- column.width = wrapped_width.call(column.header)
204
+ columns.each do |column|
205
+ column.width = wrapped_width(column.header)
207
206
  end
208
207
 
209
208
  @sources.each do |source|
210
- column_registry.each do |label, column|
211
- width = wrapped_width.call(column.formatted_cell_content(source))
209
+ columns.each do |column|
210
+ width = wrapped_width(column.formatted_cell_content(source))
212
211
  column.width = width if width > column.width
213
212
  end
214
213
  end
215
214
 
216
215
  if max_table_width
217
- total_columns_width = column_registry.inject(0) do |sum, label_with_column|
218
- _label, column = label_with_column
219
- sum + column.width
220
- end
216
+ total_columns_width = columns.inject(0) { |sum, column| sum + column.width }
221
217
  total_padding = column_registry.count * 2
222
218
  total_borders = column_registry.count + 1
223
219
  unadjusted_table_width = total_columns_width + total_padding + total_borders
@@ -230,9 +226,7 @@ module Tabulo
230
226
  required_reduction = [unadjusted_table_width - max_table_width, 0].max
231
227
 
232
228
  required_reduction.times do
233
- _first_label, first_column = column_registry.first
234
- widest_column = column_registry.inject(first_column) do |widest, label_with_column|
235
- _label, column = label_with_column
229
+ widest_column = columns.inject(columns.first) do |widest, column|
236
230
  column.width >= widest.width ? column : widest
237
231
  end
238
232
 
@@ -245,7 +239,7 @@ module Tabulo
245
239
 
246
240
  # @!visibility private
247
241
  def formatted_body_row(source, with_header: false)
248
- cells = column_registry.map { |label, column| column.body_subcells(source) }
242
+ cells = column_registry.map { |_, column| column.body_subcells(source) }
249
243
  inner = format_row(cells, @wrap_body_cells_to)
250
244
  if with_header
251
245
  join_lines([horizontal_rule, formatted_header, horizontal_rule, inner])
@@ -316,5 +310,14 @@ module Tabulo
316
310
  def join_lines(lines)
317
311
  lines.join($/) # join strings with cross-platform newline
318
312
  end
313
+
314
+ # @!visibility private
315
+ # @return [Fixnum] the length of the longest segment of str when split by newlines
316
+ def wrapped_width(str)
317
+ segments = str.split($/)
318
+ segments.inject(1) do |length, segment|
319
+ length > segment.length ? length : segment.length
320
+ end
321
+ end
319
322
  end
320
323
  end
@@ -1,3 +1,3 @@
1
1
  module Tabulo
2
- VERSION = "0.6.3"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = "Enumerable ASCII table"
13
13
  spec.description = "Enumerable ASCII table"
14
- spec.homepage = "https://github.com/matt-harvey/tabulo"
14
+ spec.homepage = "https://matt-harvey.github.io/tabulo"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.required_ruby_version = ">= 2.1.10"
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.14.6"
26
+ spec.add_development_dependency "bundler", "~> 1.15.1"
27
27
  spec.add_development_dependency "rake", "~> 11.0"
28
28
  spec.add_development_dependency "rspec", "~> 3.0"
29
29
  spec.add_development_dependency "simplecov"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabulo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Harvey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-07 00:00:00.000000000 Z
11
+ date: 2017-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.14.6
19
+ version: 1.15.1
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.14.6
26
+ version: 1.15.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -155,6 +155,7 @@ files:
155
155
  - README.md
156
156
  - Rakefile
157
157
  - VERSION
158
+ - _config.yml
158
159
  - bin/console
159
160
  - bin/setup
160
161
  - lib/tabulo.rb
@@ -164,7 +165,7 @@ files:
164
165
  - lib/tabulo/table.rb
165
166
  - lib/tabulo/version.rb
166
167
  - tabulo.gemspec
167
- homepage: https://github.com/matt-harvey/tabulo
168
+ homepage: https://matt-harvey.github.io/tabulo
168
169
  licenses:
169
170
  - MIT
170
171
  metadata: {}