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

Instance Method Summary collapse

Constructor Details

#initialize(context:, tools:) ⇒ Session

Creates a session with all dependencies injected

Parameters:

  • context (Context)

    the shared runtime dependencies (arguments, output, history)

  • tools (Tools)

    the collection of configured tools



17
18
19
20
21
# File 'lib/reviewer/session.rb', line 17

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

Returns:

  • (Integer)

    the maximum exit status from all tools



33
34
35
# File 'lib/reviewer/session.rb', line 33

def format
  run_tools(:format)
end

#reviewInteger

Runs the review command for the current set of tools

Returns:

  • (Integer)

    the maximum exit status from all tools



26
27
28
# File 'lib/reviewer/session.rb', line 26

def review
  run_tools(:review)
end