win_gui 0.2.18 → 0.2.19

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/HISTORY CHANGED
@@ -77,3 +77,7 @@
77
77
  == 0.2.18 / 2011-02-17
78
78
 
79
79
  * Full Regexp support for Window find operations
80
+
81
+ == 0.2.19 / 2011-02-22
82
+
83
+ * Command line arguments in WinGui::App.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.18
1
+ 0.2.19
data/lib/win_gui/app.rb CHANGED
@@ -56,8 +56,9 @@ module WinGui
56
56
  def launch(opts)
57
57
  app_path = opts.delete(:path) || opts.delete(:app_path)
58
58
  dir_path = opts.delete(:dir) || opts.delete(:cd)
59
+ args = opts.delete(:args) || opts.delete(:argv)
59
60
 
60
- launch_app app_path, dir_path
61
+ launch_app app_path, dir_path, args
61
62
 
62
63
  defaults = {timeout: LAUNCH_TIMEOUT,
63
64
  raise: WinGui::Errors::InitError.new("Unable to launch App with #{opts.inspect}")}
@@ -70,10 +71,11 @@ module WinGui
70
71
  @cygwin_flag ||= RUBY_PLATFORM =~ /cygwin/
71
72
  end
72
73
 
73
- def launch_app(app_path, dir_path)
74
+ def launch_app(app_path, dir_path, args = nil)
74
75
 
75
76
  app = cygwin? ? app_path.to_s : app_path.to_s.gsub(/\//, "\\")
76
77
  command = cygwin? ? "cmd /c start `cygpath -w #{app}`" : "start #{app}"
78
+ command += " #{args}" if args
77
79
 
78
80
  if dir_path
79
81
  dir = cygwin? ? dir_path.to_s : dir_path.to_s.gsub(/\//, "\\")
@@ -61,7 +61,7 @@ module WinGui
61
61
  # :raise:: raise this exception instead of returning nil if nothing found
62
62
  #
63
63
  def top_level opts={}
64
- if opts[:class].is_a?(Regexp) or opts[:title].is_a?(Regexp)
64
+ if opts[:class].is_a?(Regexp) || opts[:title].is_a?(Regexp)
65
65
  lookup_window_in_collection(opts) { WinGui.enum_windows }
66
66
  else
67
67
  lookup_window(opts) { WinGui.find_window opts[:class], opts[:title] }
@@ -84,7 +84,7 @@ module WinGui
84
84
  def child(opts={})
85
85
  if opts[:indirect]
86
86
  self.class.lookup_window_in_collection(opts) { enum_child_windows }
87
- elsif opts[:class].is_a?(Regexp) or opts[:title].is_a?(Regexp)
87
+ elsif opts[:class].is_a?(Regexp) || opts[:title].is_a?(Regexp)
88
88
  self.class.lookup_window_in_collection(opts) do
89
89
  enum_child_windows.select { |handle| child? handle }
90
90
  end
@@ -18,6 +18,13 @@ describe WinGui::App do
18
18
  @app.main_window.should == window
19
19
  end
20
20
 
21
+ it 'wraps new App around existing Window, given a Regexp' do
22
+ window = Window.top_level(:title => Regexp.new(WIN_TITLE))
23
+ @app = App.new(window)
24
+ @app.should be_an App
25
+ @app.main_window.should == window
26
+ end
27
+
21
28
  it 'wraps new App around active window handle (of top-level Window)' do
22
29
  window = Window.top_level(title: WIN_TITLE)
23
30
  @app = App.new(window.handle)
@@ -42,6 +49,11 @@ describe WinGui::App do
42
49
  @app.should be_an App
43
50
  end
44
51
 
52
+ it 'finds already launched App given valid Regexp' do
53
+ use { @app = App.find(:title => Regexp.new(WIN_TITLE)) }
54
+ @app.should be_an App
55
+ end
56
+
45
57
  it 'returns nil if asked to find App with invalid Window info' do
46
58
  App.find(title: IMPOSSIBLE).should == nil
47
59
  end
@@ -58,6 +70,11 @@ describe WinGui::App do
58
70
  @app.should be_an App
59
71
  end
60
72
 
73
+ it 'launches new App given valid path and Regexp' do
74
+ use { @app = App.launch(:path => APP_PATH, :title => Regexp.new(WIN_TITLE)) }
75
+ @app.should be_an App
76
+ end
77
+
61
78
  it 'raises error if asked to launch App with invalid path' do
62
79
  expect { App.launch(path: IMPOSSIBLE, title: WIN_TITLE) }.
63
80
  to raise_error WinGui::Errors::InitError, /Unable to launch "Impossible"/
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: win_gui
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.18
5
+ version: 0.2.19
6
6
  platform: ruby
7
7
  authors:
8
8
  - arvicco
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-17 00:00:00 +03:00
13
+ date: 2011-02-22 00:00:00 +03:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency