Sha256: cae8d10133b8d52219d6ee654e83358fe6d4fcb36083dd0ab0bcff99b427bf66

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

module LicenseFinder
  class Dependency < LicenseFinder::Persistence::Dependency
    def approved
      return super if super
      self.approved = config.whitelist.include?(license)
    end

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

    def readme_files
      super || (self.readme_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

1 entries across 1 versions & 1 rubygems

Version Path
license_finder-0.7.0 lib/license_finder/dependency.rb