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



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

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 = case status
                      when :found_in_jar
                        "was inside the jar"
                      when :found_via_sha1
                        "found by sha1 search from search.maven.org"
                      when :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:"

        # URI.encode_www_form_component correctly escapes spaces to '+' for query params.
        clean_name = pom_getter.cleanup_name(name)
        query = "#{clean_name} pom"
        puts "http://google.com/#q=#{URI.encode_www_form_component(query)}"
      end
    end
  end
end