sikulinewrc 0.0.3 → 0.0.4

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/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in sikulirc.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sikulirc.gemspec
4
+ gemspec
data/LICENSE CHANGED
@@ -1,22 +1,22 @@
1
- Copyright (c) 2012 TODO: Write your name
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1
+ Copyright (c) 2012 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
22
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,40 +1,40 @@
1
- # Sikulirc
2
-
3
- Ruby wrapped client API of sikuli server
4
-
5
- ## Installation
6
-
7
- To get Sikuli Server, Please go to http://github.com/enix12enix/sikuli-remote-control and follow instruction
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- gem 'sikulirc', :git => 'git://github.com/powerkx/sikulirc.git'
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install sikulirc
20
-
21
- ## Usage
22
-
23
- require 'sikulirc'
24
-
25
- rs = Sikulirc::RemoteScreen.new("127.0.0.1")
26
- rs.click "D:\\1.png"
27
- rs.app_focus "title"
28
- rs.type_in_field "D:\\field.png", "content"
29
- rs.page_down
30
- rs.wait "D:\\field.png"
31
- rs.find "D:\\field.png"
32
- rs.set_min_similarity 0.9
33
-
34
- ## Contributing
35
-
36
- 1. Fork it
37
- 2. Create your feature branch (`git checkout -b my-new-feature`)
38
- 3. Commit your changes (`git commit -am 'Added some feature'`)
39
- 4. Push to the branch (`git push origin my-new-feature`)
40
- 5. Create new Pull Request
1
+ # Sikulinewrc
2
+
3
+ Ruby wrapped client API of sikuli server
4
+
5
+ ## Installation
6
+
7
+ To get Sikuli Server, Please go to http://github.com/enix12enix/sikuli-remote-control and follow instruction
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'sikulinewrc', :git => 'git://github.com/powerkx/sikulinewrc.git'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install sikulinewrc
20
+
21
+ ## Usage
22
+
23
+ require 'sikulinewrc'
24
+
25
+ rs = Sikulinewrc::RemoteScreen.new("127.0.0.1")
26
+ rs.click "D:\\1.png"
27
+ rs.app_focus "title"
28
+ rs.type_in_field "D:\\field.png", "content"
29
+ rs.page_down
30
+ rs.wait "D:\\field.png"
31
+ rs.find "D:\\field.png"
32
+ rs.set_min_similarity 0.9
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -1,47 +1,47 @@
1
- require 'net/http'
2
-
3
- module Sikulirc
4
- module Command
5
-
6
- COMMANDS = {}
7
-
8
- def self.load
9
- Dir.foreach(File.expand_path("../commands/", __FILE__)) do |file_name|
10
- if file_name == ".." or file_name == "."
11
- next
12
- end
13
- cmd = {}
14
- File.open(File.expand_path("../commands/#{file_name}", __FILE__)).each_with_index do |line, index|
15
- cmd["cmd#{index}"] = line.tr("\n", '')
16
- end
17
- COMMANDS[file_name] = cmd
18
- end
19
- end
20
-
21
- load
22
-
23
- def execute_command(uri, cmd_name, args_hash=nil, &block)
24
- req = Net::HTTP::Post.new(uri.path)
25
- req.set_form_data(args_hash.nil? ? {"type"=> "sikuli"}.merge(COMMANDS.fetch(cmd_name)) : {"type"=> "sikuli"}.merge(COMMANDS.fetch(cmd_name)).merge(build_arg(args_hash)))
26
- res = Net::HTTP.start(uri.hostname, uri.port) do |http|
27
- http.request(req)
28
- end
29
- if block_given?
30
- yield res.body
31
- else
32
- res.body
33
- end
34
- end
35
-
36
- private
37
-
38
- def build_arg(args_hash)
39
- arg = Hash['args' => '|']
40
- args_hash.each do |k, v|
41
- arg['args'] = arg['args'] + "#{k}=#{v}|"
42
- end
43
- arg
44
- end
45
-
46
- end
47
- end
1
+ require 'net/http'
2
+
3
+ module Sikulinewrc
4
+ module Command
5
+
6
+ COMMANDS = {}
7
+
8
+ def self.load
9
+ Dir.foreach(File.expand_path("../commands/", __FILE__)) do |file_name|
10
+ if file_name == ".." or file_name == "."
11
+ next
12
+ end
13
+ cmd = {}
14
+ File.open(File.expand_path("../commands/#{file_name}", __FILE__)).each_with_index do |line, index|
15
+ cmd["cmd#{index}"] = line.tr("\n", '')
16
+ end
17
+ COMMANDS[file_name] = cmd
18
+ end
19
+ end
20
+
21
+ load
22
+
23
+ def execute_command(uri, cmd_name, args_hash=nil, &block)
24
+ req = Net::HTTP::Post.new(uri.path)
25
+ req.set_form_data(args_hash.nil? ? {"type"=> "sikuli"}.merge(COMMANDS.fetch(cmd_name)) : {"type"=> "sikuli"}.merge(COMMANDS.fetch(cmd_name)).merge(build_arg(args_hash)))
26
+ res = Net::HTTP.start(uri.hostname, uri.port) do |http|
27
+ http.request(req)
28
+ end
29
+ if block_given?
30
+ yield res.body
31
+ else
32
+ res.body
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def build_arg(args_hash)
39
+ arg = Hash['args' => '|']
40
+ args_hash.each do |k, v|
41
+ arg['args'] = arg['args'] + "#{k}=#{v}|"
42
+ end
43
+ arg
44
+ end
45
+
46
+ end
47
+ end
@@ -1,2 +1,2 @@
1
- from sikuli.Sikuli import App
1
+ from sikuli.Sikuli import App
2
2
  App.focus(content)
@@ -1,4 +1,4 @@
1
- from sikuli.Sikuli import Screen
2
- scr = Screen()
3
- scr.wait(psc, int(timeout))
1
+ from sikuli.Sikuli import Screen
2
+ scr = Screen()
3
+ scr.wait(psc, int(timeout))
4
4
  scr.click(psc)
@@ -1,5 +1,5 @@
1
- from sikuli.Sikuli import Screen, Location
2
-
3
- scr = Screen()
4
- t = scr.find(psc)
5
- scr.dragDrop(t, t.offset(Location(int(xoffset), int(yoffset))))
1
+ from sikuli.Sikuli import Screen, Location
2
+
3
+ scr = Screen()
4
+ t = scr.find(psc)
5
+ scr.dragDrop(t, t.offset(Location(int(xoffset), int(yoffset))))
@@ -1,3 +1,3 @@
1
- from sikuli.Sikuli import Screen
2
- scr = Screen()
1
+ from sikuli.Sikuli import Screen
2
+ scr = Screen()
3
3
  scr.find(psc)
@@ -1,5 +1,5 @@
1
- from sikuli.Sikuli import Screen, Key
2
- import time
3
- scr=Screen()
4
- time.sleep(3)
1
+ from sikuli.Sikuli import Screen, Key
2
+ import time
3
+ scr=Screen()
4
+ time.sleep(3)
5
5
  scr.type(Key.PAGE_DOWN)
@@ -0,0 +1,2 @@
1
+ from sikuli.Sikuli import Settings
2
+ Settings.MinSimilarity=float(similarity)
@@ -1,5 +1,5 @@
1
- from sikuli.Sikuli import Screen, KEY_CTRL, Key
2
- scr = Screen()
3
- scr.type(psc, 'a', KEY_CTRL)
4
- scr.type(Key.BACKSPACE)
1
+ from sikuli.Sikuli import Screen, KEY_CTRL, Key
2
+ scr = Screen()
3
+ scr.type(psc, 'a', KEY_CTRL)
4
+ scr.type(Key.BACKSPACE)
5
5
  scr.paste(psc, content)
@@ -1,3 +1,3 @@
1
- from sikuli.Sikuli import Screen
2
- scr = Screen()
1
+ from sikuli.Sikuli import Screen
2
+ scr = Screen()
3
3
  scr.wait(psc, int(timeout))
@@ -1,7 +1,7 @@
1
- module Sikulirc
2
-
3
- class ImageNotFound < StandardError; end
4
-
5
- class CommandError < StandardError; end
6
-
7
- end
1
+ module Sikulinewrc
2
+
3
+ class ImageNotFound < StandardError; end
4
+
5
+ class CommandError < StandardError; end
6
+
7
+ end
@@ -1,65 +1,65 @@
1
- # require "sikulirc/command"
2
-
3
- require "rexml/document"
4
- require "uri"
5
-
6
- module Sikulirc
7
- class RemoteScreen
8
- include Command
9
- include REXML
10
-
11
- def initialize(server, port="9000")
12
- @serv = URI("http://#{server}:#{port}/script.do")
13
- end
14
-
15
- def app_focus(app)
16
- execute_command(@serv, 'set_min_similarity', :content => app)
17
- end
18
-
19
- def page_down
20
- execute_command(@serv, "page_down")
21
- end
22
-
23
- def set_min_similarity(similarity = 0.7)
24
- execute_command(@serv, 'set_min_similarity', :similarity => similarity)
25
- end
26
-
27
- def click(psc, timeout = 120)
28
- execute_command(@serv, "click", :psc => psc, :timeout => timeout) { |xml_dump| process_result(xml_dump, psc) }
29
- end
30
-
31
- def find(psc)
32
- execute_command(@serv, 'find', :psc => psc) { |xml_dump| process_result(xml_dump, psc) }
33
- end
34
-
35
- def type_in_field(psc, content)
36
- execute_command(@serv, 'type_in_field', :psc => psc, :content => content) { |xml_dump| process_result(xml_dump, psc) }
37
- end
38
-
39
- def wait(psc, timeout = 120)
40
- execute_command(@serv, "wait", :psc => psc, :timeout => timeout) { |xml_dump| process_result(xml_dump, psc) }
41
- end
42
-
43
- def drag_drop(psc, xoffset, yoffset)
44
- execute_command(@serv, "drag_drop", :psc => psc, :xoffset => xoffset, :yoffset => yoffset)
45
- end
46
-
47
- private
48
-
49
- def raise_exception(exception_message, psc)
50
- if exception_message.include? "FindFailed: can not find"
51
- raise Sikulirc::ImageNotFound, "The image '#{psc}' does not exist."
52
- else
53
- raise Sikulirc::CommandError, "Something wrong with the command.\n\n#{exception_message}"
54
- end
55
- end
56
-
57
- def process_result(xml_dump, psc)
58
- doc = Document.new(xml_dump)
59
- if doc.elements["/script/status"].text == "FAIL"
60
- raise_exception(doc.elements["//message"].text, psc)
61
- end
62
- end
63
-
64
- end
65
- end
1
+ # require "sikulinewrc/command"
2
+
3
+ require "rexml/document"
4
+ require "uri"
5
+
6
+ module Sikulinewrc
7
+ class RemoteScreen
8
+ include Command
9
+ include REXML
10
+
11
+ def initialize(server, port="9000")
12
+ @serv = URI("http://#{server}:#{port}/script.do")
13
+ end
14
+
15
+ def app_focus(content)
16
+ execute_command(@serv, 'app_focus', :content => content)
17
+ end
18
+
19
+ def page_down
20
+ execute_command(@serv, "page_down")
21
+ end
22
+
23
+ def set_min_similarity(similarity = 0.7)
24
+ execute_command(@serv, 'set_min_similarity', :similarity => similarity)
25
+ end
26
+
27
+ def click(psc, timeout = 120)
28
+ execute_command(@serv, "click", :psc => psc, :timeout => timeout) { |xml_dump| process_result(xml_dump, psc) }
29
+ end
30
+
31
+ def find(psc)
32
+ execute_command(@serv, 'find', :psc => psc) { |xml_dump| process_result(xml_dump, psc) }
33
+ end
34
+
35
+ def type_in_field(psc, content)
36
+ execute_command(@serv, 'type_in_field', :psc => psc, :content => content) { |xml_dump| process_result(xml_dump, psc) }
37
+ end
38
+
39
+ def wait(psc, timeout = 120)
40
+ execute_command(@serv, "wait", :psc => psc, :timeout => timeout) { |xml_dump| process_result(xml_dump, psc) }
41
+ end
42
+
43
+ def drag_drop(psc, xoffset, yoffset)
44
+ execute_command(@serv, "drag_drop", :psc => psc, :xoffset => xoffset, :yoffset => yoffset)
45
+ end
46
+
47
+ private
48
+
49
+ def raise_exception(exception_message, psc)
50
+ if exception_message.include? "FindFailed: can not find"
51
+ raise Sikulinewrc::ImageNotFound, "The image '#{psc}' does not exist."
52
+ else
53
+ raise Sikulinewrc::CommandError, "Something wrong with the command.\n\n#{exception_message}"
54
+ end
55
+ end
56
+
57
+ def process_result(xml_dump, psc)
58
+ doc = Document.new(xml_dump)
59
+ if doc.elements["/script/status"].text == "FAIL"
60
+ raise_exception(doc.elements["//message"].text, psc)
61
+ end
62
+ end
63
+
64
+ end
65
+ end
@@ -0,0 +1,3 @@
1
+ module Sikulinewrc
2
+ VERSION = "0.0.4"
3
+ end
@@ -0,0 +1,9 @@
1
+ require "sikulinewrc/version"
2
+
3
+ require "sikulinewrc/command"
4
+ require "sikulinewrc/exception"
5
+ require "sikulinewrc/remote_screen"
6
+
7
+ module Sikulinewrc
8
+
9
+ end
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'rake'
3
+
4
+ $:.push File.expand_path("../lib", __FILE__)
5
+ require "sikulinewrc/version"
6
+
7
+ Gem::Specification.new do |gem|
8
+ gem.authors = ["David Wang"]
9
+ gem.email = ["davidwangm@hotmail.com"]
10
+ gem.description = %q{Allows you to call sikuli remote server.}
11
+ gem.summary = %q{Ruby wrapped for sikuli remote server client api}
12
+ gem.homepage = "http://github.com/powerkx/sikulinewrc"
13
+
14
+ gem.files = FileList['lib/**/*', 'bin/*', '[A-Z]*', 'test/**/*'].to_a
15
+ gem.name = "sikulinewrc"
16
+ gem.require_paths = ["lib"]
17
+ gem.version = Sikulinewrc::VERSION
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sikulinewrc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-17 00:00:00.000000000 Z
12
+ date: 2014-06-23 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Allows you to call sikuli remote server.
15
15
  email:
@@ -18,25 +18,25 @@ executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
- - lib/sikulirc/command.rb
22
- - lib/sikulirc/commands/app_focus
23
- - lib/sikulirc/commands/click
24
- - lib/sikulirc/commands/drag_drop
25
- - lib/sikulirc/commands/find
26
- - lib/sikulirc/commands/page_down
27
- - lib/sikulirc/commands/set_min_similarity
28
- - lib/sikulirc/commands/type_in_field
29
- - lib/sikulirc/commands/wait
30
- - lib/sikulirc/exception.rb
31
- - lib/sikulirc/remote_screen.rb
32
- - lib/sikulirc/version.rb
33
- - lib/sikulirc.rb
21
+ - lib/sikulinewrc/command.rb
22
+ - lib/sikulinewrc/commands/app_focus
23
+ - lib/sikulinewrc/commands/click
24
+ - lib/sikulinewrc/commands/drag_drop
25
+ - lib/sikulinewrc/commands/find
26
+ - lib/sikulinewrc/commands/page_down
27
+ - lib/sikulinewrc/commands/set_min_similarity
28
+ - lib/sikulinewrc/commands/type_in_field
29
+ - lib/sikulinewrc/commands/wait
30
+ - lib/sikulinewrc/exception.rb
31
+ - lib/sikulinewrc/remote_screen.rb
32
+ - lib/sikulinewrc/version.rb
33
+ - lib/sikulinewrc.rb
34
34
  - Gemfile
35
35
  - LICENSE
36
36
  - Rakefile
37
37
  - README.md
38
- - sikulirc.gemspec
39
- homepage: http://github.com/powerkx/sikulirc
38
+ - sikulinewrc.gemspec
39
+ homepage: http://github.com/powerkx/sikulinewrc
40
40
  licenses: []
41
41
  post_install_message:
42
42
  rdoc_options: []
@@ -1,2 +0,0 @@
1
- from sikuli.Sikuli import Settings
2
- Settings.MinSimilarity=float(similarity)
@@ -1,3 +0,0 @@
1
- module Sikulirc
2
- VERSION = "0.0.3"
3
- end
data/lib/sikulirc.rb DELETED
@@ -1,9 +0,0 @@
1
- require "sikulirc/version"
2
-
3
- require "sikulirc/command"
4
- require "sikulirc/exception"
5
- require "sikulirc/remote_screen"
6
-
7
- module Sikulirc
8
-
9
- end
data/sikulirc.gemspec DELETED
@@ -1,18 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require 'rake'
3
-
4
- $:.push File.expand_path("../lib", __FILE__)
5
- require "sikulirc/version"
6
-
7
- Gem::Specification.new do |gem|
8
- gem.authors = ["David Wang"]
9
- gem.email = ["davidwangm@hotmail.com"]
10
- gem.description = %q{Allows you to call sikuli remote server.}
11
- gem.summary = %q{Ruby wrapped for sikuli remote server client api}
12
- gem.homepage = "http://github.com/powerkx/sikulirc"
13
-
14
- gem.files = FileList['lib/**/*', 'bin/*', '[A-Z]*', 'test/**/*'].to_a
15
- gem.name = "sikulinewrc"
16
- gem.require_paths = ["lib"]
17
- gem.version = Sikulirc::VERSION
18
- end