Class: Pod::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-force-static-framework/command/framework.rb

Class Method Summary collapse

Class Method Details

.from_string(spec_contents, path, subspec_name = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cocoapods-force-static-framework/command/framework.rb', line 14

def self.from_string(spec_contents, path, subspec_name = nil)
  name = ''
  path = Pathname.new(path).expand_path
  spec = nil
  case path.extname
  when '.podspec'
    name = File.basename(path, '.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'
    name = File.basename(path, '.podspec.json')
    spec = Specification.from_json(spec_contents)
  else
    raise Informative, "Unsupported specification format `#{path.extname}` for spec at `#{path}`."
  end
  if Pod.static_framework_names.include?(name)
    spec.static_framework = true
  end
  spec.defined_in_file = path
  spec.subspec_by_name(subspec_name, true)
end