Class: Mvnizer::Mvnize

Inherits:
Object
  • Object
show all
Includes:
Configuration
Defined in:
lib/mvnizer/mvnize.rb

Overview

Mvnize is the main entry point into Mvnizer.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configuration

#conf

Constructor Details

#initialize(coordinate_parser = Mvnizer::CoordinateParser.new) ⇒ Mvnize

Returns a new instance of Mvnize.



7
8
9
# File 'lib/mvnizer/mvnize.rb', line 7

def initialize(coordinate_parser = Mvnizer::CoordinateParser.new)
  @coordinate_parser = coordinate_parser
end

Instance Attribute Details

#outObject



11
12
13
# File 'lib/mvnizer/mvnize.rb', line 11

def out
  @out ||= $stdout
end

Instance Method Details

#run(options) ⇒ Object

Execute the right command depending on the :command parameter passed in options. If the command does not exit, throw an error.

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/mvnizer/mvnize.rb', line 18

def run(options)
  raise ArgumentError, "Please give a name to the project." unless options[:name]

  case options[:command]
  when "new"
    project_details = define_project(options)
    project_command = Mvnizer::Command::ProjectFactory.create(project_details.type)

    project_command.run(project_details)
    out.puts("Project #{project_details.artifact_id} created successfully.")
  when "search"
    search_command = Command::SearchArtefact.new
    search_command.run(options)
  when "add"
    add_command = Command::AddDependency.new
    add_command.run(options)
  else
    raise ArgumentError, "#{options[:command]} is not a valid command."
  end
end