Class: Caddy
- Inherits:
-
Object
- Object
- Caddy
- Defined in:
- lib/brisk/caddy.rb
Class Attribute Summary collapse
-
.caddy_daemon_path ⇒ Object
Returns the value of attribute caddy_daemon_path.
-
.caddy_path ⇒ Object
Returns the value of attribute caddy_path.
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 Attribute Details
.caddy_daemon_path ⇒ Object
Returns the value of attribute caddy_daemon_path.
11 12 13 |
# File 'lib/brisk/caddy.rb', line 11 def caddy_daemon_path @caddy_daemon_path end |
.caddy_path ⇒ Object
Returns the value of attribute caddy_path.
10 11 12 |
# File 'lib/brisk/caddy.rb', line 10 def caddy_path @caddy_path end |
Class Method Details
.download ⇒ Object
32 33 34 |
# File 'lib/brisk/caddy.rb', line 32 def self.download system "sudo -u #{ENV['SUDO_USER']} brew install caddy" end |
.install ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/brisk/caddy.rb', line 15 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
48 49 50 51 52 53 |
# File 'lib/brisk/caddy.rb', line 48 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(caddy_daemon_path, new_file) end |
.install_caddy_directory ⇒ Object
43 44 45 46 |
# File 'lib/brisk/caddy.rb', line 43 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
36 37 38 39 40 41 |
# File 'lib/brisk/caddy.rb', line 36 def self.install_caddy_file FileSystem.copy_file(caddy_path, 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
26 27 28 29 30 |
# File 'lib/brisk/caddy.rb', line 26 def self.is_installed? system "brew list | grep caddy >> /dev/null" $? == 0 end |
.restart ⇒ Object
55 56 57 58 59 |
# File 'lib/brisk/caddy.rb', line 55 def self.restart stop start end |
.start ⇒ Object
61 62 63 |
# File 'lib/brisk/caddy.rb', line 61 def self.start system "launchctl load /Library/LaunchDaemons/com.frankleef.caddyBriskServer.plist > /dev/null" end |
.stop ⇒ Object
65 66 67 |
# File 'lib/brisk/caddy.rb', line 65 def self.stop system "launchctl unload /Library/LaunchDaemons/com.frankleef.caddyBriskServer.plist > /dev/null" end |