Class: Picobox::Shell::StartupScript
- Inherits:
-
Object
- Object
- Picobox::Shell::StartupScript
- Defined in:
- lib/picobox/shell/startup_script.rb
Instance Attribute Summary collapse
-
#os ⇒ Object
readonly
Returns the value of attribute os.
Class Method Summary collapse
Instance Method Summary collapse
- #filename ⇒ Object
-
#initialize(os) ⇒ StartupScript
constructor
A new instance of StartupScript.
- #install_extensions ⇒ Object
- #uninstall_extensions ⇒ Object
Constructor Details
#initialize(os) ⇒ StartupScript
Returns a new instance of StartupScript.
19 20 21 |
# File 'lib/picobox/shell/startup_script.rb', line 19 def initialize(os) @os = os end |
Instance Attribute Details
#os ⇒ Object (readonly)
Returns the value of attribute os.
17 18 19 |
# File 'lib/picobox/shell/startup_script.rb', line 17 def os @os end |
Class Method Details
.get(os) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/picobox/shell/startup_script.rb', line 5 def get(os) case "#{os.user_shell}:#{os.to_s}" when /\/bin\/bash:darwin/, /\/bin\/bash:linux/ Shell::Bash.new(os) when /\/bin\/zsh:darwin/, /\/bin\/zsh:linux/ Shell::Zsh.new(os) else raise Errors::ShellNotSupported, "#{os.user_shell}:#{os.to_s}" end end |
Instance Method Details
#filename ⇒ Object
43 44 45 |
# File 'lib/picobox/shell/startup_script.rb', line 43 def filename raise ::NotImplementedError, 'must have filename' end |
#install_extensions ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/picobox/shell/startup_script.rb', line 23 def install_extensions source = "#{Picobox.extensions_dir}/extensions.bash" dest = os.shell_extensions TTY::File.copy_file source, dest TTY::File.append_to_file( filename, "\n#{extension}\n" ) end |
#uninstall_extensions ⇒ Object
36 37 38 39 40 |
# File 'lib/picobox/shell/startup_script.rb', line 36 def uninstall_extensions TTY::File.gsub_file filename, /#{Regexp.escape(extension)}/ do "# picobox removed #{Time.now}" end end |