Module: Hosts

Defined in:
lib/hosts.rb,
lib/Hosts/Lib/autoload.rb

Defined Under Namespace

Modules: Lib

Constant Summary collapse

VERSION =
"0.2.0"
LIB_PATH =
File.dirname(File.dirname(File.expand_path("../", __FILE__)))

Class Method Summary collapse

Class Method Details

.dirObject



26
27
28
# File 'lib/hosts.rb', line 26

def self.dir
  File.dirname(File.expand_path(__FILE__))
end

.hosts_fileObject



30
31
32
# File 'lib/hosts.rb', line 30

def self.hosts_file
  return "/etc/hosts"
end

.mainObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/hosts.rb', line 6

def self.main
  @sub_commands = {}
  @sub_commands['add']  = Hosts::Lib::Commands::Add
  @sub_commands['flush']  = Hosts::Lib::Commands::Flush
  @sub_commands['help'] = Hosts::Lib::Commands::Help
  @sub_commands['list']  = Hosts::Lib::Commands::List
  @sub_commands['rm']  = Hosts::Lib::Commands::Rm
  @sub_commands['version']  = Hosts::Lib::Commands::Version

  if ARGV[0] == nil
    Hosts::Lib::Commands::Help.run([]);
  elsif @sub_commands[ARGV[0]].nil?
    puts "'#{ARGV[0]}' is not a sub command. See 'hosts help'"
  else
    sub_cmd_obj = @sub_commands[ARGV[0].downcase]
    ARGV.shift; # Remove subcommand from ARGV, rest is options
    sub_cmd_obj.run(ARGV)
  end
end

.sub_commandsObject

attr_reader :sub_commands



35
36
37
# File 'lib/hosts.rb', line 35

def self.sub_commands
  return @sub_commands
end