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.
25 26 27 28 29 30 31 |
# File 'lib/warp/dir/command/install.rb', line 25 def initialize(*args) self.installed = [] self.existing = [] self.wrapper = File.read(::Warp::Dir::SHELL_WRAPPER) self.shell_init_files = ::Warp::Dir::DOTFILES super(*args) end |
Instance Attribute Details
#existing ⇒ Object
Returns the value of attribute existing.
7 8 9 |
# File 'lib/warp/dir/command/install.rb', line 7 def existing @existing end |
#installed ⇒ Object
Returns the value of attribute installed.
7 8 9 |
# File 'lib/warp/dir/command/install.rb', line 7 def installed @installed end |
#shell_init_files ⇒ Object
Returns the value of attribute shell_init_files.
7 8 9 |
# File 'lib/warp/dir/command/install.rb', line 7 def shell_init_files @shell_init_files end |
#wrapper ⇒ Object
Returns the value of attribute wrapper.
7 8 9 |
# File 'lib/warp/dir/command/install.rb', line 7 def wrapper @wrapper end |
Class Method Details
.already_installed?(file_path) ⇒ Boolean
14 15 16 17 18 19 20 21 22 |
# File 'lib/warp/dir/command/install.rb', line 14 def already_installed?(file_path) path = ::Warp::Dir.absolute(file_path) matches = if File.exists?(path) File.open path do |file| file.find { |line| line =~ /warp-dir/ } end end matches end |
Instance Method Details
#run(*args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/warp/dir/command/install.rb', line 33 def run(*args) self.shell_init_files = config[:dotfile].split(',') if config[:dotfile] self.shell_init_files.any? { |dotfile| append_wrapper_to(dotfile) } 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 |