Class: Tetra::GetPomSubcommand

Inherits:
Subcommand
  • Object
show all
Defined in:
lib/tetra/ui/get_pom_subcommand.rb

Overview

tetra get-pom

Instance Method Summary collapse

Methods inherited from Subcommand

#bypass_parsing, #checking_exceptions, #configure_log_level, #ensure_dry_running, #format_path, #print_generation_result, #verbose=, #very_verbose=, #very_very_verbose=

Methods included from Logging

#log

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/tetra/ui/get_pom_subcommand.rb', line 8

def execute
  checking_exceptions do
    project = Tetra::Project.new(".")
    ensure_dry_running(:is_not_in_progress, project) do
      pom_getter = Tetra::PomGetter.new

      path, status = pom_getter.get_pom(name)
      if path
        text_status = (
          if status == :found_in_jar
            "was inside the jar"
          elsif status == :found_via_sha1
            "found by sha1 search from search.maven.org"
          elsif status == :found_via_heuristic
            "found by heuristic search from search.maven.org"
          end
        )

        puts "#{format_path(path, project)} written, #{text_status}"
      else
        puts "#{name}'s pom not found. Try:"
        puts "http://google.com/#q=#{URI.encode(pom_getter.cleanup_name(name) + ' pom')}"
      end
    end
  end
end