Sha256: 054e7948892a50784aa7d6cef1c226b6fce9d4a6e38a2eda27f343e5abaa025a

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module LicenseFinder
  class Dependency < LicenseFinder::Persistence::Dependency
    def approved
      self.approved = !!(config.whitelisted?(license) || super)
    end

    def license_files
      super || (self.license_files = [])
    end

    def bundler_groups
      super || (self.bundler_groups = [])
    end

    def children
      super || (self.children = [])
    end

    def parents
      super || (self.parents = [])
    end

    def approve!
      self.approved = true
      save
    end

    def license_url
      LicenseFinder::LicenseUrl.find_by_name license
    end

    def merge(other)
      raise "Cannot merge dependencies with different names. Expected #{name}, was #{other.name}." unless other.name == name

      new_attributes = other.attributes.merge("notes" => notes)

      if other.license == license || other.license == 'other'
        new_attributes["approved"] = approved
        new_attributes["license"]  = license
      else
        new_attributes["approved"] = nil
      end

      update_attributes new_attributes

      self
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
license_finder-0.7.3 lib/license_finder/dependency.rb
license_finder-0.7.1 lib/license_finder/dependency.rb