cocoapods-core 0.17.0.rc1

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 (36) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +36 -0
  4. data/lib/cocoapods-core/core_ui.rb +19 -0
  5. data/lib/cocoapods-core/dependency.rb +295 -0
  6. data/lib/cocoapods-core/gem_version.rb +6 -0
  7. data/lib/cocoapods-core/lockfile.rb +440 -0
  8. data/lib/cocoapods-core/platform.rb +171 -0
  9. data/lib/cocoapods-core/podfile/dsl.rb +459 -0
  10. data/lib/cocoapods-core/podfile/target_definition.rb +503 -0
  11. data/lib/cocoapods-core/podfile.rb +345 -0
  12. data/lib/cocoapods-core/requirement.rb +15 -0
  13. data/lib/cocoapods-core/source/validator.rb +183 -0
  14. data/lib/cocoapods-core/source.rb +284 -0
  15. data/lib/cocoapods-core/specification/consumer.rb +356 -0
  16. data/lib/cocoapods-core/specification/dsl/attribute.rb +245 -0
  17. data/lib/cocoapods-core/specification/dsl/attribute_support.rb +76 -0
  18. data/lib/cocoapods-core/specification/dsl/deprecations.rb +47 -0
  19. data/lib/cocoapods-core/specification/dsl/platform_proxy.rb +67 -0
  20. data/lib/cocoapods-core/specification/dsl.rb +1110 -0
  21. data/lib/cocoapods-core/specification/linter.rb +436 -0
  22. data/lib/cocoapods-core/specification/root_attribute_accessors.rb +152 -0
  23. data/lib/cocoapods-core/specification/set/presenter.rb +229 -0
  24. data/lib/cocoapods-core/specification/set/statistics.rb +277 -0
  25. data/lib/cocoapods-core/specification/set.rb +171 -0
  26. data/lib/cocoapods-core/specification/yaml.rb +60 -0
  27. data/lib/cocoapods-core/specification.rb +592 -0
  28. data/lib/cocoapods-core/standard_error.rb +84 -0
  29. data/lib/cocoapods-core/vendor/dependency.rb +264 -0
  30. data/lib/cocoapods-core/vendor/requirement.rb +208 -0
  31. data/lib/cocoapods-core/vendor/version.rb +333 -0
  32. data/lib/cocoapods-core/vendor.rb +56 -0
  33. data/lib/cocoapods-core/version.rb +99 -0
  34. data/lib/cocoapods-core/yaml_converter.rb +202 -0
  35. data/lib/cocoapods-core.rb +23 -0
  36. metadata +154 -0
@@ -0,0 +1,84 @@
1
+ module Pod
2
+
3
+ # Namespaces all the errors raised by CocoaPods.
4
+ #
5
+ class StandardError < ::StandardError; end
6
+
7
+ #-------------------------------------------------------------------------#
8
+
9
+ # Wraps an exception raised by a DSL file in order to show to the user the
10
+ # contents of the line that raised the exception.
11
+ #
12
+ class DSLError < StandardError
13
+
14
+ # @return [String] the description that should be presented to the user.
15
+ #
16
+ attr_reader :description
17
+
18
+ # @return [String] the path of the dsl file that raised the exception.
19
+ #
20
+ attr_reader :dsl_path
21
+
22
+ # @return [Exception] the backtrace of the exception raised by the
23
+ # evaluation of the dsl file.
24
+ #
25
+ attr_reader :backtrace
26
+
27
+ # @param [Exception] backtrace @see backtrace
28
+ # @param [String] dsl_path @see dsl_path
29
+ #
30
+ def initialize(description, dsl_path, backtrace)
31
+ @description = description
32
+ @dsl_path = dsl_path
33
+ @backtrace = backtrace
34
+ end
35
+
36
+ # The message of the exception reports the content of podspec for the
37
+ # line that generated the original exception.
38
+ #
39
+ # @example Output
40
+ #
41
+ # Invalid podspec at `RestKit.podspec` - undefined method
42
+ # `exclude_header_search_paths=' for #<Pod::Specification for
43
+ # `RestKit/Network (0.9.3)`>
44
+ #
45
+ # from spec-repos/master/RestKit/0.9.3/RestKit.podspec:36
46
+ # -------------------------------------------
47
+ # # because it would break: #import <CoreData/CoreData.h>
48
+ # > ns.exclude_header_search_paths = 'Code/RestKit.h'
49
+ # end
50
+ # -------------------------------------------
51
+ #
52
+ # @return [String] the message of the exception.
53
+ #
54
+ def message
55
+ unless @message
56
+ m = description.dup
57
+
58
+ return m unless backtrace && dsl_path && File.exist?(dsl_path)
59
+
60
+ trace_line = backtrace.find { |l| l =~ /#{dsl_path}/ }
61
+ return m unless trace_line
62
+ line_numer = trace_line.split(':')[1].to_i - 1
63
+ return m unless line_numer
64
+ lines = File.readlines(dsl_path.to_s)
65
+ indent = " # "
66
+ indicator = indent.dup.gsub("#", ">")
67
+ first_line = ( line_numer.zero? )
68
+ last_line = ( line_numer == (lines.count - 1) )
69
+
70
+ m << "\n #\n"
71
+ m << "#{indent}from #{trace_line.gsub(/:in.*$/,'')}\n"
72
+ m << "#{indent}-------------------------------------------\n"
73
+ m << "#{indent}#{ lines[line_numer - 1] }" unless first_line
74
+ m << "#{indicator}#{ lines[line_numer] }"
75
+ m << "#{indent}#{ lines[line_numer + 1] }" unless last_line
76
+ m << "\n" unless m.end_with?("\n")
77
+ m << "#{indent}-------------------------------------------\n"
78
+ m << " #"
79
+ @message = m
80
+ end
81
+ @message
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,264 @@
1
+ module Pod::Vendor
2
+
3
+ # require "rubygems/requirement"
4
+
5
+ ##
6
+ # The Dependency class holds a Gem name and a Gem::Requirement.
7
+
8
+ class Gem::Dependency
9
+
10
+ ##
11
+ # Valid dependency types.
12
+ #--
13
+ # When this list is updated, be sure to change
14
+ # Gem::Specification::CURRENT_SPECIFICATION_VERSION as well.
15
+
16
+ TYPES = [
17
+ :development,
18
+ :runtime,
19
+ ]
20
+
21
+ ##
22
+ # Dependency name or regular expression.
23
+
24
+ attr_accessor :name
25
+
26
+ ##
27
+ # Allows you to force this dependency to be a prerelease.
28
+
29
+ attr_writer :prerelease
30
+
31
+ ##
32
+ # Constructs a dependency with +name+ and +requirements+. The last
33
+ # argument can optionally be the dependency type, which defaults to
34
+ # <tt>:runtime</tt>.
35
+
36
+ def initialize name, *requirements
37
+ if Regexp === name then
38
+ msg = ["NOTE: Dependency.new w/ a regexp is deprecated.",
39
+ "Dependency.new called from #{Gem.location_of_caller.join(":")}"]
40
+ warn msg.join("\n") unless Gem::Deprecate.skip
41
+ end
42
+
43
+ type = Symbol === requirements.last ? requirements.pop : :runtime
44
+ requirements = requirements.first if 1 == requirements.length # unpack
45
+
46
+ unless TYPES.include? type
47
+ raise ArgumentError, "Valid types are #{TYPES.inspect}, "
48
+ + "not #{type.inspect}"
49
+ end
50
+
51
+ @name = name
52
+ @requirement = Gem::Requirement.create requirements
53
+ @type = type
54
+ @prerelease = false
55
+
56
+ # This is for Marshal backwards compatibility. See the comments in
57
+ # +requirement+ for the dirty details.
58
+
59
+ @version_requirements = @requirement
60
+ end
61
+
62
+ ##
63
+ # A dependency's hash is the XOR of the hashes of +name+, +type+,
64
+ # and +requirement+.
65
+
66
+ def hash # :nodoc:
67
+ name.hash ^ type.hash ^ requirement.hash
68
+ end
69
+
70
+ def inspect # :nodoc:
71
+ "<%s type=%p name=%p requirements=%p>" %
72
+ [self.class, self.type, self.name, requirement.to_s]
73
+ end
74
+
75
+ ##
76
+ # Does this dependency require a prerelease?
77
+
78
+ def prerelease?
79
+ @prerelease || requirement.prerelease?
80
+ end
81
+
82
+ def pretty_print q # :nodoc:
83
+ q.group 1, 'Gem::Dependency.new(', ')' do
84
+ q.pp name
85
+ q.text ','
86
+ q.breakable
87
+
88
+ q.pp requirement
89
+
90
+ q.text ','
91
+ q.breakable
92
+
93
+ q.pp type
94
+ end
95
+ end
96
+
97
+ ##
98
+ # What does this dependency require?
99
+
100
+ def requirement
101
+ return @requirement if defined?(@requirement) and @requirement
102
+
103
+ # @version_requirements and @version_requirement are legacy ivar
104
+ # names, and supported here because older gems need to keep
105
+ # working and Dependency doesn't implement marshal_dump and
106
+ # marshal_load. In a happier world, this would be an
107
+ # attr_accessor. The horrifying instance_variable_get you see
108
+ # below is also the legacy of some old restructurings.
109
+ #
110
+ # Note also that because of backwards compatibility (loading new
111
+ # gems in an old RubyGems installation), we can't add explicit
112
+ # marshaling to this class until we want to make a big
113
+ # break. Maybe 2.0.
114
+ #
115
+ # Children, define explicit marshal and unmarshal behavior for
116
+ # public classes. Marshal formats are part of your public API.
117
+
118
+ if defined?(@version_requirement) && @version_requirement
119
+ version = @version_requirement.instance_variable_get :@version
120
+ @version_requirement = nil
121
+ @version_requirements = Gem::Requirement.new version
122
+ end
123
+
124
+ @requirement = @version_requirements if defined?(@version_requirements)
125
+ end
126
+
127
+ def requirements_list
128
+ requirement.as_list
129
+ end
130
+
131
+ def to_s # :nodoc:
132
+ if type != :runtime then
133
+ "#{name} (#{requirement}, #{type})"
134
+ else
135
+ "#{name} (#{requirement})"
136
+ end
137
+ end
138
+
139
+ ##
140
+ # Dependency type.
141
+
142
+ def type
143
+ @type ||= :runtime
144
+ end
145
+
146
+ def == other # :nodoc:
147
+ Gem::Dependency === other &&
148
+ self.name == other.name &&
149
+ self.type == other.type &&
150
+ self.requirement == other.requirement
151
+ end
152
+
153
+ ##
154
+ # Dependencies are ordered by name.
155
+
156
+ def <=> other
157
+ self.name <=> other.name
158
+ end
159
+
160
+ ##
161
+ # Uses this dependency as a pattern to compare to +other+. This
162
+ # dependency will match if the name matches the other's name, and
163
+ # other has only an equal version requirement that satisfies this
164
+ # dependency.
165
+
166
+ def =~ other
167
+ unless Gem::Dependency === other
168
+ return unless other.respond_to?(:name) && other.respond_to?(:version)
169
+ other = Gem::Dependency.new other.name, other.version
170
+ end
171
+
172
+ return false unless name === other.name
173
+
174
+ reqs = other.requirement.requirements
175
+
176
+ return false unless reqs.length == 1
177
+ return false unless reqs.first.first == '='
178
+
179
+ version = reqs.first.last
180
+
181
+ requirement.satisfied_by? version
182
+ end
183
+
184
+ def match? name, version
185
+ return false unless self.name === name
186
+ return true if requirement.none?
187
+
188
+ requirement.satisfied_by? Gem::Version.new(version)
189
+ end
190
+
191
+ def matches_spec? spec
192
+ return false unless name === spec.name
193
+ return true if requirement.none?
194
+
195
+ requirement.satisfied_by?(spec.version)
196
+ end
197
+
198
+ ##
199
+ # Merges the requirements of +other+ into this dependency
200
+
201
+ def merge other
202
+ unless name == other.name then
203
+ raise ArgumentError,
204
+ "#{self} and #{other} have different names"
205
+ end
206
+
207
+ default = Gem::Requirement.default
208
+ self_req = self.requirement
209
+ other_req = other.requirement
210
+
211
+ return self.class.new name, self_req if other_req == default
212
+ return self.class.new name, other_req if self_req == default
213
+
214
+ self.class.new name, self_req.as_list.concat(other_req.as_list)
215
+ end
216
+
217
+ def matching_specs platform_only = false
218
+ matches = Gem::Specification.find_all { |spec|
219
+ self.name === spec.name and # TODO: == instead of ===
220
+ requirement.satisfied_by? spec.version
221
+ }
222
+
223
+ if platform_only
224
+ matches.reject! { |spec|
225
+ not Gem::Platform.match spec.platform
226
+ }
227
+ end
228
+
229
+ matches = matches.sort_by { |s| s.sort_obj } # HACK: shouldn't be needed
230
+ end
231
+
232
+ ##
233
+ # True if the dependency will not always match the latest version.
234
+
235
+ def specific?
236
+ @requirement.specific?
237
+ end
238
+
239
+ def to_specs
240
+ matches = matching_specs true
241
+
242
+ # TODO: check Gem.activated_spec[self.name] in case matches falls outside
243
+
244
+ if matches.empty? then
245
+ specs = Gem::Specification.all_names.join ", "
246
+ error = Gem::LoadError.new "Could not find #{name} (#{requirement}) amongst [#{specs}]"
247
+ error.name = self.name
248
+ error.requirement = self.requirement
249
+ raise error
250
+ end
251
+
252
+ # TODO: any other resolver validations should go here
253
+
254
+ matches
255
+ end
256
+
257
+ def to_spec
258
+ matches = self.to_specs
259
+
260
+ matches.find { |spec| spec.activated? } or matches.last
261
+ end
262
+ end
263
+
264
+ end
@@ -0,0 +1,208 @@
1
+ module Pod::Vendor
2
+
3
+ # require "rubygems/version"
4
+
5
+ ##
6
+ # A Requirement is a set of one or more version restrictions. It supports a
7
+ # 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"
17
+
18
+ class Gem::Requirement
19
+ include Comparable
20
+
21
+ OPS = { #:nodoc:
22
+ "=" => lambda { |v, r| v == r },
23
+ "!=" => lambda { |v, r| v != r },
24
+ ">" => lambda { |v, r| v > r },
25
+ "<" => lambda { |v, r| v < r },
26
+ ">=" => lambda { |v, r| v >= r },
27
+ "<=" => lambda { |v, r| v <= r },
28
+ "~>" => lambda { |v, r| v >= r && v.release < r.bump }
29
+ }
30
+
31
+ quoted = OPS.keys.map { |k| Regexp.quote k }.join "|"
32
+ PATTERN = /\A\s*(#{quoted})?\s*(#{Gem::Version::VERSION_PATTERN})\s*\z/
33
+
34
+ ##
35
+ # Factory method to create a Gem::Requirement object. Input may be
36
+ # a Version, a String, or nil. Intended to simplify client code.
37
+ #
38
+ # If the input is "weird", the default version requirement is
39
+ # returned.
40
+
41
+ def self.create input
42
+ case input
43
+ when Gem::Requirement then
44
+ input
45
+ when Gem::Version, Array then
46
+ new input
47
+ else
48
+ if input.respond_to? :to_str then
49
+ new [input.to_str]
50
+ else
51
+ default
52
+ end
53
+ end
54
+ end
55
+
56
+ ##
57
+ # 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
+
63
+ def self.default
64
+ new '>= 0'
65
+ end
66
+
67
+ ##
68
+ # Parse +obj+, returning an <tt>[op, version]</tt> pair. +obj+ can
69
+ # be a String or a Gem::Version.
70
+ #
71
+ # If +obj+ is a String, it can be either a full requirement
72
+ # specification, like <tt>">= 1.2"</tt>, or a simple version number,
73
+ # like <tt>"1.2"</tt>.
74
+ #
75
+ # parse("> 1.0") # => [">", "1.0"]
76
+ # parse("1.0") # => ["=", "1.0"]
77
+ # parse(Gem::Version.new("1.0")) # => ["=, "1.0"]
78
+
79
+ def self.parse obj
80
+ return ["=", obj] if Gem::Version === obj
81
+
82
+ unless PATTERN =~ obj.to_s
83
+ raise ArgumentError, "Illformed requirement [#{obj.inspect}]"
84
+ end
85
+
86
+ [$1 || "=", Gem::Version.new($2)]
87
+ end
88
+
89
+ ##
90
+ # An array of requirement pairs. The first element of the pair is
91
+ # the op, and the second is the Gem::Version.
92
+
93
+ attr_reader :requirements #:nodoc:
94
+
95
+ ##
96
+ # Constructs a requirement from +requirements+. Requirements can be
97
+ # Strings, Gem::Versions, or Arrays of those. +nil+ and duplicate
98
+ # requirements are ignored. An empty set of +requirements+ is the
99
+ # same as <tt>">= 0"</tt>.
100
+
101
+ def initialize *requirements
102
+ requirements = requirements.flatten
103
+ requirements.compact!
104
+ requirements.uniq!
105
+
106
+ requirements << ">= 0" if requirements.empty?
107
+ @none = (requirements == ">= 0")
108
+ @requirements = requirements.map! { |r| self.class.parse r }
109
+ end
110
+
111
+ def none?
112
+ @none ||= (to_s == ">= 0")
113
+ end
114
+
115
+ def as_list # :nodoc:
116
+ requirements.map { |op, version| "#{op} #{version}" }.sort
117
+ end
118
+
119
+ def hash # :nodoc:
120
+ requirements.hash
121
+ end
122
+
123
+ def marshal_dump # :nodoc:
124
+ fix_syck_default_key_in_requirements
125
+
126
+ [@requirements]
127
+ end
128
+
129
+ def marshal_load array # :nodoc:
130
+ @requirements = array[0]
131
+
132
+ fix_syck_default_key_in_requirements
133
+ end
134
+
135
+ def yaml_initialize(tag, vals) # :nodoc:
136
+ vals.each do |ivar, val|
137
+ instance_variable_set "@#{ivar}", val
138
+ end
139
+
140
+ fix_syck_default_key_in_requirements
141
+ end
142
+
143
+ def init_with coder # :nodoc:
144
+ yaml_initialize coder.tag, coder.map
145
+ end
146
+
147
+ def prerelease?
148
+ requirements.any? { |r| r.last.prerelease? }
149
+ end
150
+
151
+ def pretty_print q # :nodoc:
152
+ q.group 1, 'Gem::Requirement.new(', ')' do
153
+ q.pp as_list
154
+ end
155
+ end
156
+
157
+ ##
158
+ # True if +version+ satisfies this Requirement.
159
+
160
+ def satisfied_by? version
161
+ # #28965: syck has a bug with unquoted '=' YAML.loading as YAML::DefaultKey
162
+ requirements.all? { |op, rv| (OPS[op] || OPS["="]).call version, rv }
163
+ end
164
+
165
+ alias :=== :satisfied_by?
166
+ alias :=~ :satisfied_by?
167
+
168
+ ##
169
+ # True if the requirement will not always match the latest version.
170
+
171
+ def specific?
172
+ return true if @requirements.length > 1 # GIGO, > 1, > 2 is silly
173
+
174
+ not %w[> >=].include? @requirements.first.first # grab the operator
175
+ end
176
+
177
+ def to_s # :nodoc:
178
+ as_list.join ", "
179
+ end
180
+
181
+ def <=> other # :nodoc:
182
+ to_s <=> other.to_s
183
+ end
184
+
185
+ private
186
+
187
+ def fix_syck_default_key_in_requirements
188
+ Gem.load_yaml
189
+
190
+ # Fixup the Syck DefaultKey bug
191
+ @requirements.each do |r|
192
+ if r[0].kind_of? Gem::SyckDefaultKey
193
+ r[0] = "="
194
+ end
195
+ end
196
+ end
197
+ end
198
+
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:
207
+
208
+ end