Module: Canals::Tools::Completion
- Extended by:
- Completion
- Includes:
- FileUtils
- Included in:
- Completion
- Defined in:
- lib/canals/tools/completion.rb
Instance Method Summary collapse
- #cmp_file ⇒ Object
- #completion_installed? ⇒ Boolean
- #config_path ⇒ Object
- #install_completion ⇒ Object
- #update_completion ⇒ Object
- #update_config ⇒ Object
Instance Method Details
#cmp_file ⇒ Object
15 16 17 |
# File 'lib/canals/tools/completion.rb', line 15 def cmp_file File.('canals.sh', config_path) end |
#completion_installed? ⇒ Boolean
40 41 42 43 44 45 |
# File 'lib/canals/tools/completion.rb', line 40 def completion_installed? source = "source " << cmp_file rcfile = File.('.bashrc', ENV['HOME']) return false unless File.read(rcfile).include? source true end |
#config_path ⇒ Object
11 12 13 |
# File 'lib/canals/tools/completion.rb', line 11 def config_path File.(".canals", ENV['HOME']) end |
#install_completion ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/canals/tools/completion.rb', line 19 def install_completion update_completion source = "source " << cmp_file rcfile = File.('.bashrc', ENV['HOME']) return false if File.read(rcfile).include? source File.open(rcfile, 'a') { |f| f.puts("", "# added by canals gem", "[ -f #{cmp_file} ] && #{source}") } true end |
#update_completion ⇒ Object
29 30 31 32 33 |
# File 'lib/canals/tools/completion.rb', line 29 def update_completion mkdir_p(config_path) cp(Assets['canals.sh'], cmp_file) update_config end |