xcode-install 2.4.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e28c74420ebf53e8f127263aa2752211dff9bcd3
4
- data.tar.gz: e48f8d0fd268fdd9756a15dbbfdf162c29a5268d
3
+ metadata.gz: f963f106ba542c0705d573d9262d8fb92595df9d
4
+ data.tar.gz: ac247b88aba2b1548179b04c7e7a6eb6358c5004
5
5
  SHA512:
6
- metadata.gz: d0224e430c804c00c9a04e6cc37c426f7a363c29f449ebbd64fb12ed8b1f3b6acc2b23c612ad5dfd4ef30b6610d3e731688b4cc7fc58f9ac685da3c66bcb8535
7
- data.tar.gz: 6d861cc3114665ec9f1bdd53ca438b29e56ce3345b83e1831e8858e3935d61981e767d3c17818e54e4a600e770b70e9ea76e7ae09870b4ffa1e8f23adc581c57
6
+ metadata.gz: e525ac44989fb47d31f0b976228eb1952f4d710fef60def7c3aaee7059312332c9d29e258b3a3a0760f6d39d2a1b067af9f3b3fc622c49a3780a14bd8fd61593
7
+ data.tar.gz: e630821045db39f07f64840f17e6d96df9ba3cfaeca05cc3391f9b9dc8843d48038382580b96743c3ea5868afda8aed92e8135153bea24320680b99f4f7933c9
data/README.md CHANGED
@@ -153,7 +153,7 @@ XcodeInstall normally relies on the Spotlight index to locate installed versions
153
153
  indexing is happening, it might show inaccurate results and it will not be able to see installed
154
154
  versions on unindexed volumes.
155
155
 
156
- To workaround the Spotlight limitation, XcodeInstall searches `/Applications` folder to locate Xcodes when Spotlight is disabled on the machine, or when Spotlight query for Xcode does not return any results. But it still won't work if your Xcodes are located under `/Applications` folder.
156
+ To workaround the Spotlight limitation, XcodeInstall searches `/Applications` folder to locate Xcodes when Spotlight is disabled on the machine, or when Spotlight query for Xcode does not return any results. But it still won't work if your Xcodes are not located under `/Applications` folder.
157
157
 
158
158
  ## Thanks
159
159
 
@@ -23,6 +23,7 @@ module XcodeInstall
23
23
  def initialize(argv)
24
24
  @installer = Installer.new
25
25
  @version = argv.shift_argument
26
+ @version ||= File.read('.xcode-version') if File.exist?('.xcode-version')
26
27
  @url = argv.option('url')
27
28
  @force = argv.flag?('force', false)
28
29
  @should_clean = argv.flag?('clean', true)
@@ -37,7 +38,10 @@ module XcodeInstall
37
38
  super
38
39
 
39
40
  help! 'A VERSION argument is required.' unless @version
40
- fail Informative, "Version #{@version} already installed." if @installer.installed?(@version) && !@force
41
+ if @installer.installed?(@version) && !@force
42
+ print "Version #{@version} already installed."
43
+ exit(0)
44
+ end
41
45
  fail Informative, "Version #{@version} doesn't exist." unless @url || @installer.exist?(@version)
42
46
  fail Informative, "Invalid URL: `#{@url}`" unless !@url || @url =~ /\A#{URI.regexp}\z/
43
47
  end
@@ -1,3 +1,3 @@
1
1
  module XcodeInstall
2
- VERSION = '2.4.1'.freeze
2
+ VERSION = '2.5.0'.freeze
3
3
  end
data/lib/xcode/install.rb CHANGED
@@ -95,7 +95,7 @@ module XcodeInstall
95
95
 
96
96
  # Call back the block for other processes that might be interested
97
97
  matched = progress_content.match(/^\s*(\d+)/)
98
- next unless matched.length == 2
98
+ next unless matched && matched.length == 2
99
99
  percent = matched[1].to_i
100
100
  progress_block.call(percent) if progress_block
101
101
  end
@@ -277,7 +277,7 @@ HELP
277
277
  fail Informative, "Failed to download Xcode #{version}." if dmg_path.nil?
278
278
 
279
279
  if install
280
- install_dmg(dmg_path, "-#{version.to_s.split(' ')[0]}", switch, clean)
280
+ install_dmg(dmg_path, "-#{version.to_s.split(' ').join('.')}", switch, clean)
281
281
  else
282
282
  puts "Downloaded Xcode #{version} to '#{dmg_path}'"
283
283
  end
@@ -293,7 +293,12 @@ HELP
293
293
 
294
294
  def list_annotated(xcodes_list)
295
295
  installed = installed_versions.map(&:version)
296
- xcodes_list.map { |x| installed.include?(x) ? "#{x} (installed)" : x }.join("\n")
296
+ xcodes_list.map do |x|
297
+ xcode_version = x.split(' ').first # exclude "beta N", "for Lion".
298
+ xcode_version << '.0' unless xcode_version.include?('.')
299
+
300
+ installed.include?(xcode_version) ? "#{x} (installed)" : x
301
+ end.join("\n")
297
302
  end
298
303
 
299
304
  def list
@@ -383,7 +388,7 @@ HELP
383
388
  def installed
384
389
  result = `mdfind "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'" 2>/dev/null`.split("\n")
385
390
  if result.empty?
386
- result = `find /Applications -name '*.app' -type d -maxdepth 1 -exec sh -c \
391
+ result = `find /Applications -maxdepth 1 -name '*.app' -type d -exec sh -c \
387
392
  'if [ "$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" \
388
393
  "{}/Contents/Info.plist" 2>/dev/null)" == "com.apple.dt.Xcode" ]; then echo "{}"; fi' ';'`.split("\n")
389
394
  end
@@ -435,7 +440,7 @@ HELP
435
440
  return [] if scan.empty?
436
441
 
437
442
  version = scan.first.gsub(/<.*?>/, '').gsub(/.*Xcode /, '')
438
- link = body.scan(%r{<button .*"(.+?.xip)".*</button>}).first.first
443
+ link = body.scan(%r{<button .*"(.+?.(dmg|xip))".*</button>}).first.first
439
444
  notes = body.scan(%r{<a.+?href="(/go/\?id=xcode-.+?)".*>(.*)</a>}).first.first
440
445
  links << Xcode.new(version, link, notes)
441
446
  end
@@ -589,7 +594,7 @@ HELP
589
594
  end
590
595
 
591
596
  def bundle_version
592
- @bundle_version ||= Gem::Version.new(plist_entry(':DTXcode').to_i.to_s.split(//).join('.'))
597
+ @bundle_version ||= Gem::Version.new(bundle_version_string)
593
598
  end
594
599
 
595
600
  def uuid
@@ -652,6 +657,15 @@ HELP
652
657
 
653
658
  :private
654
659
 
660
+ def bundle_version_string
661
+ digits = plist_entry(':DTXcode').to_i.to_s
662
+ if digits.length < 3
663
+ digits.split(//).join('.')
664
+ else
665
+ "#{digits[0..-3]}.#{digits[-2]}.#{digits[-1]}"
666
+ end
667
+ end
668
+
655
669
  def plist_entry(keypath)
656
670
  `/usr/libexec/PlistBuddy -c "Print :#{keypath}" "#{path}/Contents/Info.plist"`.chomp
657
671
  end
data/spec/install_spec.rb CHANGED
@@ -35,6 +35,14 @@ module XcodeInstall
35
35
  Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', true, true)
36
36
  Command::Install.run(['6.3', '--no-progress'])
37
37
  end
38
+
39
+ it 'reads .xcode-version' do
40
+ Installer.any_instance.expects(:download).with('6.3', true, nil, nil).returns('/some/path')
41
+ Installer.any_instance.expects(:install_dmg).with('/some/path', '-6.3', true, true)
42
+ File.expects(:exist?).with('.xcode-version').returns(true)
43
+ File.expects(:read).returns('6.3')
44
+ Command::Install.run([])
45
+ end
38
46
  end
39
47
 
40
48
  it 'parses hdiutil output' do
data/spec/list_spec.rb CHANGED
@@ -4,7 +4,6 @@ module XcodeInstall
4
4
  describe Command::List do
5
5
  before do
6
6
  installer.stubs(:exists).returns(true)
7
- installer.stubs(:installed_versions).returns([])
8
7
  end
9
8
 
10
9
  def installer
@@ -23,11 +22,36 @@ module XcodeInstall
23
22
  installer.stubs(:xcodes).returns(xcodes)
24
23
  end
25
24
 
25
+ def fake_installed_xcode(name)
26
+ xcode_path = "/Applications/Xcode-#{name}.app"
27
+ xcode_version = name
28
+ xcode_version << '.0' unless name.include? '.'
29
+
30
+ installed_xcode = InstalledXcode.new(xcode_path)
31
+ installed_xcode.stubs(:version).returns(xcode_version)
32
+ installed_xcode.stubs(:bundle_version).returns(Gem::Version.new(xcode_version))
33
+ installed_xcode
34
+ end
35
+
36
+ def fake_installed_xcodes(*names)
37
+ xcodes = names.map { |name| fake_installed_xcode(name) }
38
+ installer.stubs(:installed_versions).returns(xcodes)
39
+ end
40
+
26
41
  describe '#list' do
27
42
  it 'lists all versions' do
28
43
  fake_xcodes '1', '2.3', '2.3.1', '2.3.2', '3 some', '4 beta', '10 beta'
44
+ fake_installed_xcodes
29
45
  installer.list.should == "1\n2.3\n2.3.1\n2.3.2\n3 some\n4 beta\n10 beta"
30
46
  end
31
47
  end
48
+
49
+ describe '#list_annotated' do
50
+ it 'lists all versions with annotations' do
51
+ fake_xcodes '1', '2.3', '2.3.1', '2.3.2', '3 some', '4.3.1 for Lion', '9.4.1', '10 beta'
52
+ fake_installed_xcodes '2.3', '4.3.1', '10'
53
+ installer.list.should == "1\n2.3 (installed)\n2.3.1\n2.3.2\n3 some\n4.3.1 for Lion (installed)\n9.4.1\n10 beta (installed)"
54
+ end
55
+ end
32
56
  end
33
57
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcode-install
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Bügling
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-07 00:00:00.000000000 Z
11
+ date: 2018-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: claide
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  requirements: []
162
162
  rubyforge_project:
163
- rubygems_version: 2.6.10
163
+ rubygems_version: 2.6.8
164
164
  signing_key:
165
165
  specification_version: 4
166
166
  summary: Xcode installation manager.