Class: Pfm::Command::GeneratorCommands::ServerBuild

Inherits:
Base
  • Object
show all
Defined in:
lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb

Instance Attribute Summary

Attributes inherited from Base

#errors, #params

Instance Method Summary collapse

Methods inherited from Base

#initialize, #params_valid?, #read_and_validate_params, #setup_context

Methods inherited from Base

#build_base_dir, #build_dir, #build_exists?, #build_setup, #deploy_setup, #deploy_setupv2, #inf_base_dir, #initialize, #needs_help?, #needs_version?, #run_with_default_options, #templates_dir, #verbose?

Methods included from Helpers

debug, err, msg, system_command

Constructor Details

This class inherits a constructor from Pfm::Command::GeneratorCommands::Base

Instance Method Details

#base_dirObject



52
53
54
# File 'lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb', line 52

def base_dir
  "builds/#{@params.first}"
end

#default_build_filesObject



35
36
37
38
39
40
41
# File 'lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb', line 35

def default_build_files
  %w(
    metadata
  ).each do |file|
    FileUtils.touch("#{base_dir}/#{file}", verbose: verbose?(params))
  end
end

#default_cookbooksObject



43
44
45
46
47
48
49
50
# File 'lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb', line 43

def default_cookbooks
  %w(
    chef/bake/cookbooks/bake
    chef/fry/cookbooks/fry
  ).each do |cookbook|
    system("chef generate cookbook #{base_dir}/#{cookbook} -g #{__dir__}/skeletons/code_generator")
  end
end

#mk_build_dirsObject



25
26
27
28
29
30
31
32
33
# File 'lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb', line 25

def mk_build_dirs
  %w(
    chef/bake/cookbooks
    chef/fry/cookbooks
    chef/vendor/cookbooks
  ).each do |path|
    FileUtils.mkdir_p("#{base_dir}/#{path}", verbose: verbose?(params))
  end
end

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/iapi-idlc-sdk-pfm/command/generator_commands/server_build.rb', line 9

def run
  read_and_validate_params
  if params_valid?
    setup_context

    mk_build_dirs
    default_build_files
    default_cookbooks
  else
    errors.each { |error| err("Error: #{error}") }
    parse_options(params)
    msg(opt_parser)
    1
  end
end