Class: NexusAPI::Search

Inherits:
Thor
  • Object
show all
Includes:
CLIUtils
Defined in:
lib/nexus_api/cli_commands/search.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CLIUtils

#if_file_exists?, #print_element, #print_paginating_set, #print_set, #repository_set?, #set, #setup

Instance Attribute Details

#apiObject

Returns the value of attribute api.



3
4
5
# File 'lib/nexus_api/cli_commands/search.rb', line 3

def api
  @api
end

Instance Method Details

#assetObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/nexus_api/cli_commands/search.rb', line 14

def asset
  setup
  results = Array.new.tap do |results|
    loop do
      results.concat(
        @api.search_asset(
          name:       options[:name],
          format:     options[:type],
          repository: options[:repository],
          sha1:       options[:sha1],
          version:    options[:version],
          paginate:   true,
        )
      )
      break unless @api.paginate?
    end
  end.select { |result| result['path'].include?(options[:name]) }
  puts options[:full] ? results : results.map { |result| result['path'] }
end