carthage_cache 0.7.0 → 0.8.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: 4d9073ae5c1c8c1606fae0af3e8fcbd4cc970174
4
- data.tar.gz: a5b435d18b552a2f57e12ac5af3f644de3358340
3
+ metadata.gz: 14c557ec9aff88645661930d8726c26353cf9eb1
4
+ data.tar.gz: d4f6a67baf8b14d2e20ba7cfeca16fbf413dc22d
5
5
  SHA512:
6
- metadata.gz: 509ab485f2f00b67e736426445b0959627bea03ec853047f4c7db4907fa78c33189f1582569edae94ca162dd6922180e2f715fd0584d394edc8034c93923bd32
7
- data.tar.gz: b236a7d83332526ca67f4b8448f0db7840186bbcf3102ebe76b4cef1b6cf46beea878cb6c7b2c56721583552ee6bfa63570c349e2ad7ecf11b59010b50ec28c6
6
+ metadata.gz: f8cb4a55c9a8887c655e1103a51ee3ec6db841137aab8ba97327608e9b286dafe71b4186bececa928f0a22658c298bb69c632ca0e6313bc1a64521d27f6cb390
7
+ data.tar.gz: aa0922188cc9ec64a75194f6b7ea7fa9152d3ff947099f32d497be7f4eface163481b39c91f3b18072e968d7b36ae552c29283b3039cc0e7bfdf6e18c2267508
@@ -1,6 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- #require "bundler/setup"
3
+ if Gem::Specification::find_all_by_name('bundler').any?
4
+ require 'bundler/setup'
5
+ else
6
+ require 'rubygems'
7
+ gem 'carthage_cache'
8
+ end
9
+
4
10
  require "commander/import"
5
11
  require "carthage_cache"
6
12
 
@@ -90,3 +96,12 @@ command :prune do |c|
90
96
  app.prune_build_directory(options.prune_white_list)
91
97
  end
92
98
  end
99
+
100
+ command :validate do |c|
101
+ c.syntax = "#{PROGRAM_NAME} validate [PROJECT_PATH]"
102
+ c.description = 'Validates the cache archive for the current Cartfile.resolved.'
103
+ c.action do |args, options|
104
+ app = CarthageCache::Application.new(args.first || ".", verbose, config)
105
+ exit 1 unless app.validate_installation
106
+ end
107
+ end
@@ -11,10 +11,11 @@ require "carthage_cache/configuration_validator"
11
11
  require "carthage_cache/configuration"
12
12
  require "carthage_cache/configurator"
13
13
  require "carthage_cache/configurator_wizard"
14
- require "carthage_cache/shell_command_executor.rb"
15
- require "carthage_cache/application.rb"
16
- require "carthage_cache/swift_version_resolver.rb"
17
- require "carthage_cache/build_collector.rb"
14
+ require "carthage_cache/shell_command_executor"
15
+ require "carthage_cache/application"
16
+ require "carthage_cache/swift_version_resolver"
17
+ require "carthage_cache/build_collector"
18
+ require "carthage_cache/carthage_cache_lock"
18
19
 
19
20
  module CarthageCache
20
21
 
@@ -41,6 +41,7 @@ module CarthageCache
41
41
  prune_white_list ||= config.prune_white_list
42
42
 
43
43
  if force || !archive_exist?
44
+ carthage_cache_lock.write_lock_digest(project.archive_key)
44
45
  prune_build_directory(prune_white_list) if prune
45
46
  archive_builder.build(platforms)
46
47
  end
@@ -48,7 +49,7 @@ module CarthageCache
48
49
 
49
50
  def prune_build_directory(white_list)
50
51
  white_list ||= config.prune_white_list
51
-
52
+
52
53
  if white_list && File.exist?(white_list)
53
54
  terminal.vputs "Prunning build directory with white list '#{white_list}' ..."
54
55
  white_list = YAML.load(File.read(white_list))
@@ -59,6 +60,16 @@ module CarthageCache
59
60
  build_collector.delete_unused_frameworks(white_list)
60
61
  end
61
62
 
63
+ def validate_installation
64
+ if carthage_cache_lock.valid_digest?(project.archive_key)
65
+ terminal.puts "You installation is valid."
66
+ true
67
+ else
68
+ terminal.puts "Your current Carthage digest '#{project.archive_key}' does not match digest '#{carthage_cache_lock.lock_digest}' in '#{carthage_cache_lock.lock_file_path}'"
69
+ false
70
+ end
71
+ end
72
+
62
73
  private
63
74
 
64
75
  def archive_installer
@@ -73,6 +84,10 @@ module CarthageCache
73
84
  @build_collector ||= BuildCollector.new(terminal, project.carthage_build_directory, project.all_frameworks)
74
85
  end
75
86
 
87
+ def carthage_cache_lock
88
+ @carthage_cache_lock ||= CarthageCacheLock.new(project.carthage_build_directory)
89
+ end
90
+
76
91
  end
77
92
 
78
93
  end
@@ -31,7 +31,14 @@ module CarthageCache
31
31
  else
32
32
  terminal.puts "Archiving Carthage build directory for all platforms."
33
33
  end
34
- filter_block = ->(platform) { platforms.map(&:downcase).include?(platform.downcase) } if platforms
34
+
35
+ filter_block = nil
36
+ if platforms
37
+ filter_block = ->(file) do
38
+ lock_file?(file) || platforms.map(&:downcase).include?(file.downcase)
39
+ end
40
+ end
41
+
35
42
  archiver.archive(project.carthage_build_directory, archive_path, &filter_block)
36
43
  archive_path
37
44
  end
@@ -41,6 +48,10 @@ module CarthageCache
41
48
  repository.upload(project.archive_filename, archive_path)
42
49
  end
43
50
 
51
+ def lock_file?(file)
52
+ file == CarthageCacheLock::LOCK_FILE_NAME
53
+ end
54
+
44
55
  end
45
56
 
46
57
  end
@@ -0,0 +1,28 @@
1
+
2
+ module CarthageCache
3
+
4
+ class CarthageCacheLock
5
+
6
+ LOCK_FILE_NAME = "CarthageCache.lock"
7
+
8
+ attr_reader :lock_file_path
9
+
10
+ def initialize(build_directory)
11
+ @lock_file_path = File.join(build_directory, LOCK_FILE_NAME)
12
+ end
13
+
14
+ def lock_digest
15
+ File.read(lock_file_path).strip if File.exist?(lock_file_path)
16
+ end
17
+
18
+ def write_lock_digest(digest)
19
+ File.open(lock_file_path, "w") { |f| f.write(digest) }
20
+ end
21
+
22
+ def valid_digest?(digest)
23
+ lock_digest == digest
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -1,3 +1,3 @@
1
1
  module CarthageCache
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carthage_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guido Marucci Blas
@@ -152,6 +152,7 @@ files:
152
152
  - lib/carthage_cache/archive_installer.rb
153
153
  - lib/carthage_cache/archiver.rb
154
154
  - lib/carthage_cache/build_collector.rb
155
+ - lib/carthage_cache/carthage_cache_lock.rb
155
156
  - lib/carthage_cache/carthage_resolved_file.rb
156
157
  - lib/carthage_cache/configuration.rb
157
158
  - lib/carthage_cache/configuration_validator.rb