Class: QB::Repo

Inherits:
Util::Resource show all
Defined in:
lib/qb/repo.rb,
lib/qb/repo/git.rb

Direct Known Subclasses

Git

Defined Under Namespace

Classes: Git

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Util::Resource

#initialize

Constructor Details

This class inherits a constructor from QB::Util::Resource

Instance Attribute Details

#nameString (readonly)

The string name of the repo.

Returns:

  • (String)

    Non-empty string.



109
# File 'lib/qb/repo.rb', line 109

prop  :name, type: t.maybe( t.non_empty_str )

#ref_pathString | Pathname? (readonly)

User-provided path value used to construct the resource instance, if any.

This may not be the same as a root path for the resource, such as with resource classes that can be constructed from any path inside the directory, like a Git.

Returns:

  • (String | Pathname)

    If the resource instance was constructed based on a path argument.

  • (nil)

    If the resource instance was not constructed based on a path argument.



92
# File 'lib/qb/repo.rb', line 92

prop  :ref_path, type: t.maybe( t.path )

#root_pathPathname (readonly)

Absolute path to the gem's root directory.

Returns:

  • (Pathname)


100
# File 'lib/qb/repo.rb', line 100

prop  :root_path, type: t.dir_path

Class Method Details

.from_path(path, git: {}) ⇒ nil, QB::Repo

Get an instance for whatever repo path is in.

Parameters:

  • path (String, Pathname)

    A path that may be in a repo.

Returns:

  • (nil)

    If path is not a part of repo we can recognize (git only at the moment, sorry).

  • (QB::Repo)

    If path is not a part of repo we can recognize.



49
50
51
# File 'lib/qb/repo.rb', line 49

def self.from_path path, git: {}
  QB::Repo::Git.from_path path, **git
end

.from_path!(path, **opts) ⇒ QB::Repo

Instantiate a QB::Repo for the repo path is in or raise if it's not in any single recognizable repo.

Parameters:

  • path

    see .from_path

  • **opts

    see .from_path

Returns:

Raises:



65
66
67
68
69
70
71
72
# File 'lib/qb/repo.rb', line 65

def self.from_path! path, **opts
  from_path( path, **opts ).tap { |repo|
    if repo.nil?
      raise QB::FSStateError,
            "Path #{ path.inspect } does not appear to be in a repo."
    end
  }
end

Instance Method Details

#tagsArray<String>

TODO:

Document tags method.

Parameters:

  • arg_name (type)

    @todo Add name param description.

Returns:

  • (Array<String>)

Raises:

  • (NotImplementedError)


122
123
124
# File 'lib/qb/repo.rb', line 122

def tags
  raise NotImplementedError
end