Class: XcodeInstall::Xcode

Inherits:
Object
  • Object
show all
Defined in:
lib/xcode/install.rb

Overview

A version of Xcode we fetched from the Apple Developer Portal we can download & install.

Sample object: <XcodeInstall::Xcode:0x007fa1d451c390

@date_modified=2015,
@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")>,

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json, url = nil, release_notes_url = nil) ⇒ Xcode

Returns a new instance of Xcode.



726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
# File 'lib/xcode/install.rb', line 726

def initialize(json, url = nil, release_notes_url = nil)
  if url.nil?
    @date_modified = json['dateModified'].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']
  else
    @name = json
    @path = url.split('/').last
    url_prefix = 'https://developer.apple.com/'
    @url = "#{url_prefix}#{url}"
    @release_notes_url = "#{url_prefix}#{release_notes_url}"
  end

  begin
    @version = Gem::Version.new(@name.split(' ')[0])
  rescue
    @version = Installer::MINIMUM_VERSION
  end
end

Instance Attribute Details

#date_modifiedObject (readonly)

Returns the value of attribute date_modified.



712
713
714
# File 'lib/xcode/install.rb', line 712

def date_modified
  @date_modified
end

#installedObject Also known as: installed?

Accessor since it’s set by the ‘Installer`



722
723
724
# File 'lib/xcode/install.rb', line 722

def installed
  @installed
end

#nameObject (readonly)

The name might include extra information like “for Lion” or “beta 2”



715
716
717
# File 'lib/xcode/install.rb', line 715

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



716
717
718
# File 'lib/xcode/install.rb', line 716

def path
  @path
end

#release_notes_urlObject (readonly)

Returns the value of attribute release_notes_url.



719
720
721
# File 'lib/xcode/install.rb', line 719

def release_notes_url
  @release_notes_url
end

#urlObject (readonly)

Returns the value of attribute url.



717
718
719
# File 'lib/xcode/install.rb', line 717

def url
  @url
end

#versionObject (readonly)

Returns the value of attribute version.



718
719
720
# File 'lib/xcode/install.rb', line 718

def version
  @version
end

Class Method Details

.new_prerelease(version, url, release_notes_path) ⇒ Object



758
759
760
761
762
# File 'lib/xcode/install.rb', line 758

def self.new_prerelease(version, url, release_notes_path)
  new('name' => version,
      'files' => [{ 'remotePath' => url.split('=').last }],
      'release_notes_path' => release_notes_path)
end

Instance Method Details

#==(other) ⇒ Object



753
754
755
756
# File 'lib/xcode/install.rb', line 753

def ==(other)
  date_modified == other.date_modified && name == other.name && path == other.path && \
    url == other.url && version == other.version
end

#to_sObject



749
750
751
# File 'lib/xcode/install.rb', line 749

def to_s
  "Xcode #{version} -- #{url}"
end