class Peacock::Engine::Ignorer
Public Class Methods
new(opt_hash)
click to toggle source
# File lib/peacock/engine/ignorer.rb, line 13 def initialize(opt_hash) @hash = check_and_return_hash(opt_hash) @logger = Peacock::Logger.new(@hash.silent?) path = determine_git_ignore_path @git_ignore = File.open(path, 'a+') end
start_engine(opt_hash)
click to toggle source
# File lib/peacock/engine/ignorer.rb, line 8 def self.start_engine(opt_hash) ignorer = Ignorer.new(opt_hash) ignorer.workflow end
Public Instance Methods
check_and_write(str)
click to toggle source
# File lib/peacock/engine/ignorer.rb, line 42 def check_and_write(str) unless entry_exists?(str) insert_in_gitignore(str) end @git_ignore.rewind end
entry_exists?(entry)
click to toggle source
# File lib/peacock/engine/ignorer.rb, line 50 def entry_exists?(entry) @git_ignore.each do |line| return true if line.chomp == entry end false end
ignore_directories()
click to toggle source
# File lib/peacock/engine/ignorer.rb, line 30 def ignore_directories @hash.dirs.each do |dir| check_and_write(dir) end end
ignore_files()
click to toggle source
# File lib/peacock/engine/ignorer.rb, line 36 def ignore_files @hash.files.each do |file| check_and_write(file) end end
ignore_files_and_directories()
click to toggle source
# File lib/peacock/engine/ignorer.rb, line 25 def ignore_files_and_directories ignore_files ignore_directories end
insert_in_gitignore(str)
click to toggle source
# File lib/peacock/engine/ignorer.rb, line 57 def insert_in_gitignore(str) @git_ignore.write(str + "\n") Git.remove_from_cache(prepare_arg(str)) @logger.ignore(str) end
prepare_arg(str)
click to toggle source
if directory then remove leading slash
# File lib/peacock/engine/ignorer.rb, line 64 def prepare_arg(str) if str.start_with?('/') str[1..-1] else str end end
workflow()
click to toggle source
# File lib/peacock/engine/ignorer.rb, line 20 def workflow ignore_files_and_directories @git_ignore.close end