forked from rubygems/rubygems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CL2notes
executable file
·56 lines (46 loc) · 1.12 KB
/
CL2notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env ruby
$:.unshift 'lib'
require 'rubygems'
def format_text(text, wrap, indent=0)
result = []
work = text.dup
while work.length > wrap
if work =~ /^(.{0,#{wrap}})[ \n]/o then
result << $1
work.slice!(0, $&.length)
else
result << work.slice!(0, wrap)
end
end
result << work if work.length.nonzero?
result.join("\n").gsub(/^/, " " * indent)
end
version = ARGV.shift || Gem::VERSION
entries = Hash.new { |h,file| h[file] = [] }
entry = []
file = nil
IO.foreach 'ChangeLog' do |line|
case line
when /^\s*$/,
/^#/,
/^\d{4}-\d{2}-\d{2}/ then
next
when /^\s+\*\s+([^:]+?):\s+#{version}/ then
entries[file] << entry.join(' ') unless entry.empty?
break
when /^\s+\*\s+([^:]+?):\s+/ then
entries[file] << entry.join(' ') unless entry.empty?
file = $1
entry = [$'.strip]
when /^\s+/ then
entry << $'.strip
end
end
entries.sort_by { |file, | file }.each do |file, file_entries|
puts "* #{file}"
file_entries.each do |file_entry|
file_entry = format_text file_entry, 74, 4
file_entry.sub! ' ', ' * '
puts file_entry
end
end