Class: Smeagol::Repository
- Inherits:
-
Object
- Object
- Smeagol::Repository
- Defined in:
- lib/smeagol/repository.rb
Overview
Repostiory encapsulation. This class serves two needs, as a wiki repo (for Config) and as a site repo (for Settings). Which fields are actually used depends on which of these two use cases is at play.
Instance Attribute Summary collapse
-
#bare ⇒ Object
Is the repository bare?.
-
#cname ⇒ Object
Returns the value of attribute cname.
-
#origin ⇒ Object
Site’s git repo uri.
-
#path ⇒ Object
Returns the value of attribute path.
-
#ref ⇒ Object
(also: #tag, #branch)
For deployment site, if the repo is using detached branch approach, then specify the branch name here.
-
#secret ⇒ Object
Passcode, if needed to interact with repo.
Instance Method Summary collapse
- #auto_update? ⇒ Boolean
-
#clone ⇒ Object
Clone repo to path.
-
#initialize(opts = {}) ⇒ Repository
constructor
A new instance of Repository.
-
#pull ⇒ Object
(also: #update)
Pull down any changes.
- #repo ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Repository
Returns a new instance of Repository.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/smeagol/repository.rb', line 11 def initialize(opts={}) opts = OpenStruct.new(opts) @path = opts.path @origin = opts.origin @ref = opts.ref || opts.tag || opts.branch || 'master' @bare = opts. @secret = opts.secret @cname = opts.cname @update = opts.update end |
Instance Attribute Details
#bare ⇒ Object
Is the repository bare?
46 47 48 |
# File 'lib/smeagol/repository.rb', line 46 def @bare end |
#cname ⇒ Object
Returns the value of attribute cname.
49 50 51 |
# File 'lib/smeagol/repository.rb', line 49 def cname @cname end |
#origin ⇒ Object
Site’s git repo uri. e.g. ‘[email protected]:trans/trans.github.com.git`
27 28 29 |
# File 'lib/smeagol/repository.rb', line 27 def origin @origin end |
#path ⇒ Object
Returns the value of attribute path.
23 24 25 |
# File 'lib/smeagol/repository.rb', line 23 def path @path end |
#ref ⇒ Object Also known as: tag, branch
For deployment site, if the repo is using detached branch approach, then specify the branch name here. This will typically be used for GitHub projects using ‘gh-pages`. Default is `master`.
32 33 34 |
# File 'lib/smeagol/repository.rb', line 32 def ref @ref end |
#secret ⇒ Object
Passcode, if needed to interact with repo.
43 44 45 |
# File 'lib/smeagol/repository.rb', line 43 def secret @secret end |
Instance Method Details
#auto_update? ⇒ Boolean
52 53 54 |
# File 'lib/smeagol/repository.rb', line 52 def auto_update? @update end |
#clone ⇒ Object
Clone repo to path.
76 77 78 79 80 81 |
# File 'lib/smeagol/repository.rb', line 76 def clone # dummy location tmp = ::File.join(::Dir.tmpdir, 'smeagol', Time.to_i) git = Grit::Git.new(tmp) git.clone({:quiet=>false, :verbose=>true, :progress=>true, :branch=>branch}, origin, path) end |
#pull ⇒ Object Also known as: update
Pull down any changes.
64 65 66 |
# File 'lib/smeagol/repository.rb', line 64 def pull repo.git.pull({}, 'origin', branch) end |
#repo ⇒ Object
57 58 59 |
# File 'lib/smeagol/repository.rb', line 57 def repo @repo ||= Grit::Repo.new(path, :is_bare=>) end |