You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2020/07/12 16:53:35 UTC

[whimsy] branch master updated: += make_entry - create basic entry

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 002e4d2  += make_entry - create basic entry
002e4d2 is described below

commit 002e4d2dca1a07d598fe75f8445e6be66cd80374
Author: Sebb <se...@apache.org>
AuthorDate: Sun Jul 12 17:53:26 2020 +0100

    += make_entry - create basic entry
    
    Also start adding unit tests
---
 lib/spec/lib/member_spec.rb         | 47 +++++++++++++++++++
 lib/test/svn/foundation/members.txt | 94 +++++++++++++++++++++++++++++++++++++
 lib/whimsy/asf/member.rb            | 39 +++++++++++++++
 3 files changed, 180 insertions(+)

diff --git a/lib/spec/lib/member_spec.rb b/lib/spec/lib/member_spec.rb
new file mode 100644
index 0000000..9f296d9
--- /dev/null
+++ b/lib/spec/lib/member_spec.rb
@@ -0,0 +1,47 @@
+require 'spec_helper'
+require 'whimsy/asf'
+
+set_svn('foundation') # need private file
+
+describe ASF::Member do
+  it  "find_text_by_id('notinavail') should return nil" do
+    res = ASF::Member.find_text_by_id('notinavail')
+    expect(res).to eq(nil)
+  end
+  it  "find_text_by_id('banana') should return entry" do
+    res = ASF::Member.find_text_by_id('banana')
+    expect(res).to match(%r{^Barry N Anaheim.+Avail ID: banana}m)
+  end
+  it  "find_text_by_id('cherry') should return entry (emeritus)" do
+    res = ASF::Member.find_text_by_id('cherry')
+    expect(res).to match(%r{^Charlie .+^ Avail ID: cherry}m)
+  end
+  it  "find_text_by_id('elder') should return entry (deceased)" do
+    res = ASF::Member.find_text_by_id('elder')
+    expect(res).to match(%r{^El Dorado.+^ Avail ID: elder}m)
+  end
+  fields = {fullname: 'Full Name', address: "Line 1\nLine2", availid: 'a-b-c', email: 'user@domain.invalid'}
+  it "make_entry() should raise error" do
+    expect { ASF::Member.make_entry(fields.reject{|k,v| k == :fullname}) }.to raise_error(ArgumentError, ':fullname is required')
+    expect { ASF::Member.make_entry(fields.reject{|k,v| k == :address}) }.to raise_error(ArgumentError, ':address is required')
+    expect { ASF::Member.make_entry(fields.reject{|k,v| k == :availid}) }.to raise_error(ArgumentError, ':availid is required')
+    expect { ASF::Member.make_entry(fields.reject{|k,v| k == :email}) }.to raise_error(ArgumentError, ':email is required')
+  end
+  it "make_entry(fields) should create entry" do
+    res = ASF::Member.make_entry(fields)
+    expect(res).to eq("Full Name\n    Line 1\n    Line2\n    Email: user@domain.invalid\n Forms on File: ASF Membership Application\n Avail ID: a-b-c\n")
+  end
+  it "make_entry({country:}}) should create entry with country" do
+    res = ASF::Member.make_entry(fields.merge({country: 'UN'}))
+    expect(res).to match(%r{^    UN$})
+  end
+  it "make_entry({tele:}}) should create entry with Tel:" do
+    res = ASF::Member.make_entry(fields.merge({tele: '123-456'}))
+    expect(res).to match(%r{^      Tel: 123-456$})
+  end
+  it "make_entry({fax:}}) should create entry with Fax:" do
+    res = ASF::Member.make_entry(fields.merge({fax: '123-456'}))
+    expect(res).to match(%r{^      Fax: 123-456$})
+  end
+end
+
diff --git a/lib/test/svn/foundation/members.txt b/lib/test/svn/foundation/members.txt
new file mode 100644
index 0000000..5e7b5fe
--- /dev/null
+++ b/lib/test/svn/foundation/members.txt
@@ -0,0 +1,94 @@
+
+                   Apache Software Foundation Membership
+
+             $Date: 2020-07-07 00:46:04 +0100 (Tue, 07 Jul 2020) $
+
+     This list includes address information which is considered private.
+     Do not republish this information outside our private ASF member list
+     without prior consent.   Beware that this file is used to compute
+     some public web pages, see below.  We now number 2 active members.
+     Members are allowed to change any of their information in this
+     file with the exception of "Forms on File", which is maintained
+     by the ASF Secretary.
+     NOTE:
+     When updating this file, be sure you only update your own
+     information. Before committing changes, perform svn diff
+     to be sure.
+     Please ensure that you keep at least the "Email:" tag up-to-date.
+
+     Encoding: utf-8
+
+Active (Voting) Members
+=======================
+
+ *) Barry N Anaheim
+    123 Main Street Apt 12
+    San Francisco, CA 94117
+    USA
+    Email: random@gmail.com.invalid
+      Tel: +1 234 456 890
+ Forms on File: ASF Membership Application
+ Avail ID: banana
+
+ *) Alice P Plesk
+    123 Main Street Apt 12
+    Los Angeles, CA 987654
+    USA
+    Email: dummy@gmail.com.invalid
+      Tel: +1 234 456 890
+ Forms on File: ASF Membership Application
+ Avail ID: apple
+
+Emeritus (Non-voting) Members
+=============================
+
+Note:   Moving members from the above list to the list
+        below should only be done by the Secretary who
+        will do so after the ASF receives a signed paper
+        from the member stating the transition. See
+        section 4.3 of the bylaws.
+
+ *) Damsel Fly
+    London
+    UK
+    Email: damsel@gmail.com.invalid
+ Forms on File: ASF Membership Application
+ Avail ID: damson
+
+ *) Charlie Ryman
+    123 Main Street Apt 12
+    Los Angeles, CA 987654
+    USA
+    Email: nemo@gmail.com.invalid
+ Forms on File: ASF Membership Application
+ Avail ID: cherry
+
+Other (Non-voting) Representatives
+==================================
+
+ *) Adam Zulu
+    Email: nemo@erewhon
+
+Deceased Members
+================
+
+ *) El Dorado /* deceased, 1 January 1970 */
+    Paris
+    France
+    Email: dorado@gmail.com.invalid
+ Forms on File: ASF Membership Application
+ Avail ID: elder
+
+Project Names / URLS
+====================
+
+Note: these definitions are used by the parse-projects.pl
+      script, which in turn is used to build some public
+      pages via a ritual still evolving.  Follow the name: URL format.
+
+Abdera: http://incubator.apache.org/projects/abdera.html
+ActiveMQ: http://activemq.apache.org/
+APR: http://apr.apache.org/
+ApacheCon: http://www.apachecon.com/
+Ant: http://ant.apache.org/
+Alexandria: http://jakarta.apache.org/alexandria/
diff --git a/lib/whimsy/asf/member.rb b/lib/whimsy/asf/member.rb
index 1592a34..a05ff1e 100644
--- a/lib/whimsy/asf/member.rb
+++ b/lib/whimsy/asf/member.rb
@@ -180,6 +180,45 @@ module ASF
       @@mtime = Time.now
       @@text = WeakRef.new(text)
     end
+
+    # create an entry in the standard format:
+    # *) First Last
+    #    Street
+    #    Town
+    #    Country
+    #    Email: id@apache.org
+    #      Tel: 1234
+    # Forms on File: ASF Membership Application
+    # Avail ID: id
+    # Parameters:
+    # fields - hash:
+    #  :fullname - required
+    #  :address - required, multi-line allowed
+    #  :availid - required
+    #  :email - required
+    #  :country - optional
+    #  :tele - optional
+    #  :fax - optional
+    def self.make_entry(fields={})
+      fullname = fields[:fullname] or raise ArgumentError.new(":fullname is required")
+      address = fields[:address]   or raise ArgumentError.new(":address is required")
+      availid = fields[:availid]   or raise ArgumentError.new(":availid is required")
+      email = fields[:email]       or raise ArgumentError.new(":email is required")
+      country = fields[:country] || ''
+      tele = fields[:tele] || ''
+      fax = fields[:fax] || ''
+      [
+        fullname, # will be prefixed by ' *) '
+        # Each line of address is indented
+        ("#{address.gsub(/^/,'    ').gsub(/\r/,'')}"),
+        ("    #{country}"     unless country.empty?),
+         "    Email: #{email}",
+        ("      Tel: #{tele}" unless tele.empty?),
+        ("      Fax: #{fax}"  unless fax.empty?),
+        " Forms on File: ASF Membership Application",
+        " Avail ID: #{availid}"
+      ].compact.join("\n") + "\n"
+    end
   end
 
   class Person