Class: Moron::Hook
- Inherits:
-
Object
- Object
- Moron::Hook
- Defined in:
- lib/moron/hook.rb
Constant Summary collapse
- KEY_PREFIX =
%[command="%b %u -r %d",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty]
Instance Method Summary collapse
-
#initialize(path, binary_path) ⇒ Hook
constructor
A new instance of Hook.
- #run ⇒ Object
Constructor Details
#initialize(path, binary_path) ⇒ Hook
Returns a new instance of Hook.
4 5 6 7 |
# File 'lib/moron/hook.rb', line 4 def initialize(path, binary_path) @path = path @binary_path = binary_path end |
Instance Method Details
#run ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/moron/hook.rb', line 9 def run if !@path.match(/\.git$/) puts "Is this a git repository ?" exit 1 end require 'git' g = Git.(@path) t = g.gtree('HEAD^{tree}') t = t.subtrees["keydir"] File.open File.("~/.ssh/authorized_keys"), 'w' do |f| write_keys(t, f) end end |