work_md 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/work_md +1 -0
- data/lib/work_md/commands/tyesterday.rb +6 -2
- data/lib/work_md/file.rb +42 -32
- data/lib/work_md/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7f163bb109aa82d9095042209b18157e3ba0ff0ab23456b43e0cd65ba90aeee
|
4
|
+
data.tar.gz: a78b3daa4090a73e1bcdda5e51eb30718a4787f2932027c5945e6e14322b826b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2e117fa8755001b8f4ccb44a77666e2c3b8f25c1deb959d8c702c55096bfb4cf625923eb09cf184ff3aef14659beabfdd3718ecd492384044efb5b01010ca29
|
7
|
+
data.tar.gz: 7a555df5793cbc958eff5ff7f42a5078357afeb9ab66b561ff4a82a04c0e120c565f22041e8bf1bff3b8e5f5ca345945b570cd015b66b92f037b481a4fd602b6
|
data/bin/work_md
CHANGED
@@ -5,8 +5,12 @@ module WorkMd
|
|
5
5
|
class Tyesterday
|
6
6
|
class << self
|
7
7
|
def execute(_argv = [])
|
8
|
-
|
9
|
-
|
8
|
+
filenames =
|
9
|
+
[DateTime.now, Date.today.prev_day].map do |date|
|
10
|
+
WorkMd::File.create_if_not_exist(date)
|
11
|
+
end
|
12
|
+
|
13
|
+
WorkMd::File.open_in_editor(filenames[0], filenames[1])
|
10
14
|
end
|
11
15
|
end
|
12
16
|
end
|
data/lib/work_md/file.rb
CHANGED
@@ -1,49 +1,59 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'byebug'
|
4
|
+
|
3
5
|
module WorkMd
|
4
6
|
class File
|
5
7
|
def self.open_or_create(some_date)
|
8
|
+
open_in_editor(create_if_not_exist(some_date))
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.create_if_not_exist(some_date)
|
6
12
|
t = WorkMd::Config.translations
|
7
13
|
work_dir = WorkMd::Config.work_dir
|
8
14
|
|
9
15
|
::FileUtils
|
10
16
|
.mkdir_p("#{work_dir}/#{some_date.strftime('%Y/%m')}")
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
17
|
+
|
18
|
+
filename = "#{some_date.strftime('%Y/%m/%d')}.md"
|
19
|
+
|
20
|
+
return filename if ::File.exist?("#{work_dir}/#{filename}")
|
21
|
+
|
22
|
+
::File.open(
|
23
|
+
"#{work_dir}/#{filename}",
|
24
|
+
'w+'
|
25
|
+
) do |f|
|
26
|
+
# rubocop:disable Layout/LineLength
|
27
|
+
f.puts("# #{some_date.strftime('%d/%m/%Y')} - #{WorkMd::Config.title} \n\n")
|
28
|
+
# rubocop:enable Layout/LineLength
|
29
|
+
f.puts("### #{t[:tasks]}:\n\n")
|
30
|
+
f.puts("- [ ]\n\n")
|
31
|
+
f.puts("---\n\n")
|
32
|
+
f.puts("### #{t[:meetings]}:\n\n")
|
33
|
+
f.puts("- [ ]\n\n")
|
34
|
+
f.puts("---\n\n")
|
35
|
+
f.puts("### #{t[:interruptions]}:\n\n")
|
36
|
+
f.puts("---\n\n")
|
37
|
+
f.puts("### #{t[:difficulties]}:\n\n")
|
38
|
+
f.puts("---\n\n")
|
39
|
+
f.puts("### #{t[:observations]}:\n\n")
|
40
|
+
f.puts("---\n\n")
|
41
|
+
f.puts("### #{t[:pomodoros]}:\n\n")
|
42
|
+
f.puts("0\n\n")
|
34
43
|
end
|
35
44
|
|
45
|
+
filename
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.open_in_editor(filename1, filename2 = nil)
|
36
49
|
editor = WorkMd::Config.editor
|
37
50
|
|
38
|
-
::FileUtils.cd(work_dir) do
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
command: editor
|
45
|
-
)
|
46
|
-
end
|
51
|
+
::FileUtils.cd(WorkMd::Config.work_dir) do
|
52
|
+
ENV['EDITOR'] = editor unless editor.nil?
|
53
|
+
|
54
|
+
return ::TTY::Editor.open(filename1) if filename2.nil?
|
55
|
+
|
56
|
+
::TTY::Editor.open(filename1, filename2)
|
47
57
|
end
|
48
58
|
end
|
49
59
|
end
|
data/lib/work_md/version.rb
CHANGED