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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9855222330a767946be0b647797086cda4513eee3813e87d5aa6b0a7ed246b1b
4
- data.tar.gz: 549a65285d0ef8f09c8f1a07054973f7bc317a9f039b0957ebe4fe7a79b27ea7
3
+ metadata.gz: 60baeb22867d9f1b436e4ab27cf588224f168aa1fa26db06bc1b8750b92d784c
4
+ data.tar.gz: 0c86df74a65049916202344feeeaa727fafdd6c6442f118cc538c950a64e0471
5
5
  SHA512:
6
- metadata.gz: 499ef63790c67f397444e6cb88f4a7d533d0313cd94be3d4f95e1b9c54a5ff68e01ad701340f82a483ca4683dcb4874e26f3fcd6ae50cb4dedb173cdb8e1a68c
7
- data.tar.gz: b21908c6e3069ea74d7d32e7ad61d7f475144d046c077b2de18c82b85373ae24ba2bbcad1e039c7ba9c9dfcb389d639404e39907ada83efb05e85143a0e01fd0
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", "< 11.0"
9
+ gem "rake", ">= 12.3.3"
10
10
  gem "json", "~> 2.5.1"
11
- gem "rspec", "~> 2.8.0"
11
+ gem "rspec", "~> 3.10.0"
12
12
  gem "bundler"
13
- gem "jeweler", "~> 2.3.9"
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.0)
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.1.3)
9
- faraday (0.9.2)
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
- git (1.8.1)
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.16.0)
14
- addressable (~> 2.4.0)
31
+ github_api (0.19.0)
32
+ addressable (~> 2.4)
15
33
  descendants_tracker (~> 0.0.4)
16
- faraday (~> 0.8, < 0.10)
17
- hashie (>= 3.4)
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 (4.1.0)
37
+ hashie (3.6.0)
21
38
  highline (2.0.3)
22
- jeweler (2.3.9)
39
+ json (2.5.1)
40
+ juwelier (2.4.9)
23
41
  builder
24
42
  bundler
25
- git (>= 1.2.5)
26
- github_api (~> 0.16.0)
27
- highline (>= 1.6.15)
28
- nokogiri (>= 1.5.10)
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
- json (2.5.1)
34
- jwt (2.2.2)
35
- mime-types (2.99.3)
36
- mini_portile2 (2.5.0)
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.11.3)
41
- mini_portile2 (~> 2.5.0)
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 (3.3.1)
50
- racc (1.5.2)
51
- rack (2.2.3)
52
- rake (10.5.0)
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.0)
55
- rspec (2.8.0)
56
- rspec-core (~> 2.8.0)
57
- rspec-expectations (~> 2.8.0)
58
- rspec-mocks (~> 2.8.0)
59
- rspec-core (2.8.0)
60
- rspec-expectations (2.8.0)
61
- diff-lcs (~> 1.1.2)
62
- rspec-mocks (2.8.0)
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
- rake (< 11.0)
74
- rspec (~> 2.8.0)
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 'jeweler'
15
- Jeweler::Tasks.new do |gem|
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
- Jeweler::RubygemsDotOrgTasks.new
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) do |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.2
1
+ 0.5.5
@@ -1,2 +1,2 @@
1
1
  #include <ruby/ruby.h>
2
- #import <Foundation/Foundation.h>
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
- image = CGDisplayCreateImageForRect((CGDirectDisplayID)0, CGRectMake(intX, intY, 1, 1));
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
- width = (int)CGDisplayPixelsWide((CGDirectDisplayID)0);
41
- height = (int)CGDisplayPixelsHigh((CGDirectDisplayID)0);
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.h'
2
- require 'util.h'
1
+ require 'event_dispatcher'
2
+ require 'util'
3
3
 
4
4
  module Mac
5
5
  class Robot
6
- class Error < StandardError; end
7
- class OutOfResolution < Error; end
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
- raise OutOfResolution if display_pixel_size.width < x || display_pixel_size.height < y
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(unit, wheel_count, scroll_y, scroll_x, scroll_z)
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 [scroll_y, scroll_x, scroll_z]
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
@@ -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 do
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(:y => 10) # down 10 lines
24
- subject.scroll_wheel(:y => -10) # up 10 lines
25
- subject.scroll_wheel_pixel(:x => 10, :y => -20, :z => 5)
26
- subject.scroll_wheel_pixel(:y => 20, :x => -10, :z => -5)
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.should be_a_kind_of(Float)
43
- color.green.should be_a_kind_of(Float)
44
- color.blue.should be_a_kind_of(Float)
45
- color.alpha.should be_a_kind_of(Float)
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
- lambda {
51
- subject.get_pixel_color(p, 0)
52
- }.should raise_error(Mac::Robot::OutOfResolution)
48
+ expect { subject.get_pixel_color(p, 0) }.to raise_error(
49
+ Mac::Robot::OutOfResolution
50
+ )
53
51
 
54
- lambda {
55
- subject.get_pixel_color(0, p)
56
- }.should raise_error(Mac::Robot::OutOfResolution)
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.should be_a_kind_of(Float)
65
- color.green.should be_a_kind_of(Float)
66
- color.blue.should be_a_kind_of(Float)
67
- color.alpha.should be_a_kind_of(Float)
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.should eql(20)
75
- subject.mouse_current_location.y.should eql(0)
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.2
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: 2021-04-16 00:00:00.000000000 Z
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: '11.0'
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: '11.0'
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: 2.8.0
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: 2.8.0
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: jeweler
70
+ name: juwelier
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 2.3.9
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.3.9
82
+ version: 2.4.9
83
83
  description: A Library to Automate User Interactions
84
84
  email: youpy@buycheapviagraonlinenow.com
85
85
  executables: []