Class: Sparkleology::FindApplicationCommand
- Inherits:
-
Object
- Object
- Sparkleology::FindApplicationCommand
- Defined in:
- lib/sparkleology/find_application_command.rb
Overview
This command class takes an OS X application name, such as ‘Skitch’, and returns the Sparkle RSS feed URL containing the latest update information. Pass the application name to the initializer, and call run
.
+Sparkleology::FindApplicationCommand.new('Skitch').run+
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
Instance Method Summary collapse
- #home_path ⇒ Object
-
#initialize(app_name) ⇒ FindApplicationCommand
constructor
A new instance of FindApplicationCommand.
- #paths ⇒ Object
- #plist_path ⇒ Object
- #run ⇒ Object
- #url_for_latest_versions ⇒ Object
Constructor Details
#initialize(app_name) ⇒ FindApplicationCommand
Returns a new instance of FindApplicationCommand.
9 10 11 |
# File 'lib/sparkleology/find_application_command.rb', line 9 def initialize(app_name) @app_name = app_name end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
7 8 9 |
# File 'lib/sparkleology/find_application_command.rb', line 7 def app_name @app_name end |
Instance Method Details
#home_path ⇒ Object
39 40 41 |
# File 'lib/sparkleology/find_application_command.rb', line 39 def home_path ENV['TEST_HOME'] || ENV['HOME'] || File.('~') end |
#paths ⇒ Object
35 36 37 |
# File 'lib/sparkleology/find_application_command.rb', line 35 def paths ["#{home_path}/Applications", "/Applications"] end |
#plist_path ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sparkleology/find_application_command.rb', line 17 def plist_path @plist_path ||= begin full_app_name = app_name.gsub(/\.app$/,'') + ".app" self.paths. map { |root_path| File.join(root_path, full_app_name, "Contents/Info.plist") }. find { |plist| File.exists?(plist) } end || begin raise Sparkleology::InvalidApplicationNameException, app_name end end |
#run ⇒ Object
13 14 15 |
# File 'lib/sparkleology/find_application_command.rb', line 13 def run url_for_latest_versions end |
#url_for_latest_versions ⇒ Object
28 29 30 31 32 33 |
# File 'lib/sparkleology/find_application_command.rb', line 28 def url_for_latest_versions application_info = Plist::parse_xml(plist_path) application_info['SUFeedURL'] || begin raise Sparkleology::NonSparkleApplicationException, app_name end end |