cocoapods-core 0.17.0.rc5 → 0.17.0.rc6

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.
@@ -102,7 +102,13 @@ module Pod
102
102
  # clients.
103
103
  #
104
104
  def to_s
105
- "#{name} (#{version})"
105
+ if name && version.version != ""
106
+ "#{name} (#{version})"
107
+ elsif name
108
+ name
109
+ else
110
+ "No-name"
111
+ end
106
112
  end
107
113
 
108
114
  # @return [String] A string suitable for debugging.
@@ -234,7 +240,7 @@ module Pod
234
240
  if platform
235
241
  specs = specs.select { |s| s.supported_on_platform?(platform) }
236
242
  end
237
- specs = specs.map { |s| Dependency.new(s.name, version) }
243
+ specs.map { |s| Dependency.new(s.name, version) }
238
244
  end
239
245
 
240
246
  # Returns the dependencies on other Pods or subspecs of other Pods.
@@ -527,19 +533,19 @@ module Pod
527
533
  def self.from_file(path, subspec_name = nil)
528
534
  path = Pathname.new(path)
529
535
  unless path.exist?
530
- raise StandardError, "No podspec exists at path `#{path}`."
536
+ raise Informative, "No podspec exists at path `#{path}`."
531
537
  end
532
538
 
533
539
  case path.extname
534
540
  when '.podspec'
535
541
  spec = ::Pod._eval_podspec(path)
536
542
  unless spec.is_a?(Specification)
537
- raise StandardError, "Invalid podspec file at path `#{path}`."
543
+ raise Informative, "Invalid podspec file at path `#{path}`."
538
544
  end
539
545
  when '.yaml'
540
546
  spec = Specification.from_yaml(path.read)
541
547
  else
542
- raise StandardError, "Unsupported specification format `#{path.extname}`."
548
+ raise Informative, "Unsupported specification format `#{path.extname}`."
543
549
  end
544
550
 
545
551
  spec.defined_in_file = path
@@ -144,13 +144,7 @@ module Pod
144
144
  def dependencies
145
145
  value = value_for_attribute(:dependencies)
146
146
  value.map do |name, requirements|
147
- if Array(requirements).all?{ |req| req.is_a?(String) }
148
- Dependency.new(name, requirements)
149
- else
150
- raise Informative, "Unsupported parameters for `#{name}` " \
151
- "dependency `#{requirements.to_s}` in #{spec}.\n" \
152
- "Specifications don't support external sources"
153
- end
147
+ Dependency.new(name, requirements)
154
148
  end
155
149
  end
156
150
 
@@ -391,7 +391,7 @@ module Pod
391
391
  # The deployment target of the platform.
392
392
  #
393
393
  def deployment_target=(*args)
394
- raise StandardError, "The deployment target can be declared only per platform."
394
+ raise Informative, "The deployment target can be declared only per platform."
395
395
  end
396
396
 
397
397
  #-----------------------------------------------------------------------#
@@ -435,8 +435,9 @@ module Pod
435
435
  #
436
436
  def dependency(*args)
437
437
  name, *version_requirements = args
438
- raise StandardError, "A specification can't require self as a subspec" if name == self.name
439
- raise StandardError, "A subspec can't require one of its parents specifications" if @parent && @parent.name.include?(name)
438
+ raise Informative, "A specification can't require itself as a subspec" if name == self.name
439
+ raise Informative, "A subspec can't require one of its parents specifications" if @parent && @parent.name.include?(name)
440
+ raise Informative, "Unsupported version requirements" unless version_requirements.all? { |req| req.is_a?(String) }
440
441
  attributes_hash["dependencies"] ||= {}
441
442
  attributes_hash["dependencies"][name] = version_requirements
442
443
  end
@@ -25,18 +25,23 @@ module Pod
25
25
  end
26
26
 
27
27
  elsif method == :header_mappings
28
- raise StandardError, "[#{to_s}] The use of the `header_mappings` hook has been deprecated."
28
+ raise Informative, "[#{to_s}] The use of the `header_mappings` hook has been deprecated.\n" \
29
+ "Use the `header_dir` and the `header_mappings_dir` attributes."
30
+
31
+ elsif method == :copy_header_mapping
32
+ raise Informative, "[#{to_s}] The use of the `copy_header_mapping` hook has been deprecated.\n" \
33
+ "Use the `header_dir` and the `header_mappings_dir` attributes."
29
34
  end
30
35
  end
31
36
 
32
37
  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."
38
+ raise Informative, "[#{to_s}] Clean paths are deprecated. CocoaPods now " \
39
+ "cleans unused files by default. Use the `preserve_paths` attribute if needed."
35
40
  end
36
41
 
37
42
  [ :part_of_dependency=, :part_of=, :exclude_header_search_paths= ].each do |method|
38
43
  define_method method do |value|
39
- raise StandardError, "[#{to_s}] Attribute `#{method.to_s[0..-2]}` has been deprecated."
44
+ raise Informative, "[#{to_s}] Attribute `#{method.to_s[0..-2]}` has been deprecated."
40
45
  end
41
46
  end
42
47
 
@@ -35,6 +35,12 @@ module Pod
35
35
  end
36
36
  end
37
37
 
38
+ # @return [Bool] Whether the more strict validation of the master repo
39
+ # should be used. Specifically The master repo treats certain
40
+ # warnings as errors.
41
+ #
42
+ attr_accessor :master_repo_mode
43
+
38
44
  # Lints the specification adding a {Result} for any failed check to the
39
45
  # {#results} list.
40
46
  #
@@ -90,30 +96,28 @@ module Pod
90
96
  def perform_textual_analysis
91
97
  return unless @file
92
98
  text = @file.read
93
- error "`config.ios?' and `config.osx?' are deprecated." if text =~ /config\..?os.?/
99
+ error "`config.ios?` and `config.osx?` are deprecated." if text =~ /config\..?os.?/
94
100
  error "clean_paths are deprecated (use preserve_paths)." if text =~ /clean_paths/
95
- warning "Comments must be deleted." if text.scan(/^\s*#/).length > 24
101
+ master_repo_error "Comments must be deleted." if text.scan(/^\s*#\s+/).length > 24
96
102
  end
97
103
 
98
104
  # Checks that every root only attribute which is required has a value.
99
105
  #
100
106
  # @return [void]
101
107
  #
102
- def check_required_root_attributes
108
+ def check_required_root_attributes
103
109
  attributes = DSL.attributes.values.select(&:root_only?)
104
110
  attributes.each do |attr|
105
- # if spec.respond_to?(attr.name)
106
- value = spec.send(attr.name)
107
- next unless attr.required?
108
- unless value && (!value.respond_to?(:empty?) || !value.empty?)
109
- if attr.name == :license
110
- warning("Missing required attribute `#{attr.name}`.")
111
- else
112
- error("Missing required attribute `#{attr.name}`.")
113
- end
111
+ value = spec.send(attr.name)
112
+ next unless attr.required?
113
+ unless value && (!value.respond_to?(:empty?) || !value.empty?)
114
+ if attr.name == :license
115
+ warning("Missing required attribute `#{attr.name}`.")
116
+ else
117
+ error("Missing required attribute `#{attr.name}`.")
114
118
  end
115
119
  end
116
- # end
120
+ end
117
121
  end
118
122
 
119
123
  # Runs the validation hook for root only attributes.
@@ -200,18 +204,18 @@ module Pod
200
204
  # Performs validations related to the `summary` attribute.
201
205
  #
202
206
  def _validate_summary(s)
203
- warning "The summary should be short use `description` (max 140 characters)." if s.length > 140
204
- warning "The summary is not meaningful." if s =~ /A short description of/
207
+ master_repo_error "The summary should be short use `description` (max 140 characters)." if s.length > 140
208
+ master_repo_error "The summary is not meaningful." if s =~ /A short description of/
205
209
  warning "The summary should end with proper punctuation." if s !~ /(\.|\?|!)$/
206
210
  end
207
211
 
208
212
  # Performs validations related to the `description` attribute.
209
213
  #
210
214
  def _validate_description(d)
211
- warning "The description is not meaningful." if d =~ /An optional longer description of/
212
- warning "The description should end with proper punctuation." if d !~ /(\.|\?|!)$/
213
- warning "The description is equal to the summary." if d == spec.summary
214
- warning "The description is shorter than the summary." if d.length < spec.summary.length
215
+ master_repo_error "The description is not meaningful." if d =~ /An optional longer description of/
216
+ master_repo_error "The description should end with proper punctuation." if d !~ /(\.|\?|!)$/
217
+ master_repo_error "The description is equal to the summary." if d == spec.summary
218
+ master_repo_error "The description is shorter than the summary." if d.length < spec.summary.length
215
219
  end
216
220
 
217
221
  # Performs validations related to the `license` attribute.
@@ -219,8 +223,8 @@ module Pod
219
223
  def _validate_license(l)
220
224
  type = l[:type]
221
225
  warning "Missing license type." if type.nil?
222
- warning "Sample license type." if type && type =~ /\(example\)/
223
- warning "Invalid license type." if type && type.gsub(' ', '').gsub("\n", '').empty?
226
+ master_repo_error "Invalid license type." if type && type.gsub(' ', '').gsub("\n", '').empty?
227
+ error "Sample license type." if type && type =~ /\(example\)/
224
228
  end
225
229
 
226
230
  # Performs validations related to the `source` attribute.
@@ -233,14 +237,14 @@ module Pod
233
237
 
234
238
  error "Example source." if git =~ /http:\/\/EXAMPLE/
235
239
  error 'The commit of a Git source cannot be `HEAD`.' if commit && commit.downcase =~ /head/
236
- warning 'The version should be included in the Git tag.' if tag && !tag.include?(version)
237
- warning "Github repositories should end in `.git`." if github && !git.end_with?('.git')
238
- warning "Github repositories should use `https` link." if github && !git.start_with?('https://github.com') && !git.start_with?('git://gist.github.com')
240
+ master_repo_error 'The version should be included in the Git tag.' if tag && !tag.include?(version)
241
+ master_repo_error "Github repositories should end in `.git`." if github && !git.end_with?('.git')
242
+ master_repo_error "Github repositories should use `https` link." if github && !git.start_with?('https://github.com') && !git.start_with?('git://gist.github.com')
239
243
 
240
244
  if version == '0.0.1'
241
245
  error 'Git sources should specify either a commit or a tag.' if commit.nil? && tag.nil?
242
246
  else
243
- warning 'Git sources should specify a tag.' if tag.nil?
247
+ master_repo_error 'Git sources should specify a tag.' if tag.nil?
244
248
  end
245
249
  end
246
250
  end
@@ -272,7 +276,10 @@ module Pod
272
276
  end
273
277
  patterns.each do |pattern|
274
278
  if pattern.is_a?(Rake::FileList)
275
- warning "Rake::FileList is deprecated, use `exclude_files` (#{attrb.name})."
279
+ # TODO: enable for the 0.17 release
280
+ unless master_repo_mode
281
+ warning "Rake::FileList is deprecated, use `exclude_files` (#{attrb.name})."
282
+ end
276
283
  else
277
284
  if pattern.start_with?('/')
278
285
  error "File patterns must be relative and cannot start with a slash (#{attrb.name})."
@@ -293,11 +300,11 @@ module Pod
293
300
  # Check empty subspec attributes
294
301
  #
295
302
  def check_if_spec_is_empty
296
- methods = %w[ source_files resources preserve_paths ]
297
- empty_patterns = methods.all? { |m| consumer.send(m).empty? } && consumer.spec.subspecs.empty?
303
+ methods = %w[ source_files resources preserve_paths dependencies ]
304
+ empty_patterns = methods.all? { |m| consumer.send(m).empty? }
298
305
  empty = empty_patterns && consumer.spec.subspecs.empty?
299
306
  if empty
300
- warning "The #{consumer.spec} spec appears to be empty (no source files, resources, preserve paths or subspecs)."
307
+ error "The #{consumer.spec} spec is empty (no source files, resources, preserve paths, dependencies or subspecs)."
301
308
  end
302
309
  end
303
310
 
@@ -329,6 +336,22 @@ module Pod
329
336
  add_result(:warning, message)
330
337
  end
331
338
 
339
+ # Adds an error if the master repo mode is enabled, otherwise logs a
340
+ # warning.
341
+ #
342
+ # @param [String] message
343
+ # The message of the result.
344
+ #
345
+ # @return [void]
346
+ #
347
+ def master_repo_error(message)
348
+ if master_repo_mode
349
+ error(message)
350
+ else
351
+ warning(message)
352
+ end
353
+ end
354
+
332
355
  # Adds a result of the given type with the given message. If there is a
333
356
  # current platform it is added to the result. If a result with the same
334
357
  # type and the same message is already available the current platform is
@@ -35,8 +35,8 @@ module Pod
35
35
  @set.versions.first
36
36
  end
37
37
 
38
- # @return [Array<Version>] all the versions available sorted
39
- # ascendingly.
38
+ # @return [Array<Version>] all the versions available ascending
39
+ # order.
40
40
  #
41
41
  def versions
42
42
  @set.versions.sort.reverse
@@ -68,6 +68,9 @@ module Pod
68
68
  # @note The raw version string is still accessible with the {#version}
69
69
  # method.
70
70
  #
71
+ # @todo Adding the head information to the string representation creates
72
+ # issues (see Dependency#requirement).
73
+ #
71
74
  def to_s
72
75
  head? ? "HEAD based on #{super}" : super
73
76
  end
@@ -67,21 +67,10 @@ module Pod
67
67
  when Array then process_array(value)
68
68
  when Hash then process_hash(value, hash_keys_hint)
69
69
  else
70
- raise "Unsupported class for YAML conversion #{value.class}"
70
+ raise StandardError, "Unsupported class for YAML conversion #{value.class}"
71
71
  end
72
72
  end
73
73
 
74
- # Converts a string to YAML.
75
- #
76
- # @param [String] string
77
- # the string to convert.
78
- #
79
- # @return [String] the YAML representation of the given object.
80
- #
81
- def process_string(string)
82
- string
83
- end
84
-
85
74
  # Converts an array to YAML after sorting it.
86
75
  #
87
76
  # @param [Array] array
@@ -194,7 +183,7 @@ module Pod
194
183
  when String then value.downcase
195
184
  when Symbol then sorting_string(value.to_s)
196
185
  when Array then sorting_string(value.first)
197
- when Hash then sorting_string(value.keys.sort.first)
186
+ when Hash then value.keys.map { |key| key.to_s.downcase }.sort.first
198
187
  end
199
188
  end
200
189
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0.rc5
4
+ version: 0.17.0.rc6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Duran
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-14 00:00:00.000000000 Z
12
+ date: 2013-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -101,7 +101,9 @@ files:
101
101
  - lib/cocoapods-core/podfile/target_definition.rb
102
102
  - lib/cocoapods-core/podfile.rb
103
103
  - lib/cocoapods-core/requirement.rb
104
- - lib/cocoapods-core/source/validator.rb
104
+ - lib/cocoapods-core/source/acceptor.rb
105
+ - lib/cocoapods-core/source/aggregate.rb
106
+ - lib/cocoapods-core/source/health_reporter.rb
105
107
  - lib/cocoapods-core/source.rb
106
108
  - lib/cocoapods-core/specification/consumer.rb
107
109
  - lib/cocoapods-core/specification/dsl/attribute.rb
@@ -1,183 +0,0 @@
1
- module Pod
2
- class Source
3
-
4
- # TODO: THIS CLASS IS A STUB
5
-
6
- # Checks whether a podspec can be accepted by a source.
7
- #
8
- # This class can work on Travis but some checks are lost as the repo is
9
- # already merged during the test.
10
- #
11
- class Validator
12
-
13
- # @return [Source] the source where the podspec should be added.
14
- #
15
- attr_reader :source
16
-
17
- # @param [Pathname] repo @see Source#repo.
18
- #
19
- def initialize(repo)
20
- @source = Source.new(repo)
21
- @errors = {}
22
- @linter_results = {}
23
- end
24
-
25
- # @param [Array<Pathname>] spec_paths
26
- # a list of path that should be checked for being accepted in
27
- # specs repo.
28
- #
29
- # @return [Bool] whether to podspec can be accepted by the source.
30
- #
31
- def check(spec_paths)
32
- spec_paths = [ spec_paths ] unless spec_paths.is_a?(Array)
33
- @errors = {}
34
- spec_paths.each do |path|
35
- @spec_path = Pathname.new(path)
36
- lint
37
- next unless spec
38
- # check_spec_path
39
- check_spec_source_change
40
- check_if_untagged_version_is_acceptable
41
- check_commit_change_for_untagged_version
42
- check_dependencies
43
- end
44
- errors.values.empty?
45
- end
46
-
47
- #-----------------------------------------------------------------------#
48
-
49
- # @!group Validation results
50
-
51
- public
52
-
53
-
54
- # @return [Hash{Pathname=>Array<String>}] the errors generated by the
55
- # validation. If there is any error the podspec cannot be
56
- # accepted.
57
- #
58
- attr_reader :errors
59
-
60
- # @return [Hash{Pathname=>Array<Specification::Linter::Result>}] the
61
- # result generated by the linter for not approved specifications.
62
- #
63
- attr_reader :linter_results
64
-
65
- #-----------------------------------------------------------------------#
66
-
67
- # @!group Validation helpers
68
-
69
- private
70
-
71
- # @return [Pathname] The path of the current specification that should be
72
- # checked.
73
- #
74
- attr_reader :spec_path
75
-
76
- # @return [Specification] The current specification that should be
77
- # checked.
78
- #
79
- # @note The specification is generated by the linter that catches any
80
- # exception.
81
- #
82
- attr_reader :spec
83
-
84
-
85
- #
86
- #
87
- def error(message)
88
- @errors[spec_path] ||= []
89
- @errors[spec_path] << message
90
- end
91
-
92
- #-----------------------------------------------------------------------#
93
-
94
- # @!group Check steps
95
-
96
- private
97
-
98
- def lint
99
- linter = Specification::Linter.new(spec_path)
100
- if linter.lint
101
- @spec = linter.spec
102
- else
103
- error 'Linter failed validation.'
104
- end
105
- end
106
-
107
- # TODO: this check cannot be performed before a merge.
108
- def check_spec_path
109
- expected = "#{spec.name}/#{spec.version}/#{spec.name}.podspec"
110
- relative_path = spec_path.relative_path_from(source.repo).to_s
111
- unless relative_path == expected
112
- error "Incorrect path, the path is `#{relative_path}` and should be `#{expected}`."
113
- end
114
- end
115
-
116
- def check_spec_source_change
117
- return unless spec
118
- return unless reference_spec
119
- keys = Spec::DSL::SOURCE_KEYS.keys
120
- source = spec.source.values_at(*keys).compact.first
121
- old_source = reference_spec.source.values_at(*keys).compact.first
122
- unless source == old_source
123
- error "Attempt to change the source of the specification. " \
124
- "Source: `#{source}`. Previous: `#{old_source}`.\n " \
125
- "Contact specs repos maintainers if the library changed location."
126
- end
127
- end
128
-
129
- def check_if_untagged_version_is_acceptable
130
- return unless spec
131
- return if !spec.source[:git] || spec.source[:tag]
132
-
133
- # Allow to fix a 0.0.1 podspec
134
- if !related_specifications.any? { |s| s.version == '0.0.1' }
135
- error "There is already versioned specifications so " \
136
- "untagged versions cannot be added."
137
- elsif spec.version != Version.new('0.0.1')
138
- error "Untagged Git repositories should be versioned as 0.0.1"
139
- end
140
- end
141
-
142
- # TODO: this cannot be tested on Travis with the current setup
143
- def check_commit_change_for_untagged_version
144
- return unless spec
145
- return unless spec.version == Version.new('0.0.1')
146
- ref_spec = related_specifications.find { |s| s.version != '0.0.1' }
147
- return unless ref_spec
148
- unless ref_spec.source[:commit] == spec.source[:commit]
149
- error "Attempt to rewrite the commit of 0.0.1 version."
150
- end
151
- end
152
-
153
- def check_dependencies
154
- return unless spec
155
- spec.external_dependencies(true).each do |dep|
156
- set = source.search(dep)
157
- unless set && set.specification
158
- error "Unable to find a specification for the `#{dep}` dependency."
159
- end
160
- end
161
- end
162
-
163
- #-----------------------------------------------------------------------#
164
-
165
- # @!group Source helpers
166
-
167
- private
168
-
169
- def related_specifications
170
- versions = source.versions(spec.name)
171
- return unless versions
172
- specs = versions.sort.map { |v| source.specification(spec.name, v) }
173
- specs.reject { |s| s.defined_in_file == spec_path }
174
- end
175
-
176
- def reference_spec
177
- specs = related_specifications
178
- specs.last if specs
179
- end
180
-
181
- end
182
- end
183
- end