bullit 0.1.2 → 0.1.3
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/bullit.gemspec +1 -1
- data/lib/bullit.rb +13 -5
- data/lib/bullit/file.rb +26 -6
- data/lib/bullit/task.rb +7 -1
- data/lib/bullit/version.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7a71f4040b479e1f18de182e7a384e469743d3d
|
4
|
+
data.tar.gz: 1cf730d51f9f467833dc822a69dd339c94e505e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d7aa84e83f64da9737cd9a1848b5e937ee707e59a1b923484da9d8342b94e2ca7e3aaad8ebe2606c576e9059aaa2c965908f552c9f0b062d85daabe3c034533
|
7
|
+
data.tar.gz: 706eb52dea58b2cb39b3845f22c241ecc2730c6dc9a60cdaa4f12fbc4ec1a75eec67bd74d65bb22185639153bd30cee3cbb57ddea5468a8309e6d50ff795d9ff
|
data/Gemfile.lock
CHANGED
data/bullit.gemspec
CHANGED
data/lib/bullit.rb
CHANGED
@@ -5,7 +5,7 @@ require 'tty-prompt'
|
|
5
5
|
require "bullit/version"
|
6
6
|
require "bullit/file"
|
7
7
|
|
8
|
-
module
|
8
|
+
module Bullit
|
9
9
|
class Error < StandardError; end
|
10
10
|
|
11
11
|
Clamp do
|
@@ -14,7 +14,7 @@ module BulletJournal
|
|
14
14
|
subcommand "generate", "generator functions" do
|
15
15
|
subcommand "today", "creates task file for today" do
|
16
16
|
def execute
|
17
|
-
|
17
|
+
Bullit::File.generate_today_file(loud?)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -31,7 +31,15 @@ module BulletJournal
|
|
31
31
|
def execute
|
32
32
|
prompt = TTY::Prompt.new
|
33
33
|
text = prompt.ask('what do you need to do?') if text.nil?
|
34
|
-
|
34
|
+
Bullit::File.add_task(text)
|
35
|
+
show_tasks
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
subcommand "delete", "delete a task" do
|
40
|
+
parameter "TASK_NUMBER", "what the task is", required: true
|
41
|
+
def execute
|
42
|
+
Bullit::File.delete_task(task_number.to_i)
|
35
43
|
show_tasks
|
36
44
|
end
|
37
45
|
end
|
@@ -39,14 +47,14 @@ module BulletJournal
|
|
39
47
|
subcommand "complete", "complete a task" do
|
40
48
|
parameter "TASK_NUMBER", "what the task is", required: true
|
41
49
|
def execute
|
42
|
-
|
50
|
+
Bullit::File.complete_task(task_number.to_i)
|
43
51
|
show_tasks
|
44
52
|
end
|
45
53
|
end
|
46
54
|
end
|
47
55
|
|
48
56
|
def show_tasks
|
49
|
-
if tasks =
|
57
|
+
if tasks = Bullit::File.today_tasks
|
50
58
|
tasks = tasks.each_with_index.map{ |t,i| [i,t[:text], t[:complete] == true ? ' ✅' : ' ❌']}
|
51
59
|
|
52
60
|
puts TTY::Table.new(['#', 'Task', ''], tasks).render(:unicode)
|
data/lib/bullit/file.rb
CHANGED
@@ -5,7 +5,7 @@ require 'pry'
|
|
5
5
|
|
6
6
|
require 'bullit/task'
|
7
7
|
|
8
|
-
module
|
8
|
+
module Bullit
|
9
9
|
class File
|
10
10
|
def self.generate_today_file(loud)
|
11
11
|
today_file.dirname.mkpath unless today_file.dirname.exist?
|
@@ -28,7 +28,7 @@ module BulletJournal
|
|
28
28
|
|
29
29
|
def self.incomplete_tasks_from_yesterday(loud)
|
30
30
|
if yesterday_file.exist?
|
31
|
-
file =
|
31
|
+
file = yesterday_file_contents
|
32
32
|
|
33
33
|
return {} if file[:tasks].empty?
|
34
34
|
|
@@ -36,7 +36,7 @@ module BulletJournal
|
|
36
36
|
unless t[:complete] == true
|
37
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
38
|
if action == 'complete'
|
39
|
-
t
|
39
|
+
t = t.to_task.mark_as_complete
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -58,7 +58,7 @@ module BulletJournal
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def self.add_task(text)
|
61
|
-
file =
|
61
|
+
file = today_file_contents
|
62
62
|
|
63
63
|
if file[:tasks] == {}
|
64
64
|
file[:tasks] = [ Task.new(text: text).to_h ]
|
@@ -69,12 +69,24 @@ module BulletJournal
|
|
69
69
|
today_file.write(YAML.dump(file))
|
70
70
|
end
|
71
71
|
|
72
|
+
def self.delete_task(task_number)
|
73
|
+
file = today_file_contents
|
74
|
+
|
75
|
+
unless file[:tasks].nil?
|
76
|
+
unless file[:tasks][task_number].nil?
|
77
|
+
file[:tasks].delete_at(task_number)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
today_file.write(YAML.dump(file))
|
82
|
+
end
|
83
|
+
|
72
84
|
def self.complete_task(task_number)
|
73
|
-
file =
|
85
|
+
file = today_file_contents
|
74
86
|
|
75
87
|
unless file[:tasks].nil?
|
76
88
|
unless file[:tasks][task_number].nil?
|
77
|
-
file[:tasks][task_number] =
|
89
|
+
file[:tasks][task_number] = file[:tasks][task_number].to_task.mark_as_complete
|
78
90
|
today_file.write(YAML.dump(file))
|
79
91
|
end
|
80
92
|
end
|
@@ -90,6 +102,10 @@ module BulletJournal
|
|
90
102
|
Pathname("#{Dir.home}/.bullit/journal/#{year}/#{week}/#{weekday}.yaml")
|
91
103
|
end
|
92
104
|
|
105
|
+
def self.today_file_contents
|
106
|
+
YAML.load(today_file.read)
|
107
|
+
end
|
108
|
+
|
93
109
|
def self.yesterday_file
|
94
110
|
t = Time.now
|
95
111
|
|
@@ -104,5 +120,9 @@ module BulletJournal
|
|
104
120
|
Pathname("#{Dir.home}/.bullit/journal/#{year}/#{week-1}/7.yaml")
|
105
121
|
end
|
106
122
|
end
|
123
|
+
|
124
|
+
def self.yesterday_file_contents
|
125
|
+
YAML.load(yesterday_file.read)
|
126
|
+
end
|
107
127
|
end
|
108
128
|
end
|
data/lib/bullit/task.rb
CHANGED
data/lib/bullit/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = "0.1.
|
1
|
+
module Bullit
|
2
|
+
VERSION = "0.1.3"
|
3
3
|
end
|