Class: BetweenMeals::Repo
- Inherits:
-
Object
- Object
- BetweenMeals::Repo
- Defined in:
- lib/between_meals/repo.rb,
lib/between_meals/repo/hg.rb,
lib/between_meals/repo/git.rb,
lib/between_meals/repo/svn.rb,
lib/between_meals/repo/hg/cmd.rb,
lib/between_meals/repo/git/cmd.rb,
lib/between_meals/repo/svn/cmd.rb
Overview
Local checkout wrapper
Defined Under Namespace
Instance Attribute Summary collapse
-
#bin ⇒ Object
Returns the value of attribute bin.
-
#repo_path ⇒ Object
readonly
Returns the value of attribute repo_path.
Class Method Summary collapse
Instance Method Summary collapse
-
#changes(_start_ref, _end_ref) ⇒ Object
Return files changed between two revisions.
- #checkout ⇒ Object
- #create(_url) ⇒ Object
- #email ⇒ Object
- #exists? ⇒ Boolean
-
#files ⇒ Object
Return all files.
- #head ⇒ Object
- #head_msg ⇒ Object
- #head_msg= ⇒ Object
- #head_parents ⇒ Object
- #head_rev ⇒ Object
-
#initialize(repo_path, logger) ⇒ Repo
constructor
A new instance of Repo.
- #last_author ⇒ Object
- #last_msg ⇒ Object
- #last_msg= ⇒ Object
- #latest_revision ⇒ Object
- #name ⇒ Object
-
#setup ⇒ Object
This method must succeed in the case of no repo directory so that users can call ‘checkout`.
- #status ⇒ Object
- #update ⇒ Object
- #upstream?(_rev) ⇒ Boolean
- #valid_ref?(_rev) ⇒ Boolean
Constructor Details
#initialize(repo_path, logger) ⇒ Repo
Returns a new instance of Repo.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/between_meals/repo.rb', line 24 def initialize(repo_path, logger) @repo_path = repo_path @logger = logger @repo = nil @bin = nil setup rescue StandardError @logger.warn("Unable to read repo from #{File.(repo_path)}") exit(1) end |
Instance Attribute Details
#bin ⇒ Object
Returns the value of attribute bin.
22 23 24 |
# File 'lib/between_meals/repo.rb', line 22 def bin @bin end |
#repo_path ⇒ Object (readonly)
Returns the value of attribute repo_path.
22 23 24 |
# File 'lib/between_meals/repo.rb', line 22 def repo_path @repo_path end |
Class Method Details
.get(type, repo_path, logger) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/between_meals/repo.rb', line 35 def self.get(type, repo_path, logger) case type when 'auto' unless File.directory?(repo_path) logger.warn("#{repo_path} does not point to a repo") exit(1) end logger.info('Trying to detect repo type') require 'between_meals/repo/git' require 'between_meals/repo/hg' require 'between_meals/repo/svn' [ BetweenMeals::Repo::Git, BetweenMeals::Repo::Hg, BetweenMeals::Repo::Svn, ].each do |klass| begin r = klass.new(repo_path, logger) if r.exists? logger.info("Repo found to be #{klass.to_s.split('::').last}") return r end rescue StandardError logger.debug("Skipping #{klass}") end end logger.warn("Failed detecting repo type at #{repo_path}") exit(1) when 'svn' require 'between_meals/repo/svn' BetweenMeals::Repo::Svn.new(repo_path, logger) when 'git' require 'between_meals/repo/git' BetweenMeals::Repo::Git.new(repo_path, logger) when 'hg' require 'between_meals/repo/hg' BetweenMeals::Repo::Hg.new(repo_path, logger) else fail "Do not know repo type #{type}" end end |
Instance Method Details
#changes(_start_ref, _end_ref) ⇒ Object
Return files changed between two revisions
122 123 124 |
# File 'lib/between_meals/repo.rb', line 122 def changes(_start_ref, _end_ref) fail "#{__method__} not implemented" end |
#checkout ⇒ Object
139 140 141 |
# File 'lib/between_meals/repo.rb', line 139 def checkout fail "#{__method__} not implemented" end |
#create(_url) ⇒ Object
117 118 119 |
# File 'lib/between_meals/repo.rb', line 117 def create(_url) fail "#{__method__} not implemented" end |
#email ⇒ Object
159 160 161 |
# File 'lib/between_meals/repo.rb', line 159 def email fail "#{__method__} not implemented" end |
#exists? ⇒ Boolean
82 83 84 |
# File 'lib/between_meals/repo.rb', line 82 def exists? fail "#{__method__} not implemented" end |
#files ⇒ Object
Return all files
131 132 133 |
# File 'lib/between_meals/repo.rb', line 131 def files fail "#{__method__} not implemented" end |
#head ⇒ Object
135 136 137 |
# File 'lib/between_meals/repo.rb', line 135 def head fail "#{__method__} not implemented" end |
#head_msg ⇒ Object
101 102 103 |
# File 'lib/between_meals/repo.rb', line 101 def head_msg fail "#{__method__} not implemented" end |
#head_msg= ⇒ Object
105 106 107 |
# File 'lib/between_meals/repo.rb', line 105 def head_msg= fail "#{__method__} not implemented" end |
#head_parents ⇒ Object
109 110 111 |
# File 'lib/between_meals/repo.rb', line 109 def head_parents fail "#{__method__} not implemented" end |
#head_rev ⇒ Object
97 98 99 |
# File 'lib/between_meals/repo.rb', line 97 def head_rev fail "#{__method__} not implemented" end |
#last_author ⇒ Object
143 144 145 |
# File 'lib/between_meals/repo.rb', line 143 def fail "#{__method__} not implemented" end |
#last_msg ⇒ Object
147 148 149 |
# File 'lib/between_meals/repo.rb', line 147 def last_msg fail "#{__method__} not implemented" end |
#last_msg= ⇒ Object
151 152 153 |
# File 'lib/between_meals/repo.rb', line 151 def last_msg= fail "#{__method__} not implemented" end |
#latest_revision ⇒ Object
113 114 115 |
# File 'lib/between_meals/repo.rb', line 113 def latest_revision fail "#{__method__} not implemented" end |
#name ⇒ Object
155 156 157 |
# File 'lib/between_meals/repo.rb', line 155 def name fail "#{__method__} not implemented" end |
#setup ⇒ Object
This method must succeed in the case of no repo directory so that users can call ‘checkout`. Users may call `exists?` to find out if we have an underlying repo yet.
93 94 95 |
# File 'lib/between_meals/repo.rb', line 93 def setup fail "#{__method__} not implemented" end |
#status ⇒ Object
86 87 88 |
# File 'lib/between_meals/repo.rb', line 86 def status fail "#{__method__} not implemented" end |
#update ⇒ Object
126 127 128 |
# File 'lib/between_meals/repo.rb', line 126 def update fail "#{__method__} not implemented" end |
#upstream?(_rev) ⇒ Boolean
163 164 165 |
# File 'lib/between_meals/repo.rb', line 163 def upstream?(_rev) fail "#{__method__} not implemented" end |
#valid_ref?(_rev) ⇒ Boolean
167 168 169 |
# File 'lib/between_meals/repo.rb', line 167 def valid_ref?(_rev) fail "#{__method__} not implemented" end |