class Pod::Command::Bin::Search
Public Class Methods
new(argv)
click to toggle source
Calls superclass method
Pod::Command::Bin::new
# File lib/cocoapods-miBin/command/bin/search.rb, line 22 def initialize(argv) @code = argv.flag?('code') @stats = argv.flag?('stats') @use_pager = argv.flag?('pager', true) @use_regex = argv.flag?('regex') @query = argv.arguments! unless argv.arguments.empty? super end
options()
click to toggle source
# File lib/cocoapods-miBin/command/bin/search.rb, line 13 def self.options [ ['--code', '查找源码 spec'], ['--stats', '展示额外信息'], ['--no-pager', '不以 pager 形式展示'], ['--regex', '`QUERY` 视为正则'] ] end
Public Instance Methods
print_sets(sets)
click to toggle source
# File lib/cocoapods-miBin/command/bin/search.rb, line 53 def print_sets(sets) sets.each do |set| begin if @stats UI.pod(set, :stats) else UI.pod(set, :normal) end rescue DSLError UI.warn "Skipping `#{set.name}` because the podspec contains errors." end end end
run()
click to toggle source
# File lib/cocoapods-miBin/command/bin/search.rb, line 36 def run query_regex = @query.reduce([]) do |result, q| result << (@use_regex ? q : Regexp.escape(q)) end.join(' ').strip source = @code ? code_source : binary_source aggregate = Pod::Source::Aggregate.new([source]) sets = aggregate.search_by_name(query_regex, true) if @use_pager UI.with_pager { print_sets(sets) } else print_sets(sets) end end
validate!()
click to toggle source
Calls superclass method
Pod::Command::Bin#validate!
# File lib/cocoapods-miBin/command/bin/search.rb, line 31 def validate! super help! '必须指定查找的组件.' unless @query end