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.("../", __FILE__)))
Class Method Summary collapse
- .dir ⇒ Object
- .hosts_file ⇒ Object
- .main ⇒ Object
-
.sub_commands ⇒ Object
attr_reader :sub_commands.
Class Method Details
.dir ⇒ Object
26 27 28 |
# File 'lib/hosts.rb', line 26 def self.dir File.dirname(File.(__FILE__)) end |
.hosts_file ⇒ Object
30 31 32 |
# File 'lib/hosts.rb', line 30 def self.hosts_file return "/etc/hosts" end |
.main ⇒ Object
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_commands ⇒ Object
attr_reader :sub_commands
35 36 37 |
# File 'lib/hosts.rb', line 35 def self.sub_commands return @sub_commands end |