class Pod::Command::Search

@CocoaPods 0.0.2

Public Class Methods

new(argv) click to toggle source
Calls superclass method
# File lib/cocoapods-search/command/search.rb, line 31
def initialize(argv)
  @use_regex = argv.flag?('regex')
  @simple_search = argv.flag?('simple')
  @stats = argv.flag?('stats')
  @web = argv.flag?('web')
  @platform_filters = Platform.all.map do |platform|
    argv.flag?(platform.name.to_s) ? platform.to_sym : nil
  end.compact
  @query = argv.arguments! unless argv.arguments.empty?
  config.silent = false
  @use_pager = argv.flag?('pager', true)
  super
end
options() click to toggle source
Calls superclass method
# File lib/cocoapods-search/command/search.rb, line 17
def self.options
  options = [
    ['--regex',   'Interpret the `QUERY` as a regular expression'],
    ['--simple',    'Search only by name'],
    ['--stats',   'Show additional stats (like GitHub watchers and forks)'],
    ['--web',     'Searches on cocoapods.org'],
  ]
  options += Platform.all.map do |platform|
    ["--#{platform.name.to_s}",     "Restricts the search to Pods supported on #{Platform.string_name(platform.to_sym)}"]
  end
  options << ['--no-pager',    'Do not pipe search results into a pager']
  options.concat(super.reject { |option, _| option == '--silent' })
end

Public Instance Methods

print_sets(sets) click to toggle source
run() click to toggle source
# File lib/cocoapods-search/command/search.rb, line 58
def run
  ensure_master_spec_repo_exists!
  if @web
    web_search
  else
    local_search
  end
end
sources_manager() click to toggle source
# File lib/cocoapods-search/command/search.rb, line 67
def sources_manager
  defined?(Pod::SourcesManager) ? Pod::SourcesManager : config.sources_manager
end
validate!() click to toggle source
Calls superclass method
# File lib/cocoapods-search/command/search.rb, line 45
def validate!
  super
  help! 'A search query is required.' unless @query

  unless @web || !@use_regex
    begin
      /#{@query.join(' ').strip}/
    rescue RegexpError
      help! 'A valid regular expression is required.'
    end
  end
end