Class: Pod::Command::Bin::Source::List

Inherits:
Pod::Command::Bin::Source show all
Defined in:
lib/cocoapods-meitu-bin/command/bin/source/list.rb

Constant Summary collapse

SPECIAL_DIRS =
%w[. .. .DS_Store].freeze

Instance Method Summary collapse

Methods inherited from Pod::Command::Bin::Source

#source_dir, #target_path

Methods included from CBin::SpecFilesHelper

#binary_spec, #binary_spec_files, #binary_template_spec, #binary_template_spec_file, #binary_template_spec_files, #clear_binary_spec_file_if_needed, #code_spec, #code_spec_files, #create_binary_spec_file, #find_spec_file, #spec_files

Methods included from CBin::SourcesHelper

#binary_source, #code_source_list, #sources_manager, #sources_option, #valid_sources

Constructor Details

#initialize(argv) ⇒ List

Returns a new instance of List.



19
20
21
22
# File 'lib/cocoapods-meitu-bin/command/bin/source/list.rb', line 19

def initialize(argv)
  @names = argv.shift_argument
  super
end

Instance Method Details

#runObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/cocoapods-meitu-bin/command/bin/source/list.rb', line 24

def run
  entries = Dir.entries(source_dir).reject { |dir| SPECIAL_DIRS.include?(dir) }
  unless @names.nil?
    name_arr = @names.split(',').map(&:downcase)
    entries.select! { |entry| name_arr.include?(entry.downcase) }
  end
  if entries.empty?
    UI.puts "无对应的源码".red
    return
  end
  entries.map do |entry|
    UI.puts "#{entry}".green
    sub_dir = "#{source_dir}/#{entry}"
    sub_entries = Dir.entries(sub_dir).reject { |dir| SPECIAL_DIRS.include?(dir) }
    sub_entries.map { |sub_entry| UI.puts " - #{sub_entry}".yellow }
  end
end