Skip to content
  • 3 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Showing with 29 additions and 116 deletions.
  1. +1 −0 .gitignore
  2. +15 −0 .simplecov
  3. +1 −1 README.markdown
  4. +12 −115 lib/accessibility.rb
View
1 .gitignore
@@ -14,3 +14,4 @@ Makefile
pkg/*
TODO
unfinished/
+ci/
View
15 .simplecov
@@ -0,0 +1,15 @@
+require 'simplecov-rcov'
+
+SimpleCov.start do
+ coverage_dir 'ci/coverage'
+
+ formatter SimpleCov::Formatter::MultiFormatter[
+ SimpleCov::Formatter::HTMLFormatter,
+ SimpleCov::Formatter::RcovFormatter,
+ ]
+
+ add_filter 'test/'
+ add_group 'Elements', 'lib/ax/'
+ add_group 'Library', 'lib/accessibility/'
+ add_group 'Hacks', 'lib/ax_elements/'
+end
View
2 README.markdown
@@ -124,7 +124,7 @@ as some of the technical the technical underpinnings of AXElements.
## Development
[![Dependency Status](https://gemnasium.com/AXElements/AXElements.png)](https://gemnasium.com/AXElements/AXElements)
-[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/AXElements/AXElements)
+[![Code Climate](https://codeclimate.com/github/AXElements/AXElements.png)](https://codeclimate.com/github/AXElements/AXElements)
AXElements has reached a point where the main focus is stability,
documentation, and additional conveniences. It will be out of this
View
127 lib/accessibility.rb
@@ -1,123 +1,20 @@
require 'accessibility/version'
-require 'ax/application'
module Accessibility
- # Initialize the DEBUG value
- @debug = ENV.fetch 'AXDEBUG', $DEBUG
-end
-
-class << Accessibility
-
- ##
- # Whether or not to turn on DEBUG features in AXElements. The
- # value is initially inherited from `$DEBUG` but can be overridden
- # by an environment variable named `AXDEBUG` or changed dynamically
- # at runtime.
- #
- # @return [Boolean]
- attr_accessor :debug
- alias_method :debug?, :debug
-
- # @group Finding an application object
-
- ##
- # @note Bundle identifiers are case-sensitive.
- # @deprecated Use {AX::Aplication#initialize} instead.
- #
- # This is the standard way of creating an application object. It will
- # launch the app if it is not already running and create the
- # accessibility object.
- #
- # However, this method is a bit of a hack in cases where the app is not
- # already running; I've tried to register for notifications, launch
- # synchronously, etc., but there is always a problem with accessibility
- # not being ready right away.
- #
- # If this method fails to find an app with the appropriate bundle
- # identifier then it will raise an exception. If the problem was not a
- # typo, then it might mean that the bundle identifier has not been
- # registered with the system yet and you should launch the app once
- # manually.
- #
- # @example
- #
- # application_with_bundle_identifier 'com.apple.mail' # wait a few seconds
- # application_with_bundle_identifier 'com.marketcircle.Daylite4'
- #
- # @param bundle [String] a bundle identifier
- # @return [AX::Application,nil]
- def application_with_bundle_identifier bundle
- $stderr.puts "#{__method__} is DEPRECATED: Use AX::Application.new instead"
- if app_running?(bundle) || launch_application(bundle)
- 10.times do
- if app_running?(bundle) && (app = try_wrapping(bundle))
- return app
- else
- sleep 1
- end
- end
- else
- raise ArgumentError, "Could not launch app matching bundle id `#{bundle}'"
- end
- nil
+ class << self
+ ##
+ # Whether or not to turn on DEBUG features in AXElements. The
+ # value is initially inherited from `$DEBUG` but can be overridden
+ # by an environment variable named `AXDEBUG` or changed dynamically
+ # at runtime.
+ #
+ # @return [Boolean]
+ attr_accessor :debug
+ alias_method :debug?, :debug
end
- ##
- # @deprecated Directly initialize an {AX::Application} instance instead
- # (e.g. `AX::Application.new('Terminal')`).
- #
- # Get the accessibility object for an application given its localized
- # name. This will only work if the application is already running.
- #
- # @example
- #
- # application_with_name 'Mail'
- #
- # @param [String] name name of the application to launch
- # @return [AX::Application,nil]
- def application_with_name name
- $stderr.puts "#{__method__} is DEPRECATED: Use AX::Application.new instead"
- AX::Application.new name
- end
-
- # @endgroup
-
-
- private
-
- ##
- # Find out if the app is running and if so, return the running application
- # for that bundle.
- #
- # @param bundle [String]
- # @return [NSRunningApplication,nil]
- def app_running? bundle
- NSRunningApplication.runningApplicationsWithBundleIdentifier(bundle).first
- end
-
- ##
- # Try to wrap an application object, just in case it is not quite ready
- # for accessibility yet.
- #
- # @param bundle [String]
- # @return [AX::Application]
- def try_wrapping bundle
- AX::Application.new bundle
- rescue RuntimeError
- nil
- end
-
- ##
- # Asynchronously launch an application given the bundle identifier.
- #
- # @param [String] bundle the bundle identifier for the app
- # @return [Boolean]
- def launch_application bundle
- NSWorkspace.sharedWorkspace.launchAppWithBundleIdentifier bundle,
- options: NSWorkspaceLaunchAsync,
- additionalEventParamDescriptor: nil,
- launchIdentifier: nil
- end
+ # Initialize the DEBUG value
+ @debug = ENV.fetch 'AXDEBUG', $DEBUG
end

No commit comments for this range

Something went wrong with that request. Please try again.