Module: Ndee
- Defined in:
- lib/ndee.rb,
lib/ndee/version.rb
Constant Summary collapse
- VERSION =
"0.0.3"
Class Method Summary collapse
Class Method Details
.cli! ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ndee.rb', line 31 def self.cli! if name = ARGV.first if document_root = document_roots_by_domain[name] if Dir.exist? document_root puts "cd #{document_root}" else puts "#{document_root} doesn't exist" end else puts "#{name} not found" end else puts 'ndee cds into the DocumentRoot of the given domain.' puts 'Usage: ndee subdomain.example.com' end end |
.document_roots_by_domain ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/ndee.rb', line 5 def self.document_roots_by_domain {}.tap do |mappings| each_domain do |domain, vhost| mappings[domain] = vhost.document_root end end end |
.each_domain ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ndee.rb', line 17 def self.each_domain Dir["#{sites_available}/*.conf"].each do |conf| config = Apache::Config.new(conf) for vhost in config.virtual_hosts next unless vhost.domain for domain in [vhost.domain] + vhost.aliases yield domain, vhost end end end end |
.sites_available ⇒ Object
13 14 15 |
# File 'lib/ndee.rb', line 13 def self.sites_available '/etc/apache2/sites-available' end |