Class: XcodeInstall::Xcode
- Inherits:
-
Object
- Object
- XcodeInstall::Xcode
- 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=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")>,
Instance Attribute Summary collapse
-
#date_modified ⇒ Object
readonly
Returns the value of attribute date_modified.
-
#installed ⇒ Object
(also: #installed?)
Accessor since it’s set by the ‘Installer`.
-
#name ⇒ Object
readonly
The name might include extra information like “for Lion” or “beta 2”.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#release_notes_url ⇒ Object
readonly
Returns the value of attribute release_notes_url.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(json, url = nil, release_notes_url = nil) ⇒ Xcode
constructor
A new instance of Xcode.
- #to_s ⇒ Object
Constructor Details
#initialize(json, url = nil, release_notes_url = nil) ⇒ Xcode
Returns a new instance of Xcode.
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 |
# File 'lib/xcode/install.rb', line 774 def initialize(json, url = nil, release_notes_url = nil) if url.nil? @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'] 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_modified ⇒ Object (readonly)
Returns the value of attribute date_modified.
760 761 762 |
# File 'lib/xcode/install.rb', line 760 def date_modified @date_modified end |
#installed ⇒ Object Also known as: installed?
Accessor since it’s set by the ‘Installer`
770 771 772 |
# File 'lib/xcode/install.rb', line 770 def installed @installed end |
#name ⇒ Object (readonly)
The name might include extra information like “for Lion” or “beta 2”
763 764 765 |
# File 'lib/xcode/install.rb', line 763 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
764 765 766 |
# File 'lib/xcode/install.rb', line 764 def path @path end |
#release_notes_url ⇒ Object (readonly)
Returns the value of attribute release_notes_url.
767 768 769 |
# File 'lib/xcode/install.rb', line 767 def release_notes_url @release_notes_url end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
765 766 767 |
# File 'lib/xcode/install.rb', line 765 def url @url end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
766 767 768 |
# File 'lib/xcode/install.rb', line 766 def version @version end |
Class Method Details
.new_prerelease(version, url, release_notes_path) ⇒ Object
806 807 808 809 810 811 |
# File 'lib/xcode/install.rb', line 806 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 |
Instance Method Details
#==(other) ⇒ Object
801 802 803 804 |
# File 'lib/xcode/install.rb', line 801 def ==(other) date_modified == other.date_modified && name == other.name && path == other.path && \ url == other.url && version == other.version end |
#to_s ⇒ Object
797 798 799 |
# File 'lib/xcode/install.rb', line 797 def to_s "Xcode #{version} -- #{url}" end |