cocoapods-core 0.30.0 → 1.15.2
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 +5 -5
- data/README.md +7 -10
- data/lib/cocoapods-core/build_type.rb +121 -0
- data/lib/cocoapods-core/cdn_source.rb +501 -0
- data/lib/cocoapods-core/core_ui.rb +4 -3
- data/lib/cocoapods-core/dependency.rb +100 -73
- data/lib/cocoapods-core/gem_version.rb +1 -2
- data/lib/cocoapods-core/github.rb +32 -5
- data/lib/cocoapods-core/http.rb +86 -0
- data/lib/cocoapods-core/lockfile.rb +161 -56
- data/lib/cocoapods-core/metrics.rb +47 -0
- data/lib/cocoapods-core/platform.rb +99 -11
- data/lib/cocoapods-core/podfile/dsl.rb +623 -124
- data/lib/cocoapods-core/podfile/target_definition.rb +662 -109
- data/lib/cocoapods-core/podfile.rb +138 -65
- data/lib/cocoapods-core/requirement.rb +37 -8
- data/lib/cocoapods-core/source/acceptor.rb +16 -13
- data/lib/cocoapods-core/source/aggregate.rb +79 -103
- data/lib/cocoapods-core/source/health_reporter.rb +9 -18
- data/lib/cocoapods-core/source/manager.rb +488 -0
- data/lib/cocoapods-core/source/metadata.rb +79 -0
- data/lib/cocoapods-core/source.rb +241 -70
- data/lib/cocoapods-core/specification/consumer.rb +187 -47
- data/lib/cocoapods-core/specification/dsl/attribute.rb +49 -85
- data/lib/cocoapods-core/specification/dsl/attribute_support.rb +6 -8
- data/lib/cocoapods-core/specification/dsl/deprecations.rb +9 -126
- data/lib/cocoapods-core/specification/dsl/platform_proxy.rb +30 -20
- data/lib/cocoapods-core/specification/dsl.rb +943 -296
- data/lib/cocoapods-core/specification/json.rb +64 -23
- data/lib/cocoapods-core/specification/linter/analyzer.rb +218 -0
- data/lib/cocoapods-core/specification/linter/result.rb +128 -0
- data/lib/cocoapods-core/specification/linter.rb +310 -309
- data/lib/cocoapods-core/specification/root_attribute_accessors.rb +90 -39
- data/lib/cocoapods-core/specification/set/presenter.rb +35 -71
- data/lib/cocoapods-core/specification/set.rb +42 -96
- data/lib/cocoapods-core/specification.rb +368 -130
- data/lib/cocoapods-core/standard_error.rb +45 -24
- data/lib/cocoapods-core/trunk_source.rb +14 -0
- data/lib/cocoapods-core/vendor/requirement.rb +133 -53
- data/lib/cocoapods-core/vendor/version.rb +197 -156
- data/lib/cocoapods-core/vendor.rb +1 -5
- data/lib/cocoapods-core/version.rb +137 -42
- data/lib/cocoapods-core/yaml_helper.rb +334 -0
- data/lib/cocoapods-core.rb +10 -4
- metadata +100 -27
- data/lib/cocoapods-core/source/abstract_data_provider.rb +0 -71
- data/lib/cocoapods-core/source/file_system_data_provider.rb +0 -150
- data/lib/cocoapods-core/source/github_data_provider.rb +0 -143
- data/lib/cocoapods-core/specification/set/statistics.rb +0 -266
- data/lib/cocoapods-core/yaml_converter.rb +0 -192
@@ -1,266 +0,0 @@
|
|
1
|
-
module Pod
|
2
|
-
class Specification
|
3
|
-
class Set
|
4
|
-
|
5
|
-
# The statistics class provides information about one or more {Set} that
|
6
|
-
# is not readily available because expensive to compute or provided by a
|
7
|
-
# remote source.
|
8
|
-
#
|
9
|
-
# The class provides also facilities to work with a collection of sets.
|
10
|
-
# It always caches in memory the computed values and it can take an
|
11
|
-
# optional path to cache file that it is responsible of populating and
|
12
|
-
# invalidating.
|
13
|
-
#
|
14
|
-
# To reuse the in memory cache and to minimize the disk access to the
|
15
|
-
# cache file a shared instance is also available.
|
16
|
-
#
|
17
|
-
class Statistics
|
18
|
-
|
19
|
-
# @return [Statistics] the shared statistics instance.
|
20
|
-
#
|
21
|
-
def self.instance
|
22
|
-
@instance ||= new
|
23
|
-
end
|
24
|
-
|
25
|
-
# Allows to set the shared instance.
|
26
|
-
#
|
27
|
-
# @param [Statistics] instance
|
28
|
-
# the new shared instance or nil.
|
29
|
-
#
|
30
|
-
# @return [Statistics] the shared statistics instance.
|
31
|
-
#
|
32
|
-
def self.instance=(instance)
|
33
|
-
@instance = instance
|
34
|
-
end
|
35
|
-
|
36
|
-
# @return [Pathname] the path to the optional cache file.
|
37
|
-
#
|
38
|
-
# @note The cache file can be specified after initialization, but
|
39
|
-
# it has to be configured before requiring any value, otherwise
|
40
|
-
# it is ignored.
|
41
|
-
#
|
42
|
-
attr_accessor :cache_file
|
43
|
-
|
44
|
-
# @return [Integer] the number of seconds after which the caches of
|
45
|
-
# values that might changed are discarded.
|
46
|
-
#
|
47
|
-
# @note If not specified on initialization defaults to 3 days.
|
48
|
-
#
|
49
|
-
attr_accessor :cache_expiration
|
50
|
-
|
51
|
-
# @param [Pathname] cache_file @see cache_file
|
52
|
-
#
|
53
|
-
# @param [Integer] cache_expiration @see cache_expiration
|
54
|
-
#
|
55
|
-
def initialize(cache_file = nil, cache_expiration = (60 * 60 * 24 * 3))
|
56
|
-
require 'yaml'
|
57
|
-
|
58
|
-
@cache_file = cache_file
|
59
|
-
@cache_expiration = cache_expiration
|
60
|
-
end
|
61
|
-
|
62
|
-
#---------------------------------------------------------------------#
|
63
|
-
|
64
|
-
# @!group Accessing the statistics
|
65
|
-
|
66
|
-
# Computes the date in which the first podspec of a set was committed
|
67
|
-
# on its git source.
|
68
|
-
#
|
69
|
-
# @param [Set] set
|
70
|
-
# the set for the Pod whose creation date is needed.
|
71
|
-
#
|
72
|
-
# @note The set should be generated with only the source that is
|
73
|
-
# analyzed. If there are more than one the first one is
|
74
|
-
# processed.
|
75
|
-
#
|
76
|
-
# @note This method needs to traverse the git history of the repo and
|
77
|
-
# thus incurs in a performance hit.
|
78
|
-
#
|
79
|
-
# @return [Time] the date in which a Pod appeared for the first time on
|
80
|
-
# the {Source}.
|
81
|
-
#
|
82
|
-
def creation_date(set)
|
83
|
-
date = compute_creation_date(set)
|
84
|
-
save_cache
|
85
|
-
date
|
86
|
-
end
|
87
|
-
|
88
|
-
# Computes the date in which the first podspec of each given set was
|
89
|
-
# committed on its git source.
|
90
|
-
#
|
91
|
-
# @param [Array<Set>] sets
|
92
|
-
# the list of the sets for the Pods whose creation date is
|
93
|
-
# needed.
|
94
|
-
#
|
95
|
-
# @note @see creation_date
|
96
|
-
#
|
97
|
-
# @note This method is optimized for multiple sets because it saves
|
98
|
-
# the cache file only once.
|
99
|
-
#
|
100
|
-
# @return [Array<Time>] the list of the dates in which the Pods
|
101
|
-
# appeared for the first time on the {Source}.
|
102
|
-
#
|
103
|
-
def creation_dates(sets)
|
104
|
-
dates = {}
|
105
|
-
sets.each { |set| dates[set.name] = compute_creation_date(set) }
|
106
|
-
save_cache
|
107
|
-
dates
|
108
|
-
end
|
109
|
-
|
110
|
-
# Computes the number of likes that a Pod has on Github.
|
111
|
-
#
|
112
|
-
# @param [Set] set
|
113
|
-
# the set of the Pod.
|
114
|
-
#
|
115
|
-
# @return [Integer] the number of likes or nil if the Pod is not hosted
|
116
|
-
# on GitHub.
|
117
|
-
#
|
118
|
-
def github_watchers(set)
|
119
|
-
github_stats_if_needed(set)
|
120
|
-
get_value(set, :gh_watchers)
|
121
|
-
end
|
122
|
-
|
123
|
-
# Computes the number of forks that a Pod has on Github.
|
124
|
-
#
|
125
|
-
# @param [Set] set @see github_watchers
|
126
|
-
#
|
127
|
-
# @return [Integer] the number of forks or nil if the Pod is not hosted
|
128
|
-
# on GitHub.
|
129
|
-
#
|
130
|
-
def github_forks(set)
|
131
|
-
github_stats_if_needed(set)
|
132
|
-
get_value(set, :gh_forks)
|
133
|
-
end
|
134
|
-
|
135
|
-
# Computes the number of likes that a Pod has on Github.
|
136
|
-
#
|
137
|
-
# @param [Set] set @see github_watchers
|
138
|
-
#
|
139
|
-
# @return [Time] the time of the last push or nil if the Pod is not
|
140
|
-
# hosted on GitHub.
|
141
|
-
#
|
142
|
-
def github_pushed_at(set)
|
143
|
-
github_stats_if_needed(set)
|
144
|
-
string_time = get_value(set, :pushed_at)
|
145
|
-
Time.parse(string_time) if string_time
|
146
|
-
end
|
147
|
-
|
148
|
-
#---------------------------------------------------------------------#
|
149
|
-
|
150
|
-
private
|
151
|
-
|
152
|
-
# @return [Hash{String => Hash}] the in-memory cache, where for each
|
153
|
-
# set is stored a hash with the result of the computations.
|
154
|
-
#
|
155
|
-
def cache
|
156
|
-
unless @cache
|
157
|
-
if cache_file && cache_file.exist?
|
158
|
-
@cache = YAML.load(cache_file.read)
|
159
|
-
else
|
160
|
-
@cache = {}
|
161
|
-
end
|
162
|
-
end
|
163
|
-
@cache
|
164
|
-
end
|
165
|
-
|
166
|
-
# Returns the value for the given key of a set stored in the cache, if
|
167
|
-
# available.
|
168
|
-
#
|
169
|
-
# @param [Set] set
|
170
|
-
# the set for which the value is needed.
|
171
|
-
#
|
172
|
-
# @param [Symbol] key
|
173
|
-
# the key of the value.
|
174
|
-
#
|
175
|
-
# @return [Object] the value or nil.
|
176
|
-
#
|
177
|
-
def get_value(set, key)
|
178
|
-
if cache[set.name] && cache[set.name][key]
|
179
|
-
cache[set.name][key]
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
# Stores the given value of a set for the given key in the cache.
|
184
|
-
#
|
185
|
-
# @param [Set] set
|
186
|
-
# the set for which the value has to be stored.
|
187
|
-
#
|
188
|
-
# @param [Symbol] key
|
189
|
-
# the key of the value.
|
190
|
-
#
|
191
|
-
# @param [Object] value
|
192
|
-
# the value to store.
|
193
|
-
#
|
194
|
-
# @return [Object] the value or nil.
|
195
|
-
#
|
196
|
-
def set_value(set, key, value)
|
197
|
-
cache[set.name] ||= {}
|
198
|
-
cache[set.name][key] = value
|
199
|
-
end
|
200
|
-
|
201
|
-
# Saves the in-memory cache to the path of cache file if specified.
|
202
|
-
#
|
203
|
-
# @return [void]
|
204
|
-
#
|
205
|
-
def save_cache
|
206
|
-
if cache_file
|
207
|
-
yaml = YAML.dump(cache)
|
208
|
-
File.open(cache_file, 'w') { |f| f.write(yaml) }
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
# Analyzes the history of the git repository of the {Source} of the
|
213
|
-
# given {Set} to find when its folder was created.
|
214
|
-
#
|
215
|
-
# @param [Set] set
|
216
|
-
# the set for which the creation date is needed.
|
217
|
-
#
|
218
|
-
# @return [Time] the date in which a Pod was created.
|
219
|
-
#
|
220
|
-
def compute_creation_date(set)
|
221
|
-
date = get_value(set, :creation_date)
|
222
|
-
unless date
|
223
|
-
Dir.chdir(set.sources.first.data_provider.repo) do
|
224
|
-
git_log = `git log --first-parent --format=%ct "#{set.name}"`
|
225
|
-
creation_date = git_log.split("\n").last.to_i
|
226
|
-
date = Time.at(creation_date)
|
227
|
-
end
|
228
|
-
set_value(set, :creation_date, date)
|
229
|
-
end
|
230
|
-
date
|
231
|
-
end
|
232
|
-
|
233
|
-
# Retrieved the GitHub information from the API for the given set and
|
234
|
-
# stores it in the in-memory cache.
|
235
|
-
#
|
236
|
-
# @note If there is a valid cache and it was generated withing the
|
237
|
-
# expiration time frame this method does nothing.
|
238
|
-
#
|
239
|
-
# @param [Set] set
|
240
|
-
# the set for which the GitHub information is needed.
|
241
|
-
#
|
242
|
-
# @return [void]
|
243
|
-
#
|
244
|
-
def github_stats_if_needed(set)
|
245
|
-
update_date = get_value(set, :gh_date)
|
246
|
-
return if update_date && update_date > (Time.now - cache_expiration)
|
247
|
-
|
248
|
-
spec = set.specification
|
249
|
-
url = spec.source[:git]
|
250
|
-
repo = GitHub.repo(url) if url
|
251
|
-
|
252
|
-
if repo
|
253
|
-
set_value(set, :gh_watchers, repo['watchers'])
|
254
|
-
set_value(set, :gh_forks, repo['forks'])
|
255
|
-
set_value(set, :pushed_at, repo['pushed_at'])
|
256
|
-
set_value(set, :gh_date, Time.now)
|
257
|
-
save_cache
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
#---------------------------------------------------------------------#
|
262
|
-
|
263
|
-
end
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
@@ -1,192 +0,0 @@
|
|
1
|
-
module Pod
|
2
|
-
|
3
|
-
# Converts objects to their YAML representation.
|
4
|
-
#
|
5
|
-
# This class was created for the need having control on how the YAML is
|
6
|
-
# representation is generated. In details it provides:
|
7
|
-
#
|
8
|
-
# - sorting for hashes in ruby 1.8.x
|
9
|
-
# - ability to hint the sorting of the keys of a dictionary when converting
|
10
|
-
# it. In this case the keys are also separated by an additional new line
|
11
|
-
# feed for readability.
|
12
|
-
#
|
13
|
-
# @note This class misses important features necessary for a correct YAML
|
14
|
-
# serialization and thus it is safe to use only for the Lockfile.
|
15
|
-
# The missing features include:
|
16
|
-
# - Strings are never quoted even when ambiguous.
|
17
|
-
#
|
18
|
-
class YAMLConverter
|
19
|
-
|
20
|
-
class << self
|
21
|
-
|
22
|
-
# Returns the YAML representation of the given object. If the given object
|
23
|
-
# is an Hash it accepts an optional hint for sorting the keys.
|
24
|
-
#
|
25
|
-
# @param [String, Symbol, Array, Hash] object
|
26
|
-
# the object to convert
|
27
|
-
#
|
28
|
-
# @param [Array] hash_keys_hint
|
29
|
-
# an array to use as a hint for sorting the keys of the object to
|
30
|
-
# convert if it is an hash.
|
31
|
-
#
|
32
|
-
# @return [String] the YAML representation of the given object.
|
33
|
-
#
|
34
|
-
def convert(value)
|
35
|
-
result = process_according_to_class(value)
|
36
|
-
result << "\n"
|
37
|
-
end
|
38
|
-
|
39
|
-
def convert_hash(value, hash_keys_hint, line_separator = "\n")
|
40
|
-
result = process_hash(value, hash_keys_hint, line_separator)
|
41
|
-
result << "\n"
|
42
|
-
end
|
43
|
-
|
44
|
-
#-----------------------------------------------------------------------#
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
# Implementation notes:
|
49
|
-
#
|
50
|
-
# - each of the methods returns a YAML partial without an ending new
|
51
|
-
# line.
|
52
|
-
# - if a partial needs to be indented is responsibility of the method
|
53
|
-
# using it.
|
54
|
-
#
|
55
|
-
# ---
|
56
|
-
|
57
|
-
# @!group Private Helpers
|
58
|
-
|
59
|
-
# @return [String] the YAML representation of the given object.
|
60
|
-
#
|
61
|
-
def process_according_to_class(value, hash_keys_hint = nil)
|
62
|
-
case value
|
63
|
-
when String then value
|
64
|
-
when Symbol then ":#{value}"
|
65
|
-
when TrueClass then 'true'
|
66
|
-
when FalseClass then 'false'
|
67
|
-
when Array then process_array(value)
|
68
|
-
when Hash then process_hash(value, hash_keys_hint)
|
69
|
-
else
|
70
|
-
raise StandardError, "Unsupported class for YAML conversion " \
|
71
|
-
"#{value.class}"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# Converts an array to YAML after sorting it.
|
76
|
-
#
|
77
|
-
# @param [Array] array
|
78
|
-
# the array to convert.
|
79
|
-
#
|
80
|
-
# @return [String] the YAML representation of the given object.
|
81
|
-
#
|
82
|
-
def process_array(array)
|
83
|
-
result = []
|
84
|
-
sorted_array(array).each do |array_value|
|
85
|
-
result << process_according_to_class(array_value)
|
86
|
-
end
|
87
|
-
"- #{result * "\n- "}"
|
88
|
-
end
|
89
|
-
|
90
|
-
# Converts a hash to YAML after sorting its keys. Optionally accepts a
|
91
|
-
# hint for sorting the keys.
|
92
|
-
#
|
93
|
-
# @note If a hint for sorting the keys is provided the array is assumed
|
94
|
-
# to be the root object and the keys are separated by an
|
95
|
-
# additional new line feed for readability.
|
96
|
-
#
|
97
|
-
# @note If the value of a given key is a String it displayed inline,
|
98
|
-
# otherwise it is displayed below and indented.
|
99
|
-
#
|
100
|
-
# @param [Hash] hash
|
101
|
-
# the hash to convert.
|
102
|
-
#
|
103
|
-
# @return [String] the YAML representation of the given object.
|
104
|
-
#
|
105
|
-
def process_hash(hash, hash_keys_hint = nil, line_separator = "\n")
|
106
|
-
keys = sorted_array_with_hint(hash.keys, hash_keys_hint)
|
107
|
-
key_lines = []
|
108
|
-
keys.each do |key|
|
109
|
-
key_value = hash[key]
|
110
|
-
processed = process_according_to_class(key_value)
|
111
|
-
processed_key = process_according_to_class(key)
|
112
|
-
case key_value
|
113
|
-
when Array, Hash
|
114
|
-
key_partial_yaml = processed.lines.map { |line| " #{line}" } * ""
|
115
|
-
key_lines << "#{processed_key}:\n#{key_partial_yaml}"
|
116
|
-
else
|
117
|
-
key_lines << "#{processed_key}: #{processed}"
|
118
|
-
end
|
119
|
-
end
|
120
|
-
key_lines * line_separator
|
121
|
-
end
|
122
|
-
|
123
|
-
#-----------------------------------------------------------------------#
|
124
|
-
|
125
|
-
private
|
126
|
-
|
127
|
-
# @!group Array Sorting
|
128
|
-
|
129
|
-
# Sorts an array using another one as a sort hint. All the values of the
|
130
|
-
# hint which appear in the array will be returned respecting the order in
|
131
|
-
# the hint. If any other key is present in the original array they are
|
132
|
-
# sorted using the {#sorted_array} method.
|
133
|
-
#
|
134
|
-
# @param [Array] array
|
135
|
-
# The array which needs to be sorted.
|
136
|
-
#
|
137
|
-
# @param [Array] sort_hint
|
138
|
-
# The array which should be used to sort the keys.
|
139
|
-
#
|
140
|
-
# @return [Array] The sorted Array.
|
141
|
-
#
|
142
|
-
def sorted_array_with_hint(array, sort_hint)
|
143
|
-
if sort_hint
|
144
|
-
hinted = sort_hint & array
|
145
|
-
remaining = array - sort_hint
|
146
|
-
hinted + sorted_array(remaining)
|
147
|
-
else
|
148
|
-
sorted_array(array)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
# Sorts an array according to the string representation of it values.
|
153
|
-
# This method allows to sort arrays which contains strings or hashes.
|
154
|
-
#
|
155
|
-
# @note If the value contained in the array is another Array or a Hash
|
156
|
-
# the first value of the collection is used for sorting, as this
|
157
|
-
# method is more useful, for arrays which contains a collection
|
158
|
-
# composed by one object.
|
159
|
-
#
|
160
|
-
# @todo This stuff is here only because the Lockfile intermixes strings
|
161
|
-
# and hashes for the `PODS` key. The Lockfile should be more
|
162
|
-
# consistent.
|
163
|
-
#
|
164
|
-
# @return [Array] The sorted array.
|
165
|
-
#
|
166
|
-
def sorted_array(array)
|
167
|
-
array.sort do |x, y|
|
168
|
-
x_string = sorting_string(x)
|
169
|
-
y_string = sorting_string(y)
|
170
|
-
x_string <=> y_string
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
# Returns the string representation of a value useful for sorting.
|
175
|
-
#
|
176
|
-
# @param [String, Symbol, Array, Hash] value
|
177
|
-
# The value which needs to be sorted
|
178
|
-
#
|
179
|
-
# @return [String] A string useful to compare the value with other ones.
|
180
|
-
#
|
181
|
-
def sorting_string(value)
|
182
|
-
return "" unless value
|
183
|
-
case value
|
184
|
-
when String then value.downcase
|
185
|
-
when Symbol then sorting_string(value.to_s)
|
186
|
-
when Array then sorting_string(value.first)
|
187
|
-
when Hash then value.keys.map { |key| key.to_s.downcase }.sort.first
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|