inetmgr 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. data/Gemfile +2 -0
  2. data/RELEASE-NOTES.rdoc +5 -1
  3. data/inetmgr.gemspec +4 -1
  4. data/lib/inetmgr/configuration.rb +24 -21
  5. data/lib/inetmgr/iis_configuration.rb +18 -8
  6. data/lib/inetmgr/iis_object.rb +6 -3
  7. data/lib/inetmgr/iis_object/application.rb +5 -3
  8. data/lib/inetmgr/iis_object/application_pool.rb +5 -3
  9. data/lib/inetmgr/iis_object/auto_start_provider.rb +3 -1
  10. data/lib/inetmgr/iis_object/binding_information.rb +2 -0
  11. data/lib/inetmgr/iis_object/periodic_restart.rb +6 -3
  12. data/lib/inetmgr/iis_object/process_model.rb +21 -18
  13. data/lib/inetmgr/iis_object/recycling.rb +8 -5
  14. data/lib/inetmgr/iis_object/site.rb +3 -1
  15. data/lib/inetmgr/iis_object/site_limit.rb +10 -7
  16. data/lib/inetmgr/iis_object/site_logfile.rb +4 -1
  17. data/lib/inetmgr/iis_object/virtual_directory.rb +3 -1
  18. data/lib/inetmgr/iis_object_collection.rb +7 -4
  19. data/lib/inetmgr/site_configuration.rb +37 -34
  20. data/lib/string.rb +4 -4
  21. data/spec/application_pool_spec.rb +1 -1
  22. data/spec/bingin_information_spec.rb +21 -21
  23. data/spec/site_app_settings_spec.rb +3 -3
  24. data/spec/site_configuration_spec.rb +1 -1
  25. data/spec/site_connection_strings_spec.rb +1 -1
  26. data/spec/site_spec.rb +16 -4
  27. data/spec/site_validation_settings_spec.rb +1 -1
  28. data/spec/spec_env.rb +1 -5
  29. data/spec/string_spec.rb +16 -16
  30. data/test/print_iis_config.rb +0 -4
  31. metadata +53 -89
  32. data/doc/Application.html +0 -177
  33. data/doc/ApplicationPool.html +0 -177
  34. data/doc/AutoStartProvider.html +0 -177
  35. data/doc/BindingInformation.html +0 -349
  36. data/doc/Configuration.html +0 -283
  37. data/doc/IisConfiguration.html +0 -383
  38. data/doc/IisObject.html +0 -484
  39. data/doc/IisObjectCollection.html +0 -534
  40. data/doc/Inetmgr.html +0 -179
  41. data/doc/Inetmgr/InetmgrTask.html +0 -338
  42. data/doc/Object.html +0 -254
  43. data/doc/PeriodicRestart.html +0 -177
  44. data/doc/ProcessModel.html +0 -192
  45. data/doc/README_rdoc.html +0 -114
  46. data/doc/RSpecExtensions.html +0 -257
  47. data/doc/Recycling.html +0 -177
  48. data/doc/Site.html +0 -228
  49. data/doc/SiteConfiguration.html +0 -269
  50. data/doc/SiteLimit.html +0 -177
  51. data/doc/VirtualDirectory.html +0 -177
  52. data/doc/images/brick.png +0 -0
  53. data/doc/images/brick_link.png +0 -0
  54. data/doc/images/bug.png +0 -0
  55. data/doc/images/bullet_black.png +0 -0
  56. data/doc/images/bullet_toggle_minus.png +0 -0
  57. data/doc/images/bullet_toggle_plus.png +0 -0
  58. data/doc/images/date.png +0 -0
  59. data/doc/images/find.png +0 -0
  60. data/doc/images/loadingAnimation.gif +0 -0
  61. data/doc/images/macFFBgHack.png +0 -0
  62. data/doc/images/package.png +0 -0
  63. data/doc/images/page_green.png +0 -0
  64. data/doc/images/page_white_text.png +0 -0
  65. data/doc/images/page_white_width.png +0 -0
  66. data/doc/images/plugin.png +0 -0
  67. data/doc/images/ruby.png +0 -0
  68. data/doc/images/tag_green.png +0 -0
  69. data/doc/images/wrench.png +0 -0
  70. data/doc/images/wrench_orange.png +0 -0
  71. data/doc/images/zoom.png +0 -0
  72. data/doc/index.html +0 -166
  73. data/doc/js/darkfish.js +0 -116
  74. data/doc/js/jquery.js +0 -32
  75. data/doc/js/quicksearch.js +0 -114
  76. data/doc/js/thickbox-compressed.js +0 -10
  77. data/doc/rdoc.css +0 -706
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
@@ -1,6 +1,10 @@
1
1
  = inetmgr Release Notes
2
2
 
3
- == Latest Version (0.6.0)
3
+ == Latest Version (0.7.0)
4
+
5
+ - Merged changes from Maxim-Filimonov (https://github.com/Maxim-Filimonov/inetmgr) who was so kind to make adding sites safer and namespacing the configuration classes to avoid conflicts with other libraries.
6
+
7
+ == 0.6.0
4
8
 
5
9
  - Merged pull request from Scott Baldwin (https://github.com/scottsbaldwin) who was so kind to add support for configuring site log files.
6
10
 
@@ -4,7 +4,7 @@ require 'rake/gempackagetask'
4
4
  spec = Gem::Specification.new do |s|
5
5
 
6
6
  s.name = "inetmgr"
7
- s.version = "0.6.0"
7
+ s.version = "0.7.0"
8
8
  s.summary = "A library for managing IIS configuration settings."
9
9
  s.description = "inetmgr allows you to inspect/configure IIS configuration sections and elements."
10
10
 
@@ -18,4 +18,7 @@ spec = Gem::Specification.new do |s|
18
18
  s.files = FileList["**/**/*"].to_a
19
19
  s.require_path = "lib"
20
20
 
21
+ s.add_development_dependency 'uuid'
22
+ s.add_development_dependency 'rspec'
23
+
21
24
  end
@@ -1,21 +1,24 @@
1
-
2
- class Configuration
3
-
4
- def initialize(path, server = nil)
5
- @admin_manager = WIN32OLE.new "Microsoft.ApplicationHost.WritableAdminManager", server
6
- @admin_manager.CommitPath = path;
7
- end
8
-
9
- # applies/commits all changes made since the creation of the
10
- # IisConfiguration instance or the last time this method was called.
11
- def apply_changes
12
- @admin_manager.CommitChanges
13
- end
14
-
15
- private
16
-
17
- def get_admin_section(section_name)
18
- @admin_manager.GetAdminSection(section_name, @admin_manager.CommitPath)
19
- end
20
-
21
- end
1
+ module Inetmgr
2
+
3
+ class Configuration
4
+
5
+ def initialize(path, server = nil)
6
+ @admin_manager = WIN32OLE.new "Microsoft.ApplicationHost.WritableAdminManager", server
7
+ @admin_manager.CommitPath = path;
8
+ end
9
+
10
+ # applies/commits all changes made since the creation of the
11
+ # IisConfiguration instance or the last time this method was called.
12
+ def apply_changes
13
+ @admin_manager.CommitChanges
14
+ end
15
+
16
+ private
17
+
18
+ def get_admin_section(section_name)
19
+ @admin_manager.GetAdminSection(section_name, @admin_manager.CommitPath)
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -1,7 +1,8 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'iis_object/site.rb')
2
- require File.join(File.expand_path(File.dirname(__FILE__)), 'iis_object/application_pool.rb')
3
- require File.join(File.expand_path(File.dirname(__FILE__)), 'iis_object/auto_start_provider.rb')
1
+ require 'inetmgr/iis_object/site.rb'
2
+ require 'inetmgr/iis_object/application_pool.rb'
3
+ require 'inetmgr/iis_object/auto_start_provider.rb'
4
4
 
5
+ module Inetmgr
5
6
  # Represents the local IIS configuration settings (meta base).
6
7
  class IisConfiguration < Configuration
7
8
 
@@ -14,11 +15,17 @@ class IisConfiguration < Configuration
14
15
  yield cfg
15
16
  cfg.apply_changes
16
17
  end
17
-
18
- # Gets all configured web sites.
18
+
19
+ def generate_id(collection)
20
+ count = collection.Count
21
+ arr = (0...count).map {|index| collection.Item(index).Properties.Item('Id').Value }
22
+ (arr.max) ? (arr.max + 1) : 1
23
+ end
24
+
25
+ # Gets all configured web sites.
19
26
  def get_sites
20
- s = get_admin_section "system.applicationHost/sites"
21
- IisObjectCollection.new s.Collection, :site, Site, lambda { |site| site.id = s.Collection.Count + 1 }
27
+ s = get_admin_section "system.applicationHost/sites"
28
+ IisObjectCollection.new s.Collection, :site, Site, lambda { |site| site.id = generate_id(s.Collection) }
22
29
  end
23
30
 
24
31
  # Gets all configure application pools.
@@ -33,4 +40,7 @@ class IisConfiguration < Configuration
33
40
  IisObjectCollection.new s.Collection, :add, AutoStartProvider
34
41
  end
35
42
 
36
- end
43
+ end
44
+ end
45
+
46
+ IisConfiguration = Inetmgr::IisConfiguration
@@ -1,4 +1,5 @@
1
- # Represents an IIS configuration element. Serves as the base class for all
1
+ module Inetmgr
2
+ # Represents an IIS configuration element. Serves as the base class for all
2
3
  # IIS artifacts like Site, Application and VirtualDirectory.
3
4
  class IisObject
4
5
 
@@ -57,7 +58,7 @@ class IisObject
57
58
 
58
59
  def invoke_method name
59
60
  method = @element.Methods.Item(name.to_s).CreateInstance()
60
-
61
+
61
62
  # TODO: if block_given? change method_missing to change this:
62
63
  # method.Input.Properties.Item("key").Value = value
63
64
  # in to this:
@@ -72,7 +73,7 @@ private
72
73
  def method_missing(symbol, *args)
73
74
  name = symbol.to_s.to_camel_case
74
75
  if (/=$/.match(name))
75
-
76
+
76
77
  @element.Properties.Item(name.sub(/=$/, '')).Value = args[0]
77
78
  else
78
79
  @element.Properties.Item(name).Value
@@ -83,3 +84,5 @@ private
83
84
 
84
85
  end
85
86
 
87
+
88
+ end
@@ -1,11 +1,13 @@
1
1
  require File.join(File.expand_path(File.dirname(__FILE__)), 'virtual_directory.rb')
2
2
 
3
- class Application < IisObject
3
+ module Inetmgr
4
+ class Application < IisObject
4
5
 
5
6
  prop :auto_start, "serviceAutoStartEnabled"
6
7
  prop :auto_start_provider, "serviceAutoStartProvider"
7
8
  prop :application_pool, :applicationPool
8
-
9
+
9
10
  collection :virtual_directories, :virtualDirectory, VirtualDirectory
10
-
11
+
12
+ end
11
13
  end
@@ -1,7 +1,8 @@
1
1
  require File.join(File.expand_path(File.dirname(__FILE__)), 'process_model.rb')
2
2
  require File.join(File.expand_path(File.dirname(__FILE__)), 'recycling.rb')
3
3
 
4
- class ApplicationPool < IisObject
4
+ module Inetmgr
5
+ class ApplicationPool < IisObject
5
6
 
6
7
  # prop :managed_runtime_version, :managedRuntimeVersion
7
8
  # prop :pass_anonymous_token, :passAnonymousToken
@@ -12,9 +13,10 @@ class ApplicationPool < IisObject
12
13
  prop :classic_pipeline, :managedPipelineMode, lambda { |a| a == true ? 1 : 0 }, lambda {|value| value.to_i == 1 }
13
14
  prop :enable_32bit, :enable32BitAppOnWin64
14
15
  prop :always_running, :startMode, lambda { |a| a == true ? "AlwaysRunning" : "OnDemand" },lambda {|value| value.to_i == 1 }
15
-
16
+
16
17
  child :process_model, :processModel, ProcessModel
17
- child :recycling, :recycling, Recycling
18
+ child :recycling, :recycling, Recycling
18
19
 
19
20
  end
20
21
 
22
+ end
@@ -1,3 +1,5 @@
1
- class AutoStartProvider < IisObject
1
+ module Inetmgr
2
+ class AutoStartProvider < IisObject
2
3
 
4
+ end
3
5
  end
@@ -1,3 +1,4 @@
1
+ module Inetmgr
1
2
 
2
3
  class BindingInformation < IisObject
3
4
 
@@ -23,4 +24,5 @@ class BindingInformation < IisObject
23
24
  def disable_ds_mapper
24
25
  invoke_method("DisableDsMapper")
25
26
  end
27
+ end
26
28
  end
@@ -1,3 +1,6 @@
1
- class PeriodicRestart < IisObject
2
- children :schedule, :schedule, IisObject
3
- end
1
+ module Inetmgr
2
+ class PeriodicRestart < IisObject
3
+ children :schedule, :schedule, IisObject
4
+ end
5
+
6
+ end
@@ -1,18 +1,21 @@
1
- # Specifies security, performance, health, and reliability features of application pools.
2
- class ProcessModel < IisObject
3
-
4
- Identity_type_map = [:system, :local_service, :network_service, :specific_user, :application_pool_identity]
5
-
6
- ##
7
- # Specifies the logon type for the process identity.
8
- # - :batch indicates that the application pool identity should logon as a batch user.
9
- # - :service indicates that the application pool identity should logon as a service.
10
-
11
- prop :logon_type, :logonType, lambda {|value| value == :batch ? 0 : 1 }, lambda { |a| a == 0 ? :batch : :service }
12
-
13
- prop :identity_type, :identityType, lambda {|value| Identity_type_map.index(value)}, lambda { |a| Identity_type_map[a] }
14
- prop :user_name, :userName
15
- #prop :password
16
- prop :load_user_profile, :loadUserProfile
17
-
18
- end
1
+ module Inetmgr
2
+ # Specifies security, performance, health, and reliability features of application pools.
3
+ class ProcessModel < IisObject
4
+
5
+ Identity_type_map = [:system, :local_service, :network_service, :specific_user, :application_pool_identity]
6
+
7
+ ##
8
+ # Specifies the logon type for the process identity.
9
+ # - :batch indicates that the application pool identity should logon as a batch user.
10
+ # - :service indicates that the application pool identity should logon as a service.
11
+
12
+ prop :logon_type, :logonType, lambda {|value| value == :batch ? 0 : 1 }, lambda { |a| a == 0 ? :batch : :service }
13
+
14
+ prop :identity_type, :identityType, lambda {|value| Identity_type_map.index(value)}, lambda { |a| Identity_type_map[a] }
15
+ prop :user_name, :userName
16
+ #prop :password
17
+ prop :load_user_profile, :loadUserProfile
18
+
19
+ end
20
+
21
+ end
@@ -1,5 +1,8 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), 'periodic_restart.rb')
2
-
3
- class Recycling < IisObject
4
- child :periodic_restart, :periodicRestart, PeriodicRestart
5
- end
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'periodic_restart.rb')
2
+
3
+ module Inetmgr
4
+ class Recycling < IisObject
5
+ child :periodic_restart, :periodicRestart, PeriodicRestart
6
+ end
7
+
8
+ end
@@ -3,7 +3,8 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'site_logfile.rb')
3
3
  require File.join(File.expand_path(File.dirname(__FILE__)), 'binding_information.rb')
4
4
  require File.join(File.expand_path(File.dirname(__FILE__)), 'application.rb')
5
5
 
6
- class Site < IisObject
6
+ module Inetmgr
7
+ class Site < IisObject
7
8
 
8
9
  # name
9
10
  # id
@@ -25,3 +26,4 @@ class Site < IisObject
25
26
  end
26
27
 
27
28
  end
29
+ end
@@ -1,7 +1,10 @@
1
- class SiteLimit < IisObject
2
-
3
- prop :max_bandwidth, :maxBandwidth
4
- prop :max_connections, :maxConnections
5
- prop :connection_timeout, :connectionTimeout
6
-
7
- end
1
+ module Inetmgr
2
+ class SiteLimit < IisObject
3
+
4
+ prop :max_bandwidth, :maxBandwidth
5
+ prop :max_connections, :maxConnections
6
+ prop :connection_timeout, :connectionTimeout
7
+
8
+ end
9
+
10
+ end
@@ -1,4 +1,5 @@
1
- class SiteLogFile < IisObject
1
+ module Inetmgr
2
+ class SiteLogFile < IisObject
2
3
 
3
4
  prop :directory, :directory
4
5
  prop :log_ext_file_flags, :logExtFileFlags
@@ -6,3 +7,5 @@ class SiteLogFile < IisObject
6
7
  prop :period, :period
7
8
 
8
9
  end
10
+
11
+ end
@@ -1,5 +1,7 @@
1
- class VirtualDirectory < IisObject
1
+ module Inetmgr
2
+ class VirtualDirectory < IisObject
2
3
 
3
4
  prop :path, "path"
4
5
  prop :physical_path, :physicalPath
6
+ end
5
7
  end
@@ -1,6 +1,8 @@
1
+ module Inetmgr
2
+
1
3
  # Represents a collection of IIS configuration objects.
2
4
  class IisObjectCollection
3
-
5
+ include Enumerable
4
6
  def initialize element, item_name, type, add_callback = nil
5
7
  @collection_element = element
6
8
  @item_name = item_name
@@ -15,7 +17,7 @@ class IisObjectCollection
15
17
  def count
16
18
  size
17
19
  end
18
-
20
+
19
21
  def [](index)
20
22
  return @type.new @collection_element.Item index
21
23
  end
@@ -33,14 +35,14 @@ class IisObjectCollection
33
35
  added
34
36
  end
35
37
 
36
- def find
38
+ def find
37
39
  size.times do |i|
38
40
  instance = self[i]
39
41
  return instance if yield(instance)
40
42
  end
41
43
  nil
42
44
  end
43
-
45
+
44
46
  def exists(name)
45
47
  !(find {|s| s.name == name}).nil?
46
48
  end
@@ -48,4 +50,5 @@ class IisObjectCollection
48
50
  def remove(index)
49
51
  @collection_element.DeleteElement index
50
52
  end
53
+ end
51
54
  end
@@ -1,34 +1,37 @@
1
-
2
- class SiteConfiguration < Configuration
3
-
4
- def initialize(name, server = nil)
5
- super "MACHINE/WEBROOT/APPHOST/#{name}", server
6
- end
7
-
8
- def get_app_settings
9
- get_collection "appSettings"
10
- end
11
-
12
- def get_connection_strings
13
- get_collection "connectionStrings"
14
- end
15
-
16
- def get_validation_settings
17
- IisObject.new get_admin_section("system.webServer/validation")
18
- end
19
-
20
- def get_static_content_settings
21
- IisObject.new get_admin_section("system.webServer/staticContent")
22
- end
23
-
24
- def get_service_model_settings
25
- IisObject.new get_admin_section("system.serviceModel")
26
- end
27
-
28
- private
29
-
30
- def get_collection(name)
31
- IisObjectCollection.new get_admin_section(name).Collection, :add, IisObject
32
- end
33
-
34
- end
1
+ module Inetmgr
2
+
3
+ class SiteConfiguration < Configuration
4
+
5
+ def initialize(name, server = nil)
6
+ super "MACHINE/WEBROOT/APPHOST/#{name}", server
7
+ end
8
+
9
+ def get_app_settings
10
+ get_collection "appSettings"
11
+ end
12
+
13
+ def get_connection_strings
14
+ get_collection "connectionStrings"
15
+ end
16
+
17
+ def get_validation_settings
18
+ IisObject.new get_admin_section("system.webServer/validation")
19
+ end
20
+
21
+ def get_static_content_settings
22
+ IisObject.new get_admin_section("system.webServer/staticContent")
23
+ end
24
+
25
+ def get_service_model_settings
26
+ IisObject.new get_admin_section("system.serviceModel")
27
+ end
28
+
29
+ private
30
+
31
+ def get_collection(name)
32
+ IisObjectCollection.new get_admin_section(name).Collection, :add, IisObject
33
+ end
34
+
35
+ end
36
+
37
+ end