6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/work/md/file.rb', line 6
def self.create_and_open_parsed(parser)
parser.freeze
parsed_file_path = "#{Work::Md::Config.work_dir}/parsed.md"
t = Work::Md::Config.translations
::File.delete(parsed_file_path) if ::File.exist? parsed_file_path
::File.open(parsed_file_path, 'w+') do |f|
f.puts("# #{Work::Md::Config.title}\n\n")
f.puts("### #{t[:tasks]} (#{parser.tasks.size}):\n\n")
parser.tasks.each do |task|
f.puts("- [#{task}\n\n") if task != ' ]'
end
f.puts("---\n\n")
f.puts("### #{t[:meetings]} (#{parser.meetings.size}):\n\n")
parser.meetings.each do |meeting|
f.puts("- [#{meeting}\n\n") if meeting != ' ]'
end
f.puts("---\n\n")
f.puts("### #{t[:interruptions]} (#{parser.interruptions.size}):\n\n")
parser.interruptions.each do |interruption|
f.puts("- #{interruption}\n")
end
f.puts("\n") if parser.interruptions.size.positive?
f.puts("---\n\n")
f.puts("### #{t[:difficulties]} (#{parser.difficulties.size}):\n\n")
parser.difficulties.each do |difficulty|
f.puts("- #{difficulty}\n")
end
f.puts("\n") if parser.difficulties.size.positive?
f.puts("---\n\n")
f.puts("### #{t[:observations]} (#{parser.observations.size}):\n\n")
parser.observations.each do |observation|
f.puts("- #{observation}\n")
end
f.puts("\n") if parser.observations.size.positive?
f.puts("---\n\n")
f.puts("### #{t[:pomodoros]} (#{parser.average_pomodoros} #{t[:per_day]}):\n\n")
f.puts("**#{t[:total]}: #{parser.pomodoros_sum}**")
f.puts("\n")
parser.pomodoros_bars.each do |pomodoro_bar|
f.puts(pomodoro_bar)
f.puts("\n")
end
f.puts("---\n\n")
f.puts("### #{t[:days_bars]}:\n\n")
f.puts("**#{t[:pomodoros]}: ⬛ | #{t[:meetings]}: 📅 | #{t[:interruptions]}: ⚠️ | #{t[:difficulties]}: 😓 | #{t[:observations]}: 📝 | #{t[:tasks]}: ✔️**")
f.puts("\n")
parser.days_bars.each do |day_bar|
f.puts(day_bar)
f.puts("\n")
end
f.puts("\n\n")
end
Work::Md::File.open_in_editor([parsed_file_path])
end
|