ruby-changes:53022
From: suke <ko1@a...>
Date: Sat, 20 Oct 2018 20:54:16 +0900 (JST)
Subject: [ruby-changes:53022] suke:r65236 (trunk): refactoring define AvailableOLE.sysmon_available?
suke 2018-10-20 20:54:09 +0900 (Sat, 20 Oct 2018) New Revision: 65236 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65236 Log: refactoring define AvailableOLE.sysmon_available? * test/win32ole/test_win32ole_type_event.rb: refactoring. use AvailableOLE.sysmon_available? * test/win32ole/available_ole.rb: define AvailableOLE.sysmon_available? Added files: trunk/test/win32ole/available_ole.rb Modified files: trunk/test/win32ole/test_win32ole_type_event.rb Index: test/win32ole/test_win32ole_type_event.rb =================================================================== --- test/win32ole/test_win32ole_type_event.rb (revision 65235) +++ test/win32ole/test_win32ole_type_event.rb (revision 65236) @@ -7,15 +7,10 @@ end https://github.com/ruby/ruby/blob/trunk/test/win32ole/test_win32ole_type_event.rb#L7 require 'test/unit' if defined?(WIN32OLE_TYPE) - def sysmon_available? - WIN32OLE_TYPE.new('System Monitor Control', 'SystemMonitor') - true - rescue - false - end + require_relative 'available_ole' class TestWIN32OLE_TYPE_EVENT < Test::Unit::TestCase - unless sysmon_available? + unless AvailableOLE.sysmon_available? def test_dummy_for_skip_message skip 'System Monitor Control is not available' end Index: test/win32ole/available_ole.rb =================================================================== --- test/win32ole/available_ole.rb (nonexistent) +++ test/win32ole/available_ole.rb (revision 65236) @@ -0,0 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/test/win32ole/available_ole.rb#L1 +begin + require 'win32ole' +rescue LoadError +end + +if defined?(WIN32OLE) + module AvailableOLE + module_function + + def sysmon_available? + WIN32OLE_TYPE.new('System Monitor Control', 'SystemMonitor') + true + rescue + false + end + end +end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/