mac-robot 0.5.2 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/Gemfile.lock +63 -37
- data/Rakefile +4 -6
- data/VERSION +1 -1
- data/ext/event_dispatcher/event_dispatcher.h +1 -1
- data/ext/util/util.m +5 -3
- data/lib/mac-robot.rb +19 -15
- data/mac-robot.gemspec +0 -0
- data/spec/mac-robot_spec.rb +21 -23
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60baeb22867d9f1b436e4ab27cf588224f168aa1fa26db06bc1b8750b92d784c
|
4
|
+
data.tar.gz: 0c86df74a65049916202344feeeaa727fafdd6c6442f118cc538c950a64e0471
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92bddcbf3718d54c33785ac0b5cf95d92b276d0cd2e49eb5b6e479bca4e5f5425695a8d1f4fb6f2c5cb67921614fcd3e68bd39608a963a01e661b448626de6d7
|
7
|
+
data.tar.gz: cfb2d6448dfac40197d8117176b9c0880817f76ba85614d80afc21b8459ea891e79e052ca28c9c3f5d9c03963bd162b66af2e8e84ebbdf50058dbd386b518cb3
|
data/Gemfile
CHANGED
@@ -6,9 +6,9 @@ source "http://rubygems.org"
|
|
6
6
|
# Add dependencies to develop your gem here.
|
7
7
|
# Include everything needed to run rake, tests, features, etc.
|
8
8
|
group :development do
|
9
|
-
gem "rake", "
|
9
|
+
gem "rake", ">= 12.3.3"
|
10
10
|
gem "json", "~> 2.5.1"
|
11
|
-
gem "rspec", "~>
|
11
|
+
gem "rspec", "~> 3.10.0"
|
12
12
|
gem "bundler"
|
13
|
-
gem "
|
13
|
+
gem "juwelier", "~> 2.4.9"
|
14
14
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,44 +1,63 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
addressable (2.
|
4
|
+
addressable (2.8.0)
|
5
|
+
public_suffix (>= 2.0.2, < 5.0)
|
5
6
|
builder (3.2.4)
|
6
7
|
descendants_tracker (0.0.4)
|
7
8
|
thread_safe (~> 0.3, >= 0.3.1)
|
8
|
-
diff-lcs (1.
|
9
|
-
faraday (
|
9
|
+
diff-lcs (1.4.4)
|
10
|
+
faraday (1.8.0)
|
11
|
+
faraday-em_http (~> 1.0)
|
12
|
+
faraday-em_synchrony (~> 1.0)
|
13
|
+
faraday-excon (~> 1.1)
|
14
|
+
faraday-httpclient (~> 1.0.1)
|
15
|
+
faraday-net_http (~> 1.0)
|
16
|
+
faraday-net_http_persistent (~> 1.1)
|
17
|
+
faraday-patron (~> 1.0)
|
18
|
+
faraday-rack (~> 1.0)
|
10
19
|
multipart-post (>= 1.2, < 3)
|
11
|
-
|
20
|
+
ruby2_keywords (>= 0.0.4)
|
21
|
+
faraday-em_http (1.0.0)
|
22
|
+
faraday-em_synchrony (1.0.0)
|
23
|
+
faraday-excon (1.1.0)
|
24
|
+
faraday-httpclient (1.0.1)
|
25
|
+
faraday-net_http (1.0.1)
|
26
|
+
faraday-net_http_persistent (1.2.0)
|
27
|
+
faraday-patron (1.0.0)
|
28
|
+
faraday-rack (1.0.0)
|
29
|
+
git (1.11.0)
|
12
30
|
rchardet (~> 1.8)
|
13
|
-
github_api (0.
|
14
|
-
addressable (~> 2.4
|
31
|
+
github_api (0.19.0)
|
32
|
+
addressable (~> 2.4)
|
15
33
|
descendants_tracker (~> 0.0.4)
|
16
|
-
faraday (
|
17
|
-
hashie (>= 3.
|
18
|
-
mime-types (>= 1.16, < 3.0)
|
34
|
+
faraday (>= 0.8, < 2)
|
35
|
+
hashie (~> 3.5, >= 3.5.2)
|
19
36
|
oauth2 (~> 1.0)
|
20
|
-
hashie (
|
37
|
+
hashie (3.6.0)
|
21
38
|
highline (2.0.3)
|
22
|
-
|
39
|
+
json (2.5.1)
|
40
|
+
juwelier (2.4.9)
|
23
41
|
builder
|
24
42
|
bundler
|
25
|
-
git
|
26
|
-
github_api
|
27
|
-
highline
|
28
|
-
|
43
|
+
git
|
44
|
+
github_api
|
45
|
+
highline
|
46
|
+
kamelcase (~> 0)
|
47
|
+
nokogiri
|
29
48
|
psych
|
30
49
|
rake
|
31
50
|
rdoc
|
32
51
|
semver2
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
mini_portile2 (2.
|
52
|
+
jwt (2.3.0)
|
53
|
+
kamelcase (0.0.2)
|
54
|
+
semver2 (~> 3)
|
55
|
+
mini_portile2 (2.8.0)
|
37
56
|
multi_json (1.15.0)
|
38
57
|
multi_xml (0.6.0)
|
39
58
|
multipart-post (2.1.1)
|
40
|
-
nokogiri (1.
|
41
|
-
mini_portile2 (~> 2.
|
59
|
+
nokogiri (1.13.6)
|
60
|
+
mini_portile2 (~> 2.8.0)
|
42
61
|
racc (~> 1.4)
|
43
62
|
oauth2 (1.4.7)
|
44
63
|
faraday (>= 0.8, < 2.0)
|
@@ -46,20 +65,27 @@ GEM
|
|
46
65
|
multi_json (~> 1.3)
|
47
66
|
multi_xml (~> 0.5)
|
48
67
|
rack (>= 1.2, < 3)
|
49
|
-
psych (
|
50
|
-
|
51
|
-
|
52
|
-
|
68
|
+
psych (4.0.2)
|
69
|
+
public_suffix (4.0.6)
|
70
|
+
racc (1.6.0)
|
71
|
+
rack (2.2.3.1)
|
72
|
+
rake (13.0.6)
|
53
73
|
rchardet (1.8.0)
|
54
|
-
rdoc (6.3.
|
55
|
-
rspec (
|
56
|
-
rspec-core (~>
|
57
|
-
rspec-expectations (~>
|
58
|
-
rspec-mocks (~>
|
59
|
-
rspec-core (
|
60
|
-
|
61
|
-
|
62
|
-
|
74
|
+
rdoc (6.3.3)
|
75
|
+
rspec (3.10.0)
|
76
|
+
rspec-core (~> 3.10.0)
|
77
|
+
rspec-expectations (~> 3.10.0)
|
78
|
+
rspec-mocks (~> 3.10.0)
|
79
|
+
rspec-core (3.10.1)
|
80
|
+
rspec-support (~> 3.10.0)
|
81
|
+
rspec-expectations (3.10.1)
|
82
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
83
|
+
rspec-support (~> 3.10.0)
|
84
|
+
rspec-mocks (3.10.2)
|
85
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
86
|
+
rspec-support (~> 3.10.0)
|
87
|
+
rspec-support (3.10.3)
|
88
|
+
ruby2_keywords (0.0.5)
|
63
89
|
semver2 (3.4.2)
|
64
90
|
thread_safe (0.3.6)
|
65
91
|
|
@@ -68,10 +94,10 @@ PLATFORMS
|
|
68
94
|
|
69
95
|
DEPENDENCIES
|
70
96
|
bundler
|
71
|
-
jeweler (~> 2.3.9)
|
72
97
|
json (~> 2.5.1)
|
73
|
-
|
74
|
-
|
98
|
+
juwelier (~> 2.4.9)
|
99
|
+
rake (>= 12.3.3)
|
100
|
+
rspec (~> 3.10.0)
|
75
101
|
|
76
102
|
BUNDLED WITH
|
77
103
|
2.1.4
|
data/Rakefile
CHANGED
@@ -11,8 +11,8 @@ rescue Bundler::BundlerError => e
|
|
11
11
|
end
|
12
12
|
require 'rake'
|
13
13
|
|
14
|
-
require '
|
15
|
-
|
14
|
+
require 'juwelier'
|
15
|
+
Juwelier::Tasks.new do |gem|
|
16
16
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
17
|
gem.name = "mac-robot"
|
18
18
|
gem.homepage = "http://github.com/youpy/mac-robot"
|
@@ -23,7 +23,7 @@ Jeweler::Tasks.new do |gem|
|
|
23
23
|
gem.authors = ["youpy"]
|
24
24
|
# dependencies defined in Gemfile
|
25
25
|
end
|
26
|
-
|
26
|
+
Juwelier::RubygemsDotOrgTasks.new
|
27
27
|
|
28
28
|
# rule to build the extension: this says
|
29
29
|
# that the extension should be rebuilt
|
@@ -51,8 +51,6 @@ end
|
|
51
51
|
|
52
52
|
require 'rspec/core'
|
53
53
|
require 'rspec/core/rake_task'
|
54
|
-
RSpec::Core::RakeTask.new(:spec)
|
55
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
56
|
-
end
|
54
|
+
RSpec::Core::RakeTask.new(:spec)
|
57
55
|
|
58
56
|
task :default => :spec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.5
|
@@ -1,2 +1,2 @@
|
|
1
1
|
#include <ruby/ruby.h>
|
2
|
-
#import <
|
2
|
+
#import <CoreGraphics/CoreGraphics.h>
|
data/ext/util/util.m
CHANGED
@@ -15,7 +15,8 @@ static VALUE mUtil_get_pixel_color(int argc, VALUE *argv, VALUE self)
|
|
15
15
|
intX = NUM2INT(x);
|
16
16
|
intY = NUM2INT(y);
|
17
17
|
|
18
|
-
|
18
|
+
CGDirectDisplayID displayID = CGMainDisplayID();
|
19
|
+
image = CGDisplayCreateImageForRect(displayID, CGRectMake(intX, intY, 1, 1));
|
19
20
|
bitmap = [[NSBitmapImageRep alloc] initWithCGImage:image];
|
20
21
|
CGImageRelease(image);
|
21
22
|
color = [bitmap colorAtX:0 y:0];
|
@@ -37,8 +38,9 @@ static VALUE mUtil_get_display_pixel_size(int argc, VALUE *argv, VALUE self)
|
|
37
38
|
int width, height;
|
38
39
|
VALUE result;
|
39
40
|
|
40
|
-
|
41
|
-
|
41
|
+
CGDirectDisplayID displayID = CGMainDisplayID();
|
42
|
+
width = (int)CGDisplayPixelsWide(displayID);
|
43
|
+
height = (int)CGDisplayPixelsHigh(displayID);
|
42
44
|
|
43
45
|
result = rb_ary_new();
|
44
46
|
rb_ary_push(result, INT2NUM(width));
|
data/lib/mac-robot.rb
CHANGED
@@ -1,18 +1,16 @@
|
|
1
|
-
require 'event_dispatcher
|
2
|
-
require 'util
|
1
|
+
require 'event_dispatcher'
|
2
|
+
require 'util'
|
3
3
|
|
4
4
|
module Mac
|
5
5
|
class Robot
|
6
|
-
class Error < StandardError
|
7
|
-
|
6
|
+
class Error < StandardError
|
7
|
+
end
|
8
|
+
class OutOfResolution < Error
|
9
|
+
end
|
8
10
|
|
9
11
|
attr_reader :x, :y
|
10
12
|
|
11
|
-
BUTTONS = {
|
12
|
-
:left => 0,
|
13
|
-
:right => 1,
|
14
|
-
:center => 2
|
15
|
-
}
|
13
|
+
BUTTONS = { left: 0, right: 1, center: 2 }
|
16
14
|
|
17
15
|
def initialize
|
18
16
|
@x = 0
|
@@ -70,16 +68,16 @@ module Mac
|
|
70
68
|
|
71
69
|
def get_pixel_color(x, y)
|
72
70
|
raise OutOfResolution if x < 0 || y < 0
|
73
|
-
|
71
|
+
if display_pixel_size.width < x || display_pixel_size.height < y
|
72
|
+
raise OutOfResolution
|
73
|
+
end
|
74
74
|
|
75
75
|
# workarownd for exeption occurs when x == display_pixel_size.width
|
76
76
|
#
|
77
77
|
# *** Assertion failure in -[NSBitmapImageRep initWithCGImage:], /SourceCache/AppKit/AppKit-1265/AppKit.subproj/NSBitmapImageRep.m:1286
|
78
78
|
# An uncaught exception was raised
|
79
79
|
# Invalid parameter not satisfying: cgImage != NULL
|
80
|
-
if display_pixel_size.width == x
|
81
|
-
x = x - 0.1
|
82
|
-
end
|
80
|
+
x = x - 0.1 if display_pixel_size.width == x
|
83
81
|
|
84
82
|
color = Util.get_pixel_color(x, y)
|
85
83
|
Struct.new(:red, :green, :blue, :alpha).new(*color)
|
@@ -97,7 +95,13 @@ module Mac
|
|
97
95
|
|
98
96
|
def scroll_wheel_event(unit, scroll_y, scroll_x = 0, scroll_z = 0)
|
99
97
|
wheel_count = 3
|
100
|
-
@dispatcher.dispatchScrollWheelEvent(
|
98
|
+
@dispatcher.dispatchScrollWheelEvent(
|
99
|
+
unit,
|
100
|
+
wheel_count,
|
101
|
+
scroll_y,
|
102
|
+
scroll_x,
|
103
|
+
scroll_z
|
104
|
+
)
|
101
105
|
end
|
102
106
|
|
103
107
|
def scroll_count_extract(args = {})
|
@@ -118,7 +122,7 @@ module Mac
|
|
118
122
|
end
|
119
123
|
end
|
120
124
|
|
121
|
-
return
|
125
|
+
return scroll_y, scroll_x, scroll_z
|
122
126
|
end
|
123
127
|
|
124
128
|
def keyboard_event(keycode, keydown)
|
data/mac-robot.gemspec
CHANGED
Binary file
|
data/spec/mac-robot_spec.rb
CHANGED
@@ -2,9 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
|
3
3
|
# how to test???
|
4
4
|
describe Mac::Robot do
|
5
|
-
subject
|
6
|
-
Mac::Robot.new
|
7
|
-
end
|
5
|
+
subject { Mac::Robot.new }
|
8
6
|
|
9
7
|
describe 'mouse event' do
|
10
8
|
it 'should simulate mouse event' do
|
@@ -20,10 +18,10 @@ describe Mac::Robot do
|
|
20
18
|
|
21
19
|
describe 'scroll wheel event' do
|
22
20
|
it 'should simulate scroll wheel event' do
|
23
|
-
subject.scroll_wheel_line(:
|
24
|
-
subject.scroll_wheel(:
|
25
|
-
subject.scroll_wheel_pixel(:
|
26
|
-
subject.scroll_wheel_pixel(:
|
21
|
+
subject.scroll_wheel_line(y: 10) # down 10 lines
|
22
|
+
subject.scroll_wheel(y: -10) # up 10 lines
|
23
|
+
subject.scroll_wheel_pixel(x: 10, y: -20, z: 5)
|
24
|
+
subject.scroll_wheel_pixel(y: 20, x: -10, z: -5)
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
@@ -39,21 +37,21 @@ describe Mac::Robot do
|
|
39
37
|
describe 'color' do
|
40
38
|
it 'should get color from given coordinate' do
|
41
39
|
color = subject.get_pixel_color(0, 0)
|
42
|
-
color.red.
|
43
|
-
color.green.
|
44
|
-
color.blue.
|
45
|
-
color.alpha.
|
40
|
+
expect(color.red).to be_a_kind_of(Float)
|
41
|
+
expect(color.green).to be_a_kind_of(Float)
|
42
|
+
expect(color.blue).to be_a_kind_of(Float)
|
43
|
+
expect(color.alpha).to be_a_kind_of(Float)
|
46
44
|
end
|
47
45
|
|
48
46
|
it 'should raise if given coordinate is out of resolution' do
|
49
47
|
[9999, -1].each do |p|
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
expect { subject.get_pixel_color(p, 0) }.to raise_error(
|
49
|
+
Mac::Robot::OutOfResolution
|
50
|
+
)
|
53
51
|
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
expect { subject.get_pixel_color(0, p) }.to raise_error(
|
53
|
+
Mac::Robot::OutOfResolution
|
54
|
+
)
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
@@ -61,18 +59,18 @@ describe Mac::Robot do
|
|
61
59
|
display_pixel_size = subject.display_pixel_size
|
62
60
|
|
63
61
|
color = subject.get_pixel_color(display_pixel_size.width, 0)
|
64
|
-
color.red.
|
65
|
-
color.green.
|
66
|
-
color.blue.
|
67
|
-
color.alpha.
|
62
|
+
expect(color.red).to be_a_kind_of(Float)
|
63
|
+
expect(color.green).to be_a_kind_of(Float)
|
64
|
+
expect(color.blue).to be_a_kind_of(Float)
|
65
|
+
expect(color.alpha).to be_a_kind_of(Float)
|
68
66
|
end
|
69
67
|
end
|
70
68
|
|
71
69
|
describe 'current mouse location' do
|
72
70
|
it 'should have current mouse location' do
|
73
71
|
subject.mouse_move(20, 0)
|
74
|
-
subject.mouse_current_location.x.
|
75
|
-
subject.mouse_current_location.y.
|
72
|
+
expect(subject.mouse_current_location.x).to eql(20)
|
73
|
+
expect(subject.mouse_current_location.y).to eql(0)
|
76
74
|
end
|
77
75
|
end
|
78
76
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mac-robot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- youpy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 12.3.3
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 12.3.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 3.10.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 3.10.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,19 +67,19 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: juwelier
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 2.
|
75
|
+
version: 2.4.9
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 2.
|
82
|
+
version: 2.4.9
|
83
83
|
description: A Library to Automate User Interactions
|
84
84
|
email: youpy@buycheapviagraonlinenow.com
|
85
85
|
executables: []
|