lib/inetmgr/iis_configuration.rb in inetmgr-0.6.0 vs lib/inetmgr/iis_configuration.rb in inetmgr-0.7.0

- old
+ new

@@ -1,9 +1,10 @@ -require File.join(File.expand_path(File.dirname(__FILE__)), 'iis_object/site.rb') -require File.join(File.expand_path(File.dirname(__FILE__)), 'iis_object/application_pool.rb') -require File.join(File.expand_path(File.dirname(__FILE__)), 'iis_object/auto_start_provider.rb') +require 'inetmgr/iis_object/site.rb' +require 'inetmgr/iis_object/application_pool.rb' +require 'inetmgr/iis_object/auto_start_provider.rb' +module Inetmgr # Represents the local IIS configuration settings (meta base). class IisConfiguration < Configuration def initialize(server = nil) super "MACHINE/WEBROOT/APPHOST", server @@ -12,15 +13,21 @@ def self.configure cfg = IisConfiguration.new yield cfg cfg.apply_changes end - - # Gets all configured web sites. + + def generate_id(collection) + count = collection.Count + arr = (0...count).map {|index| collection.Item(index).Properties.Item('Id').Value } + (arr.max) ? (arr.max + 1) : 1 + end + + # Gets all configured web sites. def get_sites - s = get_admin_section "system.applicationHost/sites" - IisObjectCollection.new s.Collection, :site, Site, lambda { |site| site.id = s.Collection.Count + 1 } + s = get_admin_section "system.applicationHost/sites" + IisObjectCollection.new s.Collection, :site, Site, lambda { |site| site.id = generate_id(s.Collection) } end # Gets all configure application pools. def get_application_pools s = get_admin_section "system.applicationHost/applicationPools" @@ -31,6 +38,9 @@ def get_auto_start_providers s = get_admin_section "system.applicationHost/serviceAutoStartProviders" IisObjectCollection.new s.Collection, :add, AutoStartProvider end -end \ No newline at end of file +end +end + +IisConfiguration = Inetmgr::IisConfiguration