Module: Pod::Specification::JSONSupport

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

Instance Method Summary collapse

Instance Method Details

#safe_to_hash?Bool

Returns Whether the specification can be converted to a hash without loss of information.

Returns:

  • (Bool)

    Whether the specification can be converted to a hash without loss of information.



28
29
30
# File 'lib/cocoapods-core/specification/json.rb', line 28

def safe_to_hash?
  pre_install_callback.nil? && post_install_callback.nil?
end

#to_hashHash

Returns the hash representation of the specification including subspecs.

Returns:

  • (Hash)

    the hash representation of the specification including subspecs.



17
18
19
20
21
22
23
# File 'lib/cocoapods-core/specification/json.rb', line 17

def to_hash
  hash = attributes_hash.dup
  unless subspecs.empty?
    hash["subspecs"] = subspecs.map { |spec| spec.to_hash }
  end
  hash
end

#to_json(*a) ⇒ String

Returns the json representation of the specification.

Returns:

  • (String)

    the json representation of the specification.



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

def to_json(*a)
  require 'json'
  to_hash.to_json(*a)
end