Class: Pod::Command::Spec::Cat

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, verify_git_version!

Methods included from Pod::Config::Mixin

#config

Constructor Details

#initialize(argv) ⇒ Cat

Returns a new instance of Cat.



202
203
204
205
206
207
# File 'lib/cocoapods/command/spec.rb', line 202

def initialize(argv)
  @show_all = argv.flag?('show-all')
  @spec = argv.shift_argument
  @spec = @spec.gsub('.podspec', '') unless @spec.nil?
  super
end

Class Method Details

.optionsObject



198
199
200
# File 'lib/cocoapods/command/spec.rb', line 198

def self.options
  [['--show-all', 'Pick from all versions of the given podspec']].concat(super)
end

Instance Method Details

#runObject



214
215
216
217
218
219
220
221
222
223
224
# File 'lib/cocoapods/command/spec.rb', line 214

def run
  filepath = if @show_all
               specs = get_path_of_spec(@spec, @show_all).split(/\n/)
               index = choose_from_array(specs, "Which spec would you like to print [1-#{ specs.count }]? ")
               specs[index]
  else
    get_path_of_spec(@spec)
  end

  UI.puts File.read(filepath)
end

#validate!Object



209
210
211
212
# File 'lib/cocoapods/command/spec.rb', line 209

def validate!
  super
  help! 'A podspec name is required.' unless @spec
end