Module: Dragnet::Helpers::RepositoryHelper

Included in:
Exporters::HTMLExporter, Exporters::IDGenerator, Exporters::Serializers::TestRecordSerializer, Verifiers::Verifier
Defined in:
lib/dragnet/helpers/repository_helper.rb

Overview

Some helper methods to use when working with repositories.

Instance Method Summary collapse

Instance Method Details

#relative_to_repo(path) ⇒ Pathname

Transforms the given path into a path relative to the repository's root

Parameters:

  • path (Pathname)

    The absolute path.

Returns:

  • (Pathname)

    A path relative to the repository's root.



22
23
24
# File 'lib/dragnet/helpers/repository_helper.rb', line 22

def relative_to_repo(path)
  path.relative_path_from(repo_base)
end

#repo_basePathname

Returns The base path of the repository where the MTR and the source files are located. Used to present relative paths.

Returns:

  • (Pathname)

    The base path of the repository where the MTR and the source files are located. Used to present relative paths.



15
16
17
# File 'lib/dragnet/helpers/repository_helper.rb', line 15

def repo_base
  @repo_base ||= repository.path
end

#shorten_sha1(sha1) ⇒ String

Returns The first 10 characters of the given string (normally used to shorten SHA1s when building messages).

Returns:

  • (String)

    The first 10 characters of the given string (normally used to shorten SHA1s when building messages).



9
10
11
# File 'lib/dragnet/helpers/repository_helper.rb', line 9

def shorten_sha1(sha1)
  sha1[0...10]
end