carthage_remote_cache 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,90 @@
1
+ require 'json'
2
+ require 'fileutils'
3
+
4
+ # .version file representation, see Carthage documentation on them:
5
+ # https://github.com/Carthage/Carthage/blob/master/Documentation/VersionFile.md
6
+ class VersionFile
7
+
8
+ attr_reader :path, :version, :frameworks_by_platform
9
+
10
+ def initialize(path)
11
+ @path = path
12
+ parse
13
+ end
14
+
15
+ # Returns a Hash, e.g.
16
+ # ```
17
+ # {
18
+ # "CocoaLumberjack" => [:iOS, :watchOS],
19
+ # "Lottie" => [:iOS],
20
+ # }
21
+ # ```
22
+ def platforms_by_framework
23
+ result = Hash.new { |h, k| h[k] = [] }
24
+ for framework_name in framework_names do
25
+ @frameworks_by_platform.each do |platform, framework_names_in_platform|
26
+ if framework_names_in_platform.include?(framework_name)
27
+ result[framework_name] << platform
28
+ end
29
+ end
30
+ end
31
+ result
32
+ end
33
+
34
+ # Unique array of framework names.
35
+ def framework_names
36
+ @frameworks_by_platform.values.flatten.uniq.sort
37
+ end
38
+
39
+ # Total number of frameworks accross all platforms.
40
+ def number_of_frameworks
41
+ @frameworks_by_platform.values.flatten.count
42
+ end
43
+
44
+ def move_to_build_dir
45
+ basename = File.basename(@path)
46
+ target_path = File.join(CARTHAGE_BUILD_DIR, basename)
47
+ FileUtils.mv(@path, target_path)
48
+ @path = target_path
49
+ end
50
+
51
+ def remove
52
+ FileUtils.rm(@path)
53
+ end
54
+
55
+ def same_content?(other_version_file)
56
+ if other_version_file.nil?
57
+ false
58
+ else
59
+ FileUtils.compare_file(@path, other_version_file.path)
60
+ end
61
+ end
62
+
63
+ private
64
+
65
+ def parse
66
+ raise "File #{path} doesn't exist, has carthage been bootstrapped?" unless File.exist?(@path)
67
+
68
+ file = File.read(@path)
69
+ json = JSON.parse(file)
70
+
71
+ @version = json['commitish']
72
+ raise "Version is missing in #{@path}" if @version.nil? || @version.empty?
73
+
74
+ @frameworks_by_platform = {
75
+ :iOS => parse_platform_array(json['iOS']),
76
+ :macOS => parse_platform_array(json['Mac']),
77
+ :tvOS => parse_platform_array(json['tvOS']),
78
+ :watchOS => parse_platform_array(json['watchOS']),
79
+ }
80
+ end
81
+
82
+ def parse_platform_array(array)
83
+ if array.kind_of?(Array)
84
+ array.map { |entry| entry['name'] }
85
+ else
86
+ []
87
+ end
88
+ end
89
+
90
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: carthage_remote_cache
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Juraj Blahunka
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rerun
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: concurrent-ruby
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.5
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.0.5
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.0.4
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.0.4
83
+ - !ruby/object:Gem::Dependency
84
+ name: rest-client
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.0.2
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.0.2
97
+ - !ruby/object:Gem::Dependency
98
+ name: sinatra
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 2.0.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 2.0.0
111
+ description: Centralized cache to serve carthage frameworks. Useful for distributed
112
+ CI setup with several build machines.
113
+ email:
114
+ - jblahunka@kayak.com
115
+ executables:
116
+ - carthagerc
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - ".gitignore"
121
+ - Gemfile
122
+ - Gemfile.lock
123
+ - LICENSE
124
+ - README.md
125
+ - Rakefile
126
+ - bin/carthagerc
127
+ - carthage_remote_cache.gemspec
128
+ - dev/console
129
+ - dev/setup
130
+ - dev/start_server
131
+ - lib/api.rb
132
+ - lib/carthage_archive.rb
133
+ - lib/carthage_dependency.rb
134
+ - lib/carthage_remote_cache.rb
135
+ - lib/commands.rb
136
+ - lib/commands/download_command.rb
137
+ - lib/commands/init_command.rb
138
+ - lib/commands/server_command.rb
139
+ - lib/commands/upload_command.rb
140
+ - lib/configuration.rb
141
+ - lib/constants.rb
142
+ - lib/errors.rb
143
+ - lib/log.rb
144
+ - lib/networking.rb
145
+ - lib/server/config.ru
146
+ - lib/server/server_app.rb
147
+ - lib/utils.rb
148
+ - lib/version_file.rb
149
+ homepage: https://github.com/kayak/carthage_remote_cache
150
+ licenses:
151
+ - Apache-2.0
152
+ metadata: {}
153
+ post_install_message:
154
+ rdoc_options: []
155
+ require_paths:
156
+ - lib
157
+ required_ruby_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ required_rubygems_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ requirements: []
168
+ rubyforge_project:
169
+ rubygems_version: 2.5.2
170
+ signing_key:
171
+ specification_version: 4
172
+ summary: Centralized cache to serve carthage frameworks. Useful for distributed CI
173
+ setup with several build machines.
174
+ test_files: []