win_gui 0.2.15 → 0.2.16
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +4 -0
- data/VERSION +1 -1
- data/lib/win_gui/{application.rb → app.rb} +22 -17
- data/lib/win_gui/window.rb +1 -2
- data/spec/extension_spec.rb +1 -1
- data/spec/win_gui/{application_spec.rb → app_spec.rb} +11 -1
- data/spec/win_gui/convenience_spec.rb +1 -1
- data/spec/win_gui/window_spec.rb +1 -1
- metadata +7 -7
data/HISTORY
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.16
|
@@ -8,13 +8,13 @@ module WinGui
|
|
8
8
|
|
9
9
|
def initialize(window_or_handle)
|
10
10
|
@main_window = case window_or_handle
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
when Window
|
12
|
+
window_or_handle
|
13
|
+
when Integer
|
14
|
+
Window.new window_or_handle
|
15
|
+
else
|
16
|
+
raise WinGui::Errors::InitError, "Unable to create App from #{window_or_handle.inspect}"
|
17
|
+
end
|
18
18
|
end
|
19
19
|
|
20
20
|
# Exits application (optionally waiting _timeout_ seconds for main window to close)
|
@@ -25,8 +25,9 @@ module WinGui
|
|
25
25
|
sleep SLEEP_DELAY while @main_window.window?
|
26
26
|
end
|
27
27
|
end
|
28
|
-
# @main_window.wait_for_close(timeout) if timeout
|
28
|
+
# @main_window.wait_for_close(timeout) if timeout - does not work as Window#wait_for_close relies on window_visible?
|
29
29
|
end
|
30
|
+
|
30
31
|
alias_method :exit, :close
|
31
32
|
|
32
33
|
class << self
|
@@ -40,7 +41,6 @@ module WinGui
|
|
40
41
|
#
|
41
42
|
def find(opts)
|
42
43
|
main_window = Window.top_level(opts)
|
43
|
-
# raise WinGui::Errors::InitError, "Unable to find App with #{opts.inspect}" unless main_window
|
44
44
|
main_window ? new(main_window) : nil
|
45
45
|
end
|
46
46
|
|
@@ -72,20 +72,25 @@ module WinGui
|
|
72
72
|
|
73
73
|
def launch_app(app_path, dir_path)
|
74
74
|
|
75
|
-
|
76
|
-
command = cygwin? ? "cmd /c start `cygpath -w #{
|
75
|
+
app = cygwin? ? app_path.to_s : app_path.to_s.gsub(/\//, "\\")
|
76
|
+
command = cygwin? ? "cmd /c start `cygpath -w #{app}`" : "start #{app}"
|
77
77
|
|
78
78
|
if dir_path
|
79
|
-
|
80
|
-
|
79
|
+
dir = cygwin? ? dir_path.to_s : dir_path.to_s.gsub(/\//, "\\")
|
80
|
+
unless File.exists?(dir) && File.directory?(dir)
|
81
|
+
raise WinGui::Errors::InitError, "Unable to change to #{dir_path.inspect}"
|
82
|
+
end
|
83
|
+
unless File.exists?(app) || File.exists?(File.join(dir, app))
|
84
|
+
raise WinGui::Errors::InitError, "Unable to launch #{app_path.inspect}"
|
85
|
+
end
|
86
|
+
command = "cd #{dir} && #{command}"
|
87
|
+
else
|
88
|
+
raise WinGui::Errors::InitError, "Unable to launch #{app_path.inspect}" unless File.exists? app
|
81
89
|
end
|
82
90
|
|
83
91
|
# Launch App in a separate window
|
84
|
-
|
85
|
-
system command # TODO: make sure only valid commands are fed into system
|
86
|
-
p "Returned from system"
|
92
|
+
system command # TODO: make sure only valid commands are fed into system
|
87
93
|
end
|
88
|
-
|
89
94
|
end
|
90
95
|
end
|
91
96
|
end
|
data/lib/win_gui/window.rb
CHANGED
@@ -15,7 +15,7 @@ module WinGui
|
|
15
15
|
# Private method to dry up other window lookup methods
|
16
16
|
#
|
17
17
|
def lookup_window(opts) # :yields: index, position
|
18
|
-
# Need this to avoid handle considered local in begin..end block
|
18
|
+
# Need this to avoid handle considered local var in begin..end block
|
19
19
|
handle = yield
|
20
20
|
if opts[:timeout]
|
21
21
|
begin
|
@@ -41,7 +41,6 @@ module WinGui
|
|
41
41
|
def top_level(opts={})
|
42
42
|
lookup_window(opts) { WinGui.find_window opts[:class], opts[:title] }
|
43
43
|
end
|
44
|
-
|
45
44
|
alias_method :find, :top_level
|
46
45
|
end
|
47
46
|
|
data/spec/extension_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative "../spec_helper.rb"
|
2
2
|
|
3
3
|
module WinGuiTest
|
4
4
|
|
@@ -69,6 +69,16 @@ module WinGuiTest
|
|
69
69
|
expect { App.launch(path: APP_PATH, title: IMPOSSIBLE) }.
|
70
70
|
to raise_error WinGui::Errors::InitError, /Unable to launch App with .*?:title=>"Impossible"/
|
71
71
|
end
|
72
|
+
|
73
|
+
it 'changes to given valid directory before launch' do
|
74
|
+
use { @app = App.launch(dir: APP_PATH.sub(/LockNote.exe/, ''), path: 'Locknote.exe', title: WIN_TITLE) }
|
75
|
+
@app.should be_an App
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'raises error if given invalid directory to change' do
|
79
|
+
expect { @app = App.launch(dir: APP_PATH, path: APP_PATH, title: WIN_TITLE) }.
|
80
|
+
to raise_error WinGui::Errors::InitError, /Unable to change to ".*LockNote.exe"/
|
81
|
+
end
|
72
82
|
end
|
73
83
|
|
74
84
|
context 'properties:' do
|
data/spec/win_gui/window_spec.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: win_gui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 55
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 16
|
10
|
+
version: 0.2.16
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- arvicco
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-06 00:00:00 +04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -77,14 +77,14 @@ extra_rdoc_files:
|
|
77
77
|
files:
|
78
78
|
- lib/extension.rb
|
79
79
|
- lib/version.rb
|
80
|
-
- lib/win_gui/
|
80
|
+
- lib/win_gui/app.rb
|
81
81
|
- lib/win_gui/convenience.rb
|
82
82
|
- lib/win_gui/window.rb
|
83
83
|
- lib/win_gui.rb
|
84
84
|
- spec/extension_spec.rb
|
85
85
|
- spec/spec.opts
|
86
86
|
- spec/spec_helper.rb
|
87
|
-
- spec/win_gui/
|
87
|
+
- spec/win_gui/app_spec.rb
|
88
88
|
- spec/win_gui/convenience_spec.rb
|
89
89
|
- spec/win_gui/window_spec.rb
|
90
90
|
- features/step_definitions/win_gui_steps.rb
|
@@ -145,6 +145,6 @@ test_files:
|
|
145
145
|
- spec/extension_spec.rb
|
146
146
|
- spec/spec.opts
|
147
147
|
- spec/spec_helper.rb
|
148
|
-
- spec/win_gui/
|
148
|
+
- spec/win_gui/app_spec.rb
|
149
149
|
- spec/win_gui/convenience_spec.rb
|
150
150
|
- spec/win_gui/window_spec.rb
|