Class: Hoof::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/hoof/cli.rb

Instance Method Summary collapse

Instance Method Details

#init(name = nil) ⇒ Object



33
34
35
36
37
# File 'lib/hoof/cli.rb', line 33

def init name = nil
  name ||= File.basename Dir.getwd
  create_link File.expand_path(File.join("~/.hoof", name)), '.'
  append_to_file 'Gemfile', "\ngem 'unicorn'"
end

#restartObject



22
23
24
# File 'lib/hoof/cli.rb', line 22

def restart
  daemon 'restart'
end

#routeObject



45
46
47
48
49
50
# File 'lib/hoof/cli.rb', line 45

def route
  exec <<-E
    sudo iptables -t nat -I OUTPUT --source 0/0 --destination 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports #{Hoof.http_port} &&
    sudo iptables -t nat -I OUTPUT --source 0/0 --destination 127.0.0.1 -p tcp --dport 443 -j REDIRECT --to-ports #{Hoof.https_port}
  E
end

#startObject



12
13
14
# File 'lib/hoof/cli.rb', line 12

def start
  daemon 'start'
end

#statusObject



40
41
42
# File 'lib/hoof/cli.rb', line 40

def status
  control 'status'
end

#stopObject



17
18
19
# File 'lib/hoof/cli.rb', line 17

def stop
  daemon 'stop'
end

#unrouteObject



53
54
55
56
57
58
# File 'lib/hoof/cli.rb', line 53

def unroute
  exec <<-E
    sudo iptables -t nat -D OUTPUT --source 0/0 --destination 127.0.0.1 -p tcp --dport 80 -j REDIRECT --to-ports #{Hoof.http_port} &&
    sudo iptables -t nat -D OUTPUT --source 0/0 --destination 127.0.0.1 -p tcp --dport 443 -j REDIRECT --to-ports #{Hoof.https_port}
  E
end