Class: Peacock::Engine::Extractor
- Inherits:
-
Object
- Object
- Peacock::Engine::Extractor
show all
- Includes:
- Engine
- Defined in:
- lib/peacock/engine/extractor.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Engine
#check_and_return_hash, #determine_git_ignore_path, #determine_root_dir, #git_ignore_exists?
Constructor Details
#initialize(opt_hash) ⇒ Extractor
Returns a new instance of Extractor.
13
14
15
16
17
18
19
20
21
|
# File 'lib/peacock/engine/extractor.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_exists?(path)
@git_ignore = File.open(path, 'r')
end
|
Class Method Details
.start_engine(opt_hash) ⇒ Object
8
9
10
11
|
# File 'lib/peacock/engine/extractor.rb', line 8
def self.start_engine(opt_hash)
= Extractor.new(opt_hash)
.workflow
end
|
Instance Method Details
#determine_delete_list(ignore_lines, delete_list) ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'lib/peacock/engine/extractor.rb', line 47
def determine_delete_list(ignore_lines, delete_list)
ignore_lines.each_with_index do |line,index|
if hash_includes_line?(line)
delete_list.push(index)
@logger.(line.chomp("\n"))
end
end
end
|
#extract_files_and_directories ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/peacock/engine/extractor.rb', line 28
def extract_files_and_directories
delete_list = []
ignore_lines = @git_ignore.readlines
determine_delete_list(ignore_lines, delete_list)
delete_list.each do |entry|
ignore_lines.delete_at(entry)
end
@git_ignore.reopen(@git_ignore.path, 'w')
ignore_lines.each do |line|
@git_ignore.write(line)
end
end
|
#hash_includes_line?(line) ⇒ Boolean
56
57
58
|
# File 'lib/peacock/engine/extractor.rb', line 56
def hash_includes_line?(line)
@hash.dirs.include?(line.chomp("\n")) || @hash.files.include?(line.chomp("\n"))
end
|
#workflow ⇒ Object
23
24
25
26
|
# File 'lib/peacock/engine/extractor.rb', line 23
def workflow
extract_files_and_directories
@git_ignore.close
end
|