Class: Reviewer::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewer/session.rb,
lib/reviewer/session/formatter.rb

Overview

Run lifecycle with full dependency injection. Owns the review/format lifecycle that was previously in Reviewer module methods.

Defined Under Namespace

Classes: Formatter

Constant Summary collapse

USAGE_ERROR =

Exit status for a usage error -- the caller asked for something Reviewer cannot honour. Distinct from a tool failure so the two can be told apart.

2

Instance Method Summary collapse

Constructor Details

#initialize(context:, tools:) ⇒ Session

Creates a session with all dependencies injected



21
22
23
24
25
# File 'lib/reviewer/session.rb', line 21

def initialize(context:, tools:)
  @context = context
  @tools = tools
  context.arguments.keywords.tools = tools
end

Instance Method Details

#formatInteger

Runs the format command for the current set of tools



37
38
39
# File 'lib/reviewer/session.rb', line 37

def format
  run_tools(:format)
end

#reviewInteger

Runs the review command for the current set of tools



30
31
32
# File 'lib/reviewer/session.rb', line 30

def review
  run_tools(:review)
end