myworklog 1.0.7 → 1.1.0

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
  SHA256:
3
- metadata.gz: 42d37f3cfd48fb7dd15e989b814f76f6617abb1ae2f273af94c9fba0d7e752f8
4
- data.tar.gz: 1fd15183fb9a7f391c37414dac5bc34d65a1f8fcf0021b52c4b56286f99f63dd
3
+ metadata.gz: bdd92d2d822c08464ccc93918c903303973f5e1f958fc9ac166e483877338178
4
+ data.tar.gz: f49931374165a57565bbd2c3faba90194b1b7ac6ce4bdcb7afbbb4a3b42dc8ab
5
5
  SHA512:
6
- metadata.gz: 11608be11f9dbad29af5bd6f8210102fecac722c7bb507c4f8f361edf6c8360b3bb0dbe9730d7bc6befb4375df72c7da8ab6b4a0e784e0d0809e73b22e2abf2b
7
- data.tar.gz: 8cccbf75521a73924aaa347871b19b3c5e9eff01ce6e962dc9928499188430669e50f576950dee644db73f35b751ed2624b2041b49472fc1d3a8d44b8215590d
6
+ metadata.gz: 65ceb6290ef9a952f1167f6dd5241d155a871945de1ef4784761c2afd0da7ccab85b95f8be2ff0d1da40fdc2948745dce584317db41c745734827e7e4567b809
7
+ data.tar.gz: 2e72b7c4523afe01315125b4a3031b71052587a5b8034429b6bd34ea08101812160a1bbae7f6495bb4d75558dccd397292ed2bfbeae3770d614221700994c564
@@ -21,6 +21,14 @@ class WorkLogController
21
21
  WorkLogFileDao.new.delete(id)
22
22
  end
23
23
 
24
+ def find_by_month_and_year(month, year)
25
+ WorkLogFileDao.new.find_by_month_and_year(month, year)
26
+ end
27
+
28
+ def find_by_year(year)
29
+ WorkLogFileDao.new.find_by_year(year)
30
+ end
31
+
24
32
  private
25
33
 
26
34
  def create_work_log(date, description)
@@ -39,4 +39,24 @@ class WorkLogFileDao
39
39
  store.delete(id)
40
40
  end
41
41
  end
42
+
43
+ def find_by_month_and_year(month, year)
44
+ store = PStore.new(FULL_DB_FILE_PATH)
45
+ list = []
46
+ store.transaction(true) do
47
+ store.roots
48
+ .map { |root| list << store[root] if store[root].date.month == month && store[root].date.year == year }
49
+ end
50
+ list
51
+ end
52
+
53
+ def find_by_year(year)
54
+ store = PStore.new(FULL_DB_FILE_PATH)
55
+ list = []
56
+ store.transaction(true) do
57
+ store.roots
58
+ .map { |root| list << store[root] if store[root].date.year == year }
59
+ end
60
+ list
61
+ end
42
62
  end
data/lib/worklog_cli.rb CHANGED
@@ -16,10 +16,39 @@ class WorkLogCli < Thor
16
16
  end
17
17
  end
18
18
 
19
- desc 'list [DATE]', "prints work logs limited by DATE. Use 'today' or leave it empty for current day. Date format #{DATE_FORMAT}"
19
+ desc 'list', "Prints work logs for the current date. Date format #{DATE_FORMAT}"
20
+ long_desc <<-LONGDESC
21
+ Prints work logs for the current date if no option specified.
22
+
23
+ Availble options:
20
24
 
25
+ With -m option, prints all the work logs for the specified month, assumes the current year
26
+
27
+ With -m and -y options, prints all the work logs for the specified month and year
28
+
29
+ With -y option, prints all the work logs for the specified year
30
+
31
+ Usage examples:
32
+
33
+ `myworklog -m 2` Will print all the work logs logged in Februrary of the current year
34
+
35
+ `myworklog -m 2 -y 2019` Will print all the work logs logged in Februrary of 2019
36
+
37
+ `myworklog -y 2020` Will print all the work logs logged in 2020
38
+
39
+ LONGDESC
40
+ options :m => :numeric
41
+ options :y => :numeric
21
42
  def list(date='')
22
- print(WorkLogController.new.list(date))
43
+ if options[:m] && options[:y]
44
+ print(WorkLogController.new.find_by_month_and_year(options[:m], options[:y]))
45
+ elsif options[:m] && options[:y] == nil
46
+ print(WorkLogController.new.find_by_month_and_year(options[:m], Date.today.year))
47
+ elsif options[:m] == nil && options[:y]
48
+ print(WorkLogController.new.find_by_year(options[:y]))
49
+ else
50
+ print(WorkLogController.new.list(date))
51
+ end
23
52
  end
24
53
 
25
54
  desc 'list_all', "prints all the work logs"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myworklog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gyowanny Queiroz