Class: Pod::Command::Dependencies
- Inherits:
-
Pod::Command
- Object
- Pod::Command
- Pod::Command::Dependencies
- Includes:
- Options::ProjectDirectory
- Defined in:
- lib/cocoapods_dependencies_list/pod/command/dependencies.rb
Overview
A cocoapods plugin command ‘pod project dependencies` that outputs project dependency metadata
Constant Summary collapse
- DEFAULT_FIELDS =
%w{name version summary homepage license}
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#include_path ⇒ Object
(also: #include_path?)
readonly
Returns the value of attribute include_path.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Dependencies
constructor
A new instance of Dependencies.
- #requested_fields_from_spec(spec) ⇒ Object
- #run ⇒ Object
- #specs_by_target ⇒ Object
Constructor Details
#initialize(argv) ⇒ Dependencies
Returns a new instance of Dependencies.
30 31 32 33 34 35 36 37 |
# File 'lib/cocoapods_dependencies_list/pod/command/dependencies.rb', line 30 def initialize(argv) @targets = argv.option("targets", "").split(",").map(&:strip) @fields = argv.option("fields", "").split(",").map(&:strip) @fields = DEFAULT_FIELDS if !@fields.any? @include_path = argv.flag?("include-path", false) super end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
27 28 29 |
# File 'lib/cocoapods_dependencies_list/pod/command/dependencies.rb', line 27 def fields @fields end |
#include_path ⇒ Object (readonly) Also known as: include_path?
Returns the value of attribute include_path.
27 28 29 |
# File 'lib/cocoapods_dependencies_list/pod/command/dependencies.rb', line 27 def include_path @include_path end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
27 28 29 |
# File 'lib/cocoapods_dependencies_list/pod/command/dependencies.rb', line 27 def targets @targets end |
Class Method Details
.options ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/cocoapods_dependencies_list/pod/command/dependencies.rb', line 19 def self. [ ["--targets", "A comma-delimited list of podfile targets"], ["--fields", "A comma-delimited list of podspec fields to include"], ["--include-path", "Include the pod installation path in the installation sandbox"] ].concat(super) end |
Instance Method Details
#requested_fields_from_spec(spec) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/cocoapods_dependencies_list/pod/command/dependencies.rb', line 64 def requested_fields_from_spec(spec) @fields.reduce({}) do |accum, field| field = field.to_sym accum[field] = spec.respond_to?(field) ? spec.send(field) : nil accum end end |
#run ⇒ Object
39 40 41 42 43 44 |
# File 'lib/cocoapods_dependencies_list/pod/command/dependencies.rb', line 39 def run verify_podfile_exists! require "json" UI.puts specs_by_target.to_json end |
#specs_by_target ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/cocoapods_dependencies_list/pod/command/dependencies.rb', line 46 def specs_by_target analyzer = Installer::Analyzer.new(config.sandbox, config.podfile, config.lockfile) specs_by_target = config.with_changes(silent: true) { analyzer.analyze(false).specs_by_target } if @targets.any? specs_by_target = specs_by_target.select { |target, _| @targets.include? target.label } end specs_by_target.each do |target, specs| specs.map! do |spec| fields = requested_fields_from_spec(spec) fields[:path] = config.sandbox.pod_dir(spec.name).to_s if include_path? fields end end end |