blastr 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,6 +1,10 @@
1
+ == 0.0.16 2009-02-22
2
+
3
+ * Added support for HTTP-based, SSH-based, Rsync-based, and file system-based Git URLs.
4
+
1
5
  == 0.0.15 2009-02-21
2
6
 
3
- * Added support for local Mercurial repositories.
7
+ * Added preliminary support for local Mercurial repositories.
4
8
 
5
9
  == 0.0.14 2009-02-20
6
10
 
data/lib/blastr.rb CHANGED
@@ -6,7 +6,7 @@ module Blastr
6
6
  require 'tts/tts.rb'
7
7
  require 'people/people.rb'
8
8
 
9
- VERSION = '0.0.15'
9
+ VERSION = '0.0.16'
10
10
  COPYRIGHT = 'Copyright (c) 2009, Lasse Koskela. All Rights Reserved.'
11
11
  puts "Blastr #{VERSION}\n#{COPYRIGHT}\n"
12
12
 
data/lib/scm/git.rb CHANGED
@@ -35,7 +35,11 @@ module Blastr::SourceControl
35
35
  def name; "Git"; end
36
36
 
37
37
  def self.understands_url?(url)
38
- url.index("git://") == 0
38
+ patterns = [ /^(git:)(.*)$/, /^(.*)(\.git)(\/?)$/ ]
39
+ patterns.each do |regex|
40
+ return true if url =~ regex
41
+ end
42
+ false
39
43
  end
40
44
 
41
45
  def initialize(git_url)
data/lib/scm/scm.rb CHANGED
@@ -18,12 +18,10 @@ module Blastr::SourceControl
18
18
  @@implementations = []
19
19
 
20
20
  def self.implementation_for(url)
21
- @@implementations.each do |impl|
22
- if impl.understands_url?(url)
23
- return impl.new(url)
24
- end
25
- end
26
- raise "No SCM implementation found that would understand #{url}"
21
+ matching_implementations = @@implementations.find_all { |impl| impl.understands_url?(url) }
22
+ raise "No SCM implementation found that would understand #{url}" if matching_implementations.empty?
23
+ raise "Ambiguous SCM URL #{url} - please prefix it with the type of repository ('svn:', 'git:', 'hg:')" if matching_implementations.size > 1
24
+ return matching_implementations.first.new(url)
27
25
  end
28
26
 
29
27
  def self.register_implementation(implementation)
data/lib/scm/svn.rb CHANGED
@@ -29,7 +29,7 @@ module Blastr::SourceControl
29
29
  def name; "Subversion"; end
30
30
 
31
31
  def self.understands_url?(url)
32
- not url.match(/^(https?|svn):\/\/.+$/u).nil?
32
+ not url.match(/^(https?:|svn:)(.+)$/).nil?
33
33
  end
34
34
 
35
35
  def initialize(svn_url)
@@ -2,10 +2,40 @@ require File.dirname(__FILE__) + '/test_helper.rb'
2
2
 
3
3
  class TestScmURLMatching < Test::Unit::TestCase
4
4
 
5
- GIT_URLS = [ "git://foo.com/bar.git" ]
6
- MERCURIAL_URLS = [ "hg:http://foo.com/hg", "hg:/tmp/hg/repo" ]
7
- SVN_URLS = [ "http://foo.com/svn", "https://foo.com/svn", "svn://foo.com/svn" ]
8
- ALL_URLS = [ SVN_URLS, GIT_URLS, MERCURIAL_URLS ].flatten
5
+ GIT_URLS = [
6
+ "git://foo.com/bar.git",
7
+ "git:/path/to/repo",
8
+ "git:http://repo.com/project",
9
+ "http://github.com/user/project.git",
10
+ "http://github.com/user/project.git/",
11
+ "https://github.com/user/project.git",
12
+ "rsync://host.xz/repo.git",
13
+ "rsync://host.xz/repo.git/",
14
+ "ssh://host.xz/repo.git/",
15
+ "host.xz/repo.git",
16
+ "host.xz/repo.git/",
17
+ "user@host.xz/repo.git",
18
+ "user@host.xz/repo.git/",
19
+ "ssh://user@host.xz/repo.git/",
20
+ "ssh://user@host.xz:1234/path/to/repo.git",
21
+ "file:///path/to/local/repo.git",
22
+ "file:///path/to/local/repo.git/",
23
+ "/path/to/repo.git",
24
+ "/path/to/repo.git/" ]
25
+ MERCURIAL_URLS = [
26
+ "hg:http://foo.com/hg",
27
+ "hg:http://foo.com/hg/",
28
+ "hg:/tmp/hg/repo",
29
+ "hg:/tmp/hg/repo/" ]
30
+ SVN_URLS = [
31
+ "http://foo.com/repo",
32
+ "http://foo.com/repo/",
33
+ "https://foo.com/repo",
34
+ "https://foo.com/repo/",
35
+ "svn:http://foo.com/svn",
36
+ "svn:http://foo.com/svn/",
37
+ "svn:https://foo.com/svn",
38
+ "svn://foo.com/svn" ]
9
39
 
10
40
  def test_subversion
11
41
  assert_urls_are_understood_by(Blastr::SourceControl::Subversion, SVN_URLS)
@@ -24,8 +54,5 @@ class TestScmURLMatching < Test::Unit::TestCase
24
54
  list_of_urls.each do |url|
25
55
  assert scm.understands_url?(url), "#{url} should be understood by #{scm}!"
26
56
  end
27
- ALL_URLS.reject {|url| list_of_urls.include?(url) }.each do |url|
28
- assert scm.understands_url?(url) == false, "#{url} should not be understood by #{scm}!"
29
- end
30
57
  end
31
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blastr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lasse Koskela