Sha256: 110709a61bad1dc6b521769b6220d5ec4c4d3dbba5fe658f54e4b2de3c84ccab

Contents?: true

Size: 873 Bytes

Versions: 4

Compression:

Stored size: 873 Bytes

Contents

module LicenseFinder
  class Dependency < Sequel::Model
    many_to_one :license, class: LicenseAlias
    many_to_one :approval
    many_to_many :children, join_table: :ancestries, left_key: :parent_dependency_id, right_key: :child_dependency_id, class: self
    many_to_many :parents, join_table: :ancestries, left_key: :child_dependency_id, right_key: :parent_dependency_id, class: self
    many_to_many :bundler_groups

    def self.destroy_obsolete(current_dependencies)
      exclude(id: current_dependencies.map(&:id)).each(&:destroy)
    end

    def self.unapproved
      all.reject(&:approved?)
    end

    def approve!
      approval.state = true
      approval.save
    end

    def approved?
      (license && license.whitelisted?) || (approval && approval.state)
    end

    def set_license_manually(name)
      license.set_manually(name)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
license_finder-0.8.1-java lib/license_finder/tables/dependency.rb
license_finder-0.8.1 lib/license_finder/tables/dependency.rb
license_finder-0.8.0-java lib/license_finder/tables/dependency.rb
license_finder-0.8.0 lib/license_finder/tables/dependency.rb