accessibility_core 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,17 @@
1
+ # 0.3.4 - More adjustments for AXElements
2
+
3
+ * Add `NSContainsRect()` for MRI
4
+ * Add `CGRect#contains?` as equivalent of `NSContainsRect()`
5
+ * Change `Object#spin` to use `NSRunLoop` instead of `CFRunLoop`
6
+ (they are not as equivalent as the docs led me to believe)
7
+ * Change `Object#spin` to take a default argument of 0 seconds
8
+
9
+
1
10
  # 0.3.3 - The real 0.3.2 release
2
11
 
3
12
  * Release the real 0.3.2 gem, none of this non-regenerating gem bull
4
13
 
14
+
5
15
  # 0.3.2 - Adjustments for AXElements
6
16
 
7
17
  * Fix `Element#children` raising when AXAPI returns failure error code
@@ -5,7 +5,9 @@
5
5
  void
6
6
  spin(double seconds)
7
7
  {
8
- CFRunLoopRunInMode(kCFRunLoopDefaultMode, seconds, false);
8
+ NSDate* interval = [NSDate dateWithTimeIntervalSinceNow:seconds];
9
+ [[NSRunLoop currentRunLoop] runUntilDate:interval];
10
+ [interval release];
9
11
  }
10
12
 
11
13
 
@@ -555,9 +557,13 @@ to_ax(VALUE obj)
555
557
 
556
558
  static
557
559
  VALUE
558
- rb_spin(VALUE self, VALUE seconds)
560
+ rb_spin(int argc, VALUE* argv, VALUE self)
559
561
  {
560
- spin(NUM2DBL(seconds));
562
+ if (argc == 0)
563
+ spin(0);
564
+ else
565
+ spin(NUM2DBL(argv[0]));
566
+
561
567
  return self;
562
568
  }
563
569
 
@@ -588,6 +594,6 @@ Init_bridge()
588
594
  rb_mURI = rb_const_get(rb_cObject, rb_intern("URI"));
589
595
  rb_cURI = rb_const_get(rb_mURI, rb_intern("Generic"));
590
596
 
591
- rb_define_method(rb_cObject, "spin", rb_spin, 1); // semi-private method
597
+ rb_define_method(rb_cObject, "spin", rb_spin, -1); // semi-private method
592
598
  #endif
593
599
  }
@@ -26,6 +26,28 @@ class CGRect
26
26
  def to_rect
27
27
  self
28
28
  end
29
+
30
+ ##
31
+ # Whether or not the receiver completely encloses the `inner` rect
32
+ #
33
+ # On MacRuby this is equivalent to calling `NSContainsRect()`.
34
+ #
35
+ # @param inner [CGRect,#to_rect]
36
+ # @return [Boolean]
37
+ def contains? inner
38
+ ox = origin.x; oy = origin.y; ow = size.width; oh = size.height
39
+
40
+ inner = inner.to_rect
41
+ ix = inner.origin.x; iy = inner.origin.y
42
+ iw = inner.size.width; ih = inner.size.height
43
+
44
+ if iw.zero? || ih.zero?
45
+ false
46
+ else
47
+ (ox <= ix) && (oy <= iy) &&
48
+ ((ox + ow) >= (ix + iw)) && ((oy + oh) >= (iy + ih))
49
+ end
50
+ end
29
51
  end
30
52
 
31
53
  ##
@@ -50,6 +50,19 @@ class NSObject
50
50
  def to_ruby
51
51
  self
52
52
  end
53
+
54
+ ##
55
+ # @api semi-private
56
+ #
57
+ # Spin the run loop for the given number of seconds
58
+ #
59
+ # The script will effectively be paused while the run loop
60
+ # is "spinning".
61
+ #
62
+ # @param seconds [Number]
63
+ def spin seconds = 0
64
+ NSRunLoop.currentRunLoop.runUntilDate Time.now + seconds
65
+ end
53
66
  end
54
67
 
55
68
  ##
@@ -187,20 +200,3 @@ class NSArray
187
200
  map do |obj| obj.to_ruby end
188
201
  end
189
202
  end
190
-
191
- ##
192
- # `accessibility-core` extensions to `Object`
193
- class Object
194
-
195
- ##
196
- # Spin the run loop for the given number of seconds
197
- #
198
- # The script will effectively be paused while the run loop
199
- # is "spinning".
200
- #
201
- # @param seconds [Number]
202
- def spin seconds
203
- CFRunLoopRunInMode(KCFRunLoopDefaultMode, seconds, false)
204
- end
205
-
206
- end
@@ -127,6 +127,16 @@ class Object
127
127
  def to_ruby
128
128
  self
129
129
  end
130
+
131
+ ##
132
+ # Whether or not the `outer` rect completely encloses the `inner` rect
133
+ #
134
+ # @param outer [CGRect,#to_rect]
135
+ # @param inner [CGRect,#to_rect]
136
+ # @return [Boolean]
137
+ def NSContainsRect outer, inner
138
+ outer.to_rect.contains? inner
139
+ end
130
140
  end
131
141
 
132
142
  ##
@@ -138,4 +148,6 @@ class Array
138
148
  end
139
149
  end
140
150
 
151
+
141
152
  require 'accessibility/bridge/common'
153
+ require 'accessibility/bridge/bridge.bundle'
@@ -746,7 +746,7 @@ module Accessibility::Element
746
746
  KAXErrorCannotComplete => [
747
747
  RuntimeError,
748
748
  lambda { |*args|
749
- NSRunLoop.currentRunLoop.runUntilDate Time.now # spin the run loop once
749
+ spin # spin the run loop once
750
750
  pid = args[0].pid
751
751
  app = NSRunningApplication.runningApplicationWithProcessIdentifier pid
752
752
  if app
@@ -6,6 +6,6 @@ module Accessibility
6
6
  # Namespace for `accessibility_core` specific classes
7
7
  module Core
8
8
  # return [String]
9
- VERSION = '0.3.3'
9
+ VERSION = '0.3.4'
10
10
  end
11
11
  end
@@ -1,3 +1,5 @@
1
+ $LOAD_PATH << 'lib'
2
+
1
3
  require 'minitest/autorun'
2
4
  require 'minitest/pride'
3
5
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: accessibility_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  segments:
109
109
  - 0
110
- hash: -679855353235967514
110
+ hash: -3361611520076368904
111
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  none: false
113
113
  requirements:
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  segments:
118
118
  - 0
119
- hash: -679855353235967514
119
+ hash: -3361611520076368904
120
120
  requirements: []
121
121
  rubyforge_project:
122
122
  rubygems_version: 1.8.24