Class: Nib::Crypt::Initializer

Inherits:
Object
  • Object
show all
Defined in:
lib/nib/crypt/initializer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInitializer

Returns a new instance of Initializer.



7
8
9
# File 'lib/nib/crypt/initializer.rb', line 7

def initialize
  @key = Key.new
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/nib/crypt/initializer.rb', line 5

def key
  @key
end

Instance Method Details

#callObject

rubocop:disable Metrics/MethodLength, Metrics/AbcSize



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/nib/crypt/initializer.rb', line 12

def call
  if key.remote? && !key.local?
    puts 'Pulling existing key from S3'
    key.pull
  elsif !key.local?
    puts 'Key does not yet exist, creating'
    key.create!
    puts 'Pushing new key to to S3'
    key.push
  elsif !key.remote?
    puts 'Pushing existing key to to S3'
    key.push
  else
    puts 'Project already inialized'
  end
end