Class: PreCommitHook

Inherits:
Hook
  • Object
show all
Defined in:
lib/dot_example/pre_commit_hook.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Hook

#contains_steps?, #contents, #create_file, #create_file_if_does_not_exist, #filepath, #find_or_create, #print_new_hook_message, #print_new_steps_message, #write!

Constructor Details

#initialize(dot_env_dot_example = nil) ⇒ PreCommitHook

Returns a new instance of PreCommitHook.



2
3
4
5
6
# File 'lib/dot_example/pre_commit_hook.rb', line 2

def initialize(dot_env_dot_example = nil)
  @dot_env_dot_example = dot_env_dot_example || DotEnvDotExample.new
  @type = "pre-commit"
  create_file_if_does_not_exist
end

Instance Attribute Details

#dot_env_dot_exampleObject (readonly)

Returns the value of attribute dot_env_dot_example.



8
9
10
# File 'lib/dot_example/pre_commit_hook.rb', line 8

def dot_env_dot_example
  @dot_env_dot_example
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/dot_example/pre_commit_hook.rb', line 8

def type
  @type
end

Instance Method Details

#stepsObject

TODO: Make it possible to put .env and .env.example files somewhere else? Maybe later if people actually want this feature



12
13
14
15
16
17
# File 'lib/dot_example/pre_commit_hook.rb', line 12

def steps
  [
    "dot_example sync",
    "git add .env.example"
  ].join("\n")
end