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 2019/11/25 15:36:28 UTC
[whimsy] branch master updated: Allow retrieval of SVN URL for name
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 1278bd4 Allow retrieval of SVN URL for name
1278bd4 is described below
commit 1278bd4fbb2b0ee4817ff78da081560c4f9b3479
Author: Sebb <se...@apache.org>
AuthorDate: Mon Nov 25 15:36:18 2019 +0000
Allow retrieval of SVN URL for name
---
lib/spec/lib/svn_spec.rb | 65 ++++++++++++++++++++++++++++++++++++++++++++++++
lib/whimsy/asf/svn.rb | 28 +++++++++++++++++++++
2 files changed, 93 insertions(+)
diff --git a/lib/spec/lib/svn_spec.rb b/lib/spec/lib/svn_spec.rb
new file mode 100644
index 0000000..bfe9eea
--- /dev/null
+++ b/lib/spec/lib/svn_spec.rb
@@ -0,0 +1,65 @@
+# encoding: utf-8
+# frozen_string_literal: true
+
+require 'spec_helper'
+require 'whimsy/asf'
+
+describe ASF::SVN do
+
+ describe "ASF::SVN.repo_entry" do
+ it "should return string for 'templates'" do
+ res = ASF::SVN.repo_entry('templates')
+ expect(res.class).to equal(Hash)
+ end
+
+ it "should return nil for '__templates'" do
+ res = ASF::SVN.repo_entry('__templates')
+ expect(res.class).to equal(NilClass)
+ end
+
+ end
+
+ describe "ASF::SVN.repo_entry!" do
+ it "should return string for 'templates'" do
+ res = ASF::SVN.repo_entry!('templates')
+ expect(res.class).to equal(Hash)
+ end
+
+ it "should fail for '__templates'" do
+ expect{
+ ASF::SVN.repo_entry!('__templates')
+ }.to raise_error(Exception)
+ end
+
+ end
+
+
+ describe "ASF::SVN.svnurl" do
+ it "should return URL for 'templates'" do
+ res = ASF::SVN.svnurl('templates')
+ expect(res.class).to equal(String)
+ expect(res).to match(%r{https://.+/templates})
+ end
+
+ it "should return nil for '__templates'" do
+ res = ASF::SVN.svnurl('__templates')
+ expect(res.class).to equal(NilClass)
+ end
+
+ end
+
+ describe "ASF::SVN.svnurl!" do
+ it "should return URL for 'templates'" do
+ res = ASF::SVN.svnurl!('templates')
+ expect(res.class).to equal(String)
+ expect(res).to match(%r{https://.+/templates})
+ end
+
+ it "should fail for '__templates'" do
+ expect {
+ ASF::SVN.svnurl!('__templates')
+ }.to raise_error(Exception)
+ end
+
+ end
+end
\ No newline at end of file
diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index 2722e81..6a00b1b 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -75,6 +75,34 @@ module ASF
@@repository_entries[:svn][name]
end
+ # fetch a repository entry by name - abort if not found
+ def self.repo_entry!(name)
+ entry = self.repo_entry(name)
+ unless entry
+ raise Exception.new("Unable to find repository entry for #{name}")
+ end
+ entry
+ end
+
+ # fetch a repository URL by name
+ def self.svnurl(name)
+ entry = self.repo_entry(name) or return nil
+ url = entry['url']
+ unless url # bad entry
+ raise Exception.new("Unable to find url attribute for SVN entry #{name}")
+ end
+ return (@base+url).to_s
+ end
+
+ # fetch a repository URL by name - abort if not found
+ def self.svnurl!(name)
+ entry = self.svnurl(name)
+ unless entry
+ raise Exception.new("Unable to find url for #{name}")
+ end
+ entry
+ end
+
# find a local directory corresponding to a path in Subversion. Returns
# <tt>nil</tt> if not found.
def self.find(name)