Class: Warp::Dir::Command::Install
- Inherits:
-
Warp::Dir::Command
- Object
- Warp::Dir::Command
- Warp::Dir::Command::Install
- Defined in:
- lib/warp/dir/command/install.rb
Instance Attribute Summary collapse
-
#existing ⇒ Object
Returns the value of attribute existing.
-
#installed ⇒ Object
Returns the value of attribute installed.
-
#shell_init_files ⇒ Object
Returns the value of attribute shell_init_files.
-
#wrapper ⇒ Object
Returns the value of attribute wrapper.
Attributes inherited from Warp::Dir::Command
#formatter, #point, #point_name, #point_path, #store
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Install
constructor
A new instance of Install.
- #run(*args) ⇒ Object
Methods inherited from Warp::Dir::Command
command_name, #config, help, inherited, #inspect, installed_commands, #needs_point?, #on, #puts
Constructor Details
#initialize(*args) ⇒ Install
Returns a new instance of Install.
30 31 32 33 34 35 36 |
# File 'lib/warp/dir/command/install.rb', line 30 def initialize(*args) self.installed = [] self.existing = [] self.wrapper = ::Warp::Dir::SHELL_WRAPPER_SRCE self.shell_init_files = ::Warp::Dir::DOTFILES super(*args) end |
Instance Attribute Details
#existing ⇒ Object
Returns the value of attribute existing.
8 9 10 |
# File 'lib/warp/dir/command/install.rb', line 8 def existing @existing end |
#installed ⇒ Object
Returns the value of attribute installed.
8 9 10 |
# File 'lib/warp/dir/command/install.rb', line 8 def installed @installed end |
#shell_init_files ⇒ Object
Returns the value of attribute shell_init_files.
8 9 10 |
# File 'lib/warp/dir/command/install.rb', line 8 def shell_init_files @shell_init_files end |
#wrapper ⇒ Object
Returns the value of attribute wrapper.
8 9 10 |
# File 'lib/warp/dir/command/install.rb', line 8 def wrapper @wrapper end |
Class Method Details
.already_installed?(file_path) ⇒ Boolean
20 21 22 23 24 25 26 27 |
# File 'lib/warp/dir/command/install.rb', line 20 def already_installed?(file_path) path = ::Warp::Dir.absolute(file_path) if File.exist?(path) File.open path do |file| file.find { |line| line =~ ::Warp::Dir::SHELL_WRAPPER_REGX } end end end |
Instance Method Details
#run(*args) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/warp/dir/command/install.rb', line 38 def run(*args) self.shell_init_files = config[:dotfile].split(',') if config[:dotfile] self.shell_init_files.any? { |dotfile| append_wrapper_to(dotfile) } # Overwrites if already there install_bash_wd local_existing = self.existing local_installed = self.installed local_shell_files = self.shell_init_files if installed.empty? if existing.empty? on :error do if local_shell_files.size > 1 then "Shell init files #{local_shell_files.join(', ').yellow.bold} were not found on the filesystem.".red else "Shell init file #{local_shell_files.join(', ').yellow.bold} was not found on the filesystem.".red end end else on :error do 'Looks like you already have shell support installed.'.red "#{local_existing.join(', ').yellow.bold} already warp-dir definition. Use --force to override." end end else on :success do 'Shell support is installed in the following files:'.green.bold "#{local_installed.join(', ')}".bold.yellow end end end |