Sha256: faaec9444a325d51155785542929e30ec770b6642d16713bd356f8ac1c95397f

Contents?: true

Size: 973 Bytes

Versions: 4

Compression:

Stored size: 973 Bytes

Contents

require 'runner'

module IISConfig

  class IISObject

    def exist?(type, name)
      args = []
      args << 'LIST'
      args << type.to_s.upcase
      args << '/xml'
      result = Runner.execute_command args

      exists = false
      doc = REXML::Document.new(result)

      doc.elements.each("appcmd/#{type.to_s.upcase}[@#{type.to_s.upcase}.NAME='#{name}']") do
        exists = true
        break
      end

      exists
    end

    def start_provider_exist?(name)
      result = Runner.execute_command %W{ LIST CONFIG /section:serviceAutoStartProviders }
      exists = false
      doc = REXML::Document.new(result)

      doc.each_element("//add[@name='#{name}']") do |e|
        exists = true
        break
      end

      exists
    end

    protected

    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.8.0 lib/iisconfig/iis_object.rb
iisconfig-0.7.0 lib/iisconfig/iis_object.rb
iisconfig-0.6.0 lib/iisconfig/iis_object.rb
iisconfig-0.5.0 lib/iisconfig/iis_object.rb