Class: Repomen::Retriever
- Inherits:
-
Object
- Object
- Repomen::Retriever
- 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
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #branch_name ⇒ Object
-
#change_branch(name, update_branch = false) ⇒ Object
(also: #checkout_revision)
Changes the branch of the retrieved repo.
-
#discard_repo ⇒ Object
Removes the repo from the filesystem.
-
#initialize(url, config = default_config, &block) ⇒ Retriever
constructor
A new instance of Retriever.
- #repo_name ⇒ Object
-
#retrieved? ⇒ Boolean
Returns
trueif the repo was retrieved successfully. -
#revision ⇒ Object
Returns the revision of the repo.
- #revision_author_email ⇒ Object
- #revision_author_name ⇒ Object
- #revision_authored_at ⇒ Object
- #revision_message ⇒ Object
- #service_name ⇒ Object
-
#tag ⇒ Object
Returns the tag of the repo.
- #user_name ⇒ Object
Methods included from WithDefaultConfig
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
#path ⇒ Object (readonly)
Returns the value of attribute path.
18 19 20 |
# File 'lib/repomen/retriever.rb', line 18 def path @path end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
19 20 21 |
# File 'lib/repomen/retriever.rb', line 19 def service @service end |
#url ⇒ Object (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_name ⇒ Object
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.
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_repo ⇒ Object
Removes the repo from the filesystem
48 49 50 |
# File 'lib/repomen/retriever.rb', line 48 def discard_repo @handler.discard end |
#repo_name ⇒ Object
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
53 54 55 |
# File 'lib/repomen/retriever.rb', line 53 def retrieved? @retrieved end |
#revision ⇒ Object
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_email ⇒ Object
70 71 72 |
# File 'lib/repomen/retriever.rb', line 70 def @handler.revision_info['email'] end |
#revision_author_name ⇒ Object
66 67 68 |
# File 'lib/repomen/retriever.rb', line 66 def @handler.revision_info['name'] end |
#revision_authored_at ⇒ Object
74 75 76 |
# File 'lib/repomen/retriever.rb', line 74 def @handler.revision_info['date'] end |
#revision_message ⇒ Object
62 63 64 |
# File 'lib/repomen/retriever.rb', line 62 def @handler.revision_info['message'] end |
#service_name ⇒ Object
87 88 89 |
# File 'lib/repomen/retriever.rb', line 87 def service_name @service.name end |
#tag ⇒ Object
Returns the tag of the repo.
79 80 81 |
# File 'lib/repomen/retriever.rb', line 79 def tag @handler.tag end |
#user_name ⇒ Object
91 92 93 |
# File 'lib/repomen/retriever.rb', line 91 def user_name @service.user_name end |