class Pod::Specification
Public Class Methods
from_file(path, subspec_name = nil)
click to toggle source
# File lib/cocoapods-pdk8/hook/specification.rb, line 11 def self.from_file(path, subspec_name = nil) path = Pathname.new(path) unless path.exist? raise Informative, "No podspec exists at path `#{path}`." end return $SPECIFICATION_HASH_CACHE[path.expand_path] if $SPECIFICATION_HASH_CACHE[path.expand_path] string = File.open(path, 'r:utf-8', &:read) # Work around for Rubinius incomplete encoding in 1.9 mode if string.respond_to?(:encoding) && string.encoding.name != 'UTF-8' string.encode!('UTF-8') end specification = from_string(string, path, subspec_name) $SPECIFICATION_HASH_CACHE[path.expand_path] = specification return specification end
from_string(spec_contents, path, subspec_name = nil)
click to toggle source
# File lib/cocoapods-pdk8/hook/specification.rb, line 30 def self.from_string(spec_contents, path, subspec_name = nil) path = Pathname.new(path).expand_path key = "#{path}" return $SPECIFICATION_FROM_STRING_HASH_CACHE[key] if $SPECIFICATION_FROM_STRING_HASH_CACHE[key] spec = nil case path.extname when '.podspec' Dir.chdir(path.parent.directory? ? path.parent : Dir.pwd) do spec = ::Pod._eval_podspec(spec_contents, path) unless spec.is_a?(Specification) raise Informative, "Invalid podspec file at path `#{path}`." end end when '.json' spec = Specification.from_json(spec_contents) else raise Informative, "Unsupported specification format `#{path.extname}` for spec at `#{path}`." end spec.defined_in_file = path spec.subspec_by_name(subspec_name, true) $SPECIFICATION_FROM_STRING_HASH_CACHE[key] = spec spec end