bullit 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bullit/file.rb +29 -7
- data/lib/bullit/version.rb +1 -1
- data/lib/bullit.rb +8 -2
- metadata +1 -2
- data/tasks/2019/05/6.yaml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0960865172d22bc2dc9a29a9d01c5be340b54386'
|
4
|
+
data.tar.gz: 5d96f08fa3c2c1d14a4346793a1ab561c0ead5c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89f38b733d016cc5704c9afd3567de8373230b9b27ac9cf6a67c8e0f529a92149473fab6b48b72f01c1b98cd097daa179b5689812fb8066c4d0b1ab656aa2b28
|
7
|
+
data.tar.gz: f5f68803ff523ad17621ca39d403845bacf59b51d96895e44cb3d0e1ddeea05d6dc40dc81821831da6522533f90943f78996443d3ecf8e9cfd11e8545a50e638
|
data/Gemfile.lock
CHANGED
data/lib/bullit/file.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'yaml'
|
3
|
+
require 'tty-prompt'
|
3
4
|
require 'pry'
|
4
5
|
|
5
6
|
require 'bullit/task'
|
@@ -7,7 +8,7 @@ require 'bullit/task'
|
|
7
8
|
module BulletJournal
|
8
9
|
class File
|
9
10
|
def self.generate_today_file(loud)
|
10
|
-
today_file.dirname.mkpath
|
11
|
+
today_file.dirname.mkpath unless today_file.dirname.exist?
|
11
12
|
|
12
13
|
unless today_file.exist?
|
13
14
|
t = Time.now
|
@@ -16,7 +17,7 @@ module BulletJournal
|
|
16
17
|
|
17
18
|
file_contents = {
|
18
19
|
title: title,
|
19
|
-
tasks: incomplete_tasks_from_yesterday
|
20
|
+
tasks: incomplete_tasks_from_yesterday(loud)
|
20
21
|
}
|
21
22
|
|
22
23
|
today_file.write(YAML.dump(file_contents))
|
@@ -25,11 +26,32 @@ module BulletJournal
|
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
def self.incomplete_tasks_from_yesterday
|
29
|
+
def self.incomplete_tasks_from_yesterday(loud)
|
29
30
|
if yesterday_file.exist?
|
30
31
|
file = YAML.load(yesterday_file.read)
|
32
|
+
|
31
33
|
return {} if file[:tasks].empty?
|
32
|
-
|
34
|
+
|
35
|
+
file[:tasks].each do |t|
|
36
|
+
unless t[:complete] == true
|
37
|
+
action = TTY::Prompt.new.select("\nWould you like to complete\n\n\t'#{t[:text]}'\n\nor migrate it to today's entry?\n", %w(complete migrate))
|
38
|
+
if action == 'complete'
|
39
|
+
t[:complete] = true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
file[:tasks] = file[:tasks].reject{ |t| t[:complete] == true }
|
45
|
+
|
46
|
+
yesterday_file.write(YAML.dump(file))
|
47
|
+
|
48
|
+
binding.pry
|
49
|
+
|
50
|
+
if file[:tasks] == {}
|
51
|
+
return nil
|
52
|
+
else
|
53
|
+
return file[:tasks]
|
54
|
+
end
|
33
55
|
end
|
34
56
|
end
|
35
57
|
|
@@ -67,7 +89,7 @@ module BulletJournal
|
|
67
89
|
week = t.strftime "%W"
|
68
90
|
weekday = t.strftime "%u"
|
69
91
|
|
70
|
-
Pathname("
|
92
|
+
Pathname("#{Dir.home}/.bullit/journal/#{year}/#{week}/#{weekday}.yaml")
|
71
93
|
end
|
72
94
|
|
73
95
|
def self.yesterday_file
|
@@ -79,9 +101,9 @@ module BulletJournal
|
|
79
101
|
|
80
102
|
# TODO: the logic here is a bit dodgy... it should look for the latest file in case you don't use your machine for more than one day.
|
81
103
|
if weekday > 1
|
82
|
-
Pathname("
|
104
|
+
Pathname("#{Dir.home}/.bullit/journal/#{year}/#{week}/#{(weekday - 1).to_s}.yaml")
|
83
105
|
else
|
84
|
-
Pathname("
|
106
|
+
Pathname("#{Dir.home}/.bullit/journal/#{year}/#{week-1}/7.yaml")
|
85
107
|
end
|
86
108
|
end
|
87
109
|
end
|
data/lib/bullit/version.rb
CHANGED
data/lib/bullit.rb
CHANGED
@@ -32,6 +32,7 @@ module BulletJournal
|
|
32
32
|
prompt = TTY::Prompt.new
|
33
33
|
text = prompt.ask('what do you need to do?') if text.nil?
|
34
34
|
BulletJournal::File.add_task(text)
|
35
|
+
show_tasks
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
@@ -39,14 +40,19 @@ module BulletJournal
|
|
39
40
|
parameter "TASK_NUMBER", "what the task is", required: true
|
40
41
|
def execute
|
41
42
|
BulletJournal::File.complete_task(task_number.to_i)
|
43
|
+
show_tasks
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
46
48
|
def show_tasks
|
47
|
-
tasks = BulletJournal::File.today_tasks
|
49
|
+
if tasks = BulletJournal::File.today_tasks
|
50
|
+
tasks = tasks.each_with_index.map{ |t,i| [i,t[:text], t[:complete] == true ? ' ✅' : ' ❌']}
|
48
51
|
|
49
|
-
|
52
|
+
puts TTY::Table.new(['#', 'Task', ''], tasks).render(:unicode)
|
53
|
+
elsif tasks == {}
|
54
|
+
puts "There's no tasks for today"
|
55
|
+
end
|
50
56
|
end
|
51
57
|
end
|
52
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomek Nadolny
|
@@ -134,7 +134,6 @@ files:
|
|
134
134
|
- lib/bullit/file.rb
|
135
135
|
- lib/bullit/task.rb
|
136
136
|
- lib/bullit/version.rb
|
137
|
-
- tasks/2019/05/6.yaml
|
138
137
|
homepage: https://github.com/tomekn/bullit
|
139
138
|
licenses:
|
140
139
|
- MIT
|
data/tasks/2019/05/6.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
:title: Journal for 02/09/19
|
3
|
-
:tasks:
|
4
|
-
- :text: Get cat food
|
5
|
-
:complete: true
|
6
|
-
:created_at: '2019-02-09 16:46:24 +0000'
|
7
|
-
- :text: Finish this app
|
8
|
-
:complete: true
|
9
|
-
:created_at: '2019-02-09 17:03:43 +0000'
|
10
|
-
- :text: Add colours to the terminal.
|
11
|
-
:complete: true
|
12
|
-
:created_at: '2019-02-09 19:20:57 +0000'
|
13
|
-
- :text: Make sure the rename worked
|
14
|
-
:complete: true
|
15
|
-
:created_at: '2019-02-09 20:00:26 +0000'
|