Class: Mixlib::Install::Generator::PowerShell

Inherits:
Base
  • Object
show all
Defined in:
lib/mixlib/install/generator/powershell.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#get_script, get_script, #initialize

Constructor Details

This class inherits a constructor from Mixlib::Install::Generator::Base

Class Method Details

.detect_platform_ps1Object



35
36
37
38
39
40
# File 'lib/mixlib/install/generator/powershell.rb', line 35

def self.detect_platform_ps1
  detect_platform_command = []
  detect_platform_command << get_script("helpers.ps1")
  detect_platform_command << get_script("platform_detection.ps1")
  detect_platform_command.join("\n\n")
end

.install_ps1(context) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/mixlib/install/generator/powershell.rb', line 24

def self.install_ps1(context)
  install_project_module = []
  install_project_module << get_script("helpers.ps1")
  install_project_module << get_script("get_project_metadata.ps1", context)
  install_project_module << get_script("install_project.ps1")

  install_command = []
  install_command << ps1_modularize(install_project_module.join("\n"), "Omnitruck")
  install_command.join("\n\n")
end

.ps1_modularize(module_body, module_name) ⇒ Object



62
63
64
65
66
67
68
# File 'lib/mixlib/install/generator/powershell.rb', line 62

def self.ps1_modularize(module_body, module_name)
  ps1_module = []
  ps1_module << "new-module -name #{module_name} -scriptblock {"
  ps1_module << module_body
  ps1_module << "}"
  ps1_module.join("\n")
end

.script_base_pathObject



42
43
44
# File 'lib/mixlib/install/generator/powershell.rb', line 42

def self.script_base_path
  File.join(File.dirname(__FILE__), "powershell/scripts")
end

Instance Method Details

#artifactory_urlsObject



74
75
76
77
# File 'lib/mixlib/install/generator/powershell.rb', line 74

def artifactory_urls
  get_script("get_project_metadata_for_artifactory.ps1",
             artifacts: artifacts)
end

#artifactsObject



79
80
81
# File 'lib/mixlib/install/generator/powershell.rb', line 79

def artifacts
  @artifacts ||= Mixlib::Install::Backend::Artifactory.new(options).info
end

#install_commandObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/mixlib/install/generator/powershell.rb', line 46

def install_command
  install_project_module = []
  install_project_module << get_script("helpers.ps1")
  install_project_module << if options.for_artifactory?
                              artifactory_urls
                            else
                              get_script("get_project_metadata.ps1")
                            end
  install_project_module << get_script("install_project.ps1")

  install_command = []
  install_command << ps1_modularize(install_project_module.join("\n"), "Omnitruck")
  install_command << render_command
  install_command.join("\n\n")
end

#product_versionObject



83
84
85
86
87
88
89
# File 'lib/mixlib/install/generator/powershell.rb', line 83

def product_version
  if options.for_artifactory?
    artifacts.first.version
  else
    options.product_version
  end
end

#ps1_modularize(module_body, module_name) ⇒ Object



70
71
72
# File 'lib/mixlib/install/generator/powershell.rb', line 70

def ps1_modularize(module_body, module_name)
  self.class.ps1_modularize(module_body, module_name)
end

#render_commandObject



91
92
93
94
95
96
97
# File 'lib/mixlib/install/generator/powershell.rb', line 91

def render_command
  cmd = "install -project #{options.product_name}"
  cmd << " -version #{product_version}"
  cmd << " -channel #{options.channel}"
  cmd << " -architecture #{options.architecture}" if options.architecture
  cmd << "\n"
end