Class: KubsCLI::Copy
- Inherits:
-
Object
- Object
- KubsCLI::Copy
- Defined in:
- lib/kubs_cli/copy.rb
Overview
Copies from a repo to $HOME directory
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
- #copy_all ⇒ Object
- #copy_dotfiles ⇒ Object
- #copy_gnome_terminal_settings ⇒ Object
-
#initialize(config = KubsCLI.configuration) ⇒ Copy
constructor
A new instance of Copy.
Constructor Details
#initialize(config = KubsCLI.configuration) ⇒ Copy
Returns a new instance of Copy.
10 11 12 13 |
# File 'lib/kubs_cli/copy.rb', line 10 def initialize(config = KubsCLI.configuration) @fh = FileHelper.new @config = config end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
8 9 10 |
# File 'lib/kubs_cli/copy.rb', line 8 def config @config end |
Instance Method Details
#copy_all ⇒ Object
15 16 17 18 |
# File 'lib/kubs_cli/copy.rb', line 15 def copy_all copy_dotfiles copy_gnome_terminal_settings end |
#copy_dotfiles ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/kubs_cli/copy.rb', line 20 def copy_dotfiles Dir.each_child(@config.dotfiles) do |file| config_file = File.join(@config.dotfiles, file) local_file = File.join(@config.local_dir, ".#{file}") @fh.copy(from: config_file, to: local_file) end end |
#copy_gnome_terminal_settings ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/kubs_cli/copy.rb', line 29 def copy_gnome_terminal_settings unless @config.gnome_terminal_settings return end # This is the ONLY spot for gnome terminal gnome_path = '/org/gnome/terminal/' gnome_file = @config.gnome_terminal_settings unless File.exist?(gnome_file) KubsCLI.add_error(e: KubsCLI::Error, msg: "Could not find #{gnome_file}") return end dconf_load = "dconf load #{gnome_path} < #{config.gnome_terminal_settings}" Rake.sh(dconf_load) rescue RuntimeError => e KubsCLI.add_error(e: e, msg: 'Unable to copy gnome settings') end |