Sha256: f04428759d4fab45ca97af423f27ac822b86b47a8ea502de1f3d62fd8dd34078
Contents?: true
Size: 1.36 KB
Versions: 4
Compression:
Stored size: 1.36 KB
Contents
# frozen_string_literal: true module KubsCLI # Used to install items from a YAML file class Install def initialize(config = KubsCLI.configuration) @fh = FileHelper.new @dependencies = config.dependencies @packages = config.packages end def install_dependencies install_from_file(@dependencies) end def install_packages install_from_file(@packages) end # Installs dependencies from a given YAML file # @see lib/examples/dependencies.yaml # @return Array<String> Returns an array of strings to run via Rake to install # various packages def create_ary_from_yaml(file) hash = @fh.load_yaml(file) hash.map do |_key, value| command = value['command'] packages = value['packages'] packages = packages.join(' ') if packages.is_a?(Array) "#{command} #{packages}" end rescue StandardError => e msg = "There was an issue with creating a dependencies array from #{file}" KubsCLI.add_error(e: e, msg: msg) end # Installs dependencies from a give yaml_file via Rake.sh # @return void def install_from_file(file) ary = create_ary_from_yaml(file) ary.each do |command| Rake.sh(command.to_s) rescue StandardError => e KubsCLI.add_error(e: e, msg: "Failed with #{command}") end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
kubs_cli-0.2.2 | lib/kubs_cli/install.rb |
kubs_cli-0.2.1 | lib/kubs_cli/install.rb |
kubs_cli-0.2.0 | lib/kubs_cli/install.rb |
kubs_cli-0.1.15 | lib/kubs_cli/install.rb |