Class: Freighthop::CLI::Init

Inherits:
Object
  • Object
show all
Defined in:
lib/freighthop/cli/init.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Init

Returns a new instance of Init.



8
9
# File 'lib/freighthop/cli/init.rb', line 8

def initialize(*args)
end

Instance Attribute Details

#languageObject (readonly)

Returns the value of attribute language.



6
7
8
# File 'lib/freighthop/cli/init.rb', line 6

def language
  @language
end

Class Method Details

.match?(*args) ⇒ Boolean

Returns:

  • (Boolean)


2
3
4
# File 'lib/freighthop/cli/init.rb', line 2

def self.match?(*args)
  args.first == 'init'
end

Instance Method Details

#default_configObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/freighthop/cli/init.rb', line 21

def default_config
  {
    'freighthop::cpus'                          => 2,
    'freighthop::ram'                           => 512,
    'freighthop::languages'                     => ['ruby'],
    'freighthop::web::servers'                  => ['nginx'],
    'freighthop::web::nginx::upstream_port'     => 3000,
    'freighthop::database::servers'             => ['postgres'],
    'freighthop::database::postgres::databases' => [],
    'freighthop::database::postgres::users'     => [],
    'freighthop::ppas'                          => [],
    'freighthop::packages'                      => [ "libpq-dev" ],
  }
end

#runObject



11
12
13
14
15
16
17
18
19
# File 'lib/freighthop/cli/init.rb', line 11

def run
  if Freighthop::Config.exist?
    puts "This directory already contains a #{Freighthop::Config.file.basename}"
    exit 1
  end

  puts "Writing a new config to #{Freighthop::Config.file.basename}"
  Freighthop::Config.write(default_config)
end