Class: DotfilesInstaller::Runner
- Inherits:
-
Object
- Object
- DotfilesInstaller::Runner
- Includes:
- Actions
- Defined in:
- lib/dotfiles_installer/runner.rb
Instance Attribute Summary collapse
-
#output_io ⇒ Object
readonly
Returns the value of attribute output_io.
Instance Method Summary collapse
-
#initialize(output_io, options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #install(source_map, &block) ⇒ Object
- #uninstall(source_map) ⇒ Object
Methods included from Actions
#create, #generate, #link, #makedir, #remove, #remove_dir_if_empty, #remove_path, #replace
Constructor Details
#initialize(output_io, options = {}) ⇒ Runner
Returns a new instance of Runner.
13 14 15 16 |
# File 'lib/dotfiles_installer/runner.rb', line 13 def initialize(output_io, ={}) @output_io = output_io @options = end |
Instance Attribute Details
#output_io ⇒ Object (readonly)
Returns the value of attribute output_io.
11 12 13 |
# File 'lib/dotfiles_installer/runner.rb', line 11 def output_io @output_io end |
Instance Method Details
#install(source_map, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dotfiles_installer/runner.rb', line 18 def install(source_map, &block) replace_all = false source_map.each do |source_path, home_path| if !File.exist? self.ep(home_path) self.execute(self.create(source_path, home_path)) next end if File.identical? self.ep(source_path), self.ep(home_path) self.out "identical #{home_path}" elsif replace_all self.execute(self.replace(home_path, source_path)) else case (block_given? ? yield("overwrite #{home_path}?", "[ynaq]") : "") when 'a' replace_all = true self.execute(self.replace(home_path, source_path)) when 'y' self.execute(self.replace(home_path, source_path)) when 'q' exit else self.out "skipping #{home_path}" end end end end |
#uninstall(source_map) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/dotfiles_installer/runner.rb', line 48 def uninstall(source_map) remove_all = false source_map.each do |source_path, home_path| if !File.exist? self.ep(home_path) next end if remove_all self.execute(self.remove(home_path)) else case (block_given? ? yield("remove #{home_path}?", "[ynaq]") : "") when 'a' remove_all = true self.execute(self.remove(home_path)) when 'y' self.execute(self.remove(home_path)) when 'q' exit else self.out "skipping #{home_path}" end end end end |