Module: Pullr::SCM
- Defined in:
- lib/pullr/scm/git.rb,
lib/pullr/scm/scm.rb,
lib/pullr/scm/rsync.rb,
lib/pullr/scm/mercurial.rb,
lib/pullr/scm/sub_version.rb
Defined Under Namespace
Modules: Git, Mercurial, Rsync, SubVersion
Constant Summary collapse
- NAMES =
Mapping of known SCM names and their respective mixins
{ :git => Git, :mercurial => Mercurial, :hg => Mercurial, :sub_version => SubVersion, :subversion => SubVersion, :svn => SubVersion, :rsync => Rsync }
- SCHEMES =
Mapping of known URI schemes and their respective SCM names
{ 'git' => :git, 'hg' => :mercurial, 'svn' => :sub_version, 'svn+ssh' => :sub_version, 'rsync' => :rsync }
- EXTS =
Mapping of URI path extensions and their respective SCM names
{ '.git' => :git }
- DIRS =
Mapping of directories and the SCMs that use them
{ '.git' => :git, '.hg' => :mercurial, '.svn' => :sub_version }
Class Method Summary collapse
-
.infer_from_dir(path) ⇒ Symbol
Attempts to infer the SCM used to manage a given directory.
-
.infer_from_uri(uri) ⇒ Symbol
Attempts to infer the SCM used for the remote repository.
-
.lookup(name) ⇒ Module
Finds the SCM mixin for a given SCM name.
Class Method Details
.infer_from_dir(path) ⇒ Symbol
Attempts to infer the SCM used to manage a given directory.
75 76 77 78 79 80 81 82 83 |
# File 'lib/pullr/scm/scm.rb', line 75 def SCM.infer_from_dir(path) SCM::DIRS.each do |name,scm| if File.directory?(File.join(path,name)) return scm end end return nil end |
.infer_from_uri(uri) ⇒ Symbol
Attempts to infer the SCM used for the remote repository.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/pullr/scm/scm.rb', line 50 def SCM.infer_from_uri(uri) uri_scheme = uri.scheme if (scm = SCM::SCHEMES[uri_scheme]) return scm end uri_ext = File.extname(uri.path) if (scm = SCM::EXTS[uri_ext]) return scm end return nil end |
.lookup(name) ⇒ Module
Finds the SCM mixin for a given SCM name.
97 98 99 100 101 102 103 104 105 |
# File 'lib/pullr/scm/scm.rb', line 97 def SCM.lookup(name) name = name.to_sym unless NAMES.has_key?(name) raise(UnknownSCM,"unknown SCM #{name}",caller) end return NAMES[name] end |