Class: Caddy
- Inherits:
-
Object
- Object
- Caddy
- Defined in:
- lib/brisk/caddy.rb
Class Method Summary collapse
- .download ⇒ Object
- .install ⇒ Object
- .install_caddy_daemon ⇒ Object
- .install_caddy_directory ⇒ Object
- .install_caddy_file ⇒ Object
- .is_installed? ⇒ Boolean
- .restart ⇒ Object
- .start ⇒ Object
- .stop ⇒ Object
Class Method Details
.download ⇒ Object
24 25 26 |
# File 'lib/brisk/caddy.rb', line 24 def self.download system "sudo -u #{ENV['SUDO_USER']} brew install caddy" end |
.install ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/brisk/caddy.rb', line 7 def self.install unless is_installed? puts "Installing Caddy for you...".colorize(:green) download end install_caddy_file install_caddy_directory install_caddy_daemon end |
.install_caddy_daemon ⇒ Object
40 41 42 43 44 45 |
# File 'lib/brisk/caddy.rb', line 40 def self.install_caddy_daemon path = FileSystem.get_path("../../stubs/caddy_daemon.plist", __dir__) file = FileSystem.read(path) new_file = file.gsub("BRISK_HOME_PATH", Constants.valet_home) FileSystem.write("/Library/LaunchDaemons/com.frankleef.caddyBriskServer.plist", new_file) end |
.install_caddy_directory ⇒ Object
35 36 37 38 |
# File 'lib/brisk/caddy.rb', line 35 def self.install_caddy_directory FileSystem.create_dir(Constants.valet_home + '/Caddy') FileSystem.create_file(Constants.valet_home + '/Caddy/.keep') end |
.install_caddy_file ⇒ Object
28 29 30 31 32 33 |
# File 'lib/brisk/caddy.rb', line 28 def self.install_caddy_file FileSystem.copy_file(File.("../../stubs/Caddyfile", __dir__), Constants.valet_home + '/Caddyfile') file = FileSystem.read(Constants.valet_home + '/Caddyfile') new_file = file.gsub("BRISK_HOME_PATH", Constants.valet_home) File.write(Constants.valet_home + '/Caddyfile', new_file) end |
.is_installed? ⇒ Boolean
18 19 20 21 22 |
# File 'lib/brisk/caddy.rb', line 18 def self.is_installed? system "brew list | grep caddy >> /dev/null" $? == 0 end |
.restart ⇒ Object
47 48 49 50 51 |
# File 'lib/brisk/caddy.rb', line 47 def self.restart stop start end |
.start ⇒ Object
53 54 55 |
# File 'lib/brisk/caddy.rb', line 53 def self.start system "launchctl load /Library/LaunchDaemons/com.frankleef.caddyBriskServer.plist > /dev/null" end |
.stop ⇒ Object
57 58 59 |
# File 'lib/brisk/caddy.rb', line 57 def self.stop system "launchctl unload /Library/LaunchDaemons/com.frankleef.caddyBriskServer.plist > /dev/null" end |