Class: GitoFigure
- Inherits:
-
Object
- Object
- GitoFigure
- Defined in:
- lib/gitofigure.rb
Constant Summary collapse
- REPOS =
'/tmp/gitolites'
Instance Attribute Summary collapse
-
#repo ⇒ Object
Returns the value of attribute repo.
Class Method Summary collapse
Instance Method Summary collapse
- #authorize_keyfile(filename, msg = nil) ⇒ Object
- #authorize_keys(hsh) ⇒ Object
-
#initialize(ops = {}) ⇒ GitoFigure
constructor
A new instance of GitoFigure.
Constructor Details
#initialize(ops = {}) ⇒ GitoFigure
Returns a new instance of GitoFigure.
6 7 8 |
# File 'lib/gitofigure.rb', line 6 def initialize(ops={}) @repo = ops[:repo] end |
Instance Attribute Details
#repo ⇒ Object
Returns the value of attribute repo.
3 4 5 |
# File 'lib/gitofigure.rb', line 3 def repo @repo end |
Class Method Details
.administer(server, overrides = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gitofigure.rb', line 10 def self.administer(server, overrides={}) ops = {:git_user => 'gitolite', :repo => 'gitolite-admin', :server => server}.merge overrides upstream_url = ops[:git_user] + '@' + ops[:server] + ':' + ops[:repo] local_path = File.join(REPOS, ops[:server]) git = GitoFigure.new git.repo = Dir.exists?(local_path) ? Git.open(local_path) : Git.clone(upstream_url, ops[:server], :path => REPOS) if block_given? git.repo.pull yield git git.repo.push else return git end end |
Instance Method Details
#authorize_keyfile(filename, msg = nil) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/gitofigure.rb', line 35 def (filename, msg=nil) msg = ["Added #{File.basename(filename)}", msg].join("\n") FileUtils.mv(filename, repo.dir.to_s + '/keydir') repo.add 'keydir' repo.commit(msg) end |
#authorize_keys(hsh) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/gitofigure.rb', line 27 def (hsh) hsh.each do |name, key| filename = File.join('/', 'tmp', name.to_s + '.pub') File.open(filename, "w") {|f| f.write(key.to_s)} (filename) end end |