Class: Pod::Command::Spec::Lint

Inherits:
Pod::Command::Spec show all
Defined in:
lib/cocoapods/command/spec.rb

Overview

———————————————————————–#

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pod::Command

parse, report_error, run

Methods included from Pod::Config::Mixin

#config

Constructor Details

#initialize(argv) ⇒ Lint

Returns a new instance of Lint.



77
78
79
80
81
82
83
84
# File 'lib/cocoapods/command/spec.rb', line 77

def initialize(argv)
  @quick       =  argv.flag?('quick')
  @local       =  argv.flag?('local')
  @only_errors =  argv.flag?('only-errors')
  @clean       =  argv.flag?('clean', true)
  @podspecs_paths = argv.arguments!
  super
end

Class Method Details

.optionsObject



70
71
72
73
74
75
# File 'lib/cocoapods/command/spec.rb', line 70

def self.options
  [ ["--quick",       "Lint skips checks that would require to download and build the spec"],
    ["--local",       "Lint a podspec against the local files contained in its directory"],
    ["--only-errors", "Lint validates even if warnings are present"],
    ["--no-clean",    "Lint leaves the build directory intact for inspection"] ].concat(super)
end

Instance Method Details

#runObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/cocoapods/command/spec.rb', line 86

def run
  UI.puts
  invalid_count = 0
  podspecs_to_lint.each do |podspec|
    validator             = Validator.new(podspec)
    validator.quick       = @quick
    validator.local       = @local
    validator.no_clean    = !@clean
    validator.only_errors = @only_errors
    validator.validate
    invalid_count += 1 unless validator.validated?

    unless @clean
      UI.puts "Pods project available at `#{validator.validation_dir}/Pods/Pods.xcodeproj` for inspection."
      UI.puts
    end
  end

  count = podspecs_to_lint.count
  UI.puts "Analyzed #{count} #{'podspec'.pluralize(count)}.\n\n"
  if invalid_count == 0
    lint_passed_message = count == 1 ? "#{podspecs_to_lint.first.basename} passed validation." : "All the specs passed validation."
    UI.puts lint_passed_message.green << "\n\n"
  else
    raise Informative, count == 1 ? "The spec did not pass validation." : "#{invalid_count} out of #{count} specs failed validation."
  end
  podspecs_tmp_dir.rmtree if podspecs_tmp_dir.exist?
end