sikuli 0.1.2 → 0.1.3
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/README.md +5 -2
- data/lib/sikuli.rb +1 -23
- data/lib/sikuli/config.rb +24 -0
- data/lib/sikuli/key_code.rb +12 -14
- data/lib/sikuli/searchable.rb +1 -0
- data/lib/sikuli/version.rb +1 -1
- data/spec/{sikuli_spec.rb → sikuli/config_spec.rb} +15 -6
- data/spec/sikuli/searchable_spec.rb +4 -0
- data/spec/spec_helper.rb +2 -2
- metadata +4 -3
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Sikuli Ruby
|
|
6
6
|
Requirements
|
7
7
|
------------
|
8
8
|
|
9
|
-
* JRuby
|
9
|
+
* JRuby `rvm install jruby`
|
10
10
|
* [Sikuli X 1.0rc2](http://sikuli.org/)
|
11
11
|
* OSX
|
12
12
|
|
@@ -21,7 +21,10 @@ Usage
|
|
21
21
|
require 'java'
|
22
22
|
require 'sikuli'
|
23
23
|
|
24
|
-
Sikuli.
|
24
|
+
Sikuli::Config.run do |config|
|
25
|
+
config.image_path = "#{Dir.pwd}/images/"
|
26
|
+
config.logging = false
|
27
|
+
end
|
25
28
|
|
26
29
|
screen = Sikuli::Screen.new
|
27
30
|
screen.click(10, 10) # should open your apple menu
|
data/lib/sikuli.rb
CHANGED
@@ -5,26 +5,4 @@ require "sikuli/app"
|
|
5
5
|
require "sikuli/region"
|
6
6
|
require "sikuli/screen"
|
7
7
|
require "sikuli/key_code"
|
8
|
-
|
9
|
-
module Sikuli
|
10
|
-
include KeyCode
|
11
|
-
|
12
|
-
def self.getImagePath
|
13
|
-
paths = java.lang.System.getProperty("SIKULI_IMAGE_PATH") || ""
|
14
|
-
paths.split(":")
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.addImagePath(path)
|
18
|
-
paths = self.getImagePath
|
19
|
-
paths << path
|
20
|
-
|
21
|
-
java.lang.System.setProperty("SIKULI_IMAGE_PATH", paths.join(':'))
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.logging=(boolean)
|
25
|
-
return unless [TrueClass, FalseClass].include? boolean.class
|
26
|
-
org.sikuli.script::Settings.InfoLogs = boolean
|
27
|
-
org.sikuli.script::Settings.ActionLogs = boolean
|
28
|
-
org.sikuli.script::Settings.DebugLogs = boolean
|
29
|
-
end
|
30
|
-
end
|
8
|
+
require "sikuli/config"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Sikuli
|
2
|
+
class Config
|
3
|
+
def self.image_path
|
4
|
+
java.lang.System.getProperty("SIKULI_IMAGE_PATH")
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.image_path=(path)
|
8
|
+
java.lang.System.setProperty("SIKULI_IMAGE_PATH", path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.logging=(boolean)
|
12
|
+
return unless [TrueClass, FalseClass].include? boolean.class
|
13
|
+
org.sikuli.script::Settings.InfoLogs = boolean
|
14
|
+
org.sikuli.script::Settings.ActionLogs = boolean
|
15
|
+
org.sikuli.script::Settings.DebugLogs = boolean
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.run(*args)
|
19
|
+
if block_given?
|
20
|
+
yield self
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/sikuli/key_code.rb
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
module Sikuli
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
RIGHT_ARROW = nil
|
15
|
-
end
|
2
|
+
KEY_CMD = java.awt.event.InputEvent::META_MASK
|
3
|
+
KEY_SHIFT = java.awt.event.InputEvent::SHIFT_MASK
|
4
|
+
KEY_CTRL = java.awt.event.InputEvent::CTRL_MASK
|
5
|
+
KEY_ALT = java.awt.event.InputEvent::ALT_MASK
|
6
|
+
|
7
|
+
KEY_BACKSPACE = "\u0008"
|
8
|
+
KEY_RETURN = "\n"
|
9
|
+
|
10
|
+
UP_ARROW = nil
|
11
|
+
LEFT_ARROW = "\ue003"
|
12
|
+
DOWN_ARROW = nil
|
13
|
+
RIGHT_ARROW = nil
|
16
14
|
end
|
data/lib/sikuli/searchable.rb
CHANGED
data/lib/sikuli/version.rb
CHANGED
@@ -1,17 +1,24 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Sikuli
|
3
|
+
describe Sikuli::Config do
|
4
4
|
it "should retain a list of directories to search in for images" do
|
5
|
-
Sikuli.
|
5
|
+
Sikuli::Config.image_path = ""
|
6
|
+
java.lang.System.getProperty("SIKULI_IMAGE_PATH").should == ""
|
6
7
|
end
|
7
8
|
|
8
9
|
it "should allow a path to be added" do
|
9
|
-
Sikuli.
|
10
|
-
|
10
|
+
Sikuli::Config.run do |config|
|
11
|
+
config.image_path = '/Users/images/'
|
12
|
+
end
|
13
|
+
|
14
|
+
java.lang.System.getProperty("SIKULI_IMAGE_PATH").should == '/Users/images/'
|
15
|
+
Sikuli::Config.image_path.should == '/Users/images/'
|
11
16
|
end
|
12
17
|
|
13
18
|
it "should allow logging to be turned on" do
|
14
|
-
Sikuli.
|
19
|
+
Sikuli::Config.run do |config|
|
20
|
+
config.logging = true
|
21
|
+
end
|
15
22
|
|
16
23
|
org.sikuli.script::Settings.InfoLogs.should be_true
|
17
24
|
org.sikuli.script::Settings.ActionLogs.should be_true
|
@@ -19,7 +26,9 @@ describe Sikuli, "image path" do
|
|
19
26
|
end
|
20
27
|
|
21
28
|
it "should allow logging to be turned off" do
|
22
|
-
Sikuli.
|
29
|
+
Sikuli::Config.run do |config|
|
30
|
+
config.logging = false
|
31
|
+
end
|
23
32
|
|
24
33
|
org.sikuli.script::Settings.InfoLogs.should be_false
|
25
34
|
org.sikuli.script::Settings.ActionLogs.should be_false
|
@@ -22,6 +22,10 @@ describe Sikuli::Region, "#Searchable" do
|
|
22
22
|
@region.exists?("smiley_face.png").should be_true
|
23
23
|
end
|
24
24
|
|
25
|
+
it "should allow you to call contains?" do
|
26
|
+
@region.contains?("smiley_face.png").should be_true
|
27
|
+
end
|
28
|
+
|
25
29
|
it "should return false if the image is not found" do
|
26
30
|
@region.exists?("apple.png").should be_false
|
27
31
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,10 +3,10 @@ require 'java'
|
|
3
3
|
require 'rspec'
|
4
4
|
require 'sikuli'
|
5
5
|
|
6
|
-
Sikuli.logging = false
|
6
|
+
Sikuli::Config.logging = false
|
7
7
|
|
8
8
|
def setup_test_area
|
9
|
-
Sikuli.
|
9
|
+
Sikuli::Config.image_path = "#{Dir.pwd}/spec/support/images/"
|
10
10
|
screen = Sikuli::Screen.new
|
11
11
|
app = Sikuli::App.new('Preview')
|
12
12
|
app.focus()
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: sikuli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Chas Lemley
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- lib/sikuli.rb
|
42
42
|
- lib/sikuli/app.rb
|
43
43
|
- lib/sikuli/clickable.rb
|
44
|
+
- lib/sikuli/config.rb
|
44
45
|
- lib/sikuli/key_code.rb
|
45
46
|
- lib/sikuli/region.rb
|
46
47
|
- lib/sikuli/screen.rb
|
@@ -51,11 +52,11 @@ files:
|
|
51
52
|
- sikuli.gemspec
|
52
53
|
- spec/sikuli/app_spec.rb
|
53
54
|
- spec/sikuli/clickable_spec.rb
|
55
|
+
- spec/sikuli/config_spec.rb
|
54
56
|
- spec/sikuli/region_spec.rb
|
55
57
|
- spec/sikuli/screen_spec.rb
|
56
58
|
- spec/sikuli/searchable_spec.rb
|
57
59
|
- spec/sikuli/typeable_spec.rb
|
58
|
-
- spec/sikuli_spec.rb
|
59
60
|
- spec/spec_helper.rb
|
60
61
|
- spec/support/images/.DS_Store
|
61
62
|
- spec/support/images/apple.png
|
@@ -92,11 +93,11 @@ summary: Ruby wrapper for Sikuli GUI automation library
|
|
92
93
|
test_files:
|
93
94
|
- spec/sikuli/app_spec.rb
|
94
95
|
- spec/sikuli/clickable_spec.rb
|
96
|
+
- spec/sikuli/config_spec.rb
|
95
97
|
- spec/sikuli/region_spec.rb
|
96
98
|
- spec/sikuli/screen_spec.rb
|
97
99
|
- spec/sikuli/searchable_spec.rb
|
98
100
|
- spec/sikuli/typeable_spec.rb
|
99
|
-
- spec/sikuli_spec.rb
|
100
101
|
- spec/spec_helper.rb
|
101
102
|
- spec/support/images/.DS_Store
|
102
103
|
- spec/support/images/apple.png
|