lib/xcode/install.rb in xcode-install-2.6.4 vs lib/xcode/install.rb in xcode-install-2.6.5

- old
+ new

@@ -171,11 +171,11 @@ end seedlist.each do |current_seed| return current_seed if parsed_version && current_seed.version == parsed_version end - + nil end def exist?(version) return true if find_xcode_version(version) @@ -212,11 +212,11 @@ cached_installed_versions = installed_versions.map(&:bundle_version) all_xcodes.each do |current_xcode| current_xcode.installed = cached_installed_versions.include?(current_xcode.version) end - all_xcodes.sort_by(&:version) + all_xcodes.sort_by { |seed| [seed.version, -seed.date_modified] }.reverse end def install_dmg(dmg_path, suffix = '', switch = true, clean = true) prompt = "Please authenticate for Xcode installation.\nPassword: " xcode_path = "/Applications/Xcode#{suffix}.app" @@ -298,16 +298,20 @@ xcode = seedlist.find { |x| x.name == version } `open #{xcode.release_notes_url}` unless xcode.nil? || xcode.release_notes_url.nil? end def list_annotated(xcodes_list) - installed = installed_versions.map(&:version) + installed = installed_versions.map(&:appname_version) + xcodes_list.map do |x| - xcode_version = x.split(' ').first # exclude "beta N", "for Lion". - xcode_version << '.0' unless xcode_version.include?('.') + xcode_version = x.split(' ') # split version and "beta N", "for Lion" + xcode_version[0] << '.0' unless xcode_version[0].include?('.') - installed.include?(xcode_version) ? "#{x} (installed)" : x + # to match InstalledXcode.appname_version format + version = Gem::Version.new(xcode_version.join('.')) + + installed.include?(version) ? "#{x} (installed)" : x end.join("\n") end def list list_annotated(list_versions.sort_by(&:to_f)) @@ -599,10 +603,16 @@ def bundle_version @bundle_version ||= Gem::Version.new(bundle_version_string) end + def appname_version + appname = @path.basename('.app').to_s + version_string = appname.split('-').last + Gem::Version.new(version_string) + end + def uuid @uuid ||= plist_entry(':DVTPlugInCompatibilityUUID') end def downloadable_index_url @@ -700,11 +710,11 @@ # A version of Xcode we fetched from the Apple Developer Portal # we can download & install. # # Sample object: # <XcodeInstall::Xcode:0x007fa1d451c390 - # @date_modified=2015, + # @date_modified=1573661580, # @name="6.4", # @path="/Developer_Tools/Xcode_6.4/Xcode_6.4.dmg", # @url= # "https://developer.apple.com/devcenter/download.action?path=/Developer_Tools/Xcode_6.4/Xcode_6.4.dmg", # @version=Gem::Version.new("6.4")>, @@ -723,11 +733,11 @@ alias installed? installed def initialize(json, url = nil, release_notes_url = nil) if url.nil? - @date_modified = json['dateModified'].to_i + @date_modified = DateTime.strptime(json['dateModified'], '%m/%d/%y %H:%M').strftime('%s').to_i @name = json['name'].gsub(/^Xcode /, '') @path = json['files'].first['remotePath'] url_prefix = 'https://developer.apple.com/devcenter/download.action?path=' @url = "#{url_prefix}#{@path}" @release_notes_url = "#{url_prefix}#{json['release_notes_path']}" if json['release_notes_path'] @@ -755,9 +765,10 @@ url == other.url && version == other.version end def self.new_prerelease(version, url, release_notes_path) new('name' => version, + 'dateModified' => '01/01/70 00:00', 'files' => [{ 'remotePath' => url.split('=').last }], 'release_notes_path' => release_notes_path) end end end