class Pod::Command::Dependencies
Public Class Methods
arguments()
click to toggle source
Calls superclass method
# File lib/pod/command/dependencies.rb, line 22 def self.arguments [ CLAide::Argument.new('PODSPEC', false) ].concat(super) end
new(argv)
click to toggle source
Calls superclass method
# File lib/pod/command/dependencies.rb, line 28 def initialize(argv) @podspec_name = argv.shift_argument @ignore_lockfile = argv.flag?('ignore-lockfile', false) @repo_update = argv.flag?('repo-update', false) @produce_graphviz_output = argv.flag?('graphviz', false) @produce_image_output = argv.flag?('image', false) @use_podfile_targets = argv.flag?('use-podfile-targets', false) super end
options()
click to toggle source
Calls superclass method
# File lib/pod/command/dependencies.rb, line 12 def self.options [ ['--ignore-lockfile', 'Whether the lockfile should be ignored when calculating the dependency graph'], ['--repo-update', 'Fetch external podspecs and run `pod repo update` before calculating the dependency graph'], ['--graphviz', 'Outputs the dependency graph in Graphviz format to <podspec name>.gv or Podfile.gv'], ['--image', 'Outputs the dependency graph as an image to <podspec name>.png or Podfile.png'], ['--use-podfile-targets', 'Uses targets from the Podfile'], ].concat(super) end
Public Instance Methods
dependencies()
click to toggle source
# File lib/pod/command/dependencies.rb, line 71 def dependencies @dependencies ||= begin lockfile = config.lockfile unless @ignore_lockfile || @podspec if !lockfile || @repo_update analyzer = Installer::Analyzer.new( sandbox, podfile, lockfile ) specs = config.with_changes(skip_repo_update: !@repo_update) do analyzer.analyze(@repo_update || @podspec).specs_by_target.values.flatten(1) end lockfile = Lockfile.generate(podfile, specs, {}) end lockfile.to_hash['PODS'] end end
graphviz_data()
click to toggle source
# File lib/pod/command/dependencies.rb, line 123 def graphviz_data @graphviz ||= begin require 'graphviz' graph = GraphViz::new(output_file_basename, :type => :digraph) if @use_podfile_targets unless @podspec podfile.target_definitions.values.each do |target| target_node = graph.add_node(target.name.to_s) if target.dependencies target.dependencies.each do |dependency| pod_node = graph.add_node(dependency.name.to_s) graph.add_edge(target_node, pod_node) end end end end else root = graph.add_node(output_file_basename) unless @podspec podfile_dependencies.each do |pod| pod_node = graph.add_node(pod) graph.add_edge(root, pod_node) end end end pod_to_dependencies.each do |pod, dependencies| pod_node = graph.add_node(sanitized_pod_name(pod)) dependencies.each do |dependency| dep_node = graph.add_node(sanitized_pod_name(dependency)) graph.add_edge(pod_node, dep_node) end end graph end end
graphviz_dot_output()
click to toggle source
# File lib/pod/command/dependencies.rb, line 193 def graphviz_dot_output graphviz_data.output( :dot => "#{output_file_basename}.gv") end
graphviz_image_output()
click to toggle source
# File lib/pod/command/dependencies.rb, line 189 def graphviz_image_output graphviz_data.output( :png => "#{output_file_basename}.png") end
output_file_basename()
click to toggle source
Basename to use for output files.
# File lib/pod/command/dependencies.rb, line 178 def output_file_basename return 'Podfile' unless @podspec_name File.basename(@podspec_name, File.extname(@podspec_name)) end
pod_to_dependencies()
click to toggle source
Returns a [String: [String]] containing resolved mappings from the name of a pod to an array of the names of its dependencies.
# File lib/pod/command/dependencies.rb, line 173 def pod_to_dependencies dependencies.map { |d| d.is_a?(Hash) ? d : { d => [] } }.reduce({}) { |combined, individual| combined.merge!(individual) } end
podfile()
click to toggle source
# File lib/pod/command/dependencies.rb, line 93 def podfile @podfile ||= begin if podspec = @podspec platform = podspec.available_platforms.first platform_name = platform.name platform_version = platform.deployment_target.to_s source_urls = Config.instance.sources_manager.all.map(&:url).compact Podfile.new do install! 'cocoapods', integrate_targets: false, warn_for_multiple_pod_sources: false source_urls.each { |u| source(u) } platform platform_name, platform_version pod podspec.name, podspec: podspec.defined_in_file target 'Dependencies' end else verify_podfile_exists! config.podfile end end end
podfile_dependencies()
click to toggle source
Returns a Set of Strings of the names of dependencies specified in the Podfile.
# File lib/pod/command/dependencies.rb, line 168 def podfile_dependencies Set.new(podfile.target_definitions.values.map { |t| t.dependencies.map { |d| d.name } }.flatten) end
run()
click to toggle source
# File lib/pod/command/dependencies.rb, line 61 def run require 'yaml' UI.title "Calculating dependencies" do dependencies end graphviz_image_output if @produce_image_output graphviz_dot_output if @produce_graphviz_output yaml_output end
sandbox()
click to toggle source
# File lib/pod/command/dependencies.rb, line 114 def sandbox if @podspec require 'tmpdir' Sandbox.new(Dir.mktmpdir) else config.sandbox end end
sanitized_pod_name(name)
click to toggle source
Truncates the input string after a pod's name removing version requirements, etc.
# File lib/pod/command/dependencies.rb, line 163 def sanitized_pod_name(name) Pod::Dependency.from_string(name).name end
validate!()
click to toggle source
Calls superclass method
# File lib/pod/command/dependencies.rb, line 38 def validate! super if @podspec_name require 'pathname' path = Pathname.new(@podspec_name) if path.file? @podspec = Specification.from_file(path) else sets = Config. instance. sources_manager. search(Dependency.new(@podspec_name)) spec = sets && sets.specification @podspec = spec && spec.subspec_by_name(@podspec_name) raise Informative, "Cannot find `#{@podspec_name}`." unless @podspec end end if (@produce_image_output || @produce_graphviz_output) && Executable.which('dot').nil? raise Informative, 'GraphViz must be installed and `dot` must be in ' \ '$PATH to produce image or graphviz output.' end end
yaml_output()
click to toggle source
# File lib/pod/command/dependencies.rb, line 183 def yaml_output UI.title 'Dependencies' do UI.puts YAMLHelper.convert(dependencies) end end