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,5 +1,4 @@
|
|
1
1
|
module Pod
|
2
|
-
|
3
2
|
# The Version class stores information about the version of a
|
4
3
|
# {Specification}.
|
5
4
|
#
|
@@ -31,54 +30,30 @@ module Pod
|
|
31
30
|
# 4. 0.9
|
32
31
|
#
|
33
32
|
class Version < Pod::Vendor::Gem::Version
|
34
|
-
|
35
|
-
#
|
36
|
-
# Versioning
|
33
|
+
# Override the constants defined by the superclass to add:
|
34
|
+
# - Semantic Versioning prerelease support (with a dash). E.g.: 1.0.0-alpha1
|
35
|
+
# - Semantic Versioning metadata support (with a +) E.g: 1.0.0+96ef7ed
|
37
36
|
#
|
38
37
|
# For more info, see: http://semver.org
|
39
38
|
#
|
40
|
-
|
39
|
+
METADATA_PATTERN = '(\+[0-9a-zA-Z\-\.]+)'
|
40
|
+
VERSION_PATTERN = "[0-9]+(\\.[0-9a-zA-Z\\-]+)*#{METADATA_PATTERN}?"
|
41
41
|
ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})*\s*\z/
|
42
42
|
|
43
|
-
# @return [Bool] whether the version represents the `head` of repository.
|
44
|
-
#
|
45
|
-
attr_accessor :head
|
46
|
-
alias_method :head?, :head
|
47
|
-
|
48
43
|
# @param [String,Version] version
|
49
44
|
# A string representing a version, or another version.
|
50
45
|
#
|
51
|
-
# @todo The `from` part of the regular expression should be remove in
|
52
|
-
# CocoaPods 1.0.0.
|
53
|
-
#
|
54
46
|
def initialize(version)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
version = Regexp.last_match[2]
|
60
|
-
@head = true
|
61
|
-
end
|
62
|
-
super(version)
|
47
|
+
raise ArgumentError, "Malformed version number string #{version}" unless
|
48
|
+
self.class.correct?(version)
|
49
|
+
|
50
|
+
@version = version.to_s.strip
|
63
51
|
end
|
64
52
|
|
65
53
|
# An instance that represents version 0.
|
66
54
|
#
|
67
55
|
ZERO = new('0')
|
68
56
|
|
69
|
-
# @return [String] a string representation that indicates if the version is
|
70
|
-
# head.
|
71
|
-
#
|
72
|
-
# @note The raw version string is still accessible with the {#version}
|
73
|
-
# method.
|
74
|
-
#
|
75
|
-
# @todo Adding the head information to the string representation creates
|
76
|
-
# issues (see Dependency#requirement).
|
77
|
-
#
|
78
|
-
def to_s
|
79
|
-
head? ? "HEAD based on #{super}" : super
|
80
|
-
end
|
81
|
-
|
82
57
|
# @return [String] a string representation suitable for debugging.
|
83
58
|
#
|
84
59
|
def inspect
|
@@ -93,10 +68,12 @@ module Pod
|
|
93
68
|
# For more info, see: http://semver.org
|
94
69
|
#
|
95
70
|
def prerelease?
|
96
|
-
@prerelease
|
71
|
+
return @prerelease if defined?(@prerelease)
|
72
|
+
comparable_version = @version.sub(/#{METADATA_PATTERN}$/, '')
|
73
|
+
@prerelease = comparable_version =~ /[a-zA-Z\-]/
|
97
74
|
end
|
98
75
|
|
99
|
-
# @return [
|
76
|
+
# @return [Boolean] Whether a string representation is correct.
|
100
77
|
#
|
101
78
|
def self.correct?(version)
|
102
79
|
version.to_s =~ ANCHORED_VERSION_PATTERN
|
@@ -106,10 +83,10 @@ module Pod
|
|
106
83
|
|
107
84
|
# @!group Semantic Versioning
|
108
85
|
|
109
|
-
SEMVER_PATTERN =
|
86
|
+
SEMVER_PATTERN = "[0-9]+(\\.[0-9]+(\\.[0-9]+(-[0-9A-Za-z\\-\\.]+)?#{METADATA_PATTERN}?)?)?"
|
110
87
|
ANCHORED_SEMANTIC_VERSION_PATTERN = /\A\s*(#{SEMVER_PATTERN})*\s*\z/
|
111
88
|
|
112
|
-
# @return [
|
89
|
+
# @return [Boolean] Whether the version conforms to the Semantic Versioning
|
113
90
|
# specification (2.0.0-rc.1).
|
114
91
|
#
|
115
92
|
# @note This comparison is lenient.
|
@@ -123,22 +100,140 @@ module Pod
|
|
123
100
|
# @return [Fixnum] The semver major identifier.
|
124
101
|
#
|
125
102
|
def major
|
126
|
-
|
103
|
+
numeric_segments[0].to_i
|
127
104
|
end
|
128
105
|
|
129
106
|
# @return [Fixnum] The semver minor identifier.
|
130
107
|
#
|
131
108
|
def minor
|
132
|
-
|
109
|
+
numeric_segments[1].to_i
|
133
110
|
end
|
134
111
|
|
135
112
|
# @return [Fixnum] The semver patch identifier.
|
136
113
|
#
|
137
114
|
def patch
|
138
|
-
|
115
|
+
numeric_segments[2].to_i
|
139
116
|
end
|
140
117
|
|
141
|
-
|
118
|
+
# Compares the versions for sorting.
|
119
|
+
#
|
120
|
+
# @param [Version] other
|
121
|
+
# The other version to compare.
|
122
|
+
#
|
123
|
+
# @return [Fixnum] -1, 0, or +1 depending on whether the receiver is less
|
124
|
+
# than, equal to, or greater than other.
|
125
|
+
#
|
126
|
+
# @note Attempts to compare something that's not a {Version} return nil
|
127
|
+
#
|
128
|
+
def <=>(other)
|
129
|
+
comparison = compare_segments(other)
|
130
|
+
comparison == 0 ? version <=> other.version : comparison
|
131
|
+
end
|
142
132
|
|
133
|
+
# @private
|
134
|
+
#
|
135
|
+
# Compares the versions for equality.
|
136
|
+
#
|
137
|
+
# @param [Version] other
|
138
|
+
# The other version to compare.
|
139
|
+
#
|
140
|
+
# @return [Boolean] whether the receiver is equal to other.
|
141
|
+
#
|
142
|
+
# @note Attempts to compare something that's not a {Version} return nil
|
143
|
+
#
|
144
|
+
def ==(other)
|
145
|
+
compare_segments(other) == 0
|
146
|
+
end
|
147
|
+
|
148
|
+
# @private
|
149
|
+
#
|
150
|
+
# Compares the versions for equality.
|
151
|
+
#
|
152
|
+
# @param [Version] other
|
153
|
+
# The other version to compare.
|
154
|
+
#
|
155
|
+
# @return [Boolean] whether the receiver is greater than or equal to other.
|
156
|
+
#
|
157
|
+
# @note Attempts to compare something that's not a {Version} return nil
|
158
|
+
#
|
159
|
+
def >=(other)
|
160
|
+
comparison = compare_segments(other)
|
161
|
+
comparison >= 0
|
162
|
+
end
|
163
|
+
|
164
|
+
# @private
|
165
|
+
#
|
166
|
+
# Compares the versions for equality.
|
167
|
+
#
|
168
|
+
# @param [Version] other
|
169
|
+
# The other version to compare.
|
170
|
+
#
|
171
|
+
# @return [Boolean] whether the receiver is less than or equal to other.
|
172
|
+
#
|
173
|
+
# @note Attempts to compare something that's not a {Version} return nil
|
174
|
+
#
|
175
|
+
def <=(other)
|
176
|
+
comparison = compare_segments(other)
|
177
|
+
comparison <= 0
|
178
|
+
end
|
179
|
+
|
180
|
+
protected
|
181
|
+
|
182
|
+
# This overrides the Gem::Version implementation of `_segments` to drop the
|
183
|
+
# metadata from comparisons as per http://semver.org/#spec-item-10
|
184
|
+
#
|
185
|
+
def _segments
|
186
|
+
# segments is lazy so it can pick up version values that come from
|
187
|
+
# old marshaled versions, which don't go through marshal_load.
|
188
|
+
# since this version object is cached in @@all, its @segments should be frozen
|
189
|
+
|
190
|
+
@segments ||= @version.sub(/#{METADATA_PATTERN}$/, '').scan(/[0-9]+|[a-z]+/i).map do |s|
|
191
|
+
/^\d+$/ =~ s ? s.to_i : s
|
192
|
+
end.freeze
|
193
|
+
end
|
194
|
+
|
195
|
+
def numeric_segments
|
196
|
+
@numeric_segments ||= segments.take_while { |s| s.is_a?(Numeric) }.reverse_each.drop_while { |s| s == 0 }.reverse
|
197
|
+
end
|
198
|
+
|
199
|
+
def prerelease_segments
|
200
|
+
@prerelease_segments ||= segments.drop_while { |s| s.is_a?(Numeric) }
|
201
|
+
end
|
202
|
+
|
203
|
+
def compare_segments(other)
|
204
|
+
return unless other.is_a?(Pod::Version)
|
205
|
+
return 0 if @version == other.version
|
206
|
+
|
207
|
+
compare = proc do |segments, other_segments, is_pre_release|
|
208
|
+
limit = [segments.size, other_segments.size].max
|
209
|
+
|
210
|
+
0.upto(limit) do |i|
|
211
|
+
lhs = segments[i]
|
212
|
+
rhs = other_segments[i]
|
213
|
+
|
214
|
+
next if lhs == rhs
|
215
|
+
# If it's pre-release and the first segment, then
|
216
|
+
# this is a special case because a segment missing
|
217
|
+
# means that one is not a pre-release version
|
218
|
+
if is_pre_release && i == 0
|
219
|
+
return 1 if lhs.nil?
|
220
|
+
return -1 if rhs.nil?
|
221
|
+
else
|
222
|
+
return -1 if lhs.nil?
|
223
|
+
return 1 if rhs.nil?
|
224
|
+
end
|
225
|
+
|
226
|
+
if comparison = lhs <=> rhs
|
227
|
+
return comparison
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
compare[numeric_segments, other.numeric_segments, false]
|
233
|
+
compare[prerelease_segments, other.prerelease_segments, true]
|
234
|
+
0
|
235
|
+
end
|
236
|
+
|
237
|
+
#-------------------------------------------------------------------------#
|
143
238
|
end
|
144
239
|
end
|
@@ -0,0 +1,334 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
# Converts objects to their YAML representation.
|
5
|
+
#
|
6
|
+
# This class was created for the need having control on how the YAML is
|
7
|
+
# representation is generated. In details it provides:
|
8
|
+
#
|
9
|
+
# - sorting for hashes in ruby 1.8.x
|
10
|
+
# - ability to hint the sorting of the keys of a dictionary when converting
|
11
|
+
# it. In this case the keys are also separated by an additional new line
|
12
|
+
# feed for readability.
|
13
|
+
#
|
14
|
+
# @note This class misses important features necessary for a correct YAML
|
15
|
+
# serialization and thus it is safe to use only for the Lockfile.
|
16
|
+
# The missing features include:
|
17
|
+
# - Strings are never quoted even when ambiguous.
|
18
|
+
#
|
19
|
+
# @todo Remove any code required solely for Ruby 1.8.x.
|
20
|
+
#
|
21
|
+
class YAMLHelper
|
22
|
+
class << self
|
23
|
+
# Returns the YAML representation of the given object. If the given object
|
24
|
+
# is a Hash, it accepts an optional hint for sorting the keys.
|
25
|
+
#
|
26
|
+
# @param [String, Symbol, Array, Hash] object
|
27
|
+
# the object to convert
|
28
|
+
#
|
29
|
+
# @param [Array] hash_keys_hint
|
30
|
+
# an array to use as a hint for sorting the keys of the object to
|
31
|
+
# convert if it is a hash.
|
32
|
+
#
|
33
|
+
# @return [String] the YAML representation of the given object.
|
34
|
+
#
|
35
|
+
def convert(value)
|
36
|
+
result = process_according_to_class(value)
|
37
|
+
result << "\n"
|
38
|
+
end
|
39
|
+
|
40
|
+
def convert_hash(value, hash_keys_hint, line_separator = "\n")
|
41
|
+
result = process_hash(value, hash_keys_hint, line_separator)
|
42
|
+
result << "\n"
|
43
|
+
end
|
44
|
+
|
45
|
+
# Loads a YAML string and provide more informative
|
46
|
+
# error messages in special cases like merge conflict.
|
47
|
+
#
|
48
|
+
# @param [String] yaml_string
|
49
|
+
# The YAML String to be loaded
|
50
|
+
#
|
51
|
+
# @param [Pathname] file_path
|
52
|
+
# The (optional) file path to be used for read for the YAML file
|
53
|
+
#
|
54
|
+
# @return [Hash, Array] the Ruby YAML representaton
|
55
|
+
#
|
56
|
+
def load_string(yaml_string, file_path = nil)
|
57
|
+
YAML.safe_load(yaml_string, :permitted_classes => [Date, Time, Symbol])
|
58
|
+
rescue
|
59
|
+
if yaml_has_merge_error?(yaml_string)
|
60
|
+
raise Informative, yaml_merge_conflict_msg(yaml_string, file_path)
|
61
|
+
else
|
62
|
+
raise Informative, yaml_parsing_error_msg(yaml_string, file_path)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Loads a YAML file and leans on the #load_string imp
|
67
|
+
# to do error detection
|
68
|
+
#
|
69
|
+
# @param [Pathname] file_path
|
70
|
+
# The file path to be used for read for the YAML file
|
71
|
+
#
|
72
|
+
# @return [Hash, Array] the Ruby YAML representaton
|
73
|
+
#
|
74
|
+
def load_file(file_path)
|
75
|
+
load_string(File.read(file_path), file_path)
|
76
|
+
end
|
77
|
+
|
78
|
+
#-----------------------------------------------------------------------#
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
# Implementation notes:
|
83
|
+
#
|
84
|
+
# - each of the methods returns a YAML partial without an ending new
|
85
|
+
# line.
|
86
|
+
# - if a partial needs to be indented is responsibility of the method
|
87
|
+
# using it.
|
88
|
+
#
|
89
|
+
# ---
|
90
|
+
|
91
|
+
# @!group Private Helpers
|
92
|
+
|
93
|
+
# @return [String] the YAML representation of the given object.
|
94
|
+
#
|
95
|
+
def process_according_to_class(value, hash_keys_hint = nil)
|
96
|
+
case value
|
97
|
+
when Array then process_array(value)
|
98
|
+
when Hash then process_hash(value, hash_keys_hint)
|
99
|
+
when String then process_string(value)
|
100
|
+
else YAML.dump(value, :line_width => 2**31 - 1).sub(/\A---/, '').sub(/[.]{3}\s*\Z/, '')
|
101
|
+
end.strip
|
102
|
+
end
|
103
|
+
|
104
|
+
# Converts an array to YAML after sorting it.
|
105
|
+
#
|
106
|
+
# @param [Array] array
|
107
|
+
# the array to convert.
|
108
|
+
#
|
109
|
+
# @return [String] the YAML representation of the given object.
|
110
|
+
#
|
111
|
+
def process_array(array)
|
112
|
+
return '[]' if array.empty?
|
113
|
+
|
114
|
+
result = sorted_array(array).map do |array_value|
|
115
|
+
processed = process_according_to_class(array_value)
|
116
|
+
case array_value
|
117
|
+
when Array, Hash
|
118
|
+
if array_value.size > 1
|
119
|
+
processed = processed.gsub(/^.*/).to_a
|
120
|
+
head = processed.shift
|
121
|
+
processed.map { |s| " #{s}" }.prepend(head).join("\n")
|
122
|
+
else
|
123
|
+
processed
|
124
|
+
end
|
125
|
+
else
|
126
|
+
processed
|
127
|
+
end
|
128
|
+
end
|
129
|
+
"- #{result.join("\n- ").strip}"
|
130
|
+
end
|
131
|
+
|
132
|
+
# Converts a hash to YAML after sorting its keys. Optionally accepts a
|
133
|
+
# hint for sorting the keys.
|
134
|
+
#
|
135
|
+
# @note If a hint for sorting the keys is provided the array is assumed
|
136
|
+
# to be the root object and the keys are separated by an
|
137
|
+
# additional new line feed for readability.
|
138
|
+
#
|
139
|
+
# @note If the value of a given key is a String it displayed inline,
|
140
|
+
# otherwise it is displayed below and indented.
|
141
|
+
#
|
142
|
+
# @param [Hash] hash
|
143
|
+
# the hash to convert.
|
144
|
+
#
|
145
|
+
# @return [String] the YAML representation of the given object.
|
146
|
+
#
|
147
|
+
def process_hash(hash, hash_keys_hint = nil, line_separator = "\n")
|
148
|
+
return '{}' if hash.empty?
|
149
|
+
|
150
|
+
keys = sorted_array_with_hint(hash.keys, hash_keys_hint)
|
151
|
+
key_lines = keys.map do |key|
|
152
|
+
key_value = hash[key]
|
153
|
+
processed = process_according_to_class(key_value)
|
154
|
+
processed_key = process_according_to_class(key)
|
155
|
+
case key_value
|
156
|
+
when Hash, Array
|
157
|
+
key_partial_yaml = processed.lines.map { |line| " #{line}" } * ''
|
158
|
+
"#{processed_key}:\n#{key_partial_yaml}"
|
159
|
+
else
|
160
|
+
"#{processed_key}: #{processed}"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
key_lines * line_separator
|
164
|
+
end
|
165
|
+
|
166
|
+
# Check for merge errors in a YAML string.
|
167
|
+
#
|
168
|
+
# @param [String] yaml_string
|
169
|
+
# A YAML string to evaluate
|
170
|
+
#
|
171
|
+
# @return If a merge error was detected or not.
|
172
|
+
#
|
173
|
+
def yaml_has_merge_error?(yaml_string)
|
174
|
+
yaml_string.include?('<<<<<<< HEAD')
|
175
|
+
end
|
176
|
+
|
177
|
+
# Error message describing that a merge conflict was found
|
178
|
+
# while parsing the YAML.
|
179
|
+
#
|
180
|
+
# @param [String] yaml
|
181
|
+
# Offending YAML
|
182
|
+
#
|
183
|
+
# @param [Pathname] path
|
184
|
+
# The (optional) offending path
|
185
|
+
#
|
186
|
+
# @return [String] The Error Message
|
187
|
+
#
|
188
|
+
def yaml_merge_conflict_msg(yaml, path = nil)
|
189
|
+
err = 'ERROR: Parsing unable to continue due '
|
190
|
+
err += "to merge conflicts present in:\n"
|
191
|
+
err += "the file located at #{path}\n" if path
|
192
|
+
err + "#{yaml}"
|
193
|
+
end
|
194
|
+
|
195
|
+
# Error message describing a general error took happened
|
196
|
+
# while parsing the YAML.
|
197
|
+
#
|
198
|
+
# @param [String] yaml
|
199
|
+
# Offending YAML
|
200
|
+
#
|
201
|
+
# @param [Pathname] path
|
202
|
+
# The (optional) offending path
|
203
|
+
#
|
204
|
+
# @return [String] The Error Message
|
205
|
+
#
|
206
|
+
def yaml_parsing_error_msg(yaml, path = nil)
|
207
|
+
err = 'ERROR: Parsing unable to continue due '
|
208
|
+
err += "to parsing error:\n"
|
209
|
+
err += "contained in the file located at #{path}\n" if path
|
210
|
+
err + "#{yaml}"
|
211
|
+
end
|
212
|
+
|
213
|
+
#-----------------------------------------------------------------------#
|
214
|
+
|
215
|
+
# @!group Array Sorting
|
216
|
+
|
217
|
+
# Sorts an array using another one as a sort hint. All the values of the
|
218
|
+
# hint which appear in the array will be returned respecting the order in
|
219
|
+
# the hint. If any other key is present in the original array they are
|
220
|
+
# sorted using the {#sorted_array} method.
|
221
|
+
#
|
222
|
+
# @param [Array] array
|
223
|
+
# The array which needs to be sorted.
|
224
|
+
#
|
225
|
+
# @param [Array] sort_hint
|
226
|
+
# The array which should be used to sort the keys.
|
227
|
+
#
|
228
|
+
# @return [Array] The sorted Array.
|
229
|
+
#
|
230
|
+
def sorted_array_with_hint(array, sort_hint)
|
231
|
+
if sort_hint
|
232
|
+
hinted = sort_hint & array
|
233
|
+
remaining = array - sort_hint
|
234
|
+
hinted + sorted_array(remaining)
|
235
|
+
else
|
236
|
+
sorted_array(array)
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
public
|
241
|
+
|
242
|
+
# Sorts an array according to the string representation of it values.
|
243
|
+
# This method allows to sort arrays which contains strings or hashes.
|
244
|
+
#
|
245
|
+
# @note If the value contained in the array is another Array or a Hash
|
246
|
+
# the first value of the collection is used for sorting, as this
|
247
|
+
# method is more useful, for arrays which contains a collection
|
248
|
+
# composed by one object.
|
249
|
+
#
|
250
|
+
# @todo This stuff is here only because the Lockfile intermixes strings
|
251
|
+
# and hashes for the `PODS` key. The Lockfile should be more
|
252
|
+
# consistent.
|
253
|
+
#
|
254
|
+
# @return [Array] The sorted array.
|
255
|
+
#
|
256
|
+
def sorted_array(array)
|
257
|
+
array.each_with_index.sort_by do |element, index|
|
258
|
+
[sorting_string(element), index]
|
259
|
+
end.map(&:first)
|
260
|
+
end
|
261
|
+
|
262
|
+
private
|
263
|
+
|
264
|
+
# Returns the string representation of a value useful for sorting.
|
265
|
+
#
|
266
|
+
# @param [String, Symbol, Array, Hash] value
|
267
|
+
# The value which needs to be sorted
|
268
|
+
#
|
269
|
+
# @return [String] A string useful to compare the value with other ones.
|
270
|
+
#
|
271
|
+
def sorting_string(value)
|
272
|
+
return '' unless value
|
273
|
+
case value
|
274
|
+
when String then value.downcase
|
275
|
+
when Symbol then sorting_string(value.to_s)
|
276
|
+
when Array then sorting_string(value.first)
|
277
|
+
when Hash then value.keys.map { |key| key.to_s.downcase }.sort.first
|
278
|
+
else raise ArgumentError, "Cannot sort #{value.inspect}"
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
RESOLVED_TAGS = Regexp.union(
|
283
|
+
'null', 'Null', 'NULL', '~', '', # resolve to null
|
284
|
+
'true', 'True', 'TRUE', 'false', 'False', 'FALSE', # bool
|
285
|
+
'yes', 'Yes', 'YES', 'no', 'No', 'NO', # yes/no
|
286
|
+
'on', 'On', 'ON', 'off', 'Off', 'OFF', # no/off
|
287
|
+
Regexp.new(%{
|
288
|
+
[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] # (ymd)
|
289
|
+
|[0-9][0-9][0-9][0-9] # (year)
|
290
|
+
-[0-9][0-9]? # (month)
|
291
|
+
-[0-9][0-9]? # (day)
|
292
|
+
([Tt]|[ \t]+)[0-9][0-9]? # (hour)
|
293
|
+
:[0-9][0-9] # (minute)
|
294
|
+
:[0-9][0-9] # (second)
|
295
|
+
(\.[0-9]*)? # (fraction)
|
296
|
+
(([ \t]*)(Z|[-+][0-9][0-9]?(:[0-9][0-9])?))? # (time zone)
|
297
|
+
}, Regexp::EXTENDED), # https://yaml.org/type/timestamp.html
|
298
|
+
/[-+]?[0-9]+/, # base 10 int
|
299
|
+
/00[0-7]+/, # base 8 int
|
300
|
+
/0x[0-9a-fA-F]+/, # base 16 int
|
301
|
+
/[-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?/, # float
|
302
|
+
/[-+]?\.(inf|Inf|INF)/, # infinity
|
303
|
+
/\.(nan|NaN|NAN)/ # NaN
|
304
|
+
)
|
305
|
+
private_constant :RESOLVED_TAGS
|
306
|
+
|
307
|
+
INDICATOR_START_CHARS = %w(- ? : , [ ] { } # & * ! | > ' " % @ `).freeze
|
308
|
+
INDICATOR_START = /\A#{Regexp.union(INDICATOR_START_CHARS)}/.freeze
|
309
|
+
private_constant :INDICATOR_START_CHARS, :INDICATOR_START
|
310
|
+
|
311
|
+
RESOLVED_TAGS_PATTERN = /\A#{Regexp.union(RESOLVED_TAGS)}\z/.freeze
|
312
|
+
private_constant :RESOLVED_TAGS_PATTERN
|
313
|
+
|
314
|
+
VALID_PLAIN_SCALAR_STRING = %r{\A
|
315
|
+
[\w&&[^#{INDICATOR_START_CHARS}]] # valid first character
|
316
|
+
[\w/\ \(\)~<>=\.:`,-]* # all characters allowed after the first one
|
317
|
+
\z}ox.freeze
|
318
|
+
private_constant :VALID_PLAIN_SCALAR_STRING
|
319
|
+
|
320
|
+
def process_string(string)
|
321
|
+
case string
|
322
|
+
when RESOLVED_TAGS_PATTERN
|
323
|
+
"'#{string}'"
|
324
|
+
when /\A\s*\z/, INDICATOR_START, /:\z/
|
325
|
+
string.inspect
|
326
|
+
when VALID_PLAIN_SCALAR_STRING
|
327
|
+
string
|
328
|
+
else
|
329
|
+
string.inspect
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
data/lib/cocoapods-core.rb
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
# The Pod modules name-spaces all the classes of CocoaPods.
|
2
2
|
#
|
3
3
|
module Pod
|
4
|
-
|
5
4
|
require 'cocoapods-core/gem_version'
|
6
5
|
|
7
6
|
# Indicates a runtime error **not** caused by a bug.
|
8
7
|
#
|
9
8
|
class PlainInformative < StandardError; end
|
10
9
|
|
11
|
-
# Indicates
|
10
|
+
# Indicates a user error.
|
12
11
|
#
|
13
12
|
class Informative < PlainInformative; end
|
14
13
|
|
15
14
|
require 'pathname'
|
16
15
|
require 'cocoapods-core/vendor'
|
17
16
|
|
17
|
+
require 'active_support'
|
18
|
+
require 'active_support/core_ext'
|
19
|
+
|
18
20
|
autoload :Version, 'cocoapods-core/version'
|
19
21
|
autoload :Requirement, 'cocoapods-core/requirement'
|
20
22
|
autoload :Dependency, 'cocoapods-core/dependency'
|
@@ -22,16 +24,20 @@ module Pod
|
|
22
24
|
autoload :CoreUI, 'cocoapods-core/core_ui'
|
23
25
|
autoload :DSLError, 'cocoapods-core/standard_error'
|
24
26
|
autoload :GitHub, 'cocoapods-core/github'
|
27
|
+
autoload :HTTP, 'cocoapods-core/http'
|
25
28
|
autoload :Lockfile, 'cocoapods-core/lockfile'
|
29
|
+
autoload :Metrics, 'cocoapods-core/metrics'
|
26
30
|
autoload :Platform, 'cocoapods-core/platform'
|
27
31
|
autoload :Podfile, 'cocoapods-core/podfile'
|
28
32
|
autoload :Source, 'cocoapods-core/source'
|
33
|
+
autoload :CDNSource, 'cocoapods-core/cdn_source'
|
34
|
+
autoload :TrunkSource, 'cocoapods-core/trunk_source'
|
29
35
|
autoload :Specification, 'cocoapods-core/specification'
|
30
36
|
autoload :StandardError, 'cocoapods-core/standard_error'
|
31
|
-
autoload :
|
37
|
+
autoload :YAMLHelper, 'cocoapods-core/yaml_helper'
|
38
|
+
autoload :BuildType, 'cocoapods-core/build_type'
|
32
39
|
|
33
40
|
# TODO: Fix
|
34
41
|
#
|
35
42
|
Spec = Specification
|
36
|
-
|
37
43
|
end
|