Sha256: 2b93f6f2cb20fce291dbaf10035e161234db24b2ccf856e75dc07cb0a6d0c56f

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true
require 'license_finder'

module CocoaPodsGitlabLicenseReport
  class ReportGenerator
    def initialize(sandbox)
      @sandbox = sandbox
    end

    def generate(specs, excluded)

      dependencies = []
      licenses = {}

      specs.reject { |s| excluded.include? s.name }.each do |s|
        license_name =  s.license
        license_name = license_name[:type] if license_name.is_a?(Hash)
        license = LicenseFinder::License.find_by_name(license_name)

        dependencies << { :name => s.name,
                          :version => s.version.to_s || "0.0",
                          :package_manager => "cocoapods",
                          :path => @sandbox.manifest_path,
                          :licenses => [license_name] }

        licenses[license_name] = { :id => license_name,
                                   :name => license_name,
                                   :url => license.url || "" }
      end

      {
        :version => "2.1",
        :licenses => licenses.values.sort_by {|v| v[:id]},
        :dependencies => dependencies
      }

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cocoapods-gitlab_license_report-1.0.1 lib/cocoapods-gitlab_license_report/report_generator.rb
cocoapods-gitlab_license_report-1.0.0 lib/cocoapods-gitlab_license_report/report_generator.rb