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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0bb52a9909abacfd08ff03f14fa567e438208f8
4
- data.tar.gz: 7452bf4cd3d342fed547302eb9eab7ff75d34e89
3
+ metadata.gz: 8ed2eb053b21155e28fc842a106d28324bccad37
4
+ data.tar.gz: a3935afedcf625c1ba23589c84d22268375ceff2
5
5
  SHA512:
6
- metadata.gz: d937a7443f9266363c304f6fe8d71b4ad39f04929d4e2a6662546046bc24f2799b1f3114f7bd391dae6e70c26fa258565a899c1b09c74381dd54b5c55818a352
7
- data.tar.gz: 5e65a72ce2d72c98802f259e5ef0f78a258f0c0a277ec1f7215e5c2ef2a57055cdbdbf41648b76b260c67b869cc08f73a9be76f6c9b9178b302e9c97e0cc99c2
6
+ metadata.gz: 6a746fa645c5acdd47bbaeeb6812876883817227090f9d6473ba12c3377ac616382f13a7caa1dfedf11b8974dccc20bcbaacf6a0627196ebff80eda546a4bc0c
7
+ data.tar.gz: fc6d66322205fcb6d89450375b1bc91a9420982b6bbf9ebdd73c39b1297cce292b96363b183781bc4b5230906ad75cd8bec364c64224d601bddacea5029839c6
@@ -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("~/day-tracker")
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(project_name)
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 Time.now.strftime("%B %d - #{project_name}")
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
@@ -1,5 +1,5 @@
1
1
  module Day
2
2
  module Tracker
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: day-tracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - opsb