Class: RBCliTool::Hook
- Defined in:
- lib/rbcli-tool/generators.rb
Instance Method Summary collapse
-
#initialize(root_path, hook_type) ⇒ Hook
constructor
A new instance of Hook.
- #run ⇒ Object
Methods inherited from Generator
Constructor Details
#initialize(root_path, hook_type) ⇒ Hook
Returns a new instance of Hook.
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/rbcli-tool/generators.rb', line 85 def initialize root_path, hook_type @typename = { default: 'default_action', pre: 'pre_execution', post: 'post_execution', firstrun: 'first_run' }[hook_type] @src = "#{File.dirname(__FILE__)}/../../skeletons/project/hooks/#{@typename}.rb" @dest = "#{root_path}/hooks/#{@typename}.rb" end |
Instance Method Details
#run ⇒ Object
96 97 98 99 100 101 102 |
# File 'lib/rbcli-tool/generators.rb', line 96 def run if File.exist? @dest RBCliTool.continue_confirmation "The #{@typename} hook already exists; contents will be overwritten." FileUtils.rm_rf @dest end RBCliTool.cp_file @src, @dest end |