Class: Depends::Commands::List

Inherits:
Base
  • Object
show all
Defined in:
lib/depends/commands/list.rb

Instance Method Summary collapse

Methods inherited from Base

exit!, fatal!, #initialize, #reconfigure, #run

Constructor Details

This class inherits a constructor from Depends::Commands::Base

Instance Method Details

#run_applicationObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/depends/commands/list.rb', line 22

def run_application
  check_for_file
  load_depends_file
  if config[:versions]
    results = []
    @def.sources.each do |source|
      source_index = results.count
      results[source_index] = {:source => source.source_url, :versions => []}
      begin 
        dep = source.get_depend(config[:versions])

        dep['versions'].each do |version|
          results[source_index][:versions] << version.keep_if { |key| ['number','notes','publisher','sha1'].include?(key) }
        end
      rescue Nestful::ResourceNotFound
        puts "  Depend not found on source"
      end
      puts results.to_yaml
    end
  else
    results = []    
    @def.sources.each do |source|
      source_index = results.count
      results[source_index] = {:source => source.source_url, :depends => []}
      source.list.each do |d|
        results[source_index][:depends] << d.keep_if { |key| ['name','description'].include?(key) }
      end    
    end
    results.each do |r| 
      r[:depends].sort_by! { |h| h['name']}
    end
    puts results.to_yaml
  end
end

#setup_applicationObject



18
19
20
# File 'lib/depends/commands/list.rb', line 18

def setup_application
  Log.info "Getting Depends from sources..."
end