You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by Sam Ruby <ru...@apache.org> on 2016/03/25 18:49:44 UTC
[whimsy.git] [1/1] Commit 2af9521: add a member sort function
Commit 2af952145e2d503ebee70185033974efd1dcaf7b:
add a member sort function
Branch: refs/heads/master
Author: Sam Ruby <ru...@intertwingly.net>
Committer: Sam Ruby <ru...@intertwingly.net>
Pusher: rubys <ru...@apache.org>
------------------------------------------------------------
lib/whimsy/asf/member.rb | +++++++++++++
------------------------------------------------------------
26 changes: 26 additions, 0 deletions.
------------------------------------------------------------
diff --git a/lib/whimsy/asf/member.rb b/lib/whimsy/asf/member.rb
index b6def24..c93301b 100644
--- a/lib/whimsy/asf/member.rb
+++ b/lib/whimsy/asf/member.rb
@@ -84,6 +84,32 @@ def self.svn_change
file = "#{foundation}/members.txt"
return Time.parse(`svn info #{file}`[/Last Changed Date: (.*) \(/, 1]).gmtime
end
+
+ # sort an entire members.txt file
+ def self.sort(source)
+ # split into sections
+ sections = source.split(/^([A-Z].*\n===+\n\n)/)
+ p sections.length
+
+ # sort sections that contain names
+ sections.map! do |section|
+ next section unless section.start_with? ' *) '
+
+ # split into entries, and normalize those entries
+ entries = section.split(/^\s\*\)\s/)
+ entries.shift
+ entries.map! {|entry| " *) " + entry.strip + "\n\n"}
+
+ # sort the entries
+ entries.sort_by! do |entry|
+ ASF::Person.sortable_name(entry[/\)\s(.*?)\s*(\/\*|$)/, 1])
+ end
+
+ entries.join
+ end
+
+ sections.join
+ end
end
class Person