iisconfig 0.4.1 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 703bfb6ef00a88092ce6d6a1e176bab76d5be753
4
- data.tar.gz: 79b95a6cb3423fccd3a9fd7d2137def96f489ca6
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MWZiOWYzMTVmYTg4Y2Q0ZGE2OWJmZTAwZjAxNjJlNTBmMmFjNjk1NA==
5
+ data.tar.gz: !binary |-
6
+ M2YyZDEyZDE1ODcxZjNmMWM5ODA3ZDJmMjZmZmFjZWI0MmMzMDIyZA==
5
7
  SHA512:
6
- metadata.gz: 5504bd937abfe1b4fc9b8c34feb333c06b496e96e53ebf1a7cdee0517682d512d377478d0c7deaaade9ce70a3b3cb6404e9893b67bb8b95016ea780c52232417
7
- data.tar.gz: 72c9dd60c8771f7a653e1dd9b8d964296fb40081e9b75b5244aabcf1c7055f396122d59d2d7412d0649a86a3416c446371848ba0ba793d2dd1c42e15e61f71a6
8
+ metadata.gz: !binary |-
9
+ NWY0ZGY4MDExZWFkNjYyOTMzMDhlZDE1OTNiNjE5NGYzOWViYTg5MmNjYTI4
10
+ NmM3N2I5ZWJkMmYyZTQxZTUwMTkwZGQwNTkyNjBiZTlkMzg2M2Y1NWU3YTNi
11
+ MDczMzcxNGEwZGUxZDUzMjliNTBmNzc3MzFhMzhhMzc2MTZmODA=
12
+ data.tar.gz: !binary |-
13
+ ZWIzN2NhYjc5N2I0NTg2YWQ3NzdkMmU2MzA2MGM2ZTIyMDk4YTE3NmY5YWJi
14
+ ZGU3YzFmYjUxZTcwZjVkYjYyZmJhNjM5OTJmYjNhOGM4ODg2YjdhMzc2MGNm
15
+ MTFjZGMwMGJhMTAzYjdkNDQ1MGMyNTEwOWQ3YmE2ZGQ2NDU0ZDU=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.5.0
data/bin/iisconfig CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env ruby
2
- $:.push File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
3
-
4
- require "rainbow"
5
- require "iisconfig"
6
-
7
- # Invoke the command
1
+ #!/usr/bin/env ruby
2
+ $:.push File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
3
+
4
+ require "rainbow"
5
+ require "iisconfig"
6
+
7
+ # Invoke the command
8
8
  exit GLI.run(ARGV)
@@ -1,119 +1,119 @@
1
- require 'site'
2
- require 'ftp_site'
3
- require 'iis_object'
4
- require 'process_model'
5
-
6
- module IISConfig
7
-
8
- class AppPool < IISObject
9
-
10
- def initialize
11
- @pipeline_mode = :Classic
12
- @runtime_version = :'v2.0'
13
- @sites = []
14
- @ftp_sites = []
15
- @process_model = ProcessModel.new
16
- @enable_32bit_app_on_win64 = false
17
- end
18
-
19
- def name(name = nil)
20
- @name = name unless name.nil?
21
- @name
22
- end
23
-
24
- def runtime_version(version = nil)
25
- @runtime_version = version unless version.nil?
26
- @runtime_version
27
- end
28
-
29
- def pipeline_mode(mode = nil)
30
- @pipeline_mode = mode unless mode.nil?
31
- @pipeline_mode
32
- end
33
-
34
- def enable_32bit_app_on_win64(value = true)
35
- @enable_32bit_app_on_win64 = value
36
- end
37
-
38
- def start_mode(value)
39
- @start_mode = value
40
- @start_mode
41
- end
42
-
43
- def process_model
44
- yield @process_model
45
- end
46
-
47
- def site(&block)
48
- add_instance(@sites, IISConfig::Site, block)
49
- end
50
-
51
- def ftp_site(&block)
52
- add_instance(@ftp_sites, IISConfig::FtpSite, block)
53
- end
54
-
55
- def sites
56
- @sites
57
- end
58
-
59
- def delete
60
- %W{DELETE APPPOOL #{@name}}
61
- end
62
-
63
- def add
64
- args = []
65
- args << 'ADD'
66
- args << 'APPPOOL'
67
- args << "/name:#{@name}"
68
- args << "/managedRuntimeVersion:#{@runtime_version}"
69
- args << "/managedPipelineMode:#{pipeline_mode}"
70
- if @start_mode
71
- args << "/startMode:#{@start_mode}"
72
- end
73
- args
74
- end
75
-
76
- def required_paths
77
- paths = []
78
- @sites.each do |s|
79
- paths += s.required_paths
80
- end
81
- paths
82
- end
83
-
84
- def recycle
85
- args = []
86
- if exist? :apppool, @name
87
- args << 'RECYCLE'
88
- args << 'APPPOOL'
89
- args << "/apppool.name:#{@name}"
90
- end
91
- args
92
- end
93
-
94
- def build_commands
95
- commands = []
96
-
97
- commands << delete if exist? :apppool, @name
98
- commands << add
99
- @process_model.settings.each_pair do |key, value|
100
- commands << %W{SET CONFIG /section:applicationPools /[name='#{@name}'].processModel.#{key}:#{value}}
101
- end
102
- commands << %W{SET APPPOOL /apppool.name:#{@name} /enable32BitAppOnWin64:#{@enable_32bit_app_on_win64}}
103
-
104
- @sites.each do |s|
105
- s.app_pool @name.to_sym
106
- commands += s.build_commands
107
- end
108
-
109
- @ftp_sites.each do |s|
110
- s.app_pool @name.to_sym
111
- commands += s.build_commands
112
- end
113
-
114
- commands
115
- end
116
-
117
- end
118
-
1
+ require 'site'
2
+ require 'ftp_site'
3
+ require 'iis_object'
4
+ require 'process_model'
5
+
6
+ module IISConfig
7
+
8
+ class AppPool < IISObject
9
+
10
+ def initialize
11
+ @pipeline_mode = :Classic
12
+ @runtime_version = :'v2.0'
13
+ @sites = []
14
+ @ftp_sites = []
15
+ @process_model = ProcessModel.new
16
+ @enable_32bit_app_on_win64 = false
17
+ end
18
+
19
+ def name(name = nil)
20
+ @name = name unless name.nil?
21
+ @name
22
+ end
23
+
24
+ def runtime_version(version = nil)
25
+ @runtime_version = version unless version.nil?
26
+ @runtime_version
27
+ end
28
+
29
+ def pipeline_mode(mode = nil)
30
+ @pipeline_mode = mode unless mode.nil?
31
+ @pipeline_mode
32
+ end
33
+
34
+ def enable_32bit_app_on_win64(value = true)
35
+ @enable_32bit_app_on_win64 = value
36
+ end
37
+
38
+ def start_mode(value)
39
+ @start_mode = value
40
+ @start_mode
41
+ end
42
+
43
+ def process_model
44
+ yield @process_model
45
+ end
46
+
47
+ def site(&block)
48
+ add_instance(@sites, IISConfig::Site, block)
49
+ end
50
+
51
+ def ftp_site(&block)
52
+ add_instance(@ftp_sites, IISConfig::FtpSite, block)
53
+ end
54
+
55
+ def sites
56
+ @sites
57
+ end
58
+
59
+ def delete
60
+ %W{DELETE APPPOOL #{@name}}
61
+ end
62
+
63
+ def add
64
+ args = []
65
+ args << 'ADD'
66
+ args << 'APPPOOL'
67
+ args << "/name:#{@name}"
68
+ args << "/managedRuntimeVersion:#{@runtime_version}"
69
+ args << "/managedPipelineMode:#{pipeline_mode}"
70
+ if @start_mode
71
+ args << "/startMode:#{@start_mode}"
72
+ end
73
+ args
74
+ end
75
+
76
+ def required_paths
77
+ paths = []
78
+ @sites.each do |s|
79
+ paths += s.required_paths
80
+ end
81
+ paths
82
+ end
83
+
84
+ def recycle
85
+ args = []
86
+ if exist? :apppool, @name
87
+ args << 'RECYCLE'
88
+ args << 'APPPOOL'
89
+ args << "/apppool.name:#{@name}"
90
+ end
91
+ args
92
+ end
93
+
94
+ def build_commands
95
+ commands = []
96
+
97
+ commands << delete if exist? :apppool, @name
98
+ commands << add
99
+ @process_model.settings.each_pair do |key, value|
100
+ commands << %W{SET CONFIG /section:applicationPools /[name='#{@name}'].processModel.#{key}:#{value}}
101
+ end
102
+ commands << %W{SET APPPOOL /apppool.name:#{@name} /enable32BitAppOnWin64:#{@enable_32bit_app_on_win64}}
103
+
104
+ @sites.each do |s|
105
+ s.app_pool @name.to_sym
106
+ commands += s.build_commands
107
+ end
108
+
109
+ @ftp_sites.each do |s|
110
+ s.app_pool @name.to_sym
111
+ commands += s.build_commands
112
+ end
113
+
114
+ commands
115
+ end
116
+
117
+ end
118
+
119
119
  end
@@ -1,47 +1,58 @@
1
- require 'iis_object'
2
- require 'virtual_directory'
3
-
4
- module IISConfig
5
-
6
- class Application < IISObject
7
-
8
- def name(name)
9
- @name = name
10
- @virtual_directories = []
11
- @app_pool = nil
12
- end
13
-
14
- def path(path)
15
- @path = path
16
- end
17
-
18
- def physical_path(path)
19
- @physical_path = path
20
- end
21
-
22
- def app_pool(name)
23
- @app_pool = name
24
- end
25
-
26
- def virtual_directory(&block)
27
- add_instance(@virtual_directories, IISConfig::VirtualDirectory, block)
28
- end
29
-
30
- def build_commands(site, app_pool)
31
- commands = []
32
-
33
- commands << %W{ADD APP /site.name:#{site} /path:#{@path} /physicalPath:#{@physical_path.gsub(/\//, '\\')}}
34
-
35
- app_pool = @app_pool unless @app_pool.nil?
36
- commands << %W{SET SITE /site.name:#{site}/#{@name} /[path='#{@path}'].applicationPool:#{app_pool}}
37
-
38
- @virtual_directories.each do |s|
39
- commands += s.build_commands "#{site}/#{@name}"
40
- end
41
-
42
- commands
43
- end
44
-
45
- end
46
-
47
- end
1
+ require 'iis_object'
2
+ require 'virtual_directory'
3
+
4
+ module IISConfig
5
+
6
+ class Application < IISObject
7
+
8
+ def name(name)
9
+ @name = name
10
+ @virtual_directories = []
11
+ @app_pool = nil
12
+ end
13
+
14
+ def path(path)
15
+ @path = path
16
+ end
17
+
18
+ def auto_start_provider(name, type)
19
+ @start_provider_name = name
20
+ @start_provider_type = type
21
+ end
22
+
23
+ def physical_path(path)
24
+ @physical_path = path
25
+ end
26
+
27
+ def app_pool(name)
28
+ @app_pool = name
29
+ end
30
+
31
+ def virtual_directory(&block)
32
+ add_instance(@virtual_directories, IISConfig::VirtualDirectory, block)
33
+ end
34
+
35
+ def build_commands(site, app_pool)
36
+ commands = []
37
+
38
+ commands << %W{ADD APP /site.name:#{site} /path:#{@path} /physicalPath:#{@physical_path.gsub(/\//, '\\')}}
39
+
40
+ app_pool = @app_pool unless @app_pool.nil?
41
+ commands << %W{SET SITE /site.name:#{site}/#{@name} /[path='#{@path}'].applicationPool:#{app_pool}}
42
+
43
+ if @start_provider_name
44
+ commands << %W{set config -section:system.applicationHost/serviceAutoStartProviders /-"[name='#{@start_provider_name}']" /commit:apphost} if start_provider_exist? @start_provider_name
45
+ commands << %W{set config -section:system.applicationHost/serviceAutoStartProviders /+"[name='#{@start_provider_name}',type='#{@start_provider_type}']" /commit:apphost}
46
+ commands << %W{set app #{site}/#{@name} /serviceAutoStartEnabled:True /serviceAutoStartProvider:#{@start_provider_name}}
47
+ end
48
+
49
+ @virtual_directories.each do |s|
50
+ commands += s.build_commands "#{site}/#{@name}"
51
+ end
52
+
53
+ commands
54
+ end
55
+
56
+ end
57
+
58
+ end
@@ -1,101 +1,109 @@
1
- $:.push File.expand_path(File.dirname(__FILE__))
2
-
3
- require 'rexml/document'
4
- require 'app_pool'
5
- require 'ftp_site'
6
- require 'site'
7
-
8
- module IISConfig
9
-
10
- class IISConfiguration
11
- @@dry_run = false
12
-
13
- def initialize(options = {})
14
- @options = {recycle_apppools: false}.merge(options)
15
- @app_pools = []
16
- @sites = []
17
- @ftp_sites = []
18
- @before = []
19
- @after = []
20
- end
21
-
22
- def self.dry_run=dry_run
23
- @@dry_run = dry_run
24
- end
25
-
26
- def self.dry_run?
27
- @@dry_run
28
- end
29
-
30
- def app_pool(&block)
31
- add_instance @app_pools, IISConfig::AppPool, block
32
- end
33
-
34
- def site(&block)
35
- add_instance @sites, IISConfig::Site, block
36
- end
37
-
38
- def ftp_site(&block)
39
- add_instance @ftp_sites, IISConfig::FtpSite, block
40
- end
41
-
42
- def before(&block)
43
- @before << block
44
- end
45
-
46
- def after(&block)
47
- @after << block
48
- end
49
-
50
- def load(path)
51
- instance_eval IO.read(path), path
52
- end
53
-
54
- def run
55
- @before.each { |a| a.call }
56
-
57
- if @options[:recycle_apppools]
58
- recycle_application_pools
59
- else
60
- rebuild_all
61
- end
62
-
63
- @after.each { |a| a.call }
64
- end
65
-
66
- private
67
-
68
- def rebuild_all
69
- execute @app_pools
70
- execute @sites
71
- execute @ftp_sites
72
- end
73
-
74
- def recycle_application_pools
75
- @app_pools.each do |p|
76
- commands = p.recycle
77
- Runner.run_commands [commands] unless commands.empty?
78
- end
79
- end
80
-
81
- def execute(objects)
82
- objects.each do |p|
83
- commands = p.build_commands
84
- Runner.run_commands commands
85
-
86
- p.required_paths.each do |path|
87
- FileUtils.mkdir_p path unless Dir.exist? path
88
- end
89
- end
90
- end
91
-
92
- def add_instance(collection, type, block)
93
- instance = type.new
94
- collection << instance
95
- block.call instance if block
96
- end
97
-
98
- end
99
-
100
- end
101
-
1
+ $:.push File.expand_path(File.dirname(__FILE__))
2
+
3
+ require 'rexml/document'
4
+ require 'app_pool'
5
+ require 'ftp_site'
6
+ require 'site'
7
+
8
+ module IISConfig
9
+
10
+ class IISConfiguration
11
+ @@dry_run = false
12
+ @@verbose = false
13
+
14
+ def initialize(options = {})
15
+ @options = {recycle_apppools: false}.merge(options)
16
+ @app_pools = []
17
+ @sites = []
18
+ @ftp_sites = []
19
+ @before = []
20
+ @after = []
21
+ end
22
+
23
+ def self.dry_run=dry_run
24
+ @@dry_run = dry_run
25
+ end
26
+
27
+ def self.dry_run?
28
+ @@dry_run
29
+ end
30
+
31
+ def self.verbose=verbose
32
+ @@verbose = verbose
33
+ end
34
+
35
+ def self.verbose?
36
+ @@verbose
37
+ end
38
+
39
+ def app_pool(&block)
40
+ add_instance @app_pools, IISConfig::AppPool, block
41
+ end
42
+
43
+ def site(&block)
44
+ add_instance @sites, IISConfig::Site, block
45
+ end
46
+
47
+ def ftp_site(&block)
48
+ add_instance @ftp_sites, IISConfig::FtpSite, block
49
+ end
50
+
51
+ def before(&block)
52
+ @before << block
53
+ end
54
+
55
+ def after(&block)
56
+ @after << block
57
+ end
58
+
59
+ def load(path)
60
+ instance_eval IO.read(path), path
61
+ end
62
+
63
+ def run
64
+ @before.each { |a| a.call }
65
+
66
+ if @options[:recycle_apppools]
67
+ recycle_application_pools
68
+ else
69
+ rebuild_all
70
+ end
71
+
72
+ @after.each { |a| a.call }
73
+ end
74
+
75
+ private
76
+
77
+ def rebuild_all
78
+ execute @app_pools
79
+ execute @sites
80
+ execute @ftp_sites
81
+ end
82
+
83
+ def recycle_application_pools
84
+ @app_pools.each do |p|
85
+ commands = p.recycle
86
+ Runner.run_commands [commands] unless commands.empty?
87
+ end
88
+ end
89
+
90
+ def execute(objects)
91
+ objects.each do |p|
92
+ commands = p.build_commands
93
+ Runner.run_commands commands
94
+
95
+ p.required_paths.each do |path|
96
+ FileUtils.mkdir_p path unless Dir.exist? path
97
+ end
98
+ end
99
+ end
100
+
101
+ def add_instance(collection, type, block)
102
+ instance = type.new
103
+ collection << instance
104
+ block.call instance if block
105
+ end
106
+
107
+ end
108
+
109
+ end