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.



8
9
10
11
12
# File 'lib/chamber/commands/initialize.rb', line 8

def initialize(options = {})
  super

  self.basepath = Chamber.configuration.basepath
end

Class Method Details

.call(options = {}) ⇒ Object



28
29
30
# File 'lib/chamber/commands/initialize.rb', line 28

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

Instance Method Details

#callObject



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

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