lib/localdev.rb in localdev-0.3.0 vs lib/localdev.rb in localdev-0.3.1
- old
+ new
@@ -18,29 +18,29 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
require 'digest/md5'
class Localdev
- VERSION = '0.3.0'
+ VERSION = '0.3.1'
def initialize
@debug = false
@localdev = '/etc/hosts-localdev'
@hosts = '/etc/hosts'
@start = '#==LOCALDEV==#'
@end = '#/==LOCALDEV==#'
- if !ARGV.first.nil? && [:on, :off, :add, :remove].include?( ARGV.first.to_sym )
+ if !ARGV.first.nil? && [:on, :off, :add, :remove, :list].include?( ARGV.first.to_sym )
require_sudo
ensure_localdev_exists
end
command = ARGV.shift
command = command.to_sym unless command.nil?
object = ARGV.shift
case command
when :"--v", :"--version"
info
- when :on, :off, :status
+ when :on, :off, :status, :list
send command
when :add, :remove
require_sudo
object.nil? && exit_error_message("'localdev #{command}' requires you to provide a domain")
ensure_localdev_exists
@@ -157,11 +157,10 @@
puts "Removed '#{domain}'"
status
end
def get_status
- # do magic
status = :off
return status unless File.readable? @hosts
File.open( @hosts, 'r' ) do |file|
while line = file.gets
if line.include? @start
@@ -169,9 +168,15 @@
break
end
end
end
return status
+ end
+
+ def list
+ File.open( @localdev, 'r' ) do |file|
+ puts file.read
+ end
end
def status
puts "Localdev is #{get_status}"
end