Sha256: 557dea289a1e409459c724c17b9c50bfc6440129909dfe16f0e026ee2bbdfbd0
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
module Yapfac class Apache class Site < Scope attr_reader :config_lines def initialize(site_name) super(site_name) end def self.load(filename) s = Yapfac::Apache::Site.new(File.basename(filename, '.conf')) s.load_file(filename) s.parse! return s end def filename File.join(Yapfac.configuration.apache_path, Yapfac.configuration.sites_available_path, @name + '.conf') end def save File.write(filename, to_s) end def load_file(filename) lines = File.read(filename) lines.gsub!("\\\n", ' ') lines_a = lines.split("\n").map(&:strip) lines_a.reject! { |l| l =~ /^\s*#.*$/ } lines_a.reject! &:nil? lines_a.map { |l| l.gsub! /\s+/, ' ' } @config_lines = lines_a end def parse! scope = self @config_lines.each do |line| # Enter Child Scope if line =~ /^<(\w+)\s*(.*)?>$/ new_scope = Yapfac::Apache::Scope.new($1, $2, scope) scope.add_scope(new_scope) scope = new_scope # Exit Child Scope elsif line =~ /^<\/#{scope.name}>$/ scope = scope.parent # Add Directive elsif line =~ /^(\w+)\s*(.*)$/ directive = Yapfac::Apache::Directive.parse($1, $2) scope.add_directive(directive) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yapfac-0.2.0 | lib/yapfac/apache/site.rb |