Class: Pod::Command::Bin::Lock::Version

Inherits:
Pod::Command::Bin::Lock show all
Includes:
Pod
Defined in:
lib/cocoapods-meitu-bin/command/bin/lock/version.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Pod

match_version?

Methods inherited from Pod::Command::Bin::Lock

#analyze

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) ⇒ Version

Returns a new instance of Version.



21
22
23
24
25
# File 'lib/cocoapods-meitu-bin/command/bin/lock/version.rb', line 21

def initialize(argv)
  super
  @pod_name = argv.shift_argument
  @source = argv.flag?('source', false)
end

Class Method Details

.optionsObject



15
16
17
18
19
# File 'lib/cocoapods-meitu-bin/command/bin/lock/version.rb', line 15

def self.options
  [
    %w[--source 查看二进制对应源码版本]
  ].concat(super).uniq
end

Instance Method Details

#runObject

Raises:

  • (Informative)


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/cocoapods-meitu-bin/command/bin/lock/version.rb', line 27

def run
  super
  raise Informative, "请输入Pod库名称,如:AFNetworking" if @pod_name.nil?
  versions = []
  @analyze_result.specifications.map do |spec|
    if spec.name == @pod_name
      versions << spec.version
    end
  end
  versions = versions.uniq
  UI.puts "\n"
  raise Informative, "未查找到`#{@pod_name}`的版本号,请检查`#{@pod_name}`是否拼写错误" if versions.empty?
  UI.puts "`#{@pod_name}`版本号如下:".yellow
  versions.map do |v|
    if @source
      UI.puts "- #{get_source_version(v.to_s)}"
    else
      UI.puts "- #{v}"
    end
  end

  UI.puts "[!] `#{@pod_name}`有`#{versions.size}`个版本,可能会导致意想不到的事情,请确保每个Pod库只有一个依赖版本".yellow if versions.size > 1
end