format_array 1.1 → 1.2

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.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v1.2. Add some (thin) documentation
2
+
1
3
  v1.1. Add some trivial tests and parameterise our length
2
4
 
3
5
  v1.0. First cut
data/format_array.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{format_array}
5
- s.version = "1.1"
5
+ s.version = "1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = [""]
data/lib/format_array.rb CHANGED
@@ -1,6 +1,15 @@
1
- CUTOFF=120
1
+ # = format_array.rb
2
+ #
3
+ # == Example
4
+ #
5
+ # require 'format_array'
6
+ # # default cutoff is 120 characters
7
+ # format_array(['list','of','things'], 'PREFIX')
8
+ #
9
+ # # we can specify our own, say 76
10
+ # format_array(['list','of','things'], 'PREFIX', 76)
2
11
 
3
- def format_array(a, p, cutoff=CUTOFF, j='; ')
12
+ def format_array(a, p, cutoff=120, j='; ')
4
13
  raw = a.sort.join(j)
5
14
  tmp = "#{p}: #{raw}"
6
15
 
@@ -12,7 +21,7 @@ def format_array(a, p, cutoff=CUTOFF, j='; ')
12
21
  # try a naive longest->shortest distribution
13
22
  lines = raw.length / cutoff
14
23
  sa = a.sort_by {|s| s.length}.reverse
15
- out = Array.new(12) { Array.new }
24
+ out = Array.new(12) { Array.new } # what does magic 12 mean?
16
25
  while (sa.length > lines+1) do
17
26
  0.upto(lines) { |i|
18
27
  out[i].push sa.shift
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: format_array
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 1
9
- version: "1.1"
8
+ - 2
9
+ version: "1.2"
10
10
  platform: ruby
11
11
  authors:
12
12
  - ""