cocoapods-core 1.4.0.beta.1 → 1.4.0.beta.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 124e2ed7abb0379ce9ee365c6ced5ea69ff08865
4
- data.tar.gz: 877153422ec76b1f609d8c21410ab76942e2052c
3
+ metadata.gz: 04b207ad7a8be3b249df95233970fce16e662b04
4
+ data.tar.gz: 131a182b0be16d16ece4207bced166973a85ba78
5
5
  SHA512:
6
- metadata.gz: cb481a17edf85583140125d9b9b25b5f079edb1354fcf023f71b28f41c95a5c1069f4947cf63b5c8db8345c2851d6977aef705fcbc5884a7f336ffaf347f4005
7
- data.tar.gz: 2516b6cb3b755936f8d969f1a348804e9634634f4cb848e2e9690f03a2b3e797730092b5904860cab9568f22d32dab1be6ebfa5be6c613c1c4c1217016d2648e
6
+ metadata.gz: a2d83bbe5b1d2816b492ed9a06721824ef2b6e4838a655f1ea30fd7a5732cdf333a47474ed8160dfe8d959f5291384392e3b935d2c71c6c8c467b24a89889ddb
7
+ data.tar.gz: c383a7b24f524330eded861d3d3309e144a899fee2c034b6a868df4b14eb0434186b1f7805c404bcbdcfe694e40a27772a08be777fc0f039c5e4c663e8c59474
@@ -1,5 +1,5 @@
1
1
  module Pod
2
2
  # The version of the cocoapods-core.
3
3
  #
4
- CORE_VERSION = '1.4.0.beta.1'.freeze unless defined? Pod::CORE_VERSION
4
+ CORE_VERSION = '1.4.0.beta.2'.freeze unless defined? Pod::CORE_VERSION
5
5
  end
@@ -368,6 +368,10 @@ module Pod
368
368
  # @option options [Boolean] :show_env_vars_in_log
369
369
  # whether this script phase should output the environment variables during execution.
370
370
  #
371
+ # @option options [Symbol] :execution_position
372
+ # specifies the position of which this script phase should be executed. The currently supported values are:
373
+ # `:before_compile`, `:after_compile` and `:any` which is the default.
374
+ #
371
375
  # @return [void]
372
376
  #
373
377
  def script_phase(options)
@@ -585,29 +585,23 @@ module Pod
585
585
 
586
586
  #--------------------------------------#
587
587
 
588
- SCRIPT_PHASE_REQUIRED_KEYS = [:name, :script].freeze
589
-
590
- SCRIPT_PHASE_OPTIONAL_KEYS = [:shell_path, :input_files, :output_files, :show_env_vars_in_log].freeze
591
-
592
- ALL_SCRIPT_PHASE_KEYS = (SCRIPT_PHASE_REQUIRED_KEYS + SCRIPT_PHASE_OPTIONAL_KEYS).freeze
593
-
594
588
  # Stores the script phase to add for this target definition.
595
589
  #
596
590
  # @param [Hash] options
597
591
  # The options to use for this script phase. The required keys
598
592
  # are: `:name`, `:script`, while the optional keys are:
599
- # `:shell_path`, `:input_files`, `:output_files` and `:show_env_vars_in_log`.
593
+ # `:shell_path`, `:input_files`, `:output_files`, `:show_env_vars_in_log` and `:execution_position`.
600
594
  #
601
595
  # @return [void]
602
596
  #
603
597
  def store_script_phase(options)
604
598
  option_keys = options.keys
605
- unrecognized_keys = option_keys - ALL_SCRIPT_PHASE_KEYS
599
+ unrecognized_keys = option_keys - Specification::ALL_SCRIPT_PHASE_KEYS
606
600
  unless unrecognized_keys.empty?
607
- raise StandardError, "Unrecognized options `#{unrecognized_keys}` in shell script `#{options}` within `#{name}` target. " \
608
- "Available options are `#{ALL_SCRIPT_PHASE_KEYS}`."
601
+ raise StandardError, "Unrecognized options `#{unrecognized_keys}` in shell script `#{options[:name]}` within `#{name}` target. " \
602
+ "Available options are `#{Specification::ALL_SCRIPT_PHASE_KEYS}`."
609
603
  end
610
- missing_required_keys = SCRIPT_PHASE_REQUIRED_KEYS - option_keys
604
+ missing_required_keys = Specification::SCRIPT_PHASE_REQUIRED_KEYS - option_keys
611
605
  unless missing_required_keys.empty?
612
606
  raise StandardError, "Missing required shell script phase options `#{missing_required_keys.join(', ')}`"
613
607
  end
@@ -615,6 +609,11 @@ module Pod
615
609
  if script_phases_hash.map { |script_phase_options| script_phase_options[:name] }.include?(options[:name])
616
610
  raise StandardError, "Script phase with name `#{options[:name]}` name already present for target `#{name}`."
617
611
  end
612
+ options[:execution_position] = :any unless options.key?(:execution_position)
613
+ unless Specification::EXECUTION_POSITION_KEYS.include?(options[:execution_position])
614
+ raise StandardError, "Invalid execution position value `#{options[:execution_position]}` in shell script `#{options[:name]}` within `#{name}` target. " \
615
+ "Available options are `#{Specification::EXECUTION_POSITION_KEYS}`."
616
+ end
618
617
  script_phases_hash << options
619
618
  end
620
619
 
@@ -263,7 +263,7 @@ module Pod
263
263
  found = Pathname.glob(pod_path(query)).map { |path| path.basename.to_s }
264
264
  if [query] == found
265
265
  set = set(query)
266
- set if set.specification.name == query
266
+ set if set.specification_name == query
267
267
  end
268
268
  end
269
269
 
@@ -346,6 +346,27 @@ module Pod
346
346
  @consumers[platform] ||= Consumer.new(self, platform)
347
347
  end
348
348
 
349
+ # @return [Bool, String] The prefix_header_file value.
350
+ #
351
+ def prefix_header_file
352
+ attributes_hash['prefix_header_file']
353
+ end
354
+
355
+ # @return [Array<Hash{Symbol=>String}>] The script_phases value.
356
+ #
357
+ def script_phases
358
+ script_phases = attributes_hash['script_phases'] || []
359
+ script_phases.map do |script_phase|
360
+ phase = Specification.convert_keys_to_symbol(script_phase)
361
+ phase[:execution_position] = if phase.key?(:execution_position)
362
+ phase[:execution_position].to_sym
363
+ else
364
+ :any
365
+ end
366
+ phase
367
+ end
368
+ end
369
+
349
370
  #-------------------------------------------------------------------------#
350
371
 
351
372
  public
@@ -370,11 +391,6 @@ module Pod
370
391
  #
371
392
  # @overload supported_on_platform?(symbolic_name, deployment_target)
372
393
  #
373
- # @param [Symbol] symbolic_name
374
- # the name of the platform which is checked for support.
375
- #
376
- # @param [String] deployment_target
377
- # the deployment target which is checked for support.
378
394
  #
379
395
  def supported_on_platform?(*platform)
380
396
  platform = Platform.new(*platform)
@@ -456,7 +472,7 @@ module Pod
456
472
  # @param [Object] value
457
473
  # the value to store.
458
474
  #
459
- # @param [Symbol] platform.
475
+ # @param [Symbol] platform_name
460
476
  # If provided the attribute is stored only for the given platform.
461
477
  #
462
478
  # @note If the provides value is Hash the keys are converted to a string.
@@ -465,7 +481,7 @@ module Pod
465
481
  #
466
482
  def store_attribute(name, value, platform_name = nil)
467
483
  name = name.to_s
468
- value = convert_keys_to_string(value) if value.is_a?(Hash)
484
+ value = Specification.convert_keys_to_string(value) if value.is_a?(Hash)
469
485
  value = value.strip_heredoc.strip if value.respond_to?(:strip_heredoc)
470
486
  if platform_name
471
487
  platform_name = platform_name.to_s
@@ -489,8 +505,6 @@ module Pod
489
505
  end
490
506
  end
491
507
 
492
- private
493
-
494
508
  # Converts the keys of the given hash to a string.
495
509
  #
496
510
  # @param [Object] value
@@ -498,16 +512,33 @@ module Pod
498
512
  #
499
513
  # @return [Hash] the hash with the strings instead of the keys.
500
514
  #
501
- def convert_keys_to_string(value)
515
+ def self.convert_keys_to_string(value)
502
516
  return unless value
503
517
  result = {}
504
518
  value.each do |key, subvalue|
505
- subvalue = convert_keys_to_string(subvalue) if subvalue.is_a?(Hash)
519
+ subvalue = Specification.convert_keys_to_string(subvalue) if subvalue.is_a?(Hash)
506
520
  result[key.to_s] = subvalue
507
521
  end
508
522
  result
509
523
  end
510
524
 
525
+ # Converts the keys of the given hash to a string.
526
+ #
527
+ # @param [Object] value
528
+ # the value that needs to be stripped from the Symbols.
529
+ #
530
+ # @return [Hash] the hash with the strings instead of the keys.
531
+ #
532
+ def self.convert_keys_to_symbol(value)
533
+ return unless value
534
+ result = {}
535
+ value.each do |key, subvalue|
536
+ subvalue = Specification.convert_keys_to_symbol(subvalue) if subvalue.is_a?(Hash)
537
+ result[key.to_sym] = subvalue
538
+ end
539
+ result
540
+ end
541
+
511
542
  #-------------------------------------------------------------------------#
512
543
 
513
544
  public
@@ -649,7 +680,7 @@ module Pod
649
680
  def validate_cocoapods_version
650
681
  unless cocoapods_version.satisfied_by?(Version.create(CORE_VERSION))
651
682
  raise Informative, "`#{name}` requires CocoaPods version `#{cocoapods_version}`, " \
652
- "which is not satisified by your current version, `#{CORE_VERSION}`."
683
+ "which is not satisfied by your current version, `#{CORE_VERSION}`."
653
684
  end
654
685
  end
655
686
  end
@@ -179,6 +179,11 @@ module Pod
179
179
  #
180
180
  spec_attr_accessor :resource_bundles
181
181
 
182
+ # @return [Array<Hash{Symbol=>String}>] An array of hashes where each hash
183
+ # represents a script phase.
184
+ #
185
+ spec_attr_accessor :script_phases
186
+
182
187
  # @return [Array<String>] A hash where the key represents the
183
188
  # paths of the resources to copy and the values the paths of
184
189
  # the resources that should be copied.
@@ -324,7 +329,11 @@ module Pod
324
329
  #
325
330
  def prepare_value(attr, value)
326
331
  if attr.container == Array
327
- value = [*value].compact
332
+ value = if value.is_a?(Hash)
333
+ [value]
334
+ else
335
+ [*value].compact
336
+ end
328
337
  end
329
338
 
330
339
  hook_name = prepare_hook_name(attr)
@@ -362,6 +371,29 @@ module Pod
362
371
  end
363
372
  end
364
373
 
374
+ # Converts the array of hashes (script phases) where keys are strings into symbols.
375
+ #
376
+ # @param [Array<Hash{String=>String}>] value.
377
+ # The value of the attribute as specified by the user.
378
+ #
379
+ # @return [Array<Hash{Symbol=>String}>] the script phases array with symbols for each hash instead of strings.
380
+ #
381
+ def _prepare_script_phases(value)
382
+ if value
383
+ value.map do |script_phase|
384
+ if script_phase.is_a?(Hash)
385
+ phase = Specification.convert_keys_to_symbol(script_phase)
386
+ phase[:execution_position] = if phase.key?(:execution_position)
387
+ phase[:execution_position].to_sym
388
+ else
389
+ :any
390
+ end
391
+ phase
392
+ end
393
+ end.compact
394
+ end
395
+ end
396
+
365
397
  # Ensures that the file patterns of the resource bundles are contained in
366
398
  # an array.
367
399
  #
@@ -855,20 +855,31 @@ module Pod
855
855
  #
856
856
  # A path to a prefix header file to inject in the prefix header of the
857
857
  # pod project.
858
+ # `false` indicates that the default CocoaPods prefix header should not
859
+ # be generated.
860
+ # `true` is the default and indicates that the default CocoaPods prefix
861
+ # header should be generated.
858
862
  #
859
863
  # ---
860
864
  #
861
- # This attribute is __not recommended__ as Pods should not pollute the
862
- # prefix header of other libraries or of the user project.
865
+ # The file path options is __not recommended__ as Pods should not
866
+ # pollute the prefix header of other libraries or of the user project.
867
+ #
863
868
  #
864
869
  # @example
865
870
  #
866
871
  # spec.prefix_header_file = 'iphone/include/prefix.pch'
867
872
  #
868
- # @param [String] path
869
- # The path to the prefix header file.
873
+ # @example
874
+ #
875
+ # spec.prefix_header_file = false
876
+ #
877
+ # @param [Bool, String] path
878
+ # The path to the prefix header file or whether to disable
879
+ # prefix_header generation.
870
880
  #
871
881
  attribute :prefix_header_file,
882
+ :types => [TrueClass, FalseClass, String],
872
883
  :inherited => true
873
884
 
874
885
  #------------------#
@@ -1123,7 +1134,7 @@ module Pod
1123
1134
 
1124
1135
  #------------------#
1125
1136
 
1126
- # @!method resource_bundles=(*frameworks)
1137
+ # @!method resource_bundles=(*resource_bundles)
1127
1138
  #
1128
1139
  # This attribute allows to define the name and the file of the resource
1129
1140
  # bundles which should be built for the Pod. They are specified as a
@@ -1261,6 +1272,55 @@ module Pod
1261
1272
  attribute :module_map,
1262
1273
  :root_only => true
1263
1274
 
1275
+ #------------------#
1276
+
1277
+ SCRIPT_PHASE_REQUIRED_KEYS = [:name, :script].freeze
1278
+
1279
+ SCRIPT_PHASE_OPTIONAL_KEYS = [:shell_path, :input_files, :output_files, :show_env_vars_in_log, :execution_position].freeze
1280
+
1281
+ EXECUTION_POSITION_KEYS = [:before_compile, :after_compile, :any].freeze
1282
+
1283
+ ALL_SCRIPT_PHASE_KEYS = (SCRIPT_PHASE_REQUIRED_KEYS + SCRIPT_PHASE_OPTIONAL_KEYS).freeze
1284
+
1285
+ # @!method script_phases=(*script_phases)
1286
+ #
1287
+ # This attribute allows to define a script phase to execute as part of compilation of the Pod.
1288
+ # Unlike a prepare command, script phases execute as part of `xcodebuild` they can also utilize all environment
1289
+ # variables that are set during compilation.
1290
+ #
1291
+ # A Pod can provide multiple script phases to execute and they will be added in the order they were
1292
+ # declared and after taking into consideration their execution position setting.
1293
+ #
1294
+ # **Note** In order to provide visibility and awareness of the contents of all script phases,
1295
+ # a warning will be presented to the user upon installing your pod if it includes any script phases.
1296
+ #
1297
+ # @example
1298
+ #
1299
+ # spec.script_phase = { :name => 'Hello World', :script => 'echo "Hello World"' }
1300
+ #
1301
+ # @example
1302
+ #
1303
+ # spec.script_phase = { :name => 'Hello World', :script => 'echo "Hello World"', :execution_position => :before_compile }
1304
+ #
1305
+ # @example
1306
+ #
1307
+ # spec.script_phase = { :name => 'Hello World', :script => 'puts "Hello World"', :shell_path => '/usr/bin/ruby' } }
1308
+ #
1309
+ # @example
1310
+ #
1311
+ # spec.script_phases = [
1312
+ # { :name => 'Hello World', :script => 'echo "Hello World"' },
1313
+ # { :name => 'Hello Ruby World', :script => 'puts "Hello World"', :shell_path => '/usr/bin/ruby' } },
1314
+ # ]
1315
+ #
1316
+ # @param [Array<Hash{Symbol=>String}>] script_phases
1317
+ # An array of hashes where each hash represents a single script phase.
1318
+ #
1319
+ attribute :script_phases,
1320
+ :types => [Hash],
1321
+ :container => Array,
1322
+ :singularize => true
1323
+
1264
1324
  #-----------------------------------------------------------------------#
1265
1325
 
1266
1326
  # @!group Subspecs
@@ -394,6 +394,27 @@ module Pod
394
394
  end
395
395
  end
396
396
 
397
+ # Performs validations related to the `script_phases` attribute.
398
+ #
399
+ def _validate_script_phases(s)
400
+ s.each do |script_phase|
401
+ keys = script_phase.keys
402
+ unrecognized_keys = keys - Specification::ALL_SCRIPT_PHASE_KEYS
403
+ unless unrecognized_keys.empty?
404
+ results.add_error('script_phases', "Unrecognized options `#{unrecognized_keys}` in script phase `#{script_phase[:name]}`. " \
405
+ "Available options are `#{Specification::ALL_SCRIPT_PHASE_KEYS}`.")
406
+ end
407
+ missing_required_keys = Specification::SCRIPT_PHASE_REQUIRED_KEYS - keys
408
+ unless missing_required_keys.empty?
409
+ results.add_error('script_phases', "Missing required shell script phase options `#{missing_required_keys.join(', ')}` in script phase `#{script_phase[:name]}`.")
410
+ end
411
+ unless Specification::EXECUTION_POSITION_KEYS.include?(script_phase[:execution_position])
412
+ results.add_error('script_phases', "Invalid execution position value `#{script_phase[:execution_position]}` in shell script `#{script_phase[:name]}`. " \
413
+ "Available options are `#{Specification::EXECUTION_POSITION_KEYS}`.")
414
+ end
415
+ end
416
+ end
417
+
397
418
  # Performs validations related to github sources.
398
419
  #
399
420
  def perform_github_source_checks(s)
@@ -92,7 +92,7 @@ module Pod
92
92
  if license.is_a?(String)
93
93
  { :type => license }
94
94
  elsif license.is_a?(Hash)
95
- license = convert_keys_to_symbol(license)
95
+ license = Specification.convert_keys_to_symbol(license)
96
96
  license[:text] = license[:text].strip_heredoc if license[:text]
97
97
  license
98
98
  else
@@ -110,7 +110,7 @@ module Pod
110
110
  # should be retrieved.
111
111
  #
112
112
  def source
113
- convert_keys_to_symbol(attributes_hash['source'])
113
+ Specification.convert_keys_to_symbol(attributes_hash['source'])
114
114
  end
115
115
 
116
116
  # @return [String] A short description of the Pod.
@@ -187,27 +187,6 @@ module Pod
187
187
  end
188
188
 
189
189
  #---------------------------------------------------------------------#
190
-
191
- private
192
-
193
- # Converts the keys of the given hash to a string.
194
- #
195
- # @param [Object] value
196
- # the value that needs to be stripped from the Symbols.
197
- #
198
- # @return [Hash] the hash with the strings instead of the keys.
199
- #
200
- def convert_keys_to_symbol(value)
201
- return unless value
202
- result = {}
203
- value.each do |key, subvalue|
204
- subvalue = convert_keys_to_symbol(subvalue) if subvalue.is_a?(Hash)
205
- result[key.to_sym] = subvalue
206
- end
207
- result
208
- end
209
-
210
- #---------------------------------------------------------------------#
211
190
  end
212
191
  end
213
192
  end
@@ -30,7 +30,7 @@ module Pod
30
30
  # the sources that contain a Pod.
31
31
  #
32
32
  def initialize(name, sources = [])
33
- @name = name
33
+ @name = name
34
34
  @sources = Array(sources)
35
35
  end
36
36
 
@@ -50,6 +50,12 @@ module Pod
50
50
  Specification.from_file(highest_version_spec_path)
51
51
  end
52
52
 
53
+ # @return [Specification] the top level specification for this set for any version.
54
+ #
55
+ def specification_name
56
+ Specification.from_file(specification_paths_for_version(any_version).first).name
57
+ end
58
+
53
59
  # @return [Array<String>] the paths to specifications for the given
54
60
  # version
55
61
  #
@@ -78,18 +84,16 @@ module Pod
78
84
  # is used to disambiguate.
79
85
  #
80
86
  def highest_version_spec_path
81
- specification_paths_for_version(highest_version).first
87
+ @highest_version_spec_path ||= specification_paths_for_version(highest_version).first
82
88
  end
83
89
 
84
90
  # @return [Hash{Source => Version}] all the available versions for the
85
91
  # Pod grouped by source.
86
92
  #
87
93
  def versions_by_source
88
- result = {}
89
- sources.each do |source|
94
+ @versions_by_source ||= sources.each_with_object({}) do |source, result|
90
95
  result[source] = source.versions(name)
91
96
  end
92
- result
93
97
  end
94
98
 
95
99
  def ==(other)
@@ -127,6 +131,14 @@ module Pod
127
131
  }
128
132
  end
129
133
 
134
+ private
135
+
136
+ # @return [Version] A version known for this specification.
137
+ #
138
+ def any_version
139
+ versions_by_source.values.flatten.uniq.first
140
+ end
141
+
130
142
  #-----------------------------------------------------------------------#
131
143
 
132
144
  # The Set::External class handles Pods from external sources. Pods from
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: 1.4.0.beta.1
4
+ version: 1.4.0.beta.2
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: 2017-09-24 00:00:00.000000000 Z
12
+ date: 2017-10-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport