Class: Pod::Command::Lib::Lint

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

Overview

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pod::Command

#ensure_master_spec_repo_exists!, report_error, run

Methods included from Pod::Config::Mixin

#config

Constructor Details

#initialize(argv) ⇒ Lint

Returns a new instance of Lint.



130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/cocoapods/command/lib.rb', line 130

def initialize(argv)
  @quick           = argv.flag?('quick')
  @allow_warnings  = argv.flag?('allow-warnings')
  @clean           = argv.flag?('clean', true)
  @fail_fast       = argv.flag?('fail-fast', false)
  @subspecs        = argv.flag?('subspecs', true)
  @only_subspec    = argv.option('subspec')
  @use_frameworks  = !argv.flag?('use-libraries')
  @source_urls     = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
  @podspecs_paths  = argv.arguments!
  super
end

Class Method Details

.optionsObject



117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/cocoapods/command/lib.rb', line 117

def self.options
  [['--quick',       'Lint skips checks that would require to download and build the spec'],
   ['--allow-warnings', 'Lint validates even if warnings are present'],
   ['--subspec=NAME', 'Lint validates only the given subspec'],
   ['--no-subspecs', 'Lint skips validation of subspecs'],
   ['--no-clean', 'Lint leaves the build directory intact for inspection'],
   ['--fail-fast', 'Lint stops on the first failing platform or subspec'],
   ['--use-libraries', 'Lint uses static libraries to install the spec'],
   ['--sources=https://github.com/artsy/Specs,master', 'The sources from which to pull dependant pods ' \
    '(defaults to https://github.com/CocoaPods/Specs.git). '\
    'Multiple sources must be comma-delimited.']].concat(super)
end

Instance Method Details

#runObject



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/cocoapods/command/lib.rb', line 147

def run
  UI.puts
  podspecs_to_lint.each do |podspec|
    validator                = Validator.new(podspec, @source_urls)
    validator.local          = true
    validator.quick          = @quick
    validator.no_clean       = !@clean
    validator.fail_fast      = @fail_fast
    validator.allow_warnings = @allow_warnings
    validator.no_subspecs    = !@subspecs || @only_subspec
    validator.only_subspec   = @only_subspec
    validator.use_frameworks = @use_frameworks
    validator.validate

    unless @clean
      UI.puts "Pods project available at `#{validator.validation_dir}/Pods/Pods.xcodeproj` for inspection."
      UI.puts
    end
    if validator.validated?
      UI.puts "#{validator.spec.name} passed validation.".green
    else
      spec_name = podspec
      spec_name = validator.spec.name if validator.spec
      message = "#{spec_name} did not pass validation, due to #{validator.failure_reason}."

      if @clean
        message << "\nYou can use the `--no-clean` option to inspect " \
          'any issue.'
      end
      raise Informative, message
    end
  end
end

#validate!Object



143
144
145
# File 'lib/cocoapods/command/lib.rb', line 143

def validate!
  super
end