class BB8::Commands::InitialiseEnvironment

Attributes

name[R]
voltos_bundle[R]

Public Class Methods

call(name, voltos_bundle, *arguments) click to toggle source
# File lib/bb8/commands/initialise_environment.rb, line 2
def self.call(name, voltos_bundle, *arguments)
  new(name, voltos_bundle).call
end
new(name, voltos_bundle) click to toggle source
# File lib/bb8/commands/initialise_environment.rb, line 6
def initialize(name, voltos_bundle)
  @name, @voltos_bundle = name, voltos_bundle
end

Public Instance Methods

call() click to toggle source
# File lib/bb8/commands/initialise_environment.rb, line 10
def call
  FileUtils.mkdir_p name
  Dir.chdir name
  File.write '.bb8_bundle', voltos_bundle

  append_token unless set_bundle?
  BB8::SetEncryptionKeys.call
end

Private Instance Methods

append_token() click to toggle source
# File lib/bb8/commands/initialise_environment.rb, line 23
def append_token
  File.open('.env', 'a') do |file|
    file.puts "VOLTOS_KEY=#{bundle.token}"
  end
end
bundle() click to toggle source
# File lib/bb8/commands/initialise_environment.rb, line 29
def bundle
  @bundle ||= BB8::Voltos.bundles.detect { |bundle|
    bundle.name == voltos_bundle
  } || BB8::Voltos::Bundle.create(voltos_bundle)
end
set_bundle?() click to toggle source
# File lib/bb8/commands/initialise_environment.rb, line 35
def set_bundle?
  File.exist?('.env') && File.read('.env')[/^VOLTOS_KEY=(\w+)/]
end