AXElements 1.0.0.alpha9 → 1.0.0.alpha10

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/History.markdown CHANGED
@@ -3,11 +3,12 @@
3
3
  * Added History.markdown to track notable changes
4
4
  * Added `Application.frontmost_application`
5
5
  * Added `Application.menu_bar_owner`
6
- * Added `SystemWide.status_bar_items`
6
+ * Added `SystemWide.status_items`
7
7
  * Added `SystemWide.desktop`
8
8
  * Added `Application.finder`
9
9
  * Added `Application.dock`
10
10
  * Added `DSL#record` to run a screen recording of the given block
11
+ * Added `Accessibility::SystemInfo` for getting information about the running system
11
12
 
12
13
  * Ported `mouse.rb` to C and moved code to [MRMouse](https://github.com/ferrous26/MRMouse)
13
14
 
@@ -247,7 +247,7 @@ module Accessibility::DSL
247
247
  # @param path [String,Regexp]
248
248
  # @return [Boolean]
249
249
  def select_menu_item app, *path
250
- app.select_menu_item *path
250
+ app.application.select_menu_item *path
251
251
  end
252
252
 
253
253
  ##
@@ -0,0 +1,165 @@
1
+ require 'accessibility/version'
2
+
3
+ ##
4
+ # Interface for collecting some simple information about the system.
5
+ # This information may be useful as diagnostic output when running
6
+ # tests, or if you simply need to find the hostname of the machine so
7
+ # it can be passed to another process to initiate a connection.
8
+ #
9
+ # This module extends itself, so all methods are available on the module
10
+ # and you will want to use the module as a utility module.
11
+ module Accessibility::SystemInfo
12
+ extend self
13
+
14
+ ##
15
+ # All hostnames that the system responds to
16
+ #
17
+ # @example
18
+ #
19
+ # Accessibility::SystemInfo.hostnames
20
+ # # => ["ferrous.local", "localhost"]
21
+ #
22
+ # @return [Array<String>]
23
+ def hostnames
24
+ host.names
25
+ end
26
+
27
+ ##
28
+ # The first, and likely common, name the system responds to
29
+ #
30
+ # @example
31
+ #
32
+ # Accessibility::SystemInfo.hostname # => "ferrous.local"
33
+ #
34
+ # @return [Array<String>]
35
+ def hostname
36
+ hostnames.first
37
+ end
38
+
39
+ ##
40
+ # All IP addresses the system has interfaces for
41
+ #
42
+ # @example
43
+ #
44
+ # Accessibility::SystemInfo.addresses
45
+ # # => ["fe80::6aa8:6dff:fe20:822%en1", "192.168.0.17", "fe80::1%lo0", "127.0.0.1", "::1"]
46
+ #
47
+ # @return [Array<String>]
48
+ def addresses
49
+ host.addresses
50
+ end
51
+
52
+ ##
53
+ # All IPv4 addresses the system has interfaces for
54
+ #
55
+ # @example
56
+ #
57
+ # Accessibility::SystemInfo.ipv4_addresses
58
+ # # => ["192.168.0.17", "127.0.0.1"]
59
+ #
60
+ # @return [Array<String>]
61
+ def ipv4_addresses
62
+ addresses.select { |address| address.match /\./ }
63
+ end
64
+
65
+ ##
66
+ # All IPv6 addresses the system has interfaces for
67
+ #
68
+ # @example
69
+ #
70
+ # Accessibility::SystemInfo.ipv6_addresses
71
+ # # => ["fe80::6aa8:6dff:fe20:822%en1", "fe80::1%lo0", "::1"]
72
+ #
73
+ # @return [Array<String>]
74
+ def ipv6_addresses
75
+ addresses.select { |address| address.match /:/ }
76
+ end
77
+
78
+ ##
79
+ # System model string
80
+ #
81
+ # @example
82
+ #
83
+ # Accessibility::SystemInfo.model # => "MacBookPro8,2"
84
+ #
85
+ # @return [String]
86
+ def model
87
+ @model ||= `sysctl hw.model`.split.last.chomp
88
+ end
89
+
90
+ ##
91
+ # OS X version string
92
+ #
93
+ # @example
94
+ #
95
+ # Accessibility::SystemInfo.osx_version # => "Version 10.8.2 (Build 12C60)"
96
+ #
97
+ # @return [String]
98
+ def osx_version
99
+ pinfo.operatingSystemVersionString
100
+ end
101
+
102
+ ##
103
+ # System uptime, in seconds
104
+ #
105
+ # @example
106
+ #
107
+ # Accessibility::SystemInfo.uptime # => 22999.76858776
108
+ #
109
+ # @return [Float]
110
+ def uptime
111
+ pinfo.systemUptime
112
+ end
113
+
114
+ ##
115
+ # Total number of CPUs the system could use
116
+ #
117
+ # May not be the same as {#num_active_processors}.
118
+ #
119
+ # @example
120
+ #
121
+ # Accessibility::SystemInfo.num_processors # => 8
122
+ #
123
+ # @return [Fixnum]
124
+ def num_processors
125
+ pinfo.processorCount
126
+ end
127
+
128
+ ##
129
+ # Number of CPUs the system current has enabled
130
+ #
131
+ # @example
132
+ #
133
+ # Accessibility::SystemInfo.num_active_processors # => 8
134
+ #
135
+ # @return [Fixnum]
136
+ def num_active_processors
137
+ pinfo.activeProcessorCount
138
+ end
139
+
140
+ ##
141
+ # Total amount of memory for the system, in bytes
142
+ #
143
+ # @example
144
+ #
145
+ # Accessibility::SystemInfo.total_ram # => 17179869184
146
+ #
147
+ # @return [Fixnum]
148
+ def total_ram
149
+ pinfo.physicalMemory
150
+ end
151
+ alias_method :ram, :total_ram
152
+
153
+
154
+ private
155
+
156
+ def host
157
+ NSHost.currentHost
158
+ end
159
+
160
+ def pinfo
161
+ NSProcessInfo.processInfo
162
+ end
163
+
164
+ end
165
+
@@ -4,7 +4,7 @@
4
4
  # The main AXElements namespace.
5
5
  module Accessibility
6
6
  # @return [String]
7
- VERSION = '1.0.0.alpha9'
7
+ VERSION = '1.0.0.alpha10'
8
8
 
9
9
  # @return [String]
10
10
  CODE_NAME = 'ルナトーン'
data/lib/ax_elements.rb CHANGED
@@ -2,6 +2,8 @@
2
2
  require 'accessibility/dsl'
3
3
  include Accessibility::DSL
4
4
 
5
+ require 'accessibility/system_info'
6
+
5
7
  ##
6
8
  # The Mac OS X dock application.
7
9
  #
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: AXElements
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 1.0.0.alpha9
5
+ version: 1.0.0.alpha10
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mark Rada
@@ -115,6 +115,7 @@ files:
115
115
  - lib/accessibility/qualifier.rb
116
116
  - lib/accessibility/statistics.rb
117
117
  - lib/accessibility/string.rb
118
+ - lib/accessibility/system_info.rb
118
119
  - lib/accessibility/translator.rb
119
120
  - lib/accessibility/version.rb
120
121
  - lib/accessibility.rb