cocoapods-core 0.17.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9ec7156242ce09d5db9a9527275defb79e0727bb
4
+ data.tar.gz: 4d33bcedda0b6089ebb42650bd02ac234d361330
5
+ SHA512:
6
+ metadata.gz: 1ceabc9d9aedd42ebc5e9273779bd141b0d99e19ca8766824e3ee00dd63cec388ca84fd15d52c21ab74d0c9732e66b02ede288976f292f474cb4839d34df31ce
7
+ data.tar.gz: 334537cee3087739db642d937b8bfa713f947d822b95224261c1b8f05d6c198f1a73c35f6d3db6eafde0175e73e0a72eb60e4386d7dd855ea2e95899ed6d7d49
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 - 2012 Eloy Durán <eloy.de.enige@gmail.com>
2
+ Copyright (c) 2012 Fabio Pelosin <fabiopelosin@gmail.com>
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # CocoaPods Core
2
+
3
+ [![Master Build Status](https://secure.travis-ci.org/CocoaPods/Core.png?branch=master)](https://secure.travis-ci.org/CocoaPods/Core)
4
+
5
+ __This gem has not been released yet__.
6
+
7
+ The CocoaPods-Core gem provides support to work with the models of CocoaPods. It is intended to be used in place of the CocoaPods when the the installation of the dependencies is not needed. Therefore, it is suitable for web services.
8
+
9
+ Provides support for working with the following models:
10
+
11
+ - `Pod::Specification` - [podspec files](http://cocoapods.github.com/specification.html).
12
+ - `Pod::Podfile` - [podfile specifications](http://cocoapods.github.com/podfile.html).
13
+ - `Pod::Source` - collections of podspec files like the [CocoaPods Spec repo](https://github.com/CocoaPods/Specs).
14
+
15
+ The gem also provides support for ancillary features like `Pod::Specification::Set::Presenter` suitable for presetting descriptions of Pods and the `Specification::Linter`, which ensures the validity of podspec files.
16
+
17
+ ## Installation
18
+
19
+ ```
20
+ $ [sudo] gem install cocoapods-core
21
+ ```
22
+
23
+ The `cocoapods-core` gem requires either:
24
+
25
+ - Ruby 1.8.7 (shipped with OS X 10.8).
26
+ - Ruby 1.9.3 (recommended).
27
+
28
+ ## Collaborate
29
+
30
+ All CocoaPods development happens on GitHub, there is a repository for [CocoaPods](https://github.com/CocoaPods/CocoaPods) and one for the [CocoaPods specs](https://github.com/CocoaPods/Specs). Contributing patches or Pods is really easy and gratifying. You even get push access when one of your specs or patches is accepted.
31
+
32
+ Follow [@CocoaPodsOrg](http://twitter.com/CocoaPodsOrg) to get up to date information about what's going on in the CocoaPods world.
33
+
34
+ ## License
35
+
36
+ This gem and CocoaPods are available under the MIT license.
@@ -0,0 +1,19 @@
1
+ module Pod
2
+
3
+ # Manages the UI output so dependent gems can customize it.
4
+ #
5
+ module CoreUI
6
+
7
+ class << self
8
+ def puts(message)
9
+ STDOUT.puts message
10
+ end
11
+
12
+ def warn(message)
13
+ STDERR.puts message
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,295 @@
1
+ module Pod
2
+
3
+ # The Dependency allows to specify dependencies of a {Podfile} or a
4
+ # {Specification} on a Pod. It stores the name of the dependency, version
5
+ # requirements and external sources information.
6
+ #
7
+ # This class leverages the RubyGems dependency class with minor extension to
8
+ # support CocoaPods specific features like subspecs.
9
+ #
10
+ class Dependency < Pod::Vendor::Gem::Dependency
11
+
12
+ # @return [Hash{Symbol=>String}] a hash describing the external source
13
+ # where the pod should be fetched. The external source has to
14
+ # provide its own {Specification} file.
15
+ #
16
+ attr_accessor :external_source
17
+
18
+ # @return [Bool] whether the dependency should use the podspec with the
19
+ # highest know version but force the downloader to checkout the
20
+ # `head` of the source repository.
21
+ #
22
+ attr_accessor :head
23
+ alias_method :head?, :head
24
+
25
+ # @overload initialize(name, requirements)
26
+ #
27
+ # @param [String] name
28
+ # the name of the Pod.
29
+ #
30
+ # @param [Array] requirements
31
+ # an array specifying the version requirements of the
32
+ # dependency.
33
+ #
34
+ # @example Initialization with version requirements.
35
+ #
36
+ # Dependency.new('AFNetworking')
37
+ # Dependency.new('AFNetworking', '~> 1.0')
38
+ # Dependency.new('AFNetworking', '>= 0.5', '< 0.7')
39
+ #
40
+ # @overload initialize(name, external_source)
41
+ #
42
+ # @param [String] name
43
+ # the name of the Pod.
44
+ #
45
+ # @param [Hash] external_source
46
+ # a hash describing the external source.
47
+ #
48
+ # @example Initialization with an external source.
49
+ #
50
+ # Dependency.new('libPusher', {:git => 'example.com/repo.git'})
51
+ # Dependency.new('libPusher', {:local => 'path/to/folder'})
52
+ # Dependency.new('libPusher', {:podspec => 'example.com/libPusher.podspec'})
53
+ #
54
+ # @overload initialize(name, is_head)
55
+ #
56
+ # @param [String] name
57
+ # the name of the Pod.
58
+ #
59
+ # @param [Symbol] is_head
60
+ # a symbol that can be `:head` or nil.
61
+ #
62
+ # @example Initialization with the head option
63
+ #
64
+ # Dependency.new('RestKit', :head)
65
+ #
66
+ def initialize(name = nil, *requirements)
67
+ if requirements.last.is_a?(Hash)
68
+ @external_source = requirements.pop
69
+ elsif requirements.last == :head
70
+ @head = true
71
+ requirements.pop
72
+ unless requirements.empty?
73
+ raise StandardError, "A `:head` dependency may not specify version requirements."
74
+ end
75
+ end
76
+
77
+ super(name, *requirements)
78
+ end
79
+
80
+ # @return [Version] whether the dependency points to a specific version.
81
+ #
82
+ attr_accessor :specific_version
83
+
84
+ # @return [Requirement] the requirement of this dependency (a set of
85
+ # one or more version restrictions).
86
+ #
87
+ def requirement
88
+ return Requirement.new(specific_version) if specific_version
89
+ super
90
+ end
91
+
92
+ # @return [Bool] whether the dependency points to a subspec.
93
+ #
94
+ def subspec_dependency?
95
+ @name.include?('/')
96
+ end
97
+
98
+ # @return [Bool] whether the dependency points to an external source.
99
+ #
100
+ def external?
101
+ !@external_source.nil?
102
+ end
103
+
104
+ # Creates a new dependency with the name of the top level spec and the same
105
+ # version requirements.
106
+ #
107
+ # @note This is used by the {Specification::Set} class to merge
108
+ # dependencies and resolve the required version of a Pod regardless
109
+ # what particular specification (subspecs or top level) is
110
+ # required.
111
+ #
112
+ # @return [Dependency] a dependency with the same versions requirements
113
+ # that is guaranteed to point to a top level specification.
114
+ #
115
+ def to_root_dependency
116
+ dep = dup
117
+ dep.name = root_name
118
+ dep
119
+ end
120
+
121
+ # Returns the name of the Pod that the dependency is pointing to.
122
+ #
123
+ # @note In case this is a dependency for a subspec, e.g.
124
+ # 'RestKit/Networking', this returns 'RestKit', which is what the
125
+ # Pod::Source needs to know to retrieve the correct {Specification}
126
+ # from disk.
127
+ #
128
+ # @return [String] the name of the Pod.
129
+ #
130
+ def root_name
131
+ subspec_dependency? ? @name.split('/').first : @name
132
+ end
133
+
134
+ # Checks if a dependency would be satisfied by the requirements of another
135
+ # dependency.
136
+ #
137
+ # @param [Dependency] other
138
+ # the other dependency.
139
+ #
140
+ # @note This is used by the Lockfile to check if a stored dependency is
141
+ # still compatible with the Podfile.
142
+ #
143
+ # @return [Bool] whether the dependency is compatible with the given one.
144
+ #
145
+ def compatible?(other)
146
+ return false unless name == other.name
147
+ return false unless head? == other.head?
148
+ return false unless external_source == other.external_source
149
+
150
+ other.requirement.requirements.all? do | operator, version |
151
+ self.requirement.satisfied_by? Version.new(version)
152
+ end
153
+ end
154
+
155
+ # @return [Bool] whether the dependency is equal to another taking into
156
+ # account the loaded specification, the head options and the
157
+ # external source.
158
+ #
159
+ def ==(other)
160
+ super && head? == other.head? && @external_source == other.external_source
161
+ end
162
+ alias :eql? :==
163
+
164
+ # Merges the version requirements of the dependency with another one.
165
+ #
166
+ # @param [Dependency] other
167
+ # the other dependency to merge with.
168
+ #
169
+ # @note If one of the decencies specifies an external source or is head,
170
+ # the resulting dependency preserves this attributes.
171
+ #
172
+ # @return [Dependency] a dependency (not necessary a new instance) that
173
+ # includes also the version requirements of the given one.
174
+ #
175
+ def merge(other)
176
+ dep = super
177
+ dep.head = head? || other.head?
178
+ if external_source || other.external_source
179
+ self_external_source = external_source || {}
180
+ other_external_source = other.external_source || {}
181
+ dep.external_source = self_external_source.merge(other_external_source)
182
+ end
183
+ dep
184
+ end
185
+
186
+ #-------------------------------------------------------------------------#
187
+
188
+ # !@group String representation
189
+
190
+ # Creates a string representation of the dependency suitable for
191
+ # serialization and de-serialization without loss of information. The
192
+ # string is also suitable for UI.
193
+ #
194
+ # @note This representation is used by the {Lockfile}.
195
+ #
196
+ # @example Output examples
197
+ #
198
+ # "libPusher"
199
+ # "libPusher (= 1.0)"
200
+ # "libPusher (~> 1.0.1)"
201
+ # "libPusher (> 1.0, < 2.0)"
202
+ # "libPusher (HEAD)"
203
+ # "libPusher (from `www.example.com')"
204
+ # "libPusher (defined in Podfile)"
205
+ # "RestKit/JSON"
206
+ #
207
+ # @return [String] the representation of the dependency.
208
+ #
209
+ def to_s
210
+ version = ''
211
+ if external?
212
+ version << external_source_description
213
+ elsif head?
214
+ version << 'HEAD'
215
+ elsif @version_requirements != Requirement.default
216
+ version << @version_requirements.to_s
217
+ end
218
+ result = @name.dup
219
+ result << " (#{version})" unless version.empty?
220
+ result
221
+ end
222
+
223
+ # Generates a dependency from its string representation.
224
+ #
225
+ # @param [String] string
226
+ # The string that describes the dependency generated from
227
+ # {#to_s}.
228
+ #
229
+ # @note The information about external sources is not completely
230
+ # serialized in the string representation and should be stored a
231
+ # part by clients that need to create a dependency equal to the
232
+ # original one.
233
+ #
234
+ # @return [Dependency] the dependency described by the string.
235
+ #
236
+ def self.from_string(string)
237
+ match_data = string.match(/(\S*)( (.*))?/)
238
+ name = match_data[1]
239
+ version = match_data[2]
240
+ version = version.gsub(/[()]/,'') if version
241
+ case version
242
+ when nil || /from `(.*)(`|')/
243
+ Dependency.new(name)
244
+ when /HEAD/
245
+ Dependency.new(name, :head)
246
+ else
247
+ Dependency.new(name, version)
248
+ end
249
+ end
250
+
251
+ # @return [String] a string representation suitable for debugging.
252
+ #
253
+ def inspect
254
+ "<#{self.class} name=#{self.name} requirements=#{requirement.to_s} " \
255
+ "external_source=#{external_source||'nil'}>"
256
+ end
257
+
258
+ #--------------------------------------#
259
+
260
+ private
261
+
262
+ # Creates a string representation of the external source suitable for UI.
263
+ #
264
+ # @example Output examples
265
+ #
266
+ # "from `www.example.com/libPusher.git', tag `v0.0.1'"
267
+ # "from `www.example.com/libPusher.podspec'"
268
+ # "from `~/path/to/libPusher'"
269
+ #
270
+ # @todo Improve the description for Mercurial and Subversion.
271
+ #
272
+ # @return [String] the description of the external source.
273
+ #
274
+ def external_source_description
275
+ source = external_source
276
+ if source.key?(:git)
277
+ desc = "`#{source[:git]}`"
278
+ desc << ", commit `#{source[:commit]}`" if source[:commit]
279
+ desc << ", branch `#{source[:branch]}`" if source[:branch]
280
+ desc << ", tag `#{source[:tag]}`" if source[:tag]
281
+ elsif source.key?(:hg)
282
+ desc = "`#{source[:hg]}`"
283
+ elsif source.key?(:svn)
284
+ desc = "`#{source[:svn]}`"
285
+ elsif source.key?(:podspec)
286
+ desc = "`#{source[:podspec]}`"
287
+ elsif source.key?(:local)
288
+ desc = "`#{source[:local]}`"
289
+ else
290
+ desc = "`#{source.to_s}`"
291
+ end
292
+ "from #{desc}"
293
+ end
294
+ end
295
+ end
@@ -0,0 +1,6 @@
1
+ module Pod
2
+
3
+ # The version of the cocoapods-core.
4
+ #
5
+ CORE_VERSION = '0.17.0.rc1' unless defined? Pod::CORE_VERSION
6
+ end