Module: Metior::VCS

Included in:
Git, GitHub
Defined in:
lib/metior/vcs.rb

Overview

This module provides functionality to automatically register new VCS implementations Modules

Author:

  • Sebastian Staudt

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object

Including VCS will make a Module available as a supported VCS type in Metior

Examples:

This will automatically register ExoticVCS as :exotic

module ExoticVCS

  NAME = :exotic

  include Metior::VCS

end

Parameters:

  • mod (Module)

    The Module that provides a Metior implementation for a specific VCS

Raises:

  • (RuntimeError)

    if the VCS Module does not have the NAME constant defined prior to including Metior::VCS

See Also:



114
115
116
117
118
119
120
121
122
123
# File 'lib/metior/vcs.rb', line 114

def self.included(mod)
  mod.extend ClassMethods
  mod.send :class_variable_set, :@@features, {
    :file_stats => true,
    :line_stats => true
  }

  raise "#{mod}::NAME is not set." unless mod.const_defined? :NAME
  Metior.vcs_types[mod::NAME.to_sym] = mod
end

Instance Method Details

#support!(feature) ⇒ Object

Checks if a specific feature is supported by the VCS (or its implementation) and raises an error if the feature is not available

Raises:

  • (UnsupportedError)

    if the feature is not supported by the VCS (or its implementation)

See Also:



131
132
133
# File 'lib/metior/vcs.rb', line 131

def support!(feature)
  raise UnsupportedError.new(vcs) unless supports? feature
end

#supports?(feature) ⇒ true, false

Checks if a specific feature is supported by the VCS (or its implementation)

Returns:

  • (true, false)

    true if the feature is supported

See Also:



140
141
142
# File 'lib/metior/vcs.rb', line 140

def supports?(feature)
  vcs.supports? feature
end

#vcsMetior::VCS

Returns the VCS module that is included by this object

Returns:

  • (Metior::VCS)

    The VCS implementation module of this object

See Also:



148
149
150
# File 'lib/metior/vcs.rb', line 148

def vcs
  Metior.vcs_types[singleton_class::NAME.to_sym]
end