class Hook
Public Instance Methods
contains_steps?()
click to toggle source
# File lib/dot_example/hook.rb, line 42 def contains_steps? contents.include?(steps) end
contents()
click to toggle source
# File lib/dot_example/hook.rb, line 10 def contents File.read(filepath) end
create_file()
click to toggle source
# File lib/dot_example/hook.rb, line 24 def create_file %x[ touch #{filepath} ] %x[ chmod +x #{filepath} ] print_new_hook_message end
create_file_if_does_not_exist()
click to toggle source
# File lib/dot_example/hook.rb, line 18 def create_file_if_does_not_exist unless Dir.glob(filepath).any? create_file end end
filepath()
click to toggle source
# File lib/dot_example/hook.rb, line 14 def filepath File.join(".git", "hooks", type) end
find_or_create()
click to toggle source
# File lib/dot_example/hook.rb, line 30 def find_or_create end
print_new_hook_message()
click to toggle source
# File lib/dot_example/hook.rb, line 2 def print_new_hook_message puts Paint["New #{type} hook created", :green] end
print_new_steps_message()
click to toggle source
# File lib/dot_example/hook.rb, line 6 def print_new_steps_message puts Paint[ "New steps added to #{type} hook\n#{steps}", :green] end
write!()
click to toggle source
# File lib/dot_example/hook.rb, line 33 def write! unless contains_steps? File.open(filepath, "a") do |file| file.puts steps end print_new_steps_message end end