Class: Rgc::Keygen

Inherits:
Object
  • Object
show all
Defined in:
lib/rgc/keygen.rb

Instance Method Summary collapse

Constructor Details

#initialize(global_options, options, args) ⇒ Keygen

Returns a new instance of Keygen.



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/rgc/keygen.rb', line 3

def initialize(global_options, options, args)
  if File.exists?(path = args.first)
    abort "Key file already exists."
  end

  begin
    File.open(path, 'w') do |f|
      f.write(generate_secure_key)
    end
  rescue
    abort "Cannot open #{path} for writing."
  end
end