Class: Pod::Command::Bin::Lock::Dependency
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Pod
match_version?
#analyze
#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
#binary_source, #code_source_list, #sources_manager, #sources_option, #valid_sources
Constructor Details
Returns a new instance of Dependency.
24
25
26
27
28
|
# File 'lib/cocoapods-mtxx-bin/command/bin/lock/dependency.rb', line 24
def initialize(argv)
super
@pod_name = argv.shift_argument
@reverse = argv.flag?('reverse', false)
end
|
Class Method Details
.options ⇒ Object
18
19
20
21
22
|
# File 'lib/cocoapods-mtxx-bin/command/bin/lock/dependency.rb', line 18
def self.options
[
%w[--reverse 分析依赖`POD_NAME`的库]
].concat(super).uniq
end
|
Instance Method Details
#dependencies ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/cocoapods-mtxx-bin/command/bin/lock/dependency.rb', line 40
def dependencies
deps = []
@analyze_result.specifications.map do |spec|
if spec.name == @pod_name
deps.concat(spec.all_dependencies)
end
end
deps.uniq!
UI.puts "\n"
if deps.empty?
UI.puts "`#{@pod_name}`无依赖的库".red
else
UI.puts "`#{@pod_name}`依赖的库如下:".yellow
deps.map { |dep| UI.puts "- #{dep}" }
UI.puts "total #{deps.size} deps".green
end
end
|
#reverse_dependencies ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/cocoapods-mtxx-bin/command/bin/lock/dependency.rb', line 58
def reverse_dependencies
pods = []
@analyze_result.specifications.map do |spec|
spec.all_dependencies.map do |dep|
if dep.name == @pod_name
pods << spec
break
end
end
end
pods.uniq!
UI.puts "\n"
if pods.empty?
UI.puts "没有依赖`#{@pod_name}`的库".red
else
UI.puts "依赖`#{@pod_name}`的库如下:".yellow
pods.map { |dep| UI.puts "- #{dep}" }
UI.puts "total #{pods.size} pods".green
end
end
|
#run ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/cocoapods-mtxx-bin/command/bin/lock/dependency.rb', line 30
def run
super
raise Informative, "请输入Pod库名称,如:AFNetworking" if @pod_name.nil?
if @reverse
reverse_dependencies
else
dependencies
end
end
|