Class: LicenseScout::DependencyManager::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/license_scout/dependency_manager/base.rb

Direct Known Subclasses

Berkshelf, Bundler, Cargo, Cpanm, Dep, Glide, Godep, Gomod, Habitat, Mix, Npm, Rebar

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directory) ⇒ Base

Returns a new instance of Base.

Parameters:

  • directory (String)

    The fully-qualified path to the directory to be inspected


42
43
44
45
# File 'lib/license_scout/dependency_manager/base.rb', line 42

def initialize(directory)
  @directory = directory
  @deps = nil
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.


39
40
41
# File 'lib/license_scout/dependency_manager/base.rb', line 39

def directory
  @directory
end

Instance Method Details

#dependenciesArray<LicenseScout::Dependency>

Implementation's of this method in sub-classes are the methods that are responsible for all the heavy-lifting when it comes to determining the dependencies (and their licenses). They should return an array of `LicenseScout::Dependency`.

Returns:


97
98
99
# File 'lib/license_scout/dependency_manager/base.rb', line 97

def dependencies
  []
end

#detected?Boolean

Whether or not we were able to detect that this dependency manager is currently in use in our directory

Returns:

  • (Boolean)

Raises:


81
82
83
# File 'lib/license_scout/dependency_manager/base.rb', line 81

def detected?
  raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#detected?` method")
end

#install_commandString

The command to run to install dependency if one or more is missing

Returns:

  • (String)

Raises:


88
89
90
# File 'lib/license_scout/dependency_manager/base.rb', line 88

def install_command
  raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#install_command` method")
end

#nameString

The unique name of this Dependency Manager. In general, the name should follow the `<TYPE>_<NAME` pattern where:

* <TYPE> is the value of DependencyManager#type
* <NAME> is the name of the dependency manager.

Examples:

Go's various package managers

Name        Reference
--------    -----------------------------------------------
go_mod      [`gomod`](https://golang.org/cmd/go/#hdr-The_go_mod_file)
go_dep      [`godep`](https://github.com/tools/godep)
go_godep    [`dep`](https://github.com/golang/dep)
go_glide    [`glide`](https://github.com/Masterminds/glide)

Returns:

  • (String)

Raises:


60
61
62
# File 'lib/license_scout/dependency_manager/base.rb', line 60

def name
  raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#name` method")
end

#signatureString

A human-readable description of the files/folders that indicate this dependency manager is in use.

Returns:

  • (String)

Raises:


74
75
76
# File 'lib/license_scout/dependency_manager/base.rb', line 74

def signature
  raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#signature` method")
end

#typeString

The “type” of dependencies this manager manages. This can be the language, tool, etc.

Returns:

  • (String)

Raises:


67
68
69
# File 'lib/license_scout/dependency_manager/base.rb', line 67

def type
  raise LicenseScout::Exceptions::Error.new("All DependencyManagers must have a `#type` method")
end