class PodBuilder::Info

Public Class Methods

generate_info() click to toggle source
# File lib/pod_builder/info.rb, line 5
def self.generate_info
  swift_version = PodBuilder::system_swift_version
  result = {}
  name = nil

  Dir.glob(PodBuilder::prebuiltpath("**/#{Configuration.prebuilt_info_filename}")).each do |json_path|         
    name, prebuilt_info = prebuilt_info(json_path)
    result[name] = prebuilt_info
  end

  return result
end

Private Class Methods

pod_name_from_entry(line) click to toggle source
# File lib/pod_builder/info.rb, line 20
def self.pod_name_from_entry(line)
  if (matches = line&.match(/pod '(.*?)'/)) && matches.size == 2
    pod_name = matches[1]
    
    return pod_name
  end

  return "unknown_podname"
end
prebuilt_info(path) click to toggle source
# File lib/pod_builder/info.rb, line 67
def self.prebuilt_info(path)
  unless File.exist?(path)
    return {}
  end

  data = JSON.load(File.read(path))
        
  result = {}
  if swift_version = data["swift_version"]
    result.merge!({ "swift_version": swift_version})
  end
  
  pod_version = version_info_from_entry(data["entry"])
  pod_name = pod_name_from_entry(data["entry"])

  result.merge!({ "version": pod_version })
  result.merge!({ "specs": (data["specs"] || []) })
  result.merge!({ "is_static": (data["is_static"] || false) })
  result.merge!({ "original_compile_path": (data["original_compile_path"] || "") })
  
  return pod_name, result
end
version_info_from_entry(line) click to toggle source
# File lib/pod_builder/info.rb, line 30
def self.version_info_from_entry(line)
  if (matches = line&.match(/pod '(.*)', '=(.*)'/)) && matches.size == 3
    pod_name = matches[1]
    tag = matches[2]
    
    return { "tag": tag }
  elsif (matches = line&.match(/pod '(.*)', :git => '(.*)', :commit => '(.*)'/)) && matches.size == 4
    pod_name = matches[1]
    repo = matches[2]
    hash = matches[3]
    
    return { "repo": repo, "hash": hash }
  elsif (matches = line&.match(/pod '(.*)', :git => '(.*)', :branch => '(.*)'/)) && matches.size == 4
    pod_name = matches[1]
    repo = matches[2]
    branch = matches[3]
    
    return { "repo": repo, "branch": branch }
  elsif (matches = line&.match(/pod '(.*)', :git => '(.*)', :tag => '(.*)'/)) && matches.size == 4
    pod_name = matches[1]
    repo = matches[2]
    tag = matches[3]
    
    return { "repo": repo, "tag": tag }
  elsif (matches = line&.match(/pod '(.*)', :path => '(.*)'/)) && matches.size == 3
    pod_name = matches[1]
    
    return { "repo": "local" }
  elsif (matches = line&.match(/pod '(.*)', :podspec => '(.*)'/)) && matches.size == 3
    pod_name = matches[1]
    
    return { "repo": "local" }
  else
    raise "\n\nFailed extracting version from line:\n#{line}\n\n".red
  end
end