Class: Dependency::JsonGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-dependency-graph/generator/json_generator.rb

Defined Under Namespace

Classes: SpecNode

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.module_spec_hashObject



16
17
18
# File 'lib/cocoapods-dependency-graph/generator/json_generator.rb', line 16

def self.module_spec_hash 
  @@module_spec_hash
end

Instance Method Details

#create_hash(target_name, specs) ⇒ Object

Parameters:

  • specs (Array<Specification>)

    a list specification



6
7
8
9
10
11
12
13
14
# File 'lib/cocoapods-dependency-graph/generator/json_generator.rb', line 6

def create_hash(target_name, specs)
  dependencies = Array.new
  specs.each { | spec |
    next unless spec.source
    dependencies << SpecNode.new(spec).to_hash
  }
  
  {:target_name => dependencies}
end

#generate(umbrella_target, module_spec_hash) ⇒ Object

Parameters:

  • umbrella_target (UmbrellaTargetDescription)

    the CocoaPods umbrella targets generated by the installer.

  • module_spec_hash (Hash{<String, Specification>})


23
24
25
26
27
28
29
30
31
# File 'lib/cocoapods-dependency-graph/generator/json_generator.rb', line 23

def generate(umbrella_target, module_spec_hash)
  @@module_spec_hash = module_spec_hash
  target_name = umbrella_target.cocoapods_target_label
  dependency_hash = create_hash(target_name, umbrella_target.specs)
  # puts dependency_hash.to_json
  File.open("cocoapods_dependency_json.json","w") do |f|
    f.write(dependency_hash.to_json)
  end
end