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 +4 -4
- data/lib/work_log_controller.rb +8 -0
- data/lib/work_log_file_dao.rb +20 -0
- data/lib/worklog_cli.rb +31 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bdd92d2d822c08464ccc93918c903303973f5e1f958fc9ac166e483877338178
|
4
|
+
data.tar.gz: f49931374165a57565bbd2c3faba90194b1b7ac6ce4bdcb7afbbb4a3b42dc8ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65ceb6290ef9a952f1167f6dd5241d155a871945de1ef4784761c2afd0da7ccab85b95f8be2ff0d1da40fdc2948745dce584317db41c745734827e7e4567b809
|
7
|
+
data.tar.gz: 2e72b7c4523afe01315125b4a3031b71052587a5b8034429b6bd34ea08101812160a1bbae7f6495bb4d75558dccd397292ed2bfbeae3770d614221700994c564
|
data/lib/work_log_controller.rb
CHANGED
@@ -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)
|
data/lib/work_log_file_dao.rb
CHANGED
@@ -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
|
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
|
-
|
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"
|