work-md 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/work/md/cli.rb +1 -0
- data/lib/work/md/commands/parse.rb +1 -58
- data/lib/work/md/commands/plast.rb +31 -0
- data/lib/work/md/file.rb +61 -0
- data/lib/work/md/version.rb +1 -1
- data/lib/work/md.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f71380cbbd01039015727e92f5de5e621b1a3511914e4a6b81ef50de192ea43d
|
4
|
+
data.tar.gz: 7952a1d0d8c232a40ac18bdf90ff5f3b728aa57b3868170821204136492b04ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11d3bc8deb4aa7ba041a171a28b825eed5ce1690a53644ab331583f219f970a58c1dfcfcf7c95460e4ab2634efad01f5bdfe9e68a754da7f859ae40c43ab9a5d
|
7
|
+
data.tar.gz: e4a5616a87b0d249ef703b775f6956af217f578bd9fc3cd88e2becd43a45d96f5daed154704e174c7e1724cf703234be2e848e5e805932275b407727c709cef6
|
data/lib/work/md/cli.rb
CHANGED
@@ -6,9 +6,6 @@ module Work
|
|
6
6
|
class Parse
|
7
7
|
class << self
|
8
8
|
def execute(argv = [])
|
9
|
-
parsed_file_path = Work::Md::Config.work_dir + '/parsed.md'
|
10
|
-
t = Work::Md::Config.translations
|
11
|
-
|
12
9
|
parser = Work::Md::Parser::Engine.new
|
13
10
|
args_hash_to_parser = -> (args, received_parser) {
|
14
11
|
year = args['y'] || Time.new.year
|
@@ -40,61 +37,7 @@ module Work
|
|
40
37
|
args_hash_to_parser.(args_hash, parser)
|
41
38
|
end
|
42
39
|
|
43
|
-
parser
|
44
|
-
|
45
|
-
::File.delete(parsed_file_path) if ::File.exist? parsed_file_path
|
46
|
-
|
47
|
-
::File.open(parsed_file_path, 'w+') do |f|
|
48
|
-
f.puts("# #{Work::Md::Config.title}\n\n")
|
49
|
-
f.puts("### #{t[:tasks]} (#{parser.tasks.size}):\n\n")
|
50
|
-
parser.tasks.each do |task|
|
51
|
-
f.puts("- [#{task}\n\n") if task != ' ]'
|
52
|
-
end
|
53
|
-
f.puts("---\n\n")
|
54
|
-
f.puts("### #{t[:meetings]} (#{parser.meetings.size}):\n\n")
|
55
|
-
parser.meetings.each do |meeting|
|
56
|
-
f.puts("- [#{meeting}\n\n") if meeting != ' ]'
|
57
|
-
end
|
58
|
-
f.puts("---\n\n")
|
59
|
-
f.puts("### #{t[:interruptions]} (#{parser.interruptions.size}):\n\n")
|
60
|
-
parser.interruptions.each do |interruption|
|
61
|
-
f.puts("- #{interruption}\n")
|
62
|
-
end
|
63
|
-
f.puts("\n") if parser.interruptions.size > 0
|
64
|
-
f.puts("---\n\n")
|
65
|
-
f.puts("### #{t[:difficulties]} (#{parser.difficulties.size}):\n\n")
|
66
|
-
parser.difficulties.each do |difficulty|
|
67
|
-
f.puts("- #{difficulty}\n")
|
68
|
-
end
|
69
|
-
f.puts("\n") if parser.difficulties.size > 0
|
70
|
-
f.puts("---\n\n")
|
71
|
-
f.puts("### #{t[:observations]} (#{parser.observations.size}):\n\n")
|
72
|
-
parser.observations.each do |observation|
|
73
|
-
f.puts("- #{observation}\n")
|
74
|
-
end
|
75
|
-
f.puts("\n") if parser.observations.size > 0
|
76
|
-
f.puts("---\n\n")
|
77
|
-
f.puts("### #{t[:pomodoros]} (#{parser.average_pomodoros} #{t[:per_day]}):\n\n")
|
78
|
-
f.puts("**#{t[:total]}: #{parser.pomodoros_sum}**")
|
79
|
-
f.puts("\n")
|
80
|
-
parser.pomodoros_bars.each do |pomodoro_bar|
|
81
|
-
f.puts(pomodoro_bar)
|
82
|
-
f.puts("\n")
|
83
|
-
end
|
84
|
-
f.puts("---\n\n")
|
85
|
-
f.puts("### #{t[:days_bars]}:\n\n")
|
86
|
-
f.puts("**#{t[:pomodoros]}: ⬛ | #{t[:meetings]}: 📅 | #{t[:interruptions]}: ⚠️ | #{t[:difficulties]}: 😓 | #{t[:observations]}: 📝 | #{t[:tasks]}: ✔️**")
|
87
|
-
|
88
|
-
f.puts("\n")
|
89
|
-
parser.days_bars.each do |day_bar|
|
90
|
-
f.puts(day_bar)
|
91
|
-
f.puts("\n")
|
92
|
-
end
|
93
|
-
|
94
|
-
f.puts("\n\n")
|
95
|
-
end
|
96
|
-
|
97
|
-
Work::Md::File.open_in_editor([parsed_file_path])
|
40
|
+
Work::Md::File.create_and_open_parsed(parser)
|
98
41
|
rescue StandardError => e
|
99
42
|
Work::Md::Cli.help(
|
100
43
|
::TTY::Box.frame(
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Work
|
4
|
+
module Md
|
5
|
+
module Commands
|
6
|
+
class Plast
|
7
|
+
class << self
|
8
|
+
def execute(argv = [])
|
9
|
+
last_n = argv.first.to_i
|
10
|
+
last_date = Date.today.prev_day
|
11
|
+
work_dir = Work::Md::Config.work_dir
|
12
|
+
parser = Work::Md::Parser::Engine.new
|
13
|
+
|
14
|
+
(1..last_n).map do
|
15
|
+
last_file_name = "#{last_date.strftime('%Y/%m/%d')}.md"
|
16
|
+
if ::File.exist?("#{work_dir}/#{last_file_name}")
|
17
|
+
parser.add_file("#{work_dir}/#{last_file_name}")
|
18
|
+
else
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
|
22
|
+
last_date = last_date.prev_day
|
23
|
+
end
|
24
|
+
|
25
|
+
Work::Md::File.create_and_open_parsed(parser)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/work/md/file.rb
CHANGED
@@ -15,6 +15,67 @@ module Work
|
|
15
15
|
::TTY::Editor.open(file_names[0], file_names[1])
|
16
16
|
end
|
17
17
|
end
|
18
|
+
|
19
|
+
def self.create_and_open_parsed(parser)
|
20
|
+
parser.freeze
|
21
|
+
|
22
|
+
parsed_file_path = Work::Md::Config.work_dir + '/parsed.md'
|
23
|
+
t = Work::Md::Config.translations
|
24
|
+
|
25
|
+
::File.delete(parsed_file_path) if ::File.exist? parsed_file_path
|
26
|
+
|
27
|
+
::File.open(parsed_file_path, 'w+') do |f|
|
28
|
+
f.puts("# #{Work::Md::Config.title}\n\n")
|
29
|
+
f.puts("### #{t[:tasks]} (#{parser.tasks.size}):\n\n")
|
30
|
+
parser.tasks.each do |task|
|
31
|
+
f.puts("- [#{task}\n\n") if task != ' ]'
|
32
|
+
end
|
33
|
+
f.puts("---\n\n")
|
34
|
+
f.puts("### #{t[:meetings]} (#{parser.meetings.size}):\n\n")
|
35
|
+
parser.meetings.each do |meeting|
|
36
|
+
f.puts("- [#{meeting}\n\n") if meeting != ' ]'
|
37
|
+
end
|
38
|
+
f.puts("---\n\n")
|
39
|
+
f.puts("### #{t[:interruptions]} (#{parser.interruptions.size}):\n\n")
|
40
|
+
parser.interruptions.each do |interruption|
|
41
|
+
f.puts("- #{interruption}\n")
|
42
|
+
end
|
43
|
+
f.puts("\n") if parser.interruptions.size.positive?
|
44
|
+
f.puts("---\n\n")
|
45
|
+
f.puts("### #{t[:difficulties]} (#{parser.difficulties.size}):\n\n")
|
46
|
+
parser.difficulties.each do |difficulty|
|
47
|
+
f.puts("- #{difficulty}\n")
|
48
|
+
end
|
49
|
+
f.puts("\n") if parser.difficulties.size.positive?
|
50
|
+
f.puts("---\n\n")
|
51
|
+
f.puts("### #{t[:observations]} (#{parser.observations.size}):\n\n")
|
52
|
+
parser.observations.each do |observation|
|
53
|
+
f.puts("- #{observation}\n")
|
54
|
+
end
|
55
|
+
f.puts("\n") if parser.observations.size.positive?
|
56
|
+
f.puts("---\n\n")
|
57
|
+
f.puts("### #{t[:pomodoros]} (#{parser.average_pomodoros} #{t[:per_day]}):\n\n")
|
58
|
+
f.puts("**#{t[:total]}: #{parser.pomodoros_sum}**")
|
59
|
+
f.puts("\n")
|
60
|
+
parser.pomodoros_bars.each do |pomodoro_bar|
|
61
|
+
f.puts(pomodoro_bar)
|
62
|
+
f.puts("\n")
|
63
|
+
end
|
64
|
+
f.puts("---\n\n")
|
65
|
+
f.puts("### #{t[:days_bars]}:\n\n")
|
66
|
+
f.puts("**#{t[:pomodoros]}: ⬛ | #{t[:meetings]}: 📅 | #{t[:interruptions]}: ⚠️ | #{t[:difficulties]}: 😓 | #{t[:observations]}: 📝 | #{t[:tasks]}: ✔️**")
|
67
|
+
|
68
|
+
f.puts("\n")
|
69
|
+
parser.days_bars.each do |day_bar|
|
70
|
+
f.puts(day_bar)
|
71
|
+
f.puts("\n")
|
72
|
+
end
|
73
|
+
|
74
|
+
f.puts("\n\n")
|
75
|
+
|
76
|
+
Work::Md::File.open_in_editor([parsed_file_path])
|
77
|
+
end
|
78
|
+
end
|
18
79
|
end
|
19
80
|
end
|
20
81
|
end
|
data/lib/work/md/version.rb
CHANGED
data/lib/work/md.rb
CHANGED
@@ -13,6 +13,7 @@ require_relative 'md/commands/last'
|
|
13
13
|
require_relative 'md/commands/tlast'
|
14
14
|
require_relative 'md/parser/engine'
|
15
15
|
require_relative 'md/commands/parse'
|
16
|
+
require_relative 'md/commands/plast'
|
16
17
|
require_relative 'md/cli'
|
17
18
|
require 'date'
|
18
19
|
require 'fileutils'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: work-md
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrique Fernandez Teixeira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-box
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- lib/work/md/commands/config.rb
|
57
57
|
- lib/work/md/commands/last.rb
|
58
58
|
- lib/work/md/commands/parse.rb
|
59
|
+
- lib/work/md/commands/plast.rb
|
59
60
|
- lib/work/md/commands/tlast.rb
|
60
61
|
- lib/work/md/commands/today.rb
|
61
62
|
- lib/work/md/commands/tyesterday.rb
|