Class: Packages::Npm::PackageFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/packages/npm/package_finder.rb

Instance Method Summary collapse

Constructor Details

#initialize(package_name, project: nil, namespace: nil, last_of_each_version: true) ⇒ PackageFinder

/!\ CAUTION: don't use last_of_each_version: false with find_by_version. Ordering is not guaranteed!


10
11
12
13
14
15
# File 'app/finders/packages/npm/package_finder.rb', line 10

def initialize(package_name, project: nil, namespace: nil, last_of_each_version: true)
  @package_name = package_name
  @project = project
  @namespace = namespace
  @last_of_each_version = last_of_each_version
end

Instance Method Details

#executeObject


17
18
19
20
21
22
23
24
25
# File 'app/finders/packages/npm/package_finder.rb', line 17

def execute
  result = base.npm
               .with_name(@package_name)
               .installable

  return result unless @last_of_each_version

  result.last_of_each_version
end