class Package
Describes how one installed Node.js package is exposed as static files.
Definitions
def initialize(name, options = {})
Initialize a package selection.
Signature
-
parameter
nameString The npm package name, including an optional scope.
-
parameter
optionsHash The package's source, include patterns and import mappings.
-
raises
ConfigurationError If the package name or options are invalid.
Implementation
def initialize(name, options = {})
unless name.is_a?(String) && NAME_PATTERN.match?(name)
raise ConfigurationError, "Invalid package name: #{name.inspect}!"
end
unless options.is_a?(Hash)
raise ConfigurationError, "Configuration for #{name} must be an object!"
end
@name = name
@source = options["source"]
@include_patterns = options["include"]
@imports = options.fetch("imports", {})
validate
end
attr :name
Signature
-
attribute
String The npm package name.
attr :source
Signature
-
attribute
String | Nil The configured package-relative source directory.
attr :include_patterns
Signature
-
attribute
Array(String) | Nil The package-relative file patterns to include.
attr :imports
Signature
-
attribute
Hash(String, String) The import specifiers exposed by the package.