Sha256: 370ae35ed2c4cbf73a1bb31e0d6f9b8938d8d28829729109178e3447cb294ed3
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 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 Pathname.new("Podfile") end def lockfile_path Pathname.new("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| Pathname.new(dir).join(filename) }.find(&:exist?) end def read_plist pathname JSON.parse(`plutil -convert json -o - '#{pathname.expand_path}'`) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
license_finder-2.0.0.rc2 | lib/license_finder/package_managers/cocoa_pods.rb |