iisadmin 0.0.1

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.
data/COPYING ADDED
File without changes
@@ -0,0 +1,4 @@
1
+ 项目修订记录:
2
+
3
+ 0.0.1
4
+ * 增加构建文件
@@ -0,0 +1 @@
1
+ IIS Admin Utils library
@@ -0,0 +1,251 @@
1
+
2
+ # Rakefile
3
+ require "rake/testtask"
4
+ require "rake/clean"
5
+ require "rake/rdoctask"
6
+ require "rake/gempackagetask"
7
+
8
+
9
+
10
+ # The name of your project
11
+ PROJECT = "IISAdmin"
12
+
13
+ # Your name, used in packaging.
14
+ MY_NAME = "Jun Tsai"
15
+
16
+ # Your email address, used in packaging.
17
+ MY_EMAIL = "Jun.Tsai At gmail.com"
18
+
19
+ # Short summary of your project, used in packaging.
20
+ PROJECT_SUMMARY = "manager IIS Web Server"
21
+
22
+ # The project's package name (as opposed to its display name). Used for
23
+ # RubyForge connectivity and packaging.
24
+ UNIX_NAME = "iisadmin"
25
+
26
+ # Your RubyForge user name.
27
+ RUBYFORGE_USER = ENV["RUBYFORGE_USER"] || "jcai"
28
+
29
+ # Directory on RubyForge where your website's files should be uploaded.
30
+ WEBSITE_DIR = "website"
31
+
32
+ # Output directory for the rdoc html files.
33
+ # If you don't have a custom homepage, and want to use the RDoc
34
+ # index.html as homepage, just set it to WEBSITE_DIR.
35
+ RDOC_HTML_DIR = "#{WEBSITE_DIR}/rdoc"
36
+
37
+
38
+
39
+ # Variable settings for extension support.
40
+ EXT_DIR = "ext"
41
+ HAVE_EXT = File.directory?(EXT_DIR)
42
+ EXTCONF_FILES = FileList["#{EXT_DIR}/**/extconf.rb"]
43
+ EXT_SOURCES = FileList["#{EXT_DIR}/**/*.{c,h}"]
44
+ # Eventually add other files from EXT_DIR, like "MANIFEST"
45
+ EXT_DIST_FILES = EXT_SOURCES + EXTCONF_FILES
46
+
47
+
48
+
49
+ REQUIRE_PATHS = ["lib"]
50
+ REQUIRE_PATHS << EXT_DIR if HAVE_EXT
51
+ $LOAD_PATH.concat(REQUIRE_PATHS)
52
+ # This library file defines the MyProject::VERSION constant.
53
+ require "#{UNIX_NAME}"
54
+ PROJECT_VERSION = eval("#{PROJECT}::VERSION") # e.g., "1.0.2"
55
+
56
+
57
+
58
+ # Clobber object files and Makefiles generated by extconf.rb.
59
+ CLOBBER.include("#{EXT_DIR}/**/*.{so,dll,o}", "#{EXT_DIR}/**/Makefile")
60
+ # Clobber .config generated by setup.rb.
61
+ CLOBBER.include(".config")
62
+
63
+
64
+
65
+ # Options common to RDocTask AND Gem::Specification.
66
+ # The --main argument specifies which file appears on the index.html page
67
+ GENERAL_RDOC_OPTS = {
68
+ "--title" => "#{PROJECT} API documentation",
69
+ "--main" => "README.rdoc"
70
+ }
71
+
72
+ # Additional RDoc formatted files, besides the Ruby source files.
73
+ RDOC_FILES = FileList["README.rdoc", "Changes.rdoc"]
74
+ # Remove the following line if you don't want to extract RDoc from
75
+ # the extension C sources.
76
+ RDOC_FILES.include(EXT_SOURCES)
77
+
78
+ # Ruby library code.
79
+ LIB_FILES = FileList["lib/**/*.rb"]
80
+
81
+ # Filelist with Test::Unit test cases.
82
+ TEST_FILES = FileList["test/**/tc_*.rb"]
83
+
84
+ # Executable scripts, all non-garbage files under bin/.
85
+ BIN_FILES = FileList["bin/*"]
86
+
87
+ # This filelist is used to create source packages.
88
+ # Include all Ruby and RDoc files.
89
+ DIST_FILES = FileList["**/*.rb", "**/*.rdoc"]
90
+ DIST_FILES.include("Rakefile", "COPYING")
91
+ DIST_FILES.include(BIN_FILES)
92
+ DIST_FILES.include("data/**/*", "test/data/**/*")
93
+ DIST_FILES.include("#{WEBSITE_DIR}/**/*.{html,css}", "man/*.[0-9]")
94
+ # Don't package files which are autogenerated by RDocTask
95
+ DIST_FILES.exclude(/^(\.\/)?#{RDOC_HTML_DIR}(\/|$)/)
96
+ # Include extension source files.
97
+ DIST_FILES.include(EXT_DIST_FILES)
98
+ # Don't package temporary files, perhaps created by tests.
99
+ DIST_FILES.exclude("**/temp_*", "**/*.tmp")
100
+ # Don't get into recursion…
101
+ DIST_FILES.exclude(/^(\.\/)?pkg(\/|$)/)
102
+
103
+
104
+
105
+ # Run the tests if rake is invoked without arguments.
106
+ task "default" => ["test"]
107
+
108
+ test_task_name = HAVE_EXT ? "run-tests" : "test"
109
+ Rake::TestTask.new(test_task_name) do |t|
110
+ t.test_files = TEST_FILES
111
+ t.libs = REQUIRE_PATHS
112
+ end
113
+
114
+
115
+
116
+ # Set an environment variable with any configuration options you want to
117
+ # be passed through to "setup.rb config".
118
+ CONFIG_OPTS = ENV["CONFIG"]
119
+ if HAVE_EXT
120
+ file_create ".config" do
121
+ ruby "setup.rb config #{CONFIG_OPTS}"
122
+ end
123
+
124
+ desc "Configure and make extension. " +
125
+ "The CONFIG variable is passed to `setup.rb config'"
126
+ task "make-ext" => ".config" do
127
+ # The -q option suppresses messages from setup.rb.
128
+ ruby "setup.rb -q setup"
129
+ end
130
+
131
+ desc "Run tests after making the extension."
132
+ task "test" do
133
+ Rake::Task["make-ext"].invoke
134
+ Rake::Task["run-tests"].invoke
135
+ end
136
+ end
137
+
138
+
139
+
140
+ # The "rdoc" task generates API documentation.
141
+ Rake::RDocTask.new("rdoc") do |t|
142
+ t.rdoc_files = RDOC_FILES + LIB_FILES
143
+ t.title = GENERAL_RDOC_OPTS["--title"]
144
+ t.main = GENERAL_RDOC_OPTS["--main"]
145
+ t.rdoc_dir = RDOC_HTML_DIR
146
+ end
147
+
148
+
149
+
150
+ GEM_SPEC = Gem::Specification.new do |s|
151
+ s.name = UNIX_NAME
152
+ s.version = PROJECT_VERSION
153
+ s.summary = PROJECT_SUMMARY
154
+ s.rubyforge_project = UNIX_NAME
155
+ s.homepage = "http://#{UNIX_NAME}.rubyforge.org/"
156
+ s.author = MY_NAME
157
+ s.email = MY_EMAIL
158
+ s.files = DIST_FILES
159
+ s.test_files = TEST_FILES
160
+ s.executables = BIN_FILES.map { |fn| File.basename(fn) }
161
+ s.has_rdoc = true
162
+ s.extra_rdoc_files = RDOC_FILES
163
+ s.rdoc_options = GENERAL_RDOC_OPTS.to_a.flatten
164
+ if HAVE_EXT
165
+ s.extensions = EXTCONF_FILES
166
+ s.require_paths >> EXT_DIR
167
+ end
168
+ end
169
+
170
+ # Now we can generate the package-related tasks.
171
+ Rake::GemPackageTask.new(GEM_SPEC) do |pkg|
172
+ pkg.need_zip = true
173
+ pkg.need_tar = true
174
+ end
175
+
176
+
177
+ desc "Upload website to RubyForge. " +
178
+ "scp will prompt for your RubyForge password."
179
+ task "publish-website" => ["rdoc"] do
180
+ rubyforge_path = "/var/www/gforge-projects/#{UNIX_NAME}/"
181
+ sh "scp -r #{WEBSITE_DIR}/* " +
182
+ "#{RUBYFORGE_USER}@rubyforge.org:#{rubyforge_path}",
183
+ :verbose => true
184
+ end
185
+
186
+ task "rubyforge-setup" do
187
+ unless File.exist?(File.join(ENV["HOME"], ".rubyforge"))
188
+ puts "rubyforge will ask you to edit its config.yml now."
189
+ puts "Please set the 'username' and 'password' entries"
190
+ puts "to your RubyForge username and RubyForge password!"
191
+ puts "Press ENTER to continue."
192
+ $stdin.gets
193
+ sh "rubyforge setup", :verbose => true
194
+ end
195
+ end
196
+
197
+ task "rubyforge-login" => ["rubyforge-setup"] do
198
+ # Note: We assume that username and password were set in
199
+ # rubyforge's config.yml.
200
+ sh "rubyforge login", :verbose => true
201
+ end
202
+
203
+ task "publish-packages" => ["package", "rubyforge-login"] do
204
+ # Upload packages under pkg/ to RubyForge
205
+ # This task makes some assumptions:
206
+ # * You have already created a package on the "Files" tab on the
207
+ # RubyForge project page. See pkg_name variable below.
208
+ # * You made entries under package_ids and group_ids for this
209
+ # project in rubyforge's config.yml. If not, eventually read
210
+ # "rubyforge --help" and then run "rubyforge setup".
211
+ pkg_name = ENV["PKG_NAME"] || UNIX_NAME
212
+ cmd = "rubyforge add_release #{UNIX_NAME} #{pkg_name} " +
213
+ "#{PROJECT_VERSION} #{UNIX_NAME}-#{PROJECT_VERSION}"
214
+ cd "pkg" do
215
+ sh(cmd + ".gem", :verbose => true)
216
+ sh(cmd + ".tgz", :verbose => true)
217
+ sh(cmd + ".zip", :verbose => true)
218
+ end
219
+ end
220
+ # The "prepare-release" task makes sure your tests run, and then generates
221
+ # files for a new release.
222
+ desc "Run tests, generate RDoc and create packages."
223
+ task "prepare-release" => ["clobber"] do
224
+ puts "Preparing release of #{PROJECT} version #{VERSION}"
225
+ Rake::Task["test"].invoke
226
+ Rake::Task["rdoc"].invoke
227
+ Rake::Task["package"].invoke
228
+ end
229
+
230
+ # The "publish" task is the overarching task for the whole project. It
231
+ # builds a release and then publishes it to RubyForge.
232
+ desc "Publish new release of #{PROJECT}"
233
+ task "publish" => ["prepare-release"] do
234
+ puts "Uploading documentation…"
235
+ Rake::Task["publish-website"].invoke
236
+ puts "Checking for rubyforge command…"
237
+ `rubyforge --help`
238
+ if $? == 0
239
+ puts "Uploading packages…"
240
+ Rake::Task["publish-packages"].invoke
241
+ puts "Release done!"
242
+ else
243
+ puts "Can't invoke rubyforge command."
244
+ puts "Either install rubyforge with 'gem install rubyforge'"
245
+ puts "and retry or upload the package files manually!"
246
+ end
247
+ end
248
+
249
+
250
+
251
+
@@ -0,0 +1,3 @@
1
+ module IISAdmin
2
+ VERSION='0.0.1'
3
+ end
@@ -0,0 +1,36 @@
1
+ # 针对winnt的用户管理
2
+ $KCODE="utf-8"
3
+ require 'win32ole'
4
+ require 'socket'
5
+ class IISUserAdmin
6
+ HOST_NAME=Socket.gethostname
7
+ @@domain_adsi=nil
8
+ def initialize
9
+ @@domain_adsi ||= WIN32OLE.connect("WinNT://#{HOST_NAME}")
10
+ puts HOST_NAME
11
+ puts @@domain_adsi
12
+ end
13
+ # 创建用户
14
+ # username 用户名
15
+ def create_user username
16
+ unless( username.nil? || exist?(username))
17
+ user=@@domain_adsi.create('user',username)
18
+ yield(user) if block_given?
19
+ user.SetInfo
20
+ end
21
+ end
22
+ # 删除用户
23
+ def delete_user username
24
+ @@domain_adsi.delete('user',username) unless (username.nil? || !exist?(username))
25
+ end
26
+ # 判断一个用户是否存在
27
+ def exist? username
28
+ return false if username.nil?
29
+ begin
30
+ WIN32OLE.connect("WinNT://#{HOST_NAME}/#{username},user")
31
+ rescue
32
+ return false
33
+ end
34
+ return true
35
+ end
36
+ end
@@ -0,0 +1,18 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__)+'/../lib')
2
+ $KCODE="utf-8"
3
+ require 'test/unit'
4
+ require 'iisadmin/user'
5
+
6
+ class TC_IISUserAdmin <Test::Unit::TestCase
7
+ def test_first
8
+ user_admin=IISUserAdmin.new
9
+ assert_not_nil(user_admin)
10
+ end
11
+ def test_create_user
12
+ user_admin=IISUserAdmin.new
13
+ assert_nothing_raised{user_admin.create_user('acai')}
14
+ assert user_admin.exist?('acai')
15
+ assert_nothing_raised{user_admin.delete_user('acai')}
16
+ assert !user_admin.exist?('acai')
17
+ end
18
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: iisadmin
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2007-03-02 00:00:00 +08:00
8
+ summary: manager IIS Web Server
9
+ require_paths:
10
+ - lib
11
+ email: Jun.Tsai At gmail.com
12
+ homepage: http://iisadmin.rubyforge.org/
13
+ rubyforge_project: iisadmin
14
+ description:
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Jun Tsai
31
+ files:
32
+ - lib/iisadmin.rb
33
+ - lib/iisadmin/user.rb
34
+ - test/tc_user.rb
35
+ - README.rdoc
36
+ - Changes.rdoc
37
+ - Rakefile
38
+ - COPYING
39
+ test_files:
40
+ - test/tc_user.rb
41
+ rdoc_options:
42
+ - --title
43
+ - IISAdmin API documentation
44
+ - --main
45
+ - README.rdoc
46
+ extra_rdoc_files:
47
+ - README.rdoc
48
+ - Changes.rdoc
49
+ executables: []
50
+
51
+ extensions: []
52
+
53
+ requirements: []
54
+
55
+ dependencies: []
56
+