Class: Dotstrap::Shell
- Inherits:
-
Object
- Object
- Dotstrap::Shell
- Defined in:
- lib/dotstrap/shell.rb
Instance Attribute Summary collapse
-
#repo_path ⇒ Object
TODO: cleanup shell class & split it into 3+ classes with inheritence.
Instance Method Summary collapse
- #config_file(sh, dir = Dotstrap.config_home) ⇒ Object
- #configure(repo_dir = @repo_path) ⇒ Object
- #configure_bash(repo_dir) ⇒ Object
- #configure_fish(repo_dir) ⇒ Object
- #configure_zsh(repo_dir) ⇒ Object
-
#initialize(repo_path) ⇒ Shell
constructor
TODO: how to handle load order? ie.
- #rm_config_file(file) ⇒ Object
- #unconfigure(repo_dir = @repo_path) ⇒ Object
- #unconfigure_bash(repo_dir) ⇒ Object
- #unconfigure_fish(repo_dir) ⇒ Object
- #unconfigure_zsh(repo_dir) ⇒ Object
Constructor Details
#initialize(repo_path) ⇒ Shell
TODO: how to handle load order? ie. load path.fish first
9 10 11 |
# File 'lib/dotstrap/shell.rb', line 9 def initialize(repo_path) @repo_path = repo_path end |
Instance Attribute Details
#repo_path ⇒ Object
TODO: cleanup shell class & split it into 3+ classes with inheritence
6 7 8 |
# File 'lib/dotstrap/shell.rb', line 6 def repo_path @repo_path end |
Instance Method Details
#config_file(sh, dir = Dotstrap.config_home) ⇒ Object
79 80 81 |
# File 'lib/dotstrap/shell.rb', line 79 def config_file(sh, dir = Dotstrap.config_home) File.join(dir, "config.#{sh}") end |
#configure(repo_dir = @repo_path) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/dotstrap/shell.rb', line 13 def configure(repo_dir = @repo_path) configure_fish(repo_dir) if should_configure_fish? configure_zsh(repo_dir) configure_bash(repo_dir) $LOG.unknown { "configuration complete" } end |
#configure_bash(repo_dir) ⇒ Object
67 68 69 |
# File 'lib/dotstrap/shell.rb', line 67 def configure_bash(repo_dir) write_config_file(bash_configs(repo_dir), config_file('bash')) end |
#configure_fish(repo_dir) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dotstrap/shell.rb', line 29 def configure_fish(repo_dir) fish_functions(repo_dir).each do |f| link_config_file(f, File.join(Dotstrap.shell_config_home('fish'), 'functions')) end fish_completions(repo_dir).each do |f| link_config_file(f, File.join(Dotstrap.shell_config_home('fish'), 'completions')) end write_config_file(fish_configs(repo_dir), config_file('fish')) end |
#configure_zsh(repo_dir) ⇒ Object
59 60 61 |
# File 'lib/dotstrap/shell.rb', line 59 def configure_zsh(repo_dir) write_config_file(zsh_configs(repo_dir), config_file('zsh')) end |
#rm_config_file(file) ⇒ Object
75 76 77 |
# File 'lib/dotstrap/shell.rb', line 75 def rm_config_file(file) FileUtils.rm_rf file end |
#unconfigure(repo_dir = @repo_path) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/dotstrap/shell.rb', line 20 def unconfigure(repo_dir = @repo_path) return unless Dir.exist?(repo_dir) unconfigure_fish(repo_dir) if should_configure_fish? unconfigure_zsh(repo_dir) unconfigure_bash(repo_dir) FileUtils.rm_r(repo_dir, force: true, secure: true) $LOG.unknown { "removed: #{repo_dir}\n" } end |
#unconfigure_bash(repo_dir) ⇒ Object
71 72 73 |
# File 'lib/dotstrap/shell.rb', line 71 def unconfigure_bash(repo_dir) unwrite_config_file(bash_configs(repo_dir), config_file('bash')) end |
#unconfigure_fish(repo_dir) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dotstrap/shell.rb', line 43 def unconfigure_fish(repo_dir) fish_functions(repo_dir).each do |f| file = File.join(Dotstrap.shell_config_home('fish'), 'functions', File.basename(f)) rm_config_file(file) end fish_completions(repo_dir).each do |f| file = File.join(Dotstrap.shell_config_home('fish'), 'completions', File.basename(f)) rm_config_file(file) end unwrite_config_file(fish_configs(repo_dir), config_file('fish')) end |
#unconfigure_zsh(repo_dir) ⇒ Object
63 64 65 |
# File 'lib/dotstrap/shell.rb', line 63 def unconfigure_zsh(repo_dir) unwrite_config_file(zsh_configs(repo_dir), config_file('zsh')) end |