Class: Repomen::Retriever

Inherits:
Object
  • Object
show all
Includes:
WithDefaultConfig
Defined in:
lib/repomen/retriever.rb

Overview

The Retriever retrieved repos and discards at will.

url = "[email protected]:atlassian_tutorial/helloworld.git"
Retriever.new(url)

When called with a block, the repo is automatically deleted afterwards

Retriever.new(url) do |local_path|
  # repo is cloned in +local_path+
end
# repo is gone

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WithDefaultConfig

#default_config

Constructor Details

#initialize(url, config = default_config, &block) ⇒ Retriever

Returns a new instance of Retriever.



19
20
21
22
23
24
25
26
27
28
# File 'lib/repomen/retriever.rb', line 19

def initialize(url, config = default_config, &block)
  service = Repo::Service.for(url)
  @handler = service.handler_class.new(url, repo_dir(service), config)
  @handler.retrieve
  @path = @handler.path
  if block
    block.call(@path)
    discard_repo
  end
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



17
18
19
# File 'lib/repomen/retriever.rb', line 17

def path
  @path
end

#urlObject (readonly)

Returns the value of attribute url.



17
18
19
# File 'lib/repomen/retriever.rb', line 17

def url
  @url
end

Instance Method Details

#discard_repoObject

Removes the repo from the filesystem



31
32
33
# File 'lib/repomen/retriever.rb', line 31

def discard_repo
  @handler.discard
end