Class VcsApp
In: lib/vcs/app.rb
Parent: Object

vcs: The version control system wrapper.

Vcs is a wrapper over any version control system.

Methods

Public Class methods

[Source]

# File lib/vcs/app.rb, line 51
    def all_vcs
      @@all_vcs.keys
    end

[Source]

# File lib/vcs/app.rb, line 38
    def grab_all_vcs
      @@all_vcs ||= {}

      if @@all_vcs.empty?
        ObjectSpace.each_object(Class) do |aClass|
          if aClass != Vcs and aClass.ancestors.include? Vcs
            name = aClass.to_s.demodulize.underscore.to_sym
            @@all_vcs[name] = aClass
          end
        end
      end
    end

[Source]

# File lib/vcs/app.rb, line 61
  def initialize ( __file__, vcs_type=nil )
    @@path = __file__.to_path
    Vcs.default ||= vcs_type
  end

[Source]

# File lib/vcs/app.rb, line 30
    def requirements
      Pathname.glob("{#{vcs_dir},#{extension_dirs.join(',')}}/*.rb") do |file|
        next if file.to_s =~ /\/(app|opt_parse|vcs|svn|version)\.rb$/
        logger.debug { file.basename.to_s } if require file.to_s
      end
      grab_all_vcs()
    end

Public Instance methods

[Source]

# File lib/vcs/app.rb, line 66
  def grab_dirs ( basename, dir=Pathname.pwd )
    results = []
    while not dir.root?
      path = dir + basename
      results << path if path.exist?
      dir = dir.parent
    end
    path = ENV['HOME'].to_path/basename
    results << path if path.exist? and not results.include? path
    results
  end

[Source]

# File lib/vcs/app.rb, line 93
  def run
    vcs = nil
    begin
      user_configuration_setup()
      Vcs.logger.color = Vcs.color? { STDERR.tty? }
      Vcs::Logger.enable_xmas_tree_colors if Vcs.xmas_tree_colors?
      vcs_extensions_setup()
      @@parser.parse! ARGV if Vcs.default.nil?
      if Vcs.default.nil?
        STDERR.puts @@parser
        STDERR.puts "
          |
          |Specify at least a Vcs type, or use a wrapped command
          |like svn, cvs, prcs in the vcs bin directory.
        ".head_cut!
        exit
      end
      vcs = @@all_vcs[Vcs.default.to_s.downcase.to_sym].new
      vcs.run_argv(ARGV)

    rescue SystemExit => ex
      raise ex
    rescue Exception => ex
      if vcs.nil?
        logger.error { "No Vcs instanciated" }
      else
        vcs.call_handlers
      end
      err = ex.to_s.sub(/\.$/, '')
      logger.debug { err = ex.long_pp ; "Backtrace enabled:" }
      err = ex.inspect if err.empty?
      logger.error { err }
      exit 1
    end
  end

[Source]

# File lib/vcs/app.rb, line 87
  def user_configuration_setup
    grab_dirs('.vcs').reverse_each do |vcs_user_conf|
      Vcs.merge_user_conf(vcs_user_conf)
    end
  end

[Source]

# File lib/vcs/app.rb, line 78
  def vcs_extensions_setup
    grab_dirs('vcs').each do |vcs_dir|
      vcs_dir = vcs_dir.expand_path
      vcs_dir.load_path!
      extension_dirs << vcs_dir
    end
    VcsApp.requirements()
  end

[Validate]