Sha256: e7ce05d8c1acd2a25ec8669d175153e63e402c8cfa0021d2444bc3ebdc56c8f0

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

$:.push File.expand_path(File.dirname(__FILE__))

require 'rexml/document'
require 'app_pool'
require 'ftp_site'
require 'site'

module IISConfig

  class IISConfiguration

    def initialize
      @app_pools = []
      @sites = []
      @ftp_sites = []
    end

    def app_pool(&block)
      add_instance @app_pools, IISConfig::AppPool, block
    end

    def site(&block)
      add_instance @sites, IISConfig::Site, block
    end

    def ftp_site(&block)
      add_instance @ftp_sites, IISConfig::FtpSite, block
    end
    
    def load(path)
      instance_eval IO.read(path), path
    end

    def run
      execute @app_pools
      execute @sites
      execute @ftp_sites
    end

    private

    def execute(objects)
      objects.each do |p|
        commands = p.build_commands
        Runner.run_commands commands

        p.required_paths.each do |path|
          FileUtils.mkdir_p path unless Dir.exist? path
        end
      end
    end

    def add_instance(collection, type, block)
      instance = type.new
      collection << instance
      block.call instance if block
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
iisconfig-0.0.2 lib/iisconfig/configuration.rb
iisconfig-0.0.1 lib/iisconfig/configuration.rb
iisconfig-0.0.1.pre3 lib/iisconfig/configuration.rb
iisconfig-0.0.1.pre2 lib/iisconfig/configuration.rb