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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27cbd77f4722a299c4e7d0a5df2ee1be91874bd2
4
- data.tar.gz: 6fa8250c7ec7d913847a59e0933067c83a9526b1
3
+ metadata.gz: c7a71f4040b479e1f18de182e7a384e469743d3d
4
+ data.tar.gz: 1cf730d51f9f467833dc822a69dd339c94e505e1
5
5
  SHA512:
6
- metadata.gz: 77d8fe890c2fb4a534c937a121e5d8a841b504ad5e1330ef66172138f6dd9832402ff77f77e35e5d97b05b6ea0d63931b4f05f8a7b20087e46a457999dc13b4a
7
- data.tar.gz: 5a845c86abdbc2c1c199108faa56310d2fd029ab47af879b7733262e206d4d22feb6da0e39333817886beef468a714fd2483b553d3bdeca014633dde7dc8e02c
6
+ metadata.gz: 8d7aa84e83f64da9737cd9a1848b5e937ee707e59a1b923484da9d8342b94e2ca7e3aaad8ebe2606c576e9059aaa2c965908f552c9f0b062d85daabe3c034533
7
+ data.tar.gz: 706eb52dea58b2cb39b3845f22c241ecc2730c6dc9a60cdaa4f12fbc4ec1a75eec67bd74d65bb22185639153bd30cee3cbb57ddea5468a8309e6d50ff795d9ff
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bullit (0.1.2)
4
+ bullit (0.1.3)
5
5
  clamp
6
6
  tty-prompt
7
7
  tty-table
@@ -5,7 +5,7 @@ require "bullit/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "bullit"
8
- spec.version = BulletJournal::VERSION
8
+ spec.version = Bullit::VERSION
9
9
  spec.authors = ["Tomek Nadolny"]
10
10
  spec.email = ["tomek.nad@gmail.com"]
11
11
 
@@ -5,7 +5,7 @@ require 'tty-prompt'
5
5
  require "bullit/version"
6
6
  require "bullit/file"
7
7
 
8
- module BulletJournal
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
- BulletJournal::File.generate_today_file(loud?)
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
- BulletJournal::File.add_task(text)
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
- BulletJournal::File.complete_task(task_number.to_i)
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 = BulletJournal::File.today_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)
@@ -5,7 +5,7 @@ require 'pry'
5
5
 
6
6
  require 'bullit/task'
7
7
 
8
- module BulletJournal
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 = YAML.load(yesterday_file.read)
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[:complete] = true
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 = YAML.load(today_file.read)
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 = YAML.load(today_file.read)
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] = Task.new(file[:tasks][task_number].to_h).mark_as_complete
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
@@ -1,4 +1,4 @@
1
- module BulletJournal
1
+ module Bullit
2
2
  class Task
3
3
  attr_accessor :text, :complete
4
4
 
@@ -21,4 +21,10 @@ module BulletJournal
21
21
  to_h
22
22
  end
23
23
  end
24
+ end
25
+
26
+ class Hash
27
+ def to_task
28
+ Bullit::Task.new(self)
29
+ end
24
30
  end
@@ -1,3 +1,3 @@
1
- module BulletJournal
2
- VERSION = "0.1.2"
1
+ module Bullit
2
+ VERSION = "0.1.3"
3
3
  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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomek Nadolny