Skip to content

Commit 1740588

Browse files
committed
Add documentation to HookContext::Base
1 parent 729f156 commit 1740588

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

lib/overcommit/hook_context/base.rb

+19-3
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,37 @@ module Overcommit::HookContext
88
# This is also important to house in a separate object so that any
99
# calculations can be memoized across all hooks in a single object, which
1010
# helps with performance.
11+
#
12+
# @abstract
1113
class Base
14+
# Creates a hook context from the given configuration and input options.
15+
#
1216
# @param config [Overcommit::Configuration]
1317
# @param args [Array<String>]
18+
# @param input [IO] standard input stream
1419
def initialize(config, args, input)
1520
@config = config
1621
@args = args
1722
@input = input
1823
end
1924

2025
# Returns the camel-cased type of this hook (e.g. PreCommit)
26+
#
27+
# @return [String]
2128
def hook_class_name
2229
self.class.name.split('::').last
2330
end
2431

2532
# Returns the snake-cased type of this hook (e.g. pre_commit)
33+
#
34+
# @return [String]
2635
def hook_type_name
2736
Overcommit::Utils.snake_case(hook_class_name)
2837
end
2938

3039
# Returns the actual name of the hook script being run (e.g. pre-commit).
40+
#
41+
# @return [String]
3142
def hook_script_name
3243
hook_type_name.gsub('_', '-')
3344
end
@@ -37,7 +48,7 @@ def hook_script_name
3748
# This is called before the hooks are run by the [HookRunner]. Different
3849
# hook types can perform different setup.
3950
def setup_environment
40-
# Implemented by subclass
51+
# Implemented by subclass, if applicable
4152
end
4253

4354
# Resets the environment to an appropriate state.
@@ -46,18 +57,23 @@ def setup_environment
4657
# Different hook types can perform different cleanup operations, which are
4758
# intended to "undo" the results of the call to {#setup_environment}.
4859
def cleanup_environment
49-
# Implemented by subclass
60+
# Implemented by subclass, if applicable
5061
end
5162

5263
# Returns a list of files that have been modified.
5364
#
5465
# By default, this returns an empty list. Subclasses should implement if
5566
# there is a concept of files changing for the type of hook being run.
67+
#
68+
# @return [Array<String>]
5669
def modified_files
5770
[]
5871
end
5972

60-
# Returns an array of lines passed to the hook via STDIN.
73+
# Returns an array of lines passed to the hook via the standard input
74+
# stream.
75+
#
76+
# @return [Array<String>]
6177
def input_lines
6278
@input_lines ||= @input.read.split("\n")
6379
end

0 commit comments

Comments
 (0)