cocoapods-core 0.17.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/README.md +36 -0
- data/lib/cocoapods-core/core_ui.rb +19 -0
- data/lib/cocoapods-core/dependency.rb +295 -0
- data/lib/cocoapods-core/gem_version.rb +6 -0
- data/lib/cocoapods-core/lockfile.rb +440 -0
- data/lib/cocoapods-core/platform.rb +171 -0
- data/lib/cocoapods-core/podfile/dsl.rb +459 -0
- data/lib/cocoapods-core/podfile/target_definition.rb +503 -0
- data/lib/cocoapods-core/podfile.rb +345 -0
- data/lib/cocoapods-core/requirement.rb +15 -0
- data/lib/cocoapods-core/source/validator.rb +183 -0
- data/lib/cocoapods-core/source.rb +284 -0
- data/lib/cocoapods-core/specification/consumer.rb +356 -0
- data/lib/cocoapods-core/specification/dsl/attribute.rb +245 -0
- data/lib/cocoapods-core/specification/dsl/attribute_support.rb +76 -0
- data/lib/cocoapods-core/specification/dsl/deprecations.rb +47 -0
- data/lib/cocoapods-core/specification/dsl/platform_proxy.rb +67 -0
- data/lib/cocoapods-core/specification/dsl.rb +1110 -0
- data/lib/cocoapods-core/specification/linter.rb +436 -0
- data/lib/cocoapods-core/specification/root_attribute_accessors.rb +152 -0
- data/lib/cocoapods-core/specification/set/presenter.rb +229 -0
- data/lib/cocoapods-core/specification/set/statistics.rb +277 -0
- data/lib/cocoapods-core/specification/set.rb +171 -0
- data/lib/cocoapods-core/specification/yaml.rb +60 -0
- data/lib/cocoapods-core/specification.rb +592 -0
- data/lib/cocoapods-core/standard_error.rb +84 -0
- data/lib/cocoapods-core/vendor/dependency.rb +264 -0
- data/lib/cocoapods-core/vendor/requirement.rb +208 -0
- data/lib/cocoapods-core/vendor/version.rb +333 -0
- data/lib/cocoapods-core/vendor.rb +56 -0
- data/lib/cocoapods-core/version.rb +99 -0
- data/lib/cocoapods-core/yaml_converter.rb +202 -0
- data/lib/cocoapods-core.rb +23 -0
- metadata +154 -0
@@ -0,0 +1,245 @@
|
|
1
|
+
module Pod
|
2
|
+
class Specification
|
3
|
+
module DSL
|
4
|
+
|
5
|
+
# A Specification attribute stores the information of an attribute. It
|
6
|
+
# also provides logic to implement any required logic.
|
7
|
+
#
|
8
|
+
class Attribute
|
9
|
+
|
10
|
+
require 'active_support/inflector/inflections'
|
11
|
+
|
12
|
+
# @return [Symbol] the name of the attribute.
|
13
|
+
#
|
14
|
+
attr_reader :name
|
15
|
+
|
16
|
+
# Returns a new attribute initialized with the given options.
|
17
|
+
#
|
18
|
+
# Attributes by default are:
|
19
|
+
#
|
20
|
+
# - inherited
|
21
|
+
# - multi-platform
|
22
|
+
#
|
23
|
+
# @param [Symbol] name @see name
|
24
|
+
#
|
25
|
+
# @param [Hash{Symbol=>Object}] options
|
26
|
+
# The options for configuring the attribute (see Options
|
27
|
+
# group).
|
28
|
+
#
|
29
|
+
# @raise If there are unrecognized options.
|
30
|
+
#
|
31
|
+
def initialize(name, options)
|
32
|
+
@name = name
|
33
|
+
|
34
|
+
@multi_platform = options.delete(:multi_platform) { true }
|
35
|
+
@inherited = options.delete(:inherited) { false }
|
36
|
+
@root_only = options.delete(:root_only) { false }
|
37
|
+
@required = options.delete(:required) { false }
|
38
|
+
@singularize = options.delete(:singularize) { false }
|
39
|
+
@file_patterns = options.delete(:file_patterns) { false }
|
40
|
+
@container = options.delete(:container) { nil }
|
41
|
+
@keys = options.delete(:keys) { nil }
|
42
|
+
@default_value = options.delete(:default_value) { nil }
|
43
|
+
@ios_default = options.delete(:ios_default) { nil }
|
44
|
+
@osx_default = options.delete(:osx_default) { nil }
|
45
|
+
@types = options.delete(:types) { [String ] }
|
46
|
+
|
47
|
+
unless options.empty?
|
48
|
+
raise StandardError, "Unrecognized options: #{options} for #{to_s}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# @return [String] A string representation suitable for UI.
|
53
|
+
#
|
54
|
+
def to_s
|
55
|
+
"Specification attribute `#{name}`"
|
56
|
+
end
|
57
|
+
|
58
|
+
# @return [String] A string representation suitable for debugging.
|
59
|
+
#
|
60
|
+
def inspect
|
61
|
+
"<#{self.class} name=#{self.name} types=#{types} " \
|
62
|
+
"multi_platform=#{multi_platform?}>"
|
63
|
+
end
|
64
|
+
|
65
|
+
#---------------------------------------------------------------------#
|
66
|
+
|
67
|
+
# @!group Options
|
68
|
+
|
69
|
+
# @return [Array<Class>] the list of the classes of the values
|
70
|
+
# supported by the attribute writer. If not specified defaults
|
71
|
+
# to #{String}.
|
72
|
+
#
|
73
|
+
attr_reader :types
|
74
|
+
|
75
|
+
# @return [Array<Class>] the list of the classes of the values
|
76
|
+
# supported by the attribute, including the container.
|
77
|
+
#
|
78
|
+
def supported_types
|
79
|
+
@supported_types ||= @types.dup.push(container).compact
|
80
|
+
end
|
81
|
+
|
82
|
+
# @return [Class] if defined it can be #{Array} or #{Hash}. It is used
|
83
|
+
# as default initialization value and to automatically wrap
|
84
|
+
# other values to arrays.
|
85
|
+
#
|
86
|
+
attr_reader :container
|
87
|
+
|
88
|
+
# @return [Array, Hash] the list of the accepted keys for an attribute
|
89
|
+
# wrapped by a Hash.
|
90
|
+
#
|
91
|
+
# @note A hash is accepted to group the keys associated only with
|
92
|
+
# certain keys (see the source attribute of a Spec).
|
93
|
+
#
|
94
|
+
attr_reader :keys
|
95
|
+
|
96
|
+
# @return [Object] if the attribute follows configuration over
|
97
|
+
# convention it can specify a default value.
|
98
|
+
#
|
99
|
+
# @note The default value is not automatically wrapped and should be
|
100
|
+
# specified within the container if any.
|
101
|
+
#
|
102
|
+
attr_reader :default_value
|
103
|
+
|
104
|
+
# @return [Object] similar to #{default_value} but for iOS.
|
105
|
+
#
|
106
|
+
attr_reader :ios_default
|
107
|
+
|
108
|
+
# @return [Object] similar to #{default_value} but for OS X.
|
109
|
+
#
|
110
|
+
attr_reader :osx_default
|
111
|
+
|
112
|
+
# @return [Bool] whether the specification should be considered invalid
|
113
|
+
# if a value for the attribute is not specified.
|
114
|
+
#
|
115
|
+
def required?; @required; end
|
116
|
+
|
117
|
+
# @return [Bool] whether the attribute should be specified only on the
|
118
|
+
# root specification.
|
119
|
+
#
|
120
|
+
def root_only?; @root_only; end
|
121
|
+
|
122
|
+
# @return [Bool] whether the attribute is multi-platform and should
|
123
|
+
# work in conjunction with #{PlatformProxy}.
|
124
|
+
#
|
125
|
+
def multi_platform?; @multi_platform; end
|
126
|
+
|
127
|
+
# @return [Bool] whether there should be a singular alias for the
|
128
|
+
# attribute writer.
|
129
|
+
#
|
130
|
+
def singularize?; @singularize; end
|
131
|
+
|
132
|
+
# @return [Bool] whether the attribute describes file patterns.
|
133
|
+
#
|
134
|
+
# @note This is mostly used by the linter.
|
135
|
+
#
|
136
|
+
def file_patterns?; @file_patterns; end
|
137
|
+
|
138
|
+
# @return [Bool] defines whether the attribute reader should join the
|
139
|
+
# values with the parent.
|
140
|
+
#
|
141
|
+
# @note Attributes stored in wrappers are always inherited.
|
142
|
+
#
|
143
|
+
def inherited?
|
144
|
+
!root_only? && @inherited
|
145
|
+
end
|
146
|
+
|
147
|
+
#---------------------------------------------------------------------#
|
148
|
+
|
149
|
+
# @!group Accessors support
|
150
|
+
|
151
|
+
# Returns the default value for the attribute.
|
152
|
+
#
|
153
|
+
# @param [Symbol] platform
|
154
|
+
# the platform for which the default value is requested.
|
155
|
+
#
|
156
|
+
# @return [Object] The default value.
|
157
|
+
#
|
158
|
+
def default(platform = nil)
|
159
|
+
if platform && multi_platform?
|
160
|
+
platform_value = ios_default if platform == :ios
|
161
|
+
platform_value = osx_default if platform == :osx
|
162
|
+
platform_value || default_value
|
163
|
+
else
|
164
|
+
default_value
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
# @return [String] the name of the setter method for the attribute.
|
169
|
+
#
|
170
|
+
def writer_name
|
171
|
+
"#{name}="
|
172
|
+
end
|
173
|
+
|
174
|
+
# @return [String] an aliased attribute writer offered for convenience
|
175
|
+
# on the DSL.
|
176
|
+
#
|
177
|
+
def writer_singular_form
|
178
|
+
"#{name.to_s.singularize}=" if singularize?
|
179
|
+
end
|
180
|
+
|
181
|
+
#---------------------------------------------------------------------#
|
182
|
+
|
183
|
+
# @!group Values validation
|
184
|
+
|
185
|
+
# Validates the value for an attribute. This validation should be
|
186
|
+
# performed before the value is prepared or wrapped.
|
187
|
+
#
|
188
|
+
# @note The this is called before preparing the value.
|
189
|
+
#
|
190
|
+
# @raise If the type is not in the allowed list.
|
191
|
+
#
|
192
|
+
# @return [void]
|
193
|
+
#
|
194
|
+
def validate_type(value)
|
195
|
+
return if value.nil?
|
196
|
+
unless supported_types.any? { |klass| value.class == klass }
|
197
|
+
raise StandardError, "Non acceptable type `#{value.class}` for "\
|
198
|
+
"#{to_s}. Allowed values: `#{types.inspect}`"
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
# Validates a value before storing.
|
203
|
+
#
|
204
|
+
# @raise If a root only attribute is set in a subspec.
|
205
|
+
#
|
206
|
+
# @raise If a unknown key is added to a hash.
|
207
|
+
#
|
208
|
+
# @return [void]
|
209
|
+
#
|
210
|
+
def validate_for_writing(spec, value)
|
211
|
+
if root_only? && !spec.root?
|
212
|
+
raise StandardError, "Can't set `#{name}` attribute for subspecs (in `#{spec.name}`)."
|
213
|
+
end
|
214
|
+
|
215
|
+
if keys
|
216
|
+
value.keys.each do |key|
|
217
|
+
unless allowed_keys.include?(key)
|
218
|
+
raise StandardError, "Unknown key `#{key}` for "\
|
219
|
+
"#{to_s}. Allowed keys: `#{allowed_keys.inspect}`"
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
if defined?(Rake) && value.is_a?(Rake::FileList)
|
224
|
+
# UI.warn "Rake::FileList is deprecated, use `exclude_files` (#{attrb.name})."
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
# @return [Array] the flattened list of the allowed keys for the
|
229
|
+
# hash of a given specification.
|
230
|
+
#
|
231
|
+
def allowed_keys
|
232
|
+
if keys.is_a?(Hash)
|
233
|
+
keys.keys.concat(keys.values.flatten.compact)
|
234
|
+
else
|
235
|
+
keys
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
#-----------------------------------------------------------------------#
|
242
|
+
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Pod
|
2
|
+
class Specification
|
3
|
+
module DSL
|
4
|
+
|
5
|
+
# @return [Array<Attribute>] The attributes of the class.
|
6
|
+
#
|
7
|
+
def self.attributes
|
8
|
+
@attributes
|
9
|
+
end
|
10
|
+
|
11
|
+
# This module provides support for storing the runtime information of the
|
12
|
+
# {Specification} DSL.
|
13
|
+
#
|
14
|
+
module AttributeSupport
|
15
|
+
|
16
|
+
# Defines a root attribute for the extended class.
|
17
|
+
#
|
18
|
+
# Root attributes make sense only in root specification, they never are
|
19
|
+
# multiplatform, they don't have inheritance, and they never have a
|
20
|
+
# default value.
|
21
|
+
#
|
22
|
+
# @param [String] name
|
23
|
+
# The name of the attribute.
|
24
|
+
#
|
25
|
+
# @param [Hash] options
|
26
|
+
# The options used to initialize the attribute.
|
27
|
+
#
|
28
|
+
# @return [void]
|
29
|
+
#
|
30
|
+
def root_attribute(name, options = {})
|
31
|
+
options[:root_only] = true
|
32
|
+
options[:multi_platform] = false
|
33
|
+
store_attribute(name, options)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Defines an attribute for the extended class.
|
37
|
+
#
|
38
|
+
# Regular attributes in general support inheritance and multi platform
|
39
|
+
# values, so resolving them for a given specification is not trivial.
|
40
|
+
#
|
41
|
+
# @param [String] name
|
42
|
+
# The name of the attribute.
|
43
|
+
#
|
44
|
+
# @param [Hash] options
|
45
|
+
# The options used to initialize the attribute.
|
46
|
+
#
|
47
|
+
# @return [void]
|
48
|
+
#
|
49
|
+
def attribute(name, options = {})
|
50
|
+
store_attribute(name, options)
|
51
|
+
end
|
52
|
+
|
53
|
+
#---------------------------------------------------------------------#
|
54
|
+
|
55
|
+
# Creates an attribute with the given name and options and stores it in
|
56
|
+
# the {DSL.attributes} hash.
|
57
|
+
#
|
58
|
+
# @param [String] name
|
59
|
+
# The name of the attribute.
|
60
|
+
#
|
61
|
+
# @param [Hash] options
|
62
|
+
# The options used to initialize the attribute.
|
63
|
+
#
|
64
|
+
# @return [void]
|
65
|
+
#
|
66
|
+
# @visibility private
|
67
|
+
#
|
68
|
+
def store_attribute(name, options)
|
69
|
+
attr = Attribute.new(name, options)
|
70
|
+
@attributes ||= {}
|
71
|
+
@attributes[name] = attr
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Pod
|
2
|
+
class Specification
|
3
|
+
module DSL
|
4
|
+
|
5
|
+
# Provides warning and errors for the deprecated attributes of the DSL.
|
6
|
+
#
|
7
|
+
module Deprecations
|
8
|
+
|
9
|
+
def preferred_dependency=(name)
|
10
|
+
self.default_subspec = name
|
11
|
+
CoreUI.warn "[#{to_s}] `preferred_dependency` has been renamed to `default_subspec`."
|
12
|
+
end
|
13
|
+
|
14
|
+
def singleton_method_added(method)
|
15
|
+
if method == :pre_install
|
16
|
+
CoreUI.warn "[#{to_s}] The use of `#{method}` by overriding the method is deprecated."
|
17
|
+
@pre_install_callback = Proc.new do |pod, target_definition|
|
18
|
+
self.pre_install(pod, target_definition)
|
19
|
+
end
|
20
|
+
|
21
|
+
elsif method == :post_install
|
22
|
+
CoreUI.warn "[#{to_s}] The use of `#{method}` by overriding the method is deprecated."
|
23
|
+
@post_install_callback = Proc.new do |target_installer|
|
24
|
+
self.post_install(target_installer)
|
25
|
+
end
|
26
|
+
|
27
|
+
elsif method == :header_mappings
|
28
|
+
raise StandardError, "[#{to_s}] The use of the `header_mappings` hook has been deprecated."
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def clean_paths=(value)
|
33
|
+
raise StandardError, "[#{to_s}] Clean paths are deprecated. CocoaPods now " \
|
34
|
+
"cleans unused files by default. Use preserver paths if needed."
|
35
|
+
end
|
36
|
+
|
37
|
+
[ :part_of_dependency=, :part_of=, :exclude_header_search_paths= ].each do |method|
|
38
|
+
define_method method do |value|
|
39
|
+
raise StandardError, "[#{to_s}] Attribute `#{method.to_s[0..-2]}` has been deprecated."
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Pod
|
2
|
+
class Specification
|
3
|
+
module DSL
|
4
|
+
|
5
|
+
# The PlatformProxy works in conjunction with Specification#_on_platform.
|
6
|
+
# It provides support for a syntax like `spec.ios.source_files = 'file'`.
|
7
|
+
#
|
8
|
+
class PlatformProxy
|
9
|
+
|
10
|
+
# @return [Specification] the specification for this platform proxy.
|
11
|
+
#
|
12
|
+
attr_accessor :spec
|
13
|
+
|
14
|
+
# @return [Symbol] the platform described by this proxy. Can be either `:ios` or
|
15
|
+
# `:osx`.
|
16
|
+
#
|
17
|
+
attr_accessor :platform
|
18
|
+
|
19
|
+
# @param [Specification] spec @see spec
|
20
|
+
# @param [Symbol] platform @see platform
|
21
|
+
#
|
22
|
+
def initialize(spec, platform)
|
23
|
+
@spec, @platform = spec, platform
|
24
|
+
end
|
25
|
+
|
26
|
+
# Defines a setter method for each attribute of the specification class,
|
27
|
+
# that forwards the message to the {#specification} using the
|
28
|
+
# {Specification#on_platform} method.
|
29
|
+
#
|
30
|
+
# @return [void]
|
31
|
+
#
|
32
|
+
def method_missing(meth, *args, &block)
|
33
|
+
attr = Specification::DSL.attributes.values.find do |attr|
|
34
|
+
attr.writer_name.to_sym == meth || (attr.writer_singular_form && attr.writer_singular_form.to_sym == meth)
|
35
|
+
end
|
36
|
+
if attr && attr.multi_platform?
|
37
|
+
spec.store_attribute(attr.name, args.first, platform)
|
38
|
+
else
|
39
|
+
super
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Allows to add dependency for the platform.
|
44
|
+
#
|
45
|
+
# @return [void]
|
46
|
+
#
|
47
|
+
def dependency(*args)
|
48
|
+
name, *version_requirements = args
|
49
|
+
platform_name = platform.to_s
|
50
|
+
spec.attributes_hash[platform_name] ||= {}
|
51
|
+
spec.attributes_hash[platform_name]["dependencies"] ||= {}
|
52
|
+
spec.attributes_hash[platform_name]["dependencies"][name] = version_requirements
|
53
|
+
end
|
54
|
+
|
55
|
+
# Allows to set the deployment target for the platform.
|
56
|
+
#
|
57
|
+
# @return [void]
|
58
|
+
#
|
59
|
+
def deployment_target=(value)
|
60
|
+
platform_name = platform.to_s
|
61
|
+
spec.attributes_hash["platforms"] ||= {}
|
62
|
+
spec.attributes_hash["platforms"][platform_name] = value
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|