Class: KubsCLI::Install
- Inherits:
-
Object
- Object
- KubsCLI::Install
- Defined in:
- lib/kubs_cli/install.rb
Overview
Used to install items from a YAML file
Instance Method Summary collapse
-
#create_ary_from_yaml(file) ⇒ Object
Installs dependencies from a given YAML file.
-
#initialize(config = KubsCLI.configuration) ⇒ Install
constructor
A new instance of Install.
- #install_dependencies ⇒ Object
-
#install_from_file(file) ⇒ Object
Installs dependencies from a give yaml_file via Rake.sh.
- #install_packages ⇒ Object
Constructor Details
#initialize(config = KubsCLI.configuration) ⇒ Install
Returns a new instance of Install.
6 7 8 9 10 |
# File 'lib/kubs_cli/install.rb', line 6 def initialize(config = KubsCLI.configuration) @fh = FileHelper.new @dependencies = config.dependencies @packages = config.packages end |
Instance Method Details
#create_ary_from_yaml(file) ⇒ Object
Installs dependencies from a given YAML file
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/kubs_cli/install.rb', line 24 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 |
#install_dependencies ⇒ Object
12 13 14 |
# File 'lib/kubs_cli/install.rb', line 12 def install_dependencies install_from_file(@dependencies) end |
#install_from_file(file) ⇒ Object
Installs dependencies from a give yaml_file via Rake.sh
41 42 43 44 45 46 47 48 49 |
# File 'lib/kubs_cli/install.rb', line 41 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 |
#install_packages ⇒ Object
16 17 18 |
# File 'lib/kubs_cli/install.rb', line 16 def install_packages install_from_file(@packages) end |