lib/mixlib/install.rb in mixlib-install-0.1.0 vs lib/mixlib/install.rb in mixlib-install-0.2.0

- old
+ new

@@ -26,10 +26,12 @@ attr_accessor :prerelease attr_accessor :nightlies + attr_accessor :install_flags + attr_accessor :endpoint attr_accessor :root attr_accessor :use_sudo @@ -43,10 +45,11 @@ def initialize(version, powershell = false, opts = {}) @version = version @powershell = powershell @http_proxy = nil @https_proxy = nil + @install_flags = nil @prerelease = false @nightly = false @endpoint = "metadata" @base_url = "https://www.chef.io/chef/install.sh" @use_sudo = true @@ -76,18 +79,19 @@ # platforms. # # @return [String] shell variable lines # @api private def install_command_vars_for_bourne - install_flags = %w[latest true].include?(version) ? "" : "-v #{version}" - install_flags << " " << "-n" if nightlies - install_flags << " " << "-p" if prerelease + flags = %w[latest true].include?(version) ? "" : "-v #{version}" + flags << " " << "-n" if nightlies + flags << " " << "-p" if prerelease + flags << " " << install_flags if install_flags [ shell_var("chef_omnibus_root", root), shell_var("chef_omnibus_url", base_url), - shell_var("install_flags", install_flags.strip), + shell_var("install_flags", flags.strip), shell_var("pretty_version", Util.pretty_version(version)), shell_var("sudo_sh", sudo("sh")), shell_var("version", version) ].join("\n") end @@ -107,25 +111,29 @@ shell_var("pretty_version", Util.pretty_version(version)), shell_var("version", version) ].join("\n") end - # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength def parse_opts(opts) opts.each do |opt, setting| case opt.to_s when "http_proxy" self.http_proxy = setting when "https_proxy" self.https_proxy = setting + when "install_flags" + self.install_flags = setting when "prerelease" self.prerelease = setting when "endpoint" self.endpoint = metadata_endpoint_from_project(setting) when "base" self.base_url = setting when "nightlies" self.nightlies = setting + when "sudo" + self.use_sudo = setting when "sudo_command" self.use_sudo = true self.sudo_command = setting end end