Class: Dependency::Graph

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods_dependency_graph.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#output_class_hashObject

Returns the value of attribute output_class_hash.



35
36
37
# File 'lib/cocoapods_dependency_graph.rb', line 35

def output_class_hash
  @output_class_hash
end

Instance Method Details

#generate(umbrella_targets) ⇒ Object

Parameters:

  • The (Array<UmbrellaTargetDescription>)

    list of the CocoaPods umbrella targets generated by the installer.



48
49
50
51
52
53
54
55
56
57
# File 'lib/cocoapods_dependency_graph.rb', line 48

def generate(umbrella_targets)
  unless umbrella_targets.length() > 0
    puts "No target detected"
  end
  
  umbrella_targets.each { |target| 
    next if target.cocoapods_target_label.end_with?("Tests")
    generate_graph_for_target(target)
  }
end

#generate_graph_for_target(umbrella_target) ⇒ Object

Parameters:

  • umbrella_target (UmbrellaTargetDescription)


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/cocoapods_dependency_graph.rb', line 60

def generate_graph_for_target(umbrella_target)
  module_spec_hash = {}
  umbrella_target.specs.each { | spec |
    module_spec_hash[spec.name] = spec
  } 
  
  init_output_hash
  output_key = Pod::Podfile::DSL.dependency_output_format
  output_key = Output::GRAPH unless output_key

  generator_string = @output_class_hash[output_key]

  unless generator_string 
    puts "The dependency_output should be one of #{Output::GRAPH}, #{Output::JSON}, and #{Output::EXCEL}"
    return 
  end

  generator_class = Object.const_get(generator_string)
  generator_class.new.generate(umbrella_target,module_spec_hash)
end

#init_output_hashObject



37
38
39
40
41
42
43
# File 'lib/cocoapods_dependency_graph.rb', line 37

def init_output_hash
  @output_class_hash = {
    :graph => 'Dependency::GraphGenerator', 
    :json => 'Dependency::JsonGenerator', 
    :excel => 'Dependency::ExcelGenerator'
  }
end