sleipnir-api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/History.txt +3 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +41 -0
  4. data/README.txt +56 -0
  5. data/Rakefile +201 -0
  6. data/TODO.txt +11 -0
  7. data/examples/reload.rb +18 -0
  8. data/helper/helper.rb +3 -0
  9. data/helper/rake.rb +58 -0
  10. data/helper/rake_sh_filter.rb +23 -0
  11. data/helper/util.rb +19 -0
  12. data/lib/sleipnir_api.rb +177 -0
  13. data/lib/sleipnir_api/dialog.rb +155 -0
  14. data/lib/sleipnir_api/key_state.rb +49 -0
  15. data/lib/sleipnir_api/output.rb +319 -0
  16. data/lib/sleipnir_api/process.rb +69 -0
  17. data/lib/sleipnir_api/profile.rb +332 -0
  18. data/lib/sleipnir_api/registry.rb +30 -0
  19. data/lib/sleipnir_api/security.rb +263 -0
  20. data/lib/sleipnir_api/sleipnir.rb +489 -0
  21. data/lib/sleipnir_api/tab.rb +359 -0
  22. data/lib/sleipnir_api/util.rb +16 -0
  23. data/lib/sleipnir_api/version.rb +9 -0
  24. data/lib/sleipnir_api/win32api.rb +17 -0
  25. data/scripts/rdoc_filter.rb +74 -0
  26. data/setup.rb +1585 -0
  27. data/spec/matchers/path_eql.rb +41 -0
  28. data/spec/sleipnir_api/dialog_mock_spec.rb +99 -0
  29. data/spec/sleipnir_api/key_state_mock_spec.rb +72 -0
  30. data/spec/sleipnir_api/output_spec.rb +242 -0
  31. data/spec/sleipnir_api/profile_mock_spec.rb +128 -0
  32. data/spec/sleipnir_api/registry_spec.rb +13 -0
  33. data/spec/sleipnir_api/security_mock_spec.rb +82 -0
  34. data/spec/sleipnir_api/security_spec.rb +129 -0
  35. data/spec/sleipnir_api/sleipnir_mock_spec.rb +70 -0
  36. data/spec/sleipnir_api/sleipnir_spec.rb +295 -0
  37. data/spec/sleipnir_api/tab_mock_spec.rb +98 -0
  38. data/spec/sleipnir_api/tab_spec.rb +105 -0
  39. data/spec/sleipnir_api_spec.rb +17 -0
  40. data/spec/spec.opts +0 -0
  41. data/spec/spec_helper.rb +8 -0
  42. metadata +91 -0
@@ -0,0 +1,69 @@
1
+ require "timeout"
2
+ require "win32ole"
3
+
4
+ require "sleipnir_api/registry"
5
+
6
+ module SleipnirAPI
7
+ class Process # :nodoc:
8
+ class <<self
9
+
10
+ include SleipnirAPI::Registry
11
+
12
+ @@wbem = nil
13
+
14
+ def exist?
15
+ not query_sleipnir.Count.zero?
16
+ end
17
+
18
+ def create(timeout = 3)
19
+ exe_path = local_server
20
+ unless File.exist?(exe_path)
21
+ raise_create_error "Sleipnir.exe not found `#{exe_path}'"
22
+ end
23
+ clazz = wbem.Get("Win32_Process")
24
+ r = clazz.Create(exe_path, nil, nil, nil)
25
+ raise_create_error "error=#{r}." unless r.zero?
26
+ wait_for_launch(timeout)
27
+ end
28
+
29
+ def wait_for_launch(timeout)
30
+ begin
31
+ timeout(timeout) {
32
+ sleep(0.1) until exist?
33
+ }
34
+ rescue Timeout::Error
35
+ raise_create_error("timed out")
36
+ end
37
+ end
38
+
39
+ def raise_create_error(msg)
40
+ raise Sleipnir::ProcessError, "Failed to create Sleipnir process: #{msg}."
41
+ end
42
+
43
+ def terminate!(handle)
44
+ query_sleipnir.each do |obj|
45
+ obj.Terminate
46
+ end
47
+ end
48
+
49
+ def query_sleipnir
50
+ wbem.ExecQuery("select * from Win32_Process where ExecutablePath='%s'" % escape(local_server))
51
+ end
52
+
53
+ def escape(str)
54
+ str.gsub(/\\/){ "\\\\" }
55
+ end
56
+ private :escape
57
+
58
+ def wbem
59
+ unless @@wbem
60
+ locator = WIN32OLE.new("WbemScripting.SWbemLocator")
61
+ @@wbem = locator.ConnectServer(".")
62
+ end
63
+ @@wbem
64
+ end
65
+ private :wbem
66
+
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,332 @@
1
+ require "sleipnir_api/util"
2
+
3
+ module SleipnirAPI
4
+
5
+ #
6
+ # このクラスは Sleipnir の COM オブジェクト (Sleipnir.API) の wrapper クラスです。
7
+ # Sleipnir の ini ファイルを操作する API を定義しています。
8
+ #
9
+ # このオブジェクトは SleipnirAPI::Sleipnir#profile で取得します。
10
+ #
11
+ # 例:
12
+ #
13
+ # pnir = SleipnirAPI.new
14
+ # ini = pnir.profile
15
+ #
16
+ # # デフォルト値
17
+ # ini.write_string("section", "key", "foobar")
18
+ # ini.get_string("section", "key") #=> "foobar"
19
+ # ini.delete("section", "key")
20
+ # ini.get_string("section", "key", :default => "default value") #=> "default value"
21
+ #
22
+ # # 暗号化
23
+ # ini.write_string("section", "key", "foobar", :cipher => true)
24
+ # ini.get_string("section", "key") #=> "tF4DxDH)[uUu"
25
+ # ini.get_string("section", "key", :cipher => true) #=> "foobar"
26
+ #
27
+ # # ファイル名指定
28
+ # count = ini.get_int("Proxy", "Count", :ini => "proxy.ini")
29
+ # (0...count).each do |i|
30
+ # p ini.get_string("Proxy", "Proxy#{i}_Title", :ini => "proxy.ini")
31
+ # end
32
+ #
33
+ class Profile
34
+ include SleipnirAPI::Util
35
+
36
+ # SleipnirAPI::Sleipnir object
37
+ attr_reader :sleipnir
38
+
39
+ def initialize(sleipnir)
40
+ @sleipnir = sleipnir
41
+ end
42
+
43
+ #
44
+ # call-seq:
45
+ # get_string(section, key)
46
+ # get_string(section, key, :default => "default value")
47
+ # get_string(section, key, :cipher => true)
48
+ # get_string(section, key, :cipher => true, :default => "default value")
49
+ # get_string(section, key, :ini => ini_filename)
50
+ # get_string(section, key, :ini => ini_filename, :default => "default value")
51
+ #
52
+ # string 型データを読み込みます。
53
+ #
54
+ # * <tt>:ini</tt> キーワード引数で、データを読み込む ini ファイルを指定できます。
55
+ # * デフォルトは <ini_dir>\script.ini です。
56
+ # * <tt>:ini</tt> に相対パスを指定した場合、SleipnirAPI::Sleipnir#user_path からの
57
+ # 相対パスと見なします。
58
+ # * <tt>:cipher</tt> に true を指定すると暗号化されたデータを複合化して読み込みます。
59
+ # * <tt>:default</tt> でキーが存在しないときに返す値を指定できます。
60
+ # * <tt>:ini</tt> と <tt>:cipher</tt> は同時には指定できません。
61
+ # 同時に指定した場合 <tt>:cipher</tt> は無視されます。
62
+ #
63
+ def get_string(section, key, opts = nil)
64
+ opts ||= {}
65
+ if opts[:ini]
66
+ api.GetProfileStringEx(section, key, opts[:default], expand_user_path(opts[:ini]))
67
+ elsif opts[:cipher]
68
+ api.GetProfileStringCipher(section, key, opts[:default])
69
+ else
70
+ api.GetProfileString(section, key, opts[:default])
71
+ end
72
+ end
73
+
74
+ #
75
+ # call-seq:
76
+ # get_int(section, key)
77
+ # get_int(section, key, :default => -1)
78
+ # get_int(section, key, :cipher => true)
79
+ # get_int(section, key, :cipher => true, :default => -1)
80
+ # get_int(section, key, :ini => ini_filename)
81
+ # get_int(section, key, :ini => ini_filename, :default => -1)
82
+ #
83
+ # int 型データを読み込みます。
84
+ # 詳細は get_string を参照してください。
85
+ #
86
+ def get_int(section, key, opts = nil)
87
+ opts ||= {}
88
+ if opts[:ini]
89
+ api.GetProfileIntEx(section, key, opts[:default], expand_user_path(opts[:ini]))
90
+ elsif opts[:cipher]
91
+ api.GetProfileIntCipher(section, key, opts[:default])
92
+ else
93
+ api.GetProfileInt(section, key, opts[:default])
94
+ end
95
+ end
96
+
97
+ #
98
+ # call-seq:
99
+ # write_string(section, key, data)
100
+ # write_string(section, key, data, :cipher => true)
101
+ #
102
+ # <ini_dir>\script.ini に string 型データを書き込みます。
103
+ #
104
+ # * <tt>:cipher</tt> に true を指定すると暗号化してデータを書き込みます。
105
+ #
106
+ def write_string(section, key, data, opts = nil)
107
+ opts ||= {}
108
+ if opts[:cipher]
109
+ api.WriteProfileStringCipher(section, key, data)
110
+ else
111
+ api.WriteProfileString(section, key, data)
112
+ end
113
+ end
114
+
115
+ #
116
+ # call-seq:
117
+ # write_int(section, key, data)
118
+ # write_int(section, key, data, :cipher => true)
119
+ #
120
+ # <ini_dir>\script.ini に int 型データを書き込みます。
121
+ #
122
+ # * <tt>:cipher</tt> に true を指定すると暗号化してデータを書き込みます。
123
+ #
124
+ def write_int(section, key, data, opts = nil)
125
+ opts ||= {}
126
+ if opts[:cipher]
127
+ api.WriteProfileIntCipher(section, key, data)
128
+ else
129
+ api.WriteProfileInt(section, key, data)
130
+ end
131
+ end
132
+
133
+ # <ini_dir>\script.ini から指定されたキーを削除します。
134
+ def delete(section, key)
135
+ api.DeleteProfileKey(section, key)
136
+ end
137
+
138
+ # <ini_dir> から expand_path します。
139
+ def expand_user_path(ini)
140
+ File.expand_path(ini, sleipnir.user_path)
141
+ end
142
+
143
+ # <ini_dir>\script.ini のパスを返します。
144
+ def script_ini
145
+ expand_user_path("script.ini")
146
+ end
147
+
148
+ end
149
+ end
150
+
151
+
152
+ __END__
153
+ ──────────────────────────────────
154
+ [void] WriteProfileInt(string strSection, string strKey, long nData)
155
+ ──────────────────────────────────
156
+
157
+ [説明]
158
+  <ini_dir>\script.ini に long 型データを書き込む。
159
+
160
+ [引数]
161
+  strSection: セクション
162
+  strKey: キー
163
+  nData: データ
164
+
165
+ [戻り値]
166
+  なし
167
+
168
+
169
+ ──────────────────────────────────────
170
+ [void] WriteProfileString(string strSection, string strKey, string strData)
171
+ ──────────────────────────────────────
172
+
173
+ [説明]
174
+  <ini_dir>\script.ini に string 型データを書き込む。
175
+
176
+ [引数]
177
+  strSection: セクション
178
+  strKey: キー
179
+  strData: データ
180
+
181
+ [戻り値]
182
+  なし
183
+
184
+
185
+ ───────────────────────────────────
186
+ [long] GetProfileInt(string strSection, string strKey, long nDefault)
187
+ ───────────────────────────────────
188
+
189
+ [説明]
190
+  <ini_dir>\script.ini から long 型データを読み込む。
191
+
192
+ [引数]
193
+  strSection: セクション
194
+  strKey: キー
195
+  nDefault: キーが存在しないときに返される値
196
+
197
+ [戻り値]
198
+  データ
199
+
200
+
201
+ ───────────────────────────────────────
202
+ [string] GetProfileString(string strSection, string strKey, string strDefault)
203
+ ───────────────────────────────────────
204
+
205
+ [説明]
206
+  <ini_dir>\script.ini から string 型データを読み込む。
207
+
208
+ [引数]
209
+  strSection: セクション
210
+  strKey: キー
211
+  strDefault: キーが存在しないときに返される値
212
+
213
+ [戻り値]
214
+  データ
215
+
216
+
217
+ ─────────────────────────────────────
218
+ [void] WriteProfileIntCipher(string strSection, string strKey, long nData)
219
+ ─────────────────────────────────────
220
+
221
+ [説明]
222
+  <ini_dir>\script.ini に long 型データを暗号化して書き込む。
223
+
224
+ [引数]
225
+  strSection: セクション
226
+  strKey: キー
227
+  nData: データ
228
+
229
+ [戻り値]
230
+  なし
231
+
232
+
233
+ ─────────────────────────────────
234
+ [void] WriteProfileStringCipher(string strSection, string strKey,
235
+ string strData)
236
+ ─────────────────────────────────
237
+
238
+ [説明]
239
+  <ini_dir>\script.ini に string 型データを暗号化して書き込む。
240
+
241
+ [引数]
242
+  strSection: セクション
243
+  strKey: キー
244
+  strData: データ
245
+
246
+ [戻り値]
247
+  なし
248
+
249
+
250
+ ──────────────────────────────────────
251
+ [long] GetProfileIntCipher(string strSection, string strKey, long nDefault)
252
+ ──────────────────────────────────────
253
+
254
+ [説明]
255
+  <ini_dir>\script.ini から暗号化された long 型データを読み込む。
256
+
257
+ [引数]
258
+  strSection: セクション
259
+  strKey: キー
260
+  nDefault: キーが存在しないときに返される値
261
+
262
+ [戻り値]
263
+  データ
264
+
265
+
266
+ ─────────────────────────────────
267
+ [string] GetProfileStringCipher(string strSection, string strKey,
268
+ string strDefault)
269
+ ─────────────────────────────────
270
+
271
+ [説明]
272
+  <ini_dir>\script.ini から暗号化された string 型データを読み込む。
273
+
274
+ [引数]
275
+  strSection: セクション
276
+  strKey: キー
277
+  strDefault: キーが存在しないときに返される値
278
+
279
+ [戻り値]
280
+  データ
281
+
282
+
283
+ ────────────────────────────────────
284
+ [long] GetProfileIntEx(string strSection, string strKey, long nDefault,
285
+ string strFileName)
286
+ ────────────────────────────────────
287
+
288
+ [説明]
289
+  strFileName で指定される INI ファイルから long 型データを読み込む。
290
+
291
+ [引数]
292
+  strSection: セクション
293
+  strKey: キー
294
+  nDefault: キーが存在しないときに返される値
295
+  strFileName: 設定を読み込むファイル
296
+
297
+ [戻り値]
298
+  データ
299
+
300
+
301
+ ─────────────────────────────────
302
+ [string] GetProfileStringEx(string strSection, string strKey,
303
+ string strDefault, string strFileName)
304
+ ─────────────────────────────────
305
+
306
+ [説明]
307
+  strFileName で指定される INI ファイルから string 型データを読み込む。一部のフ
308
+  ァイルでは "" で囲まれた文字列が返されることがあります。
309
+
310
+ [引数]
311
+  strSection: セクション
312
+  strKey: キー
313
+  strDefault: キーが存在しないときに返される値
314
+  strFileName: 設定を読み込むファイル
315
+
316
+ [戻り値]
317
+  データ
318
+
319
+ ─────────────────────────────
320
+ [void] DeleteProfileKey(string strSection, string strKey)
321
+ ─────────────────────────────
322
+
323
+ [説明]
324
+  <ini_dir>\script.ini から任意のキーを削除する。
325
+
326
+ [引数]
327
+  strSection: セクション
328
+  strKey: キー
329
+
330
+ [戻り値]
331
+  なし
332
+
@@ -0,0 +1,30 @@
1
+ require "win32/registry"
2
+
3
+ require "sleipnir_api/win32api"
4
+
5
+ module SleipnirAPI
6
+ module Registry # :nodoc:
7
+ include SleipnirAPI::Win32API
8
+ extend SleipnirAPI::Win32API
9
+
10
+ PROG_ID = "Sleipnir.API"
11
+
12
+ module_function
13
+
14
+ # Sleipnir.API �� CLSID ��Ԃ��܂��B
15
+ def clsid
16
+ reg_read_s(Win32::Registry::HKEY_CLASSES_ROOT, "#{PROG_ID}\\CLSID", nil)
17
+ end
18
+
19
+ # Sleipnir.exe �̃p�X��Ԃ��܂��B
20
+ def local_server
21
+ get_long_path_name(
22
+ reg_read_s(Win32::Registry::HKEY_CLASSES_ROOT, "CLSID\\#{clsid}\\LocalServer32", nil))
23
+ end
24
+
25
+ def reg_read_s(root, key, name) #:nodoc:
26
+ Win32::Registry.open(root, key) {|reg| reg.read_s(name) }
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,263 @@
1
+ require "sleipnir_api/util"
2
+
3
+ module SleipnirAPI
4
+
5
+ #
6
+ # このクラスは Sleipnir の COM オブジェクト (Sleipnir.API) の wrapper クラスです。
7
+ # Sleipnir のタブ毎のセキュリティ設定を操作する API を定義しています。
8
+ #
9
+ # * このオブジェクトは SleipnirAPI::Tab#security で取得します。
10
+ # * このクラスは Enumerable を include しています。
11
+ #
12
+ # セキュリティ設定はハッシュ、シンボル、属性などでアクセスできます。
13
+ #
14
+ # 例:
15
+ #
16
+ # pnir = SleipnirAPI.connect
17
+ # tab = pnir.active_tab
18
+ #
19
+ # # セキュリティ設定の取得 (すべて同じ意味)
20
+ # tab.security.javascript.enable?
21
+ # tab.security[:javascript].enable?
22
+ # tab.security.enable?(:javascript)
23
+ # tab.security.to_hash[:javascript]
24
+ #
25
+ # # セキュリティ設定の更新 (すべて同じ意味)
26
+ # tab.security.javascript.enable!
27
+ # tab.security(:javascript).enable!
28
+ # tab.security.set_security(:javascript => true)
29
+ #
30
+ # # Enumerable method
31
+ # tab.security.find_all{|e| e.disable? }
32
+ #
33
+ class Security
34
+ include Enumerable
35
+ include SleipnirAPI::Util
36
+
37
+ #
38
+ # このクラスは Sleipnir のセキュリティ設定項目をあらわします。
39
+ #
40
+ # このオブジェクトは SleipnirAPI::Security の属性から取得します。
41
+ #
42
+ class Config
43
+
44
+ attr_reader :name
45
+
46
+ def initialize(security, name)
47
+ @security = security
48
+ @name = name
49
+ end
50
+
51
+ # このセキュリティ設定が有効なら true を返します。
52
+ def enable?
53
+ @security.enable?(@name)
54
+ end
55
+
56
+ # このセキュリティ設定が無効なら true を返します。
57
+ def disable?
58
+ @security.disable?(@name)
59
+ end
60
+
61
+ # このセキュリティ設定の有効・無効を切り替えます。
62
+ #
63
+ # * <tt>enable</tt> が true なら有効にします。
64
+ # * <tt>enable</tt> が false なら無効にします。
65
+ #
66
+ # 複数のセキュリティ設定を更新する場合は、
67
+ # このメソッドを利用せず SleipnirAPI::Security#set_security を利用して
68
+ # 一括設定してください。
69
+ def enable=(enable)
70
+ @security.set_security(@name => enable)
71
+ end
72
+
73
+ # このセキュリティ設定を有効にします。
74
+ #
75
+ # 複数のセキュリティ設定を更新する場合は、
76
+ # このメソッドを利用せず SleipnirAPI::Security#set_security を利用して
77
+ # 一括設定してください。
78
+ def enable!
79
+ self.enable = true
80
+ end
81
+
82
+ # このセキュリティ設定を無効にします。
83
+ #
84
+ # 複数のセキュリティ設定を更新する場合は、
85
+ # このメソッドを利用せず SleipnirAPI::Security#set_security を利用して
86
+ # 一括設定してください。
87
+ def disable!
88
+ self.enable = false
89
+ end
90
+
91
+ def inspect
92
+ "#<%s:0x%x %s=%s>" % [self.class, self.object_id << 1, @name, enable?]
93
+ end
94
+ alias to_s inspect
95
+
96
+ end
97
+
98
+ NAME2API = [
99
+ [:javascript, :IsJavaScriptEnabled],
100
+ [:java, :IsJavaEnabled],
101
+ [:run_activex, :IsRunActiveXEnabled],
102
+ [:download_activex, :IsDownloadActiveXEnabled],
103
+ [:picture, :IsPictureEnabled],
104
+ [:sound, :IsSoundEnabled],
105
+ [:video, :IsVideoEnabled],
106
+ ]
107
+
108
+ # 「JavaScript の実行」をあらわす SleipnirAPI::Security::Config
109
+ attr_reader :javascript
110
+
111
+ # 「Java の実行」をあらわす SleipnirAPI::Security::Config
112
+ attr_reader :java
113
+
114
+ # 「ActiveX の実行」をあらわす SleipnirAPI::Security::Config
115
+ attr_reader :run_activex
116
+
117
+ # 「ActiveX のダウンロード」をあらわす SleipnirAPI::Security::Config
118
+ attr_reader :download_activex
119
+
120
+ # 「画像の再生」をあらわす SleipnirAPI::Security::Config
121
+ attr_reader :picture
122
+
123
+ # 「サウンドの再生」をあらわす SleipnirAPI::Security::Config
124
+ attr_reader :sound
125
+
126
+ # 「ビデオの再生」をあらわす SleipnirAPI::Security::Config
127
+ attr_reader :video
128
+
129
+ def initialize(tab)
130
+ @tab = tab
131
+ keys.each do |name|
132
+ instance_variable_set("@#{name}", Config.new(self, name))
133
+ end
134
+ end
135
+
136
+ # セキュリティ設定の名前 (シンボル) を配列で返します。
137
+ #
138
+ # この名前は #[], #set_security, #enable?, #disable? に指定できます。
139
+ #
140
+ # pnir.active_tab.security.keys
141
+ # #=> [:javascript, :java, :run_activex, :download_activex, :picture, :sound, :video]
142
+ #
143
+ def keys
144
+ NAME2API.map{|e| e.first }
145
+ end
146
+
147
+ # 指定された名前のセキュリティ設定を取得します。
148
+ #
149
+ # 以下の値を指定可能です。不正な値を指定した場合は nil を返します。
150
+ #
151
+ # * <tt>:javascript</tt>
152
+ # * <tt>:java</tt>
153
+ # * <tt>:run_activex</tt>
154
+ # * <tt>:download_activex</tt>
155
+ # * <tt>:picture</tt>
156
+ # * <tt>:sound</tt>
157
+ # * <tt>:video</tt>
158
+ #
159
+ # 取得できる値は同名の attribute と同じです。
160
+ #
161
+ # tab = pnir.active_tab
162
+ # tab.security[:javascript] #=> #<SleipnirAPI::Security::Config:0x2995190 javascript=true>
163
+ # tab.security.javascript #=> #<SleipnirAPI::Security::Config:0x2995190 javascript=true>
164
+ #
165
+ def [](name)
166
+ if keys.include?(name)
167
+ instance_variable_get("@#{name}")
168
+ end
169
+ end
170
+
171
+ # call-seq:
172
+ # each {|security_config| ... }
173
+ #
174
+ # すべてのセキュリティ設定を走査します。
175
+ #
176
+ # block の引数には SleipnirAPI::Security::Config オブジェクトが渡されます。
177
+ def each(&block)
178
+ keys.map{|e| self[e] }.each(&block)
179
+ end
180
+
181
+ # call-seq:
182
+ # set_security(:javascript => true_or_false,
183
+ # :java => true_or_false,
184
+ # :run_activex => true_or_false,
185
+ # :download_activex => true_or_false,
186
+ # :picture => true_or_false,
187
+ # :sound => true_or_false,
188
+ # :video => true_or_false)
189
+ #
190
+ # セキュリティ設定をハッシュで指定して更新します。
191
+ def set_security(opts)
192
+ security = to_hash
193
+ security.update(opts)
194
+ api.SetSecurity(@tab.id, *(keys.map{|e| security[e] }))
195
+ end
196
+ alias update set_security
197
+
198
+ # セキュリティ設定をハッシュで取得します。
199
+ def get_security
200
+ NAME2API.inject({}) do |h, pair|
201
+ h[pair[0]] = api.__send__(pair[1], @tab.id)
202
+ h
203
+ end
204
+ end
205
+ alias to_hash get_security
206
+
207
+ # 指定された名前のセキュリティ設定が有効なら true を返します。
208
+ def enable?(name)
209
+ api.__send__(NAME2API.assoc(name.to_sym)[1], @tab.id)
210
+ end
211
+
212
+ # 指定された名前のセキュリティ設定が無効なら true を返します。
213
+ def disable?(name)
214
+ not enable?(name)
215
+ end
216
+
217
+ def inspect
218
+ "#<%s:0x%x %s>" % [self.class, self.object_id << 1, to_hash.inspect ]
219
+ end
220
+ alias to_s inspect
221
+
222
+ # SleipnirAPI::Sleipnir object
223
+ def sleipnir
224
+ @tab.sleipnir
225
+ end
226
+
227
+ end
228
+ end
229
+
230
+
231
+ __END__
232
+ ──────────────────────────────────────
233
+ [void] SetSecurity(long id, BOOL bJavaScript, BOOL bJava, BOOL bRunActiveX,
234
+ BOOL bDownloadActiveX, BOOL bPicture, BOOL bSound,
235
+ BOOL bVideo)
236
+ ──────────────────────────────────────
237
+
238
+ [説明]
239
+  ドキュメントのセキュリティを設定する。
240
+
241
+ [引数]
242
+  id: ドキュメント固有の ID
243
+  各値: 各セキュリティ
244
+
245
+
246
+ ────────────────────
247
+ [BOOL] IsJavaScriptEnabled(long id)
248
+ [BOOL] IsJavaEnabled(long id)
249
+ [BOOL] IsRunActiveXEnabled(long id)
250
+ [BOOL] IsDownloadActiveXEnabled(long id)
251
+ [BOOL] IsPictureEnabled(long id)
252
+ [BOOL] IsSoundEnabled(long id)
253
+ [BOOL] IsVideoEnabled(long id)
254
+ ────────────────────
255
+
256
+ [説明]
257
+  ドキュメントのセキュリティを取得する。
258
+
259
+ [引数]
260
+  id: ドキュメント固有の ID
261
+
262
+ [戻り値]
263
+  有効ならば true