Class: Spandx::Dotnet::Index

Inherits:
Object
  • Object
show all
Defined in:
lib/spandx/dotnet/index.rb

Constant Summary collapse

DEFAULT_DIR =
File.expand_path(File.join(Dir.home, '.local', 'share', 'spandx'))

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directory: DEFAULT_DIR, gateway: Spandx::Dotnet::NugetGateway.new) ⇒ Index

Returns a new instance of Index.



9
10
11
12
13
14
# File 'lib/spandx/dotnet/index.rb', line 9

def initialize(directory: DEFAULT_DIR, gateway: Spandx::Dotnet::NugetGateway.new)
  @directory = directory ? File.expand_path(directory) : DEFAULT_DIR
  @name = 'nuget'
  @gateway = gateway
  @cache = Spandx::Core::Cache.new(@name, root: directory)
end

Instance Attribute Details

#cacheObject (readonly)

Returns the value of attribute cache.



7
8
9
# File 'lib/spandx/dotnet/index.rb', line 7

def cache
  @cache
end

#directoryObject (readonly)

Returns the value of attribute directory.



7
8
9
# File 'lib/spandx/dotnet/index.rb', line 7

def directory
  @directory
end

#gatewayObject (readonly)

Returns the value of attribute gateway.



7
8
9
# File 'lib/spandx/dotnet/index.rb', line 7

def gateway
  @gateway
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/spandx/dotnet/index.rb', line 7

def name
  @name
end

Instance Method Details

#update!Object



16
17
18
19
20
# File 'lib/spandx/dotnet/index.rb', line 16

def update!(*)
  queue = Queue.new
  [fetch(queue), save(queue)].each(&:join)
  cache.rebuild_index
end