Sha256: 8da1accf948d134fff3b38065d65db072da6a59482c2202ec25bd4daff8da756
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
require "json" module LicenseFinder class CocoaPods < PackageManager def current_packages podfile = YAML.load_file(lockfile_path) acknowledgements = read_plist(acknowledgements_path)["PreferenceSpecifiers"] podfile["PODS"].map do |pod| pod = pod.keys.first if pod.is_a?(Hash) pod_name, pod_version = pod.scan(/(.*)\s\((.*)\)/).flatten pod_acknowledgment = acknowledgements.detect { |hash| hash["Title"] == pod_name } || {} CocoaPodsPackage.new(pod_name, pod_version, pod_acknowledgment["FooterText"]) end end private def package_path project_path.join("Podfile") end def lockfile_path project_path.join("Podfile.lock") end def acknowledgements_path filename = 'Pods-acknowledgements.plist' directories = [ 'Pods', # cocoapods < 0.34 'Pods/Target Support Files/Pods' # cocoapods >= 0.34 ] directories.map { |dir| project_path.join(dir, filename) }.find(&:exist?) end def read_plist pathname JSON.parse(`plutil -convert json -o - '#{pathname.expand_path}'`) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
license_finder-2.0.1 | lib/license_finder/package_managers/cocoa_pods.rb |
license_finder-2.0.0 | lib/license_finder/package_managers/cocoa_pods.rb |