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.
Files changed (50) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +7 -10
  3. data/lib/cocoapods-core/build_type.rb +121 -0
  4. data/lib/cocoapods-core/cdn_source.rb +501 -0
  5. data/lib/cocoapods-core/core_ui.rb +4 -3
  6. data/lib/cocoapods-core/dependency.rb +100 -73
  7. data/lib/cocoapods-core/gem_version.rb +1 -2
  8. data/lib/cocoapods-core/github.rb +32 -5
  9. data/lib/cocoapods-core/http.rb +86 -0
  10. data/lib/cocoapods-core/lockfile.rb +161 -56
  11. data/lib/cocoapods-core/metrics.rb +47 -0
  12. data/lib/cocoapods-core/platform.rb +99 -11
  13. data/lib/cocoapods-core/podfile/dsl.rb +623 -124
  14. data/lib/cocoapods-core/podfile/target_definition.rb +662 -109
  15. data/lib/cocoapods-core/podfile.rb +138 -65
  16. data/lib/cocoapods-core/requirement.rb +37 -8
  17. data/lib/cocoapods-core/source/acceptor.rb +16 -13
  18. data/lib/cocoapods-core/source/aggregate.rb +79 -103
  19. data/lib/cocoapods-core/source/health_reporter.rb +9 -18
  20. data/lib/cocoapods-core/source/manager.rb +488 -0
  21. data/lib/cocoapods-core/source/metadata.rb +79 -0
  22. data/lib/cocoapods-core/source.rb +241 -70
  23. data/lib/cocoapods-core/specification/consumer.rb +187 -47
  24. data/lib/cocoapods-core/specification/dsl/attribute.rb +49 -85
  25. data/lib/cocoapods-core/specification/dsl/attribute_support.rb +6 -8
  26. data/lib/cocoapods-core/specification/dsl/deprecations.rb +9 -126
  27. data/lib/cocoapods-core/specification/dsl/platform_proxy.rb +30 -20
  28. data/lib/cocoapods-core/specification/dsl.rb +943 -296
  29. data/lib/cocoapods-core/specification/json.rb +64 -23
  30. data/lib/cocoapods-core/specification/linter/analyzer.rb +218 -0
  31. data/lib/cocoapods-core/specification/linter/result.rb +128 -0
  32. data/lib/cocoapods-core/specification/linter.rb +310 -309
  33. data/lib/cocoapods-core/specification/root_attribute_accessors.rb +90 -39
  34. data/lib/cocoapods-core/specification/set/presenter.rb +35 -71
  35. data/lib/cocoapods-core/specification/set.rb +42 -96
  36. data/lib/cocoapods-core/specification.rb +368 -130
  37. data/lib/cocoapods-core/standard_error.rb +45 -24
  38. data/lib/cocoapods-core/trunk_source.rb +14 -0
  39. data/lib/cocoapods-core/vendor/requirement.rb +133 -53
  40. data/lib/cocoapods-core/vendor/version.rb +197 -156
  41. data/lib/cocoapods-core/vendor.rb +1 -5
  42. data/lib/cocoapods-core/version.rb +137 -42
  43. data/lib/cocoapods-core/yaml_helper.rb +334 -0
  44. data/lib/cocoapods-core.rb +10 -4
  45. metadata +100 -27
  46. data/lib/cocoapods-core/source/abstract_data_provider.rb +0 -71
  47. data/lib/cocoapods-core/source/file_system_data_provider.rb +0 -150
  48. data/lib/cocoapods-core/source/github_data_provider.rb +0 -143
  49. data/lib/cocoapods-core/specification/set/statistics.rb +0 -266
  50. data/lib/cocoapods-core/yaml_converter.rb +0 -192
@@ -1,5 +1,4 @@
1
1
  module Pod
2
-
3
2
  # Namespaces all the errors raised by CocoaPods.
4
3
  #
5
4
  class StandardError < ::StandardError; end
@@ -10,7 +9,6 @@ module Pod
10
9
  # contents of the line that raised the exception.
11
10
  #
12
11
  class DSLError < Informative
13
-
14
12
  # @return [String] the description that should be presented to the user.
15
13
  #
16
14
  attr_reader :description
@@ -19,18 +17,28 @@ module Pod
19
17
  #
20
18
  attr_reader :dsl_path
21
19
 
22
- # @return [Exception] the backtrace of the exception raised by the
20
+ # @return [Exception] the exception raised by the
23
21
  # evaluation of the dsl file.
24
22
  #
25
- attr_reader :backtrace
23
+ attr_reader :underlying_exception
26
24
 
27
- # @param [Exception] backtrace @see backtrace
25
+ # @param [Exception] underlying_exception @see underlying_exception
28
26
  # @param [String] dsl_path @see dsl_path
29
27
  #
30
- def initialize(description, dsl_path, backtrace)
31
- @description = description
32
- @dsl_path = dsl_path
33
- @backtrace = backtrace
28
+ def initialize(description, dsl_path, underlying_exception, contents = nil)
29
+ @description = description
30
+ @dsl_path = dsl_path
31
+ @underlying_exception = underlying_exception
32
+ @contents = contents
33
+ end
34
+
35
+ # @return [String] the contents of the DSL that cause the exception to
36
+ # be raised.
37
+ #
38
+ def contents
39
+ @contents ||= begin
40
+ dsl_path && File.exist?(dsl_path) && File.read(dsl_path)
41
+ end
34
42
  end
35
43
 
36
44
  # The message of the exception reports the content of podspec for the
@@ -52,36 +60,49 @@ module Pod
52
60
  # @return [String] the message of the exception.
53
61
  #
54
62
  def message
55
- unless @message
56
- m = "\n[!] "
57
- m << description
58
- m << ". Updating CocoaPods might fix the issue.\n"
63
+ @message ||= begin
64
+ trace_line, description = parse_line_number_from_description
65
+
66
+ m = "\n[!] #{description}.\n"
59
67
  m = m.red if m.respond_to?(:red)
60
68
 
61
- return m unless backtrace && dsl_path && File.exist?(dsl_path)
69
+ backtrace = underlying_exception.backtrace
70
+ return m unless backtrace && dsl_path && contents
62
71
 
63
- trace_line = backtrace.find { |l| l.include?(dsl_path.to_s) }
72
+ trace_line = backtrace.find { |l| l.include?(dsl_path.to_s) } || trace_line
64
73
  return m unless trace_line
65
74
  line_numer = trace_line.split(':')[1].to_i - 1
66
75
  return m unless line_numer
67
- lines = File.readlines(dsl_path.to_s)
68
- indent = " # "
69
- indicator = indent.dup.gsub("#", ">")
76
+
77
+ lines = contents.lines
78
+ indent = ' # '
79
+ indicator = indent.tr('#', '>')
70
80
  first_line = (line_numer.zero?)
71
81
  last_line = (line_numer == (lines.count - 1))
72
82
 
73
83
  m << "\n"
74
84
  m << "#{indent}from #{trace_line.gsub(/:in.*$/, '')}\n"
75
85
  m << "#{indent}-------------------------------------------\n"
76
- m << "#{indent}#{ lines[line_numer - 1] }" unless first_line
77
- m << "#{indicator}#{ lines[line_numer] }"
78
- m << "#{indent}#{ lines[line_numer + 1] }" unless last_line
86
+ m << "#{indent}#{lines[line_numer - 1]}" unless first_line
87
+ m << "#{indicator}#{lines[line_numer]}"
88
+ m << "#{indent}#{lines[line_numer + 1]}" unless last_line
79
89
  m << "\n" unless m.end_with?("\n")
80
90
  m << "#{indent}-------------------------------------------\n"
81
- m << ""
82
- @message = m
83
91
  end
84
- @message
92
+ end
93
+
94
+ private
95
+
96
+ def parse_line_number_from_description
97
+ description = self.description
98
+ if dsl_path && description =~ /((#{Regexp.quote File.expand_path(dsl_path)}|#{Regexp.quote dsl_path.to_s}):\d+)/
99
+ trace_line = Regexp.last_match[1]
100
+ description = description.sub(/#{Regexp.quote trace_line}:\s*/, '')
101
+ if description =~ /^\s*\^\z/
102
+ description = description.lines[0..-3].join.chomp
103
+ end
104
+ end
105
+ [trace_line, description]
85
106
  end
86
107
  end
87
108
  end
@@ -0,0 +1,14 @@
1
+ module Pod
2
+ class TrunkSource < CDNSource
3
+ # On-disk master repo name
4
+ TRUNK_REPO_NAME = 'trunk'.freeze
5
+
6
+ # Remote CDN repo URL
7
+ TRUNK_REPO_URL = 'https://cdn.cocoapods.org/'.freeze
8
+
9
+ def url
10
+ @url ||= TRUNK_REPO_URL
11
+ super
12
+ end
13
+ end
14
+ end
@@ -1,35 +1,50 @@
1
+ # frozen_string_literal: true
1
2
  module Pod::Vendor
2
3
 
3
4
  # require "rubygems/version"
5
+ # require "rubygems/deprecate"
6
+
7
+ # If we're being loaded after yaml was already required, then
8
+ # load our yaml + workarounds now.
9
+ # Gem.load_yaml if defined? ::YAML
4
10
 
5
11
  ##
6
12
  # A Requirement is a set of one or more version restrictions. It supports a
7
13
  # few (<tt>=, !=, >, <, >=, <=, ~></tt>) different restriction operators.
8
-
9
- # REFACTOR: The fact that a requirement is singular or plural is kind of
10
- # awkward. Is Requirement the right name for this? Or should it be one
11
- # [op, number] pair, and we call the list of requirements something else?
12
- # Since a Requirement is held by a Dependency, maybe this should be made
13
- # singular and the list aspect should be pulled up into Dependency?
14
-
15
- # require "rubygems/version"
16
- # require "rubygems/deprecate"
14
+ #
15
+ # See Gem::Version for a description on how versions and requirements work
16
+ # together in RubyGems.
17
17
 
18
18
  class Gem::Requirement
19
- include Comparable
20
-
21
19
  OPS = { #:nodoc:
22
20
  "=" => lambda { |v, r| v == r },
23
21
  "!=" => lambda { |v, r| v != r },
24
- ">" => lambda { |v, r| v > r },
25
- "<" => lambda { |v, r| v < r },
22
+ ">" => lambda { |v, r| v > r },
23
+ "<" => lambda { |v, r| v < r },
26
24
  ">=" => lambda { |v, r| v >= r },
27
25
  "<=" => lambda { |v, r| v <= r },
28
26
  "~>" => lambda { |v, r| v >= r && v.release < r.bump }
29
27
  }
30
28
 
29
+ SOURCE_SET_REQUIREMENT = Struct.new(:for_lockfile).new "!" # :nodoc:
30
+
31
31
  quoted = OPS.keys.map { |k| Regexp.quote k }.join "|"
32
- PATTERN = /\A\s*(#{quoted})?\s*(#{Gem::Version::VERSION_PATTERN})\s*\z/
32
+ PATTERN_RAW = "\\s*(#{quoted})?\\s*(#{Gem::Version::VERSION_PATTERN})\\s*" # :nodoc:
33
+
34
+ ##
35
+ # A regular expression that matches a requirement
36
+
37
+ PATTERN = /\A#{PATTERN_RAW}\z/
38
+
39
+ ##
40
+ # The default requirement matches any version
41
+
42
+ DefaultRequirement = [">=", Gem::Version.new(0)]
43
+
44
+ ##
45
+ # Raised when a bad requirement is encountered
46
+
47
+ class BadRequirementError < ArgumentError; end
33
48
 
34
49
  ##
35
50
  # Factory method to create a Gem::Requirement object. Input may be
@@ -38,12 +53,14 @@ module Pod::Vendor
38
53
  # If the input is "weird", the default version requirement is
39
54
  # returned.
40
55
 
41
- def self.create(input)
56
+ def self.create input
42
57
  case input
43
58
  when Gem::Requirement then
44
59
  input
45
60
  when Gem::Version, Array then
46
61
  new input
62
+ when '!' then
63
+ source_set
47
64
  else
48
65
  if input.respond_to? :to_str then
49
66
  new [input.to_str]
@@ -55,15 +72,18 @@ module Pod::Vendor
55
72
 
56
73
  ##
57
74
  # A default "version requirement" can surely _only_ be '>= 0'.
58
- #--
59
- # This comment once said:
60
- #
61
- # "A default "version requirement" can surely _only_ be '> 0'."
62
75
 
63
76
  def self.default
64
77
  new '>= 0'
65
78
  end
66
79
 
80
+ ###
81
+ # A source set requirement, used for Gemfiles and lockfiles
82
+
83
+ def self.source_set # :nodoc:
84
+ SOURCE_SET_REQUIREMENT
85
+ end
86
+
67
87
  ##
68
88
  # Parse +obj+, returning an <tt>[op, version]</tt> pair. +obj+ can
69
89
  # be a String or a Gem::Version.
@@ -72,18 +92,22 @@ module Pod::Vendor
72
92
  # specification, like <tt>">= 1.2"</tt>, or a simple version number,
73
93
  # like <tt>"1.2"</tt>.
74
94
  #
75
- # parse("> 1.0") # => [">", "1.0"]
76
- # parse("1.0") # => ["=", "1.0"]
77
- # parse(Gem::Version.new("1.0")) # => ["=, "1.0"]
95
+ # parse("> 1.0") # => [">", Gem::Version.new("1.0")]
96
+ # parse("1.0") # => ["=", Gem::Version.new("1.0")]
97
+ # parse(Gem::Version.new("1.0")) # => ["=, Gem::Version.new("1.0")]
78
98
 
79
- def self.parse(obj)
99
+ def self.parse obj
80
100
  return ["=", obj] if Gem::Version === obj
81
101
 
82
102
  unless PATTERN =~ obj.to_s
83
- raise ArgumentError, "Illformed requirement [#{obj.inspect}]"
103
+ raise BadRequirementError, "Illformed requirement [#{obj.inspect}]"
84
104
  end
85
105
 
86
- [Regexp.last_match[1] || "=", Gem::Version.new(Regexp.last_match[2])]
106
+ if $1 == ">=" && $2 == "0"
107
+ DefaultRequirement
108
+ else
109
+ [$1 || "=", Gem::Version.new($2)]
110
+ end
87
111
  end
88
112
 
89
113
  ##
@@ -98,18 +122,62 @@ module Pod::Vendor
98
122
  # requirements are ignored. An empty set of +requirements+ is the
99
123
  # same as <tt>">= 0"</tt>.
100
124
 
101
- def initialize(*requirements)
125
+ def initialize *requirements
102
126
  requirements = requirements.flatten
103
127
  requirements.compact!
104
128
  requirements.uniq!
105
129
 
106
- requirements << ">= 0" if requirements.empty?
107
- @none = (requirements == ">= 0")
108
- @requirements = requirements.map! { |r| self.class.parse r }
130
+ if requirements.empty?
131
+ @requirements = [DefaultRequirement]
132
+ else
133
+ @requirements = requirements.map! { |r| self.class.parse r }
134
+ end
109
135
  end
110
136
 
137
+ ##
138
+ # Concatenates the +new+ requirements onto this requirement.
139
+
140
+ def concat new
141
+ new = new.flatten
142
+ new.compact!
143
+ new.uniq!
144
+ new = new.map { |r| self.class.parse r }
145
+
146
+ @requirements.concat new
147
+ end
148
+
149
+ ##
150
+ # Formats this requirement for use in a Gem::RequestSet::Lockfile.
151
+
152
+ def for_lockfile # :nodoc:
153
+ return if [DefaultRequirement] == @requirements
154
+
155
+ list = requirements.sort_by { |_, version|
156
+ version
157
+ }.map { |op, version|
158
+ "#{op} #{version}"
159
+ }.uniq
160
+
161
+ " (#{list.join ', '})"
162
+ end
163
+
164
+ ##
165
+ # true if this gem has no requirements.
166
+
111
167
  def none?
112
- @none ||= (to_s == ">= 0")
168
+ if @requirements.size == 1
169
+ @requirements[0] == DefaultRequirement
170
+ else
171
+ false
172
+ end
173
+ end
174
+
175
+ ##
176
+ # true if the requirement is for only an exact version
177
+
178
+ def exact?
179
+ return false unless @requirements.size == 1
180
+ @requirements[0][0] == "="
113
181
  end
114
182
 
115
183
  def as_list # :nodoc:
@@ -117,7 +185,7 @@ module Pod::Vendor
117
185
  end
118
186
 
119
187
  def hash # :nodoc:
120
- requirements.hash
188
+ requirements.sort.hash
121
189
  end
122
190
 
123
191
  def marshal_dump # :nodoc:
@@ -126,7 +194,7 @@ module Pod::Vendor
126
194
  [@requirements]
127
195
  end
128
196
 
129
- def marshal_load(array) # :nodoc:
197
+ def marshal_load array # :nodoc:
130
198
  @requirements = array[0]
131
199
 
132
200
  fix_syck_default_key_in_requirements
@@ -134,36 +202,51 @@ module Pod::Vendor
134
202
 
135
203
  def yaml_initialize(tag, vals) # :nodoc:
136
204
  vals.each do |ivar, val|
137
- instance_variable_set "@#{ivar}", val
138
- end
205
+ instance_variable_set "@#{ivar}", val
206
+ end
139
207
 
208
+ Gem.load_yaml
140
209
  fix_syck_default_key_in_requirements
141
210
  end
142
211
 
143
- def init_with(coder) # :nodoc:
212
+ def init_with coder # :nodoc:
144
213
  yaml_initialize coder.tag, coder.map
145
214
  end
146
215
 
216
+ def to_yaml_properties # :nodoc:
217
+ ["@requirements"]
218
+ end
219
+
220
+ def encode_with coder # :nodoc:
221
+ coder.add 'requirements', @requirements
222
+ end
223
+
224
+ ##
225
+ # A requirement is a prerelease if any of the versions inside of it
226
+ # are prereleases
227
+
147
228
  def prerelease?
148
229
  requirements.any? { |r| r.last.prerelease? }
149
230
  end
150
231
 
151
- def pretty_print(q) # :nodoc:
232
+ def pretty_print q # :nodoc:
152
233
  q.group 1, 'Gem::Requirement.new(', ')' do
153
- q.pp as_list
154
- end
234
+ q.pp as_list
235
+ end
155
236
  end
156
237
 
157
238
  ##
158
239
  # True if +version+ satisfies this Requirement.
159
240
 
160
- def satisfied_by?(version)
241
+ def satisfied_by? version
242
+ raise ArgumentError, "Need a Gem::Version: #{version.inspect}" unless
243
+ Gem::Version === version
161
244
  # #28965: syck has a bug with unquoted '=' YAML.loading as YAML::DefaultKey
162
245
  requirements.all? { |op, rv| (OPS[op] || OPS["="]).call version, rv }
163
246
  end
164
247
 
165
- alias_method :===, :satisfied_by?
166
- alias_method :=~, :satisfied_by?
248
+ alias :=== :satisfied_by?
249
+ alias :=~ :satisfied_by?
167
250
 
168
251
  ##
169
252
  # True if the requirement will not always match the latest version.
@@ -171,20 +254,20 @@ module Pod::Vendor
171
254
  def specific?
172
255
  return true if @requirements.length > 1 # GIGO, > 1, > 2 is silly
173
256
 
174
- not %w(> >=).include? @requirements.first.first # grab the operator
257
+ not %w[> >=].include? @requirements.first.first # grab the operator
175
258
  end
176
259
 
177
260
  def to_s # :nodoc:
178
261
  as_list.join ", "
179
262
  end
180
263
 
181
- def <=>(other) # :nodoc:
182
- to_s <=> other.to_s
264
+ def == other # :nodoc:
265
+ Gem::Requirement === other and to_s == other.to_s
183
266
  end
184
267
 
185
268
  private
186
269
 
187
- def fix_syck_default_key_in_requirements
270
+ def fix_syck_default_key_in_requirements # :nodoc:
188
271
  Gem.load_yaml
189
272
 
190
273
  # Fixup the Syck DefaultKey bug
@@ -196,13 +279,10 @@ module Pod::Vendor
196
279
  end
197
280
  end
198
281
 
199
- # :stopdoc:
200
- # Gem::Version::Requirement is used in a lot of old YAML specs. It's aliased
201
- # here for backwards compatibility. I'd like to remove this, maybe in RubyGems
202
- # 2.0.
203
-
204
- # ::Gem::Version::Requirement = ::Gem::Requirement
205
- Gem::Version::Requirement = Gem::Requirement
206
- # :startdoc:
282
+ class Gem::Version
283
+ # This is needed for compatibility with older yaml
284
+ # gemspecs.
207
285
 
286
+ Requirement = Gem::Requirement # :nodoc:
287
+ end
208
288
  end