AXElements 0.9.0 → 1.0.0.alpha
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/.yardopts +0 -4
- data/README.markdown +22 -17
- data/Rakefile +1 -1
- data/ext/accessibility/key_coder/extconf.rb +1 -1
- data/ext/accessibility/key_coder/key_coder.c +2 -4
- data/lib/accessibility.rb +3 -3
- data/lib/accessibility/core.rb +948 -0
- data/lib/accessibility/dsl.rb +30 -186
- data/lib/accessibility/enumerators.rb +1 -0
- data/lib/accessibility/factory.rb +78 -134
- data/lib/accessibility/graph.rb +5 -9
- data/lib/accessibility/highlighter.rb +86 -0
- data/lib/accessibility/{pretty_printer.rb → pp_inspector.rb} +4 -3
- data/lib/accessibility/qualifier.rb +3 -5
- data/lib/accessibility/screen_recorder.rb +217 -0
- data/lib/accessibility/statistics.rb +57 -0
- data/lib/accessibility/translator.rb +23 -32
- data/lib/accessibility/version.rb +2 -22
- data/lib/ax/application.rb +20 -159
- data/lib/ax/element.rb +42 -32
- data/lib/ax/scroll_area.rb +5 -6
- data/lib/ax/systemwide.rb +1 -33
- data/lib/ax_elements.rb +1 -9
- data/lib/ax_elements/core_graphics_workaround.rb +5 -0
- data/lib/ax_elements/nsarray_compat.rb +17 -97
- data/lib/ax_elements/vendor/inflection_data.rb +66 -0
- data/lib/ax_elements/vendor/inflections.rb +176 -0
- data/lib/ax_elements/vendor/inflector.rb +306 -0
- data/lib/minitest/ax_elements.rb +180 -0
- data/lib/mouse.rb +227 -0
- data/lib/rspec/expectations/ax_elements.rb +234 -0
- data/rakelib/gem.rake +3 -12
- data/rakelib/test.rake +15 -0
- data/test/helper.rb +20 -10
- data/test/integration/accessibility/test_core.rb +18 -0
- data/test/integration/accessibility/test_dsl.rb +40 -38
- data/test/integration/accessibility/test_enumerators.rb +1 -0
- data/test/integration/accessibility/test_graph.rb +0 -1
- data/test/integration/accessibility/test_qualifier.rb +2 -2
- data/test/integration/ax/test_application.rb +2 -9
- data/test/integration/ax/test_element.rb +0 -40
- data/test/integration/minitest/test_ax_elements.rb +89 -0
- data/test/integration/rspec/expectations/test_ax_elements.rb +102 -0
- data/test/sanity/accessibility/test_factory.rb +2 -2
- data/test/sanity/accessibility/test_highlighter.rb +56 -0
- data/test/sanity/accessibility/{test_pretty_printer.rb → test_pp_inspector.rb} +9 -9
- data/test/sanity/accessibility/test_statistics.rb +57 -0
- data/test/sanity/ax/test_application.rb +1 -16
- data/test/sanity/ax/test_element.rb +2 -2
- data/test/sanity/ax_elements/test_nsobject_inspect.rb +2 -4
- data/test/sanity/minitest/test_ax_elements.rb +17 -0
- data/test/sanity/rspec/expectations/test_ax_elements.rb +15 -0
- data/test/sanity/test_mouse.rb +22 -0
- data/test/test_core.rb +454 -0
- metadata +44 -69
- data/History.markdown +0 -41
- data/lib/accessibility/system_info.rb +0 -230
- data/lib/ax_elements/active_support_selections.rb +0 -10
- data/lib/ax_elements/mri.rb +0 -57
- data/test/sanity/accessibility/test_version.rb +0 -15
metadata
CHANGED
@@ -1,80 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: AXElements
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 0.
|
4
|
+
prerelease: 6
|
5
|
+
version: 1.0.0.alpha
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mark Rada
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-10-28 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: minitest
|
16
16
|
prerelease: false
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
23
|
-
type: :
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 2.0.0
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: screen_recorder
|
32
|
-
prerelease: false
|
33
|
-
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
|
-
requirements:
|
36
|
-
- - ~>
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: 0.1.5
|
39
|
-
type: :runtime
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 0.1.5
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: accessibility_core
|
48
|
-
prerelease: false
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
|
-
requirements:
|
52
|
-
- - ~>
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.4.1
|
55
|
-
type: :runtime
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.4.1
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: activesupport
|
64
|
-
prerelease: false
|
65
|
-
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
|
-
requirements:
|
68
|
-
- - ~>
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: 3.2.10
|
71
|
-
type: :runtime
|
22
|
+
version: "4.1"
|
23
|
+
type: :development
|
72
24
|
version_requirements: !ruby/object:Gem::Requirement
|
73
25
|
none: false
|
74
26
|
requirements:
|
75
27
|
- - ~>
|
76
28
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
29
|
+
version: "4.1"
|
78
30
|
- !ruby/object:Gem::Dependency
|
79
31
|
name: yard
|
80
32
|
prerelease: false
|
@@ -92,21 +44,21 @@ dependencies:
|
|
92
44
|
- !ruby/object:Gem::Version
|
93
45
|
version: 0.8.3
|
94
46
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
47
|
+
name: redcarpet
|
96
48
|
prerelease: false
|
97
49
|
requirement: !ruby/object:Gem::Requirement
|
98
50
|
none: false
|
99
51
|
requirements:
|
100
52
|
- - ~>
|
101
53
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
54
|
+
version: "1.17"
|
103
55
|
type: :development
|
104
56
|
version_requirements: !ruby/object:Gem::Requirement
|
105
57
|
none: false
|
106
58
|
requirements:
|
107
59
|
- - ~>
|
108
60
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
61
|
+
version: "1.17"
|
110
62
|
description: 'AXElements is a UI automation DSL built on top of the Mac OS X Accessibility
|
111
63
|
|
112
64
|
Framework that allows code to be written in a very natural and declarative
|
@@ -120,15 +72,18 @@ extensions:
|
|
120
72
|
- ext/accessibility/key_coder/extconf.rb
|
121
73
|
extra_rdoc_files: []
|
122
74
|
files:
|
75
|
+
- lib/accessibility/core.rb
|
123
76
|
- lib/accessibility/dsl.rb
|
124
77
|
- lib/accessibility/enumerators.rb
|
125
78
|
- lib/accessibility/errors.rb
|
126
79
|
- lib/accessibility/factory.rb
|
127
80
|
- lib/accessibility/graph.rb
|
128
|
-
- lib/accessibility/
|
81
|
+
- lib/accessibility/highlighter.rb
|
82
|
+
- lib/accessibility/pp_inspector.rb
|
129
83
|
- lib/accessibility/qualifier.rb
|
84
|
+
- lib/accessibility/screen_recorder.rb
|
85
|
+
- lib/accessibility/statistics.rb
|
130
86
|
- lib/accessibility/string.rb
|
131
|
-
- lib/accessibility/system_info.rb
|
132
87
|
- lib/accessibility/translator.rb
|
133
88
|
- lib/accessibility/version.rb
|
134
89
|
- lib/accessibility.rb
|
@@ -142,13 +97,18 @@ files:
|
|
142
97
|
- lib/ax/scroll_area.rb
|
143
98
|
- lib/ax/static_text.rb
|
144
99
|
- lib/ax/systemwide.rb
|
145
|
-
- lib/ax_elements/active_support_selections.rb
|
146
100
|
- lib/ax_elements/awesome_print.rb
|
101
|
+
- lib/ax_elements/core_graphics_workaround.rb
|
147
102
|
- lib/ax_elements/exception_workaround.rb
|
148
|
-
- lib/ax_elements/mri.rb
|
149
103
|
- lib/ax_elements/nsarray_compat.rb
|
104
|
+
- lib/ax_elements/vendor/inflection_data.rb
|
105
|
+
- lib/ax_elements/vendor/inflections.rb
|
106
|
+
- lib/ax_elements/vendor/inflector.rb
|
150
107
|
- lib/ax_elements.rb
|
151
108
|
- lib/AXElements.rb
|
109
|
+
- lib/minitest/ax_elements.rb
|
110
|
+
- lib/mouse.rb
|
111
|
+
- lib/rspec/expectations/ax_elements.rb
|
152
112
|
- ext/accessibility/key_coder/extconf.rb
|
153
113
|
- ext/accessibility/key_coder/key_coder.c
|
154
114
|
- rakelib/doc.rake
|
@@ -157,8 +117,8 @@ files:
|
|
157
117
|
- rakelib/test.rake
|
158
118
|
- Rakefile
|
159
119
|
- README.markdown
|
160
|
-
- History.markdown
|
161
120
|
- .yardopts
|
121
|
+
- test/integration/accessibility/test_core.rb
|
162
122
|
- test/integration/accessibility/test_dsl.rb
|
163
123
|
- test/integration/accessibility/test_enumerators.rb
|
164
124
|
- test/integration/accessibility/test_errors.rb
|
@@ -169,21 +129,28 @@ files:
|
|
169
129
|
- test/integration/ax/test_menu.rb
|
170
130
|
- test/integration/ax/test_row.rb
|
171
131
|
- test/integration/ax_elements/test_nsarray_compat.rb
|
132
|
+
- test/integration/minitest/test_ax_elements.rb
|
133
|
+
- test/integration/rspec/expectations/test_ax_elements.rb
|
172
134
|
- test/sanity/accessibility/test_dsl.rb
|
173
135
|
- test/sanity/accessibility/test_errors.rb
|
174
136
|
- test/sanity/accessibility/test_factory.rb
|
175
|
-
- test/sanity/accessibility/
|
137
|
+
- test/sanity/accessibility/test_highlighter.rb
|
138
|
+
- test/sanity/accessibility/test_pp_inspector.rb
|
176
139
|
- test/sanity/accessibility/test_qualifier.rb
|
140
|
+
- test/sanity/accessibility/test_statistics.rb
|
177
141
|
- test/sanity/accessibility/test_string.rb
|
178
142
|
- test/sanity/accessibility/test_translator.rb
|
179
|
-
- test/sanity/accessibility/test_version.rb
|
180
143
|
- test/sanity/ax/test_application.rb
|
181
144
|
- test/sanity/ax/test_element.rb
|
182
145
|
- test/sanity/ax/test_systemwide.rb
|
183
146
|
- test/sanity/ax_elements/test_nsarray_compat.rb
|
184
147
|
- test/sanity/ax_elements/test_nsobject_inspect.rb
|
148
|
+
- test/sanity/minitest/test_ax_elements.rb
|
149
|
+
- test/sanity/rspec/expectations/test_ax_elements.rb
|
185
150
|
- test/sanity/test_accessibility.rb
|
186
151
|
- test/sanity/test_ax_elements.rb
|
152
|
+
- test/sanity/test_mouse.rb
|
153
|
+
- test/test_core.rb
|
187
154
|
- test/helper.rb
|
188
155
|
homepage: http://github.com/Marketcircle/AXElements
|
189
156
|
licenses:
|
@@ -201,9 +168,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
201
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
169
|
none: false
|
203
170
|
requirements:
|
204
|
-
- - '
|
171
|
+
- - '>'
|
205
172
|
- !ruby/object:Gem::Version
|
206
|
-
version:
|
173
|
+
version: 1.3.1
|
207
174
|
requirements: []
|
208
175
|
rubyforge_project:
|
209
176
|
rubygems_version: 1.8.24
|
@@ -211,6 +178,7 @@ signing_key:
|
|
211
178
|
specification_version: 3
|
212
179
|
summary: A DSL for automating GUI manipulation
|
213
180
|
test_files:
|
181
|
+
- test/integration/accessibility/test_core.rb
|
214
182
|
- test/integration/accessibility/test_dsl.rb
|
215
183
|
- test/integration/accessibility/test_enumerators.rb
|
216
184
|
- test/integration/accessibility/test_errors.rb
|
@@ -221,19 +189,26 @@ test_files:
|
|
221
189
|
- test/integration/ax/test_menu.rb
|
222
190
|
- test/integration/ax/test_row.rb
|
223
191
|
- test/integration/ax_elements/test_nsarray_compat.rb
|
192
|
+
- test/integration/minitest/test_ax_elements.rb
|
193
|
+
- test/integration/rspec/expectations/test_ax_elements.rb
|
224
194
|
- test/sanity/accessibility/test_dsl.rb
|
225
195
|
- test/sanity/accessibility/test_errors.rb
|
226
196
|
- test/sanity/accessibility/test_factory.rb
|
227
|
-
- test/sanity/accessibility/
|
197
|
+
- test/sanity/accessibility/test_highlighter.rb
|
198
|
+
- test/sanity/accessibility/test_pp_inspector.rb
|
228
199
|
- test/sanity/accessibility/test_qualifier.rb
|
200
|
+
- test/sanity/accessibility/test_statistics.rb
|
229
201
|
- test/sanity/accessibility/test_string.rb
|
230
202
|
- test/sanity/accessibility/test_translator.rb
|
231
|
-
- test/sanity/accessibility/test_version.rb
|
232
203
|
- test/sanity/ax/test_application.rb
|
233
204
|
- test/sanity/ax/test_element.rb
|
234
205
|
- test/sanity/ax/test_systemwide.rb
|
235
206
|
- test/sanity/ax_elements/test_nsarray_compat.rb
|
236
207
|
- test/sanity/ax_elements/test_nsobject_inspect.rb
|
208
|
+
- test/sanity/minitest/test_ax_elements.rb
|
209
|
+
- test/sanity/rspec/expectations/test_ax_elements.rb
|
237
210
|
- test/sanity/test_accessibility.rb
|
238
211
|
- test/sanity/test_ax_elements.rb
|
212
|
+
- test/sanity/test_mouse.rb
|
213
|
+
- test/test_core.rb
|
239
214
|
- test/helper.rb
|
data/History.markdown
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# 0.9.0
|
2
|
-
|
3
|
-
* AXElements can now run on MRI as well as MacRuby
|
4
|
-
|
5
|
-
* Added `DSL#pinch` to simulate pinch gestures
|
6
|
-
* Added `DSL#rotate` to simulate rotation gestures
|
7
|
-
* Added `DSL#swipe` to simulate swipe gestures
|
8
|
-
* Added `DSL#smart_magnify` to simulate smart magnification (two finger double tap)
|
9
|
-
* Added `DSL#horizontal_scroll`
|
10
|
-
* Added `DSL#contextual_menu` hack for finding contextual menus (WIP)
|
11
|
-
* Added `NSScreen.wakeup` to the `NSScreen` class to wake up sleeping displays
|
12
|
-
* Added `Accessibility::SystemInfo` for getting information about the running system
|
13
|
-
- Added a `Battery` module for querying information about the battery status
|
14
|
-
* Added `DSL#record` to run a screen recording of the given block (actual video!)
|
15
|
-
* Added `Application.frontmost_application`
|
16
|
-
* Added `Application.menu_bar_owner`
|
17
|
-
* Added `Application.finder`
|
18
|
-
* Added `Application.dock`
|
19
|
-
* Added `SystemWide.focused_application` as override of built in attribute
|
20
|
-
* Added `SystemWide.status_items`
|
21
|
-
* Added `SystemWide.desktop`
|
22
|
-
* Added History.markdown to track notable changes
|
23
|
-
* Added CONTRIBUTING.markdown with much less stringent guidelines
|
24
|
-
|
25
|
-
* Moved MiniTest extensions to their own gem/repository [minitest-ax\_elements](https://github.com/AXElements/minitest-ax_elements)
|
26
|
-
* Moved RSpec extensions to their own gem/repository [rspec-ax\_elements](https://github.com/AXElements/rspec-ax_elements)
|
27
|
-
|
28
|
-
* Ported `mouse.rb` to C and moved code to [mouse](https://github.com/AXElements/mouse)
|
29
|
-
* Ported `core.rb` to C and moved code to [accessibility\_core](https://github.com/AXElements/accessibility_core)
|
30
|
-
* Ported `screen_recorder.rb` to C and moved code to [screen\_recorder](https://github.com/AXElements/screen_recorder)
|
31
|
-
|
32
|
-
* Changed `DSL#right_click` to accept a block; block is yielded to between click down and click up events
|
33
|
-
* Changed `AX::Element#rect` to `AX::Element#to_rect`
|
34
|
-
|
35
|
-
* Deprecate `AX::DOCK` constant, use `AX::Application.dock` instead
|
36
|
-
* Remove `Accessibility.application_with_bundle_identifier`; use `AX::Application.new` instead
|
37
|
-
* Remove `Accessibility.application_with_name; use `AX::Application.new` instead
|
38
|
-
* Remove `DSL#subtree_for`; use `Element#inspect_subtree` instead
|
39
|
-
|
40
|
-
* Fixed fetching parameterized attributes through `Element#method_missing`
|
41
|
-
* Fixed `Element#parameterized_attribute` automatically normalizing `Range` parameters
|
@@ -1,230 +0,0 @@
|
|
1
|
-
require 'accessibility/version'
|
2
|
-
require 'accessibility/extras'
|
3
|
-
|
4
|
-
##
|
5
|
-
# Interface for collecting some simple information about the system.
|
6
|
-
# This information may be useful as diagnostic output when running
|
7
|
-
# tests, or if you simply need to find the hostname of the machine so
|
8
|
-
# it can be passed to another process to initiate a connection.
|
9
|
-
#
|
10
|
-
# This module extends itself, so all methods are available on the module
|
11
|
-
# and you will want to use the module as a utility module.
|
12
|
-
module Accessibility::SystemInfo
|
13
|
-
extend self
|
14
|
-
|
15
|
-
##
|
16
|
-
# The name the machine uses for Bonjour
|
17
|
-
#
|
18
|
-
# @example
|
19
|
-
#
|
20
|
-
# Accessibility::SystemInfo.name
|
21
|
-
# # => "ferrous"
|
22
|
-
#
|
23
|
-
# @return [String]
|
24
|
-
def name
|
25
|
-
NSHost.currentHost.localizedName
|
26
|
-
end
|
27
|
-
|
28
|
-
##
|
29
|
-
# All hostnames that the system responds to
|
30
|
-
#
|
31
|
-
# @example
|
32
|
-
#
|
33
|
-
# Accessibility::SystemInfo.hostnames
|
34
|
-
# # => ["ferrous.local", "localhost"]
|
35
|
-
#
|
36
|
-
# @return [Array<String>]
|
37
|
-
def hostnames
|
38
|
-
NSHost.currentHost.names
|
39
|
-
end
|
40
|
-
|
41
|
-
##
|
42
|
-
# The first, and likely common, name the system responds to
|
43
|
-
#
|
44
|
-
# @example
|
45
|
-
#
|
46
|
-
# Accessibility::SystemInfo.hostname # => "ferrous.local"
|
47
|
-
#
|
48
|
-
# @return [Array<String>]
|
49
|
-
def hostname
|
50
|
-
hostnames.first
|
51
|
-
end
|
52
|
-
|
53
|
-
##
|
54
|
-
# All IP addresses the system has interfaces for
|
55
|
-
#
|
56
|
-
# @example
|
57
|
-
#
|
58
|
-
# Accessibility::SystemInfo.addresses
|
59
|
-
# # => ["fe80::6aa8:6dff:fe20:822%en1", "192.168.0.17", "fe80::1%lo0", "127.0.0.1", "::1"]
|
60
|
-
#
|
61
|
-
# @return [Array<String>]
|
62
|
-
def addresses
|
63
|
-
NSHost.currentHost.addresses
|
64
|
-
end
|
65
|
-
|
66
|
-
##
|
67
|
-
# All IPv4 addresses the system has interfaces for
|
68
|
-
#
|
69
|
-
# @example
|
70
|
-
#
|
71
|
-
# Accessibility::SystemInfo.ipv4_addresses
|
72
|
-
# # => ["192.168.0.17", "127.0.0.1"]
|
73
|
-
#
|
74
|
-
# @return [Array<String>]
|
75
|
-
def ipv4_addresses
|
76
|
-
addresses.select { |address| address.match /\./ }
|
77
|
-
end
|
78
|
-
|
79
|
-
##
|
80
|
-
# All IPv6 addresses the system has interfaces for
|
81
|
-
#
|
82
|
-
# @example
|
83
|
-
#
|
84
|
-
# Accessibility::SystemInfo.ipv6_addresses
|
85
|
-
# # => ["fe80::6aa8:6dff:fe20:822%en1", "fe80::1%lo0", "::1"]
|
86
|
-
#
|
87
|
-
# @return [Array<String>]
|
88
|
-
def ipv6_addresses
|
89
|
-
addresses.select { |address| address.match /:/ }
|
90
|
-
end
|
91
|
-
|
92
|
-
##
|
93
|
-
# System model string
|
94
|
-
#
|
95
|
-
# @example
|
96
|
-
#
|
97
|
-
# Accessibility::SystemInfo.model # => "MacBookPro8,2"
|
98
|
-
#
|
99
|
-
# @return [String]
|
100
|
-
def model
|
101
|
-
@model ||= `sysctl hw.model`.split.last.chomp
|
102
|
-
end
|
103
|
-
|
104
|
-
##
|
105
|
-
# OS X version string
|
106
|
-
#
|
107
|
-
# @example
|
108
|
-
#
|
109
|
-
# Accessibility::SystemInfo.osx_version # => "Version 10.8.2 (Build 12C60)"
|
110
|
-
#
|
111
|
-
# @return [String]
|
112
|
-
def osx_version
|
113
|
-
NSProcessInfo.processInfo.operatingSystemVersionString
|
114
|
-
end
|
115
|
-
|
116
|
-
##
|
117
|
-
# System uptime, in seconds
|
118
|
-
#
|
119
|
-
# @example
|
120
|
-
#
|
121
|
-
# Accessibility::SystemInfo.uptime # => 22999.76858776
|
122
|
-
#
|
123
|
-
# @return [Float]
|
124
|
-
def uptime
|
125
|
-
NSProcessInfo.processInfo.systemUptime
|
126
|
-
end
|
127
|
-
|
128
|
-
##
|
129
|
-
# Total number of CPUs the system could use
|
130
|
-
#
|
131
|
-
# May not be the same as {#num_active_processors}.
|
132
|
-
#
|
133
|
-
# @example
|
134
|
-
#
|
135
|
-
# Accessibility::SystemInfo.num_processors # => 8
|
136
|
-
#
|
137
|
-
# @return [Fixnum]
|
138
|
-
def num_processors
|
139
|
-
NSProcessInfo.processInfo.processorCount
|
140
|
-
end
|
141
|
-
|
142
|
-
##
|
143
|
-
# Number of CPUs the system current has enabled
|
144
|
-
#
|
145
|
-
# @example
|
146
|
-
#
|
147
|
-
# Accessibility::SystemInfo.num_active_processors # => 8
|
148
|
-
#
|
149
|
-
# @return [Fixnum]
|
150
|
-
def num_active_processors
|
151
|
-
NSProcessInfo.processInfo.activeProcessorCount
|
152
|
-
end
|
153
|
-
|
154
|
-
##
|
155
|
-
# Total amount of memory for the system, in bytes
|
156
|
-
#
|
157
|
-
# @example
|
158
|
-
#
|
159
|
-
# Accessibility::SystemInfo.total_ram # => 17179869184
|
160
|
-
#
|
161
|
-
# @return [Fixnum]
|
162
|
-
def total_ram
|
163
|
-
NSProcessInfo.processInfo.physicalMemory
|
164
|
-
end
|
165
|
-
alias_method :ram, :total_ram
|
166
|
-
|
167
|
-
##
|
168
|
-
# Return the current state of the battery
|
169
|
-
#
|
170
|
-
# @example
|
171
|
-
#
|
172
|
-
# battery_state # => :charged
|
173
|
-
# # unplug AC cord
|
174
|
-
# battery_state # => :discharging
|
175
|
-
# # plug AC cord back in after several minutes
|
176
|
-
# battery_state # => :charging
|
177
|
-
#
|
178
|
-
# # try this method when you have no battery
|
179
|
-
# battery_state # => :not_installed
|
180
|
-
#
|
181
|
-
# @return [Symbol]
|
182
|
-
def battery_state
|
183
|
-
Battery.state
|
184
|
-
end
|
185
|
-
|
186
|
-
##
|
187
|
-
# Returns the charge percentage of the battery (if present)
|
188
|
-
#
|
189
|
-
# A special value of `-1.0` is returned if you have no battery.
|
190
|
-
#
|
191
|
-
# @example
|
192
|
-
#
|
193
|
-
# battery_charge_level # => 1.0
|
194
|
-
# # unplug AC cord and wait a couple of minutes
|
195
|
-
# battery_charge_level # => 0.99
|
196
|
-
#
|
197
|
-
# # if you have no battery
|
198
|
-
# battery_charge_level # => -1.0
|
199
|
-
#
|
200
|
-
# @return [Float]
|
201
|
-
def battery_charge_level
|
202
|
-
Battery.level
|
203
|
-
end
|
204
|
-
alias_method :battery_level, :battery_charge_level
|
205
|
-
|
206
|
-
##
|
207
|
-
# Return an estimate on the number of minutes until the battery is drained
|
208
|
-
#
|
209
|
-
# A special value of `0` indicates that the battery is not discharging.
|
210
|
-
# You should really only call this after you know that the battery is
|
211
|
-
# discharging by calling {#battery_state} and having `:discharging` returned.
|
212
|
-
#
|
213
|
-
# A special value of `-1` is returned when the estimate is in flux and
|
214
|
-
# cannot be accurately estimated.
|
215
|
-
#
|
216
|
-
# @example
|
217
|
-
#
|
218
|
-
# # AC cord plugged in
|
219
|
-
# battery_life_estimate # => 0
|
220
|
-
# # unplug AC cord
|
221
|
-
# battery_life_estimate # => -1
|
222
|
-
# # wait a few minutes
|
223
|
-
# battery_life_estimate # => 423
|
224
|
-
#
|
225
|
-
# @return [Fixnum]
|
226
|
-
def battery_life_estimate
|
227
|
-
Battery.time_to_empty
|
228
|
-
end
|
229
|
-
|
230
|
-
end
|