mac-robot 0.5.4 → 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: a90d5f3016c0cc810bcaa51f9cb6949c7f9293661bcbaa1b7880e958d6a0e24e
4
- data.tar.gz: 81f6896b40a2c5f9cfeb624ee6883f2f95aa9e4fcb4ec4e2678cfe4eb73dcdc6
3
+ metadata.gz: 60baeb22867d9f1b436e4ab27cf588224f168aa1fa26db06bc1b8750b92d784c
4
+ data.tar.gz: 0c86df74a65049916202344feeeaa727fafdd6c6442f118cc538c950a64e0471
5
5
  SHA512:
6
- metadata.gz: c23a9f13609200d5dad63b928a9ca95fa49d524b202b8db2a9f73a8021dd97feecd4bcdec7beebdf5c36ccabb561e22de6f2af4b7654b61d10b8df9a6ca57f46
7
- data.tar.gz: 8044b323b5ac28bf8a835eb0167990ea11063168a52a9b80a895fe0661c0029fb25ac2792dd7bd93b4413f41605312858fa30f9f2aab4e4a40e077b585ff525d
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
13
  gem "juwelier", "~> 2.4.9"
14
14
  end
data/Gemfile.lock CHANGED
@@ -6,7 +6,7 @@ GEM
6
6
  builder (3.2.4)
7
7
  descendants_tracker (0.0.4)
8
8
  thread_safe (~> 0.3, >= 0.3.1)
9
- diff-lcs (1.1.3)
9
+ diff-lcs (1.4.4)
10
10
  faraday (1.8.0)
11
11
  faraday-em_http (~> 1.0)
12
12
  faraday-em_synchrony (~> 1.0)
@@ -26,7 +26,7 @@ GEM
26
26
  faraday-net_http_persistent (1.2.0)
27
27
  faraday-patron (1.0.0)
28
28
  faraday-rack (1.0.0)
29
- git (1.9.1)
29
+ git (1.11.0)
30
30
  rchardet (~> 1.8)
31
31
  github_api (0.19.0)
32
32
  addressable (~> 2.4)
@@ -52,12 +52,12 @@ GEM
52
52
  jwt (2.3.0)
53
53
  kamelcase (0.0.2)
54
54
  semver2 (~> 3)
55
- mini_portile2 (2.6.1)
55
+ mini_portile2 (2.8.0)
56
56
  multi_json (1.15.0)
57
57
  multi_xml (0.6.0)
58
58
  multipart-post (2.1.1)
59
- nokogiri (1.12.5)
60
- mini_portile2 (~> 2.6.1)
59
+ nokogiri (1.13.6)
60
+ mini_portile2 (~> 2.8.0)
61
61
  racc (~> 1.4)
62
62
  oauth2 (1.4.7)
63
63
  faraday (>= 0.8, < 2.0)
@@ -68,18 +68,23 @@ GEM
68
68
  psych (4.0.2)
69
69
  public_suffix (4.0.6)
70
70
  racc (1.6.0)
71
- rack (2.2.3)
72
- rake (10.5.0)
71
+ rack (2.2.3.1)
72
+ rake (13.0.6)
73
73
  rchardet (1.8.0)
74
74
  rdoc (6.3.3)
75
- rspec (2.8.0)
76
- rspec-core (~> 2.8.0)
77
- rspec-expectations (~> 2.8.0)
78
- rspec-mocks (~> 2.8.0)
79
- rspec-core (2.8.0)
80
- rspec-expectations (2.8.0)
81
- diff-lcs (~> 1.1.2)
82
- rspec-mocks (2.8.0)
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)
83
88
  ruby2_keywords (0.0.5)
84
89
  semver2 (3.4.2)
85
90
  thread_safe (0.3.6)
@@ -91,8 +96,8 @@ DEPENDENCIES
91
96
  bundler
92
97
  json (~> 2.5.1)
93
98
  juwelier (~> 2.4.9)
94
- rake (< 11.0)
95
- rspec (~> 2.8.0)
99
+ rake (>= 12.3.3)
100
+ rspec (~> 3.10.0)
96
101
 
97
102
  BUNDLED WITH
98
103
  2.1.4
data/Rakefile CHANGED
@@ -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.4
1
+ 0.5.5
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
@@ -3,16 +3,14 @@ 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.4
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-12-01 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