day-tracker 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/day/tracker.rb +27 -4
- data/lib/day/tracker/version.rb +1 -1
- 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: 8ed2eb053b21155e28fc842a106d28324bccad37
|
4
|
+
data.tar.gz: a3935afedcf625c1ba23589c84d22268375ceff2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a746fa645c5acdd47bbaeeb6812876883817227090f9d6473ba12c3377ac616382f13a7caa1dfedf11b8974dccc20bcbaacf6a0627196ebff80eda546a4bc0c
|
7
|
+
data.tar.gz: fc6d66322205fcb6d89450375b1bc91a9420982b6bbf9ebdd73c39b1297cce292b96363b183781bc4b5230906ad75cd8bec364c64224d601bddacea5029839c6
|
data/lib/day/tracker.rb
CHANGED
@@ -3,7 +3,7 @@ require "day/tracker/version"
|
|
3
3
|
module Day
|
4
4
|
module Tracker
|
5
5
|
class Cli < Thor
|
6
|
-
FILE_PATH = File.expand_path("
|
6
|
+
FILE_PATH = File.expand_path("~/.day-tracker")
|
7
7
|
|
8
8
|
def initialize(*args)
|
9
9
|
super
|
@@ -15,13 +15,36 @@ module Day
|
|
15
15
|
puts File.read(FILE_PATH)
|
16
16
|
end
|
17
17
|
|
18
|
-
desc "add PROJECT_NAME", "add a project for today"
|
19
|
-
def add(
|
18
|
+
desc "add PROJECT_NAME [FRACTION]", "add a project for today"
|
19
|
+
def add(project, fraction=1)
|
20
|
+
entry = format_entry(project, fraction)
|
21
|
+
return if entry_exists?(entry)
|
22
|
+
|
20
23
|
open(FILE_PATH, 'a') do |file|
|
21
|
-
file.puts
|
24
|
+
file.puts entry
|
22
25
|
end
|
26
|
+
|
27
|
+
list
|
23
28
|
end
|
24
29
|
|
30
|
+
no_commands do
|
31
|
+
def entry_exists?(entry)
|
32
|
+
File.readlines(FILE_PATH).grep(entry).any?
|
33
|
+
end
|
34
|
+
|
35
|
+
def format_entry(project, fraction)
|
36
|
+
Time.now.strftime("%B %d - #{project} - #{formatted_fraction(fraction)}")
|
37
|
+
end
|
38
|
+
|
39
|
+
def formatted_fraction(fraction)
|
40
|
+
{
|
41
|
+
"0.5": "half",
|
42
|
+
".5": "half",
|
43
|
+
"1", "full"
|
44
|
+
}[fraction]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
25
48
|
default_task :list
|
26
49
|
end
|
27
50
|
end
|
data/lib/day/tracker/version.rb
CHANGED