Class: Chamber::Commands::Initialize

Inherits:
Base
  • Object
show all
Defined in:
lib/chamber/commands/initialize.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Initialize

Returns a new instance of Initialize.



10
11
12
13
14
# File 'lib/chamber/commands/initialize.rb', line 10

def initialize(options = {})
  super

  self.basepath = Chamber.configuration.basepath
end

Class Method Details

.call(options = {}) ⇒ Object



30
31
32
# File 'lib/chamber/commands/initialize.rb', line 30

def self.call(options = {})
  self.new(options).call
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/chamber/commands/initialize.rb', line 16

def call
  shell.create_file private_key_filepath, rsa_private_key.to_pem
  shell.create_file public_key_filepath,  rsa_public_key.to_pem

  `chmod 600 #{private_key_filepath}`
  `chmod 644 #{public_key_filepath}`

  unless ::File.read(gitignore_filepath).match(/^.chamber.pem$/)
    shell.append_to_file gitignore_filepath, private_key_filepath.basename.to_s
  end

  shell.copy_file settings_template_filepath, settings_filepath
end