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.



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/repomen/retriever.rb', line 21

def initialize(url, config = default_config, &block)
  @url = url
  @service = Repo::Service.for(url)
  @handler = @service.handler_class.new(url, repo_dir(service), config)
  @retrieved = @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.



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

def path
  @path
end

#serviceObject (readonly)

Returns the value of attribute service.



19
20
21
# File 'lib/repomen/retriever.rb', line 19

def service
  @service
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

#branch_nameObject



33
34
35
# File 'lib/repomen/retriever.rb', line 33

def branch_name
  @handler.branch_name
end

#change_branch(name, update_branch = false) ⇒ Object Also known as: checkout_revision

Changes the branch of the retrieved repo.

Parameters:

  • name (String)

    name of the branch



39
40
41
42
43
44
# File 'lib/repomen/retriever.rb', line 39

def change_branch(name, update_branch = false)
  @handler.change_branch(name, update_branch)
  true
rescue Repomen::HandlerError
  false
end

#discard_repoObject

Removes the repo from the filesystem



48
49
50
# File 'lib/repomen/retriever.rb', line 48

def discard_repo
  @handler.discard
end

#repo_nameObject



83
84
85
# File 'lib/repomen/retriever.rb', line 83

def repo_name
  @service.repo_name
end

#retrieved?Boolean

Returns true if the repo was retrieved successfully

Returns:

  • (Boolean)


53
54
55
# File 'lib/repomen/retriever.rb', line 53

def retrieved?
  @retrieved
end

#revisionObject

Returns the revision of the repo.



58
59
60
# File 'lib/repomen/retriever.rb', line 58

def revision
  @handler.revision_info['commit']
end

#revision_author_emailObject



70
71
72
# File 'lib/repomen/retriever.rb', line 70

def revision_author_email
  @handler.revision_info['email']
end

#revision_author_nameObject



66
67
68
# File 'lib/repomen/retriever.rb', line 66

def revision_author_name
  @handler.revision_info['name']
end

#revision_authored_atObject



74
75
76
# File 'lib/repomen/retriever.rb', line 74

def revision_authored_at
  @handler.revision_info['date']
end

#revision_messageObject



62
63
64
# File 'lib/repomen/retriever.rb', line 62

def revision_message
  @handler.revision_info['message']
end

#service_nameObject



87
88
89
# File 'lib/repomen/retriever.rb', line 87

def service_name
  @service.name
end

#tagObject

Returns the tag of the repo.



79
80
81
# File 'lib/repomen/retriever.rb', line 79

def tag
  @handler.tag
end

#user_nameObject



91
92
93
# File 'lib/repomen/retriever.rb', line 91

def user_name
  @service.user_name
end