lib/power_stencil/utils/completion.rb in power_stencil-0.8.13 vs lib/power_stencil/utils/completion.rb in power_stencil-0.8.14
- old
+ new
@@ -1,27 +1,37 @@
module PowerStencil
module Utils
module Completion
+ class FakeIgnoreList
+ attr_accessor :return_value
+ def ignore_file?(file)
+ return_value
+ end
+ end
+
include PowerStencil::Utils::DirectoryProcessor
- def generate_zsh_completion(script_name)
+ def generate_zsh_completion(script_name, target_file, generating_project_completion)
- # Dirty hack
- config.executable_gem_layer[:file_renaming_patterns] = {'(.+)_power_stencil.sh.erb' => '\1_power_stencil' }
-
- target_dir = File.expand_path config[:completion_target][:zsh][:completion_dir]
source_dir = File.join PowerStencil::Project::Paths.system_templates_templates_path, 'zsh_command_line_completion'
+ source_template = File.join source_dir, '_power_stencil.sh.erb'
engine = PowerStencil::Engine::InitEngine.new
engine.dsl = PowerStencil::Dsl::Completion
engine.dsl.script_name = script_name
- engine.render_source source_dir, target_dir, overwrite_files: true
+ engine.dsl.generating_project_completion = generating_project_completion
- puts_and_logs "zsh auto_completion has been installed in '#{File.join target_dir, "_#{script_name}"}'.", check_verbose: false
- puts "You should ensure you have something like 'fpath=(#{target_dir} $fpath)' in your ~/.zshrc file..."
- puts 'You may have to relog for changes to be applied.'
+ engine.instance_eval do
+ @files_not_to_rename = FakeIgnoreList.new
+ files_not_to_rename.return_value = true
+ @files_not_to_render = FakeIgnoreList.new
+ files_not_to_render.return_value = false
+ end
+
+ engine.render_single_template_file source_template, target_file
+
end
end
end
\ No newline at end of file