win32olerot 0.0.1-x86-mswin32 → 0.0.2-x86-mswin32
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/ext/win32olerot/win32olerot.cpp +29 -6
- data/lib/win32olerot.so +0 -0
- data/tests/tc_basic.rb +13 -1
- metadata +1 -1
@@ -109,7 +109,7 @@ public:
|
|
109
109
|
}
|
110
110
|
}
|
111
111
|
|
112
|
-
VALUE isRunning(VALUE aMoniker)
|
112
|
+
VALUE isRunning(VALUE aMoniker, VALUE aInvalidMonikersArentRunning)
|
113
113
|
{
|
114
114
|
VALUE result = Qfalse;
|
115
115
|
|
@@ -131,10 +131,14 @@ public:
|
|
131
131
|
hr = MkParseDisplayName(pBindCtx, pBuf, &ignored, &pMoniker);
|
132
132
|
::SysFreeString(pBuf);
|
133
133
|
|
134
|
-
if(FAILED(hr))
|
134
|
+
if (FAILED(hr))
|
135
|
+
{
|
136
|
+
if (RTEST(aInvalidMonikersArentRunning))
|
137
|
+
return result;
|
138
|
+
|
135
139
|
VALUE message = hr.message();
|
136
140
|
rb_raise(eWIN32OLE_RUNTIME_ERROR,
|
137
|
-
|
141
|
+
"Failed to parse display name of moniker '%s': %s",
|
138
142
|
StringValuePtr(aMoniker),
|
139
143
|
StringValuePtr(message));
|
140
144
|
}
|
@@ -228,11 +232,30 @@ static VALUE rot_allocate(VALUE klass)
|
|
228
232
|
return Data_Wrap_Struct(klass, rot_mark, rot_free, table);
|
229
233
|
}
|
230
234
|
|
231
|
-
static VALUE rot_isRunning(VALUE rot, VALUE
|
235
|
+
static VALUE rot_isRunning(VALUE rot, VALUE vArray)
|
232
236
|
{
|
237
|
+
VALUE moniker = rb_ary_shift(vArray);
|
238
|
+
if (NIL_P(moniker))
|
239
|
+
{
|
240
|
+
rb_raise(rb_eArgError, "Missing required parameter 'moniker_name'");
|
241
|
+
}
|
242
|
+
|
243
|
+
VALUE exceptionsDontError = Qtrue;
|
244
|
+
|
245
|
+
VALUE options = rb_ary_shift(vArray);
|
246
|
+
if (!NIL_P(options))
|
247
|
+
{
|
248
|
+
VALUE optValue = rb_funcall(options, rb_intern("fetch"),
|
249
|
+
2, ID2SYM(rb_intern("raise_exception")), Qnil);
|
250
|
+
if (RTEST(optValue))
|
251
|
+
{
|
252
|
+
exceptionsDontError = Qfalse;
|
253
|
+
}
|
254
|
+
}
|
255
|
+
|
233
256
|
WIN32OLE_RunningObjectTable* pRot;
|
234
257
|
Data_Get_Struct(rot, WIN32OLE_RunningObjectTable, pRot);
|
235
|
-
return pRot->isRunning(
|
258
|
+
return pRot->isRunning(moniker, exceptionsDontError);
|
236
259
|
}
|
237
260
|
|
238
261
|
static VALUE rot_each_display_name(VALUE rot)
|
@@ -258,7 +281,7 @@ Init_win32olerot()
|
|
258
281
|
|
259
282
|
cWIN32OLE_ROT = rb_define_class_under(cWIN32OLE, "RunningObjectTable", rb_cObject);
|
260
283
|
rb_define_alloc_func(cWIN32OLE_ROT, rot_allocate);
|
261
|
-
rb_define_method(cWIN32OLE_ROT, "is_running?", RUBY_METHOD_FUNC(rot_isRunning),
|
284
|
+
rb_define_method(cWIN32OLE_ROT, "is_running?", RUBY_METHOD_FUNC(rot_isRunning), -2);
|
262
285
|
rb_define_method(cWIN32OLE_ROT, "each_display_name", RUBY_METHOD_FUNC(rot_each_display_name), 0);
|
263
286
|
rb_define_alias(cWIN32OLE_ROT, "each", "each_display_name");
|
264
287
|
}
|
data/lib/win32olerot.so
CHANGED
Binary file
|
data/tests/tc_basic.rb
CHANGED
@@ -24,6 +24,18 @@ class TC_Create < Test::Unit::TestCase
|
|
24
24
|
assert @rot.is_running?(x)
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
|
+
def test_invalid_monikers_arent_running
|
29
|
+
assert_nothing_thrown do
|
30
|
+
assert !@rot.is_running?("blah_garbage_data_here")
|
31
|
+
assert !@rot.is_running?("blah_garbage_data_here", :raise_exception => false)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_invalid_monikers_exception_with_raise_exception_option
|
36
|
+
assert_raises(WIN32OLERuntimeError) { !@rot.is_running?("blah_garbage_data_here", :raise_exception => true) }
|
37
|
+
end
|
38
|
+
|
39
|
+
|
28
40
|
end
|
29
41
|
|