You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by Craig L Russell <cl...@apache.org> on 2016/03/28 03:03:28 UTC

[whimsy.git] [1/1] Commit ac8bc55: Add utility to sort members.txt

Commit ac8bc5506f658150a750eccdac983f6340c0038d:
    Add utility to sort members.txt


Branch: refs/heads/master
Author: Craig L Russell <cr...@oracle.com>
Committer: Craig L Russell <cr...@oracle.com>
Pusher: clr <cl...@apache.org>

------------------------------------------------------------
tools/membersort.rb                                          | ++++++++++++ 
------------------------------------------------------------
23 changes: 23 additions, 0 deletions.
------------------------------------------------------------


diff --git a/tools/membersort.rb b/tools/membersort.rb
new file mode 100644
index 0000000..98b1730
--- /dev/null
+++ b/tools/membersort.rb
@@ -0,0 +1,23 @@
+# svn update and sort the members.txt file and show the differences
+
+$LOAD_PATH.unshift File.realpath(File.expand_path('../../lib', __FILE__))
+require 'whimsy/asf'
+
+FOUNDATION = ASF::SVN['private/foundation']
+
+Dir.chdir FOUNDATION
+
+members = FOUNDATION + '/members.txt'
+puts 'svn update ' + members
+system 'svn update ' + members
+
+source = File.read('members.txt')
+sorted = ASF::Member.sort(source)
+
+if source == sorted
+  puts 'no change'
+else
+  File.write('members.txt', sorted)
+  system 'svn diff members.txt'
+end
+

Re: [whimsy.git] [1/1] Commit ac8bc55: Add utility to sort members.txt

Posted by Sam Ruby <ru...@intertwingly.net>.
Excellent!

Now that you have mastered that, here's an example of code that I will
be debugging later this week that will update the membership status of
an individual:

https://github.com/apache/whimsy/blob/master/www/roster/views/actions/memstat.json.rb

Note that this uses the same sort routine.  However instead of using a
svn working directory, it does everything using a temporary directory
where it obtains a clean checkout of just the file that is to be
updated and commits it immediately.  This avoid the 'svn has gotten
wedged' issue that plagued older tools on whimsy-vm1.

Updating status using the roster tool is not likely to be the only (or
even primary) way in which status is updated in the future.  Some form
of this logic will also be needed by the secmail tool to process
emeritus requests.  And will be useful in implementing a "self
service" emeritus form as you have suggested.  As that occurs, common
logic will make its way from the separate tools into the appropriate
lib/whimsy source files.

That process of finding and refactoring out common logic is iterative.
For example, updating the count of active members at the top of
members.txt is common to both processing emeritus transitions as well
as processing new member requests.

- Sam Ruby



On Sun, Mar 27, 2016 at 9:03 PM, Craig L Russell <cl...@apache.org> wrote:
> Commit ac8bc5506f658150a750eccdac983f6340c0038d:
>     Add utility to sort members.txt
>
>
> Branch: refs/heads/master
> Author: Craig L Russell <cr...@oracle.com>
> Committer: Craig L Russell <cr...@oracle.com>
> Pusher: clr <cl...@apache.org>
>
> ------------------------------------------------------------
> tools/membersort.rb                                          | ++++++++++++
> ------------------------------------------------------------
> 23 changes: 23 additions, 0 deletions.
> ------------------------------------------------------------
>
>
> diff --git a/tools/membersort.rb b/tools/membersort.rb
> new file mode 100644
> index 0000000..98b1730
> --- /dev/null
> +++ b/tools/membersort.rb
> @@ -0,0 +1,23 @@
> +# svn update and sort the members.txt file and show the differences
> +
> +$LOAD_PATH.unshift File.realpath(File.expand_path('../../lib', __FILE__))
> +require 'whimsy/asf'
> +
> +FOUNDATION = ASF::SVN['private/foundation']
> +
> +Dir.chdir FOUNDATION
> +
> +members = FOUNDATION + '/members.txt'
> +puts 'svn update ' + members
> +system 'svn update ' + members
> +
> +source = File.read('members.txt')
> +sorted = ASF::Member.sort(source)
> +
> +if source == sorted
> +  puts 'no change'
> +else
> +  File.write('members.txt', sorted)
> +  system 'svn diff members.txt'
> +end
> +