Class: Pod::Target::Commands::Dependency
- Inherits:
-
Pod::Target::Command
- Object
- Pod::Target::Command
- Pod::Target::Commands::Dependency
- Defined in:
- lib/pod/target/commands/dependency.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(options) ⇒ Dependency
constructor
A new instance of Dependency.
- #parse ⇒ Object
Methods inherited from Pod::Target::Command
#command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which
Constructor Details
#initialize(options) ⇒ Dependency
Returns a new instance of Dependency.
13 14 15 |
# File 'lib/pod/target/commands/dependency.rb', line 13 def initialize() @options = end |
Instance Method Details
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/pod/target/commands/dependency.rb', line 17 def execute @xcworkspace = @options[:workspace] @xcworkspace ||= XCWorkspace.find_workspace @output = @options[:output] @output ||= '.' @filter = @options[:filter] @filter ||= '.*' parse end |
#parse ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/pod/target/commands/dependency.rb', line 27 def parse prompt = TTY::Prompt.new prompt.ok("Finding targets' dependencies and resolving them...") parser = Parser.new(@xcworkspace, @filter) targets = parser.all_targets graph = Pod::Target::Commands::Graph.new graph.add_target_info(targets) directory = File.join(File.dirname(@output + "/remove_dependency.csv"),"/remove_dependency.csv") File.open(directory, "w") { |f| f.write "" } nodes = graph.nodes nodes.each do |_, value| level_map = {} graph.dfs(value, level_map, 0) removes = [] value.neighbors.each do |neighbor| if level_map[neighbor.name] > 1 removes << neighbor.name end end if removes.size > 0 File.open(directory, "a") { |f| f.write value.name } removes.each { |name| File.open(directory, "a") { |f| f.write "," + name } } File.open(directory, "a") { |f| f.write "\n" } end end prompt.ok("File is write at: " + directory) end |