Class: Pullr::LocalRepository

Inherits:
Object
  • Object
show all
Includes:
Repository
Defined in:
lib/pullr/local_repository.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Repository

#infer_scm_from_dir, #infer_scm_from_uri

Constructor Details

#initialize(options = {}) ⇒ LocalRepository

Initializes the repository.

Parameters:

  • options (Hash) (defaults to: {})

    Options for the repository.

Options Hash (options):

  • :path (String)

    Path to the repository.

  • :scm (Symbol, String)

    The SCM used to manage the repository.

  • :uri (URI::Generic)

    Optional URI for the remote repository.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/pullr/local_repository.rb', line 33

def initialize(options={})
  super(options)

  @path = options[:path]

  unless @scm
    infer_scm_from_dir && infer_scm_from_uri
  end

  unless @scm
    raise(AmbigiousRepository,"could not infer the SCM from the directory #{@path.dump}",caller)
  end

  extend SCM.lookup(@scm)
end

Instance Attribute Details

#pathObject (readonly)

The path of the repository



10
11
12
# File 'lib/pullr/local_repository.rb', line 10

def path
  @path
end

#scmObject (readonly)

The SCM used for the repository



13
14
15
# File 'lib/pullr/local_repository.rb', line 13

def scm
  @scm
end

#uriObject

Optional URI for the remote repository



16
17
18
# File 'lib/pullr/local_repository.rb', line 16

def uri
  @uri
end

Instance Method Details

#nameString

The name of the repository.

Returns:

  • (String)

    The local repository name.

Since:

  • 0.1.2



57
58
59
# File 'lib/pullr/local_repository.rb', line 57

def name
  File.basename(@path)
end

#scm_dirString

The control directory used by the SCM.

Returns:

  • (String)

    The name of the control directory.



67
68
69
70
71
# File 'lib/pullr/local_repository.rb', line 67

def scm_dir
  dir, scm = SCM::DIRS.find { |dir,scm| scm == @scm }

  return dir
end

#update(uri = self.uri) ⇒ Object

Pulls any new updates for the repository down.

Parameters:

  • uri (URI::Generic) (defaults to: self.uri)

    Optional URI to pull from.



79
80
81
# File 'lib/pullr/local_repository.rb', line 79

def update(uri=self.uri)
  scm_update(@path,uri)
end