Class: XcodeInstall::Xcode

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

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.



542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
# File 'lib/xcode/install.rb', line 542

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.



535
536
537
# File 'lib/xcode/install.rb', line 535

def date_modified
  @date_modified
end

#nameObject (readonly)

Returns the value of attribute name.



536
537
538
# File 'lib/xcode/install.rb', line 536

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



537
538
539
# File 'lib/xcode/install.rb', line 537

def path
  @path
end

#release_notes_urlObject (readonly)

Returns the value of attribute release_notes_url.



540
541
542
# File 'lib/xcode/install.rb', line 540

def release_notes_url
  @release_notes_url
end

#urlObject (readonly)

Returns the value of attribute url.



538
539
540
# File 'lib/xcode/install.rb', line 538

def url
  @url
end

#versionObject (readonly)

Returns the value of attribute version.



539
540
541
# File 'lib/xcode/install.rb', line 539

def version
  @version
end

Class Method Details

.new_prerelease(version, url, release_notes_path) ⇒ Object



574
575
576
577
578
# File 'lib/xcode/install.rb', line 574

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



569
570
571
572
# File 'lib/xcode/install.rb', line 569

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

#to_sObject



565
566
567
# File 'lib/xcode/install.rb', line 565

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