Module: Pod::Specification::JSONSupport

Included in:
Pod::Specification
Defined in:
lib/cocoapods-core/specification/json.rb

Instance Method Summary collapse

Instance Method Details

#to_hashHash



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cocoapods-core/specification/json.rb', line 23

def to_hash
  hash = attributes_hash.dup
  if root? || available_platforms != parent.available_platforms
    platforms = Hash[available_platforms.map { |p| [p.name.to_s, p.deployment_target && p.deployment_target.to_s] }]
    hash['platforms'] = platforms
  end
  all_testspecs, all_subspecs = subspecs.partition(&:test_specification?)
  unless all_testspecs.empty?
    hash['testspecs'] = all_testspecs.map(&:to_hash)
  end
  unless all_subspecs.empty?
    hash['subspecs'] = all_subspecs.map(&:to_hash)
  end
  hash
end

#to_json(*a) ⇒ String



6
7
8
9
# File 'lib/cocoapods-core/specification/json.rb', line 6

def to_json(*a)
  require 'json'
  to_hash.to_json(*a) << "\n"
end

#to_pretty_json(*a) ⇒ String



13
14
15
16
# File 'lib/cocoapods-core/specification/json.rb', line 13

def to_pretty_json(*a)
  require 'json'
  JSON.pretty_generate(to_hash, *a) << "\n"
end