worklog 0.1.0 → 0.1.1
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +35 -7
- data/TODO.md +30 -0
- data/lib/worklog/decorator.rb +3 -4
- data/lib/worklog/dsl.rb +5 -0
- data/lib/worklog/entities/sheet.rb +16 -2
- data/lib/worklog/printer.rb +27 -4
- data/lib/worklog/services.rb +2 -2
- data/lib/worklog/services/{get_timelogs.rb → get_worklogs.rb} +0 -0
- data/lib/worklog/services/{new_timelog.rb → new_worklog.rb} +0 -0
- data/lib/worklog/version.rb +1 -1
- data/user stories.md +82 -0
- data/worklog.worklog +11 -0
- metadata +7 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f86fec2e2f6cb64723a6604d08a027bfbe953d39426007acbd9a3ed9581b2b09
|
|
4
|
+
data.tar.gz: 1999d9aa0ea423938ba9492f81ee21585236e69c839f2ee8eb10ff14b19920c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: babe7127b8d55f996b67711b80f095e90dd7b9bf05f211370a709b046439da00dc7140d9944617e866f47b0d2d94cf83f88c7ed49945fd62bc7475d76d4285fd
|
|
7
|
+
data.tar.gz: '092b877a042ac156d33dd7c0320e1c09b63f441218d610825ff833eaae2cc3cd2d0f66d5cc856a7c1c91d02aa6d980447eab10c919077ad62fd51cebef884a6d'
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
# Worklog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/nvoynov/worklog/actions/workflows/main.yml)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Welcome to the `worklog` gem! The gem provides a simple domain-specific language (DSL) for tracking work time and a command-line interface (CLI) for processing the time spent. It'll answer some basic questions like "how much time I've spent on this project this month?", "how much I've earned the previous week?", "how much total effort for the subject was", etc.
|
|
6
|
+
|
|
7
|
+
Hopefully, this set of [User Stories](user stories.md) helps you catch the basic idea, and the following sections of the README will clarify the usage details.
|
|
6
8
|
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
Just install it yourself as:
|
|
12
|
+
|
|
13
|
+
$ gem install worklog
|
|
14
|
+
|
|
15
|
+
Or you can (now I cannot see meaning doing that, but you certainly can) add this line to your application's Gemfile:
|
|
10
16
|
|
|
11
17
|
```ruby
|
|
12
18
|
gem 'worklog'
|
|
@@ -16,13 +22,35 @@ And then execute:
|
|
|
16
22
|
|
|
17
23
|
$ bundle install
|
|
18
24
|
|
|
19
|
-
|
|
25
|
+
## Usage
|
|
20
26
|
|
|
21
|
-
|
|
27
|
+
### Worklog CLI
|
|
22
28
|
|
|
23
|
-
|
|
29
|
+
The `worklog` gem command-line interface is build on [Thor](https://github.com/rails/thor), so that your first command should be `worklog help` or `thor list`. Then you can get help for each command individually through `worklog help COMMAND`.
|
|
30
|
+
|
|
31
|
+
### Worklog DSL
|
|
32
|
+
|
|
33
|
+
The following example shows all the DSL possibilities:
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
require 'worklog'
|
|
37
|
+
|
|
38
|
+
sheet = Woklog::DSL.build do
|
|
39
|
+
title "worklog"
|
|
40
|
+
author "nvoynov"
|
|
41
|
+
date_format "%Y-%m-%d" # @see Ruby documentations of Date.strptime
|
|
42
|
+
hourly_rate 20.00
|
|
43
|
+
|
|
44
|
+
track "2021-05-22", spent: "6h30m", task: "working on use cases"
|
|
45
|
+
track "2021-05-21", spent: "2h", task: "working on user stories", rate: 30 # this is an special hourly rate for overtime
|
|
46
|
+
track "2021-05-21", spent: "8h", task: "working on user stories"
|
|
47
|
+
track "2021-05-20", spent: "8h", task: "working on vision document"
|
|
48
|
+
end
|
|
49
|
+
sheet.spent
|
|
50
|
+
sheet.reward
|
|
51
|
+
```
|
|
24
52
|
|
|
25
|
-
|
|
53
|
+
I think to make a more serious example (sandbox) with which you can play around and see the commands in action. __TODO__ provide a complex example with multiple subjects and authors, several months of log, etc.
|
|
26
54
|
|
|
27
55
|
## Development
|
|
28
56
|
|
data/TODO.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
% TODO
|
|
2
|
+
|
|
3
|
+
0. Error handling during parsing files, stop on errors
|
|
4
|
+
1. Check if date_format parameter is valid (Date.strptime)
|
|
5
|
+
2. Rethink commands ...
|
|
6
|
+
* many subjects and authors possible or not?
|
|
7
|
+
|
|
8
|
+
I'm a team member and work for several projects in the same period of time
|
|
9
|
+
|
|
10
|
+
I'm a manager and manage one or more teams, and I want to have effort calculated. There are worklogs for all team member in a project. And I want o calculate ...
|
|
11
|
+
|
|
12
|
+
Every I can be involved in several projects
|
|
13
|
+
|
|
14
|
+
# What is there?
|
|
15
|
+
|
|
16
|
+
There is a set of employees who work for set of projects and fill down worklog for each project separately. Each employee can work for several projects for certain period of time. Each project can involve several team members.
|
|
17
|
+
|
|
18
|
+
When all worklog loaded - many files, projects, team members ... Now it combined by one project, but there can also be different authors, to that one separate worklog of one author must be combined by (title, author)
|
|
19
|
+
|
|
20
|
+
... and full report must have
|
|
21
|
+
|
|
22
|
+
* title,
|
|
23
|
+
* author,
|
|
24
|
+
* date,
|
|
25
|
+
* year
|
|
26
|
+
* month
|
|
27
|
+
* week
|
|
28
|
+
* rate,
|
|
29
|
+
* spent,
|
|
30
|
+
* task
|
data/lib/worklog/decorator.rb
CHANGED
|
@@ -31,7 +31,6 @@ module Worklog
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# TODO: this year, previous year?
|
|
34
|
-
|
|
35
34
|
def this_month
|
|
36
35
|
tracks(-> (x,_) { x >= start_of_month(Date.today) })
|
|
37
36
|
end
|
|
@@ -45,15 +44,15 @@ module Worklog
|
|
|
45
44
|
# FIXME: incorrect for sunday 1
|
|
46
45
|
def this_week
|
|
47
46
|
today = Date.today
|
|
48
|
-
from = today - today.wday
|
|
47
|
+
from = today - (today.wday - 1) % 7
|
|
49
48
|
tracks(-> (x,_) { x >= from })
|
|
50
49
|
end
|
|
51
50
|
|
|
52
51
|
# FIXME: incorrect for sunday 1
|
|
53
52
|
def prev_week
|
|
54
53
|
today = Date.today
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
from = today - 7 - (today.wday - 1) % 7
|
|
55
|
+
till = from + 6
|
|
57
56
|
tracks(-> (x,_) { x >= from && x <= till })
|
|
58
57
|
end
|
|
59
58
|
|
data/lib/worklog/dsl.rb
CHANGED
|
@@ -41,6 +41,10 @@ module Worklog
|
|
|
41
41
|
@sheet.title = title
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
+
def author(author)
|
|
45
|
+
@sheet.author = author
|
|
46
|
+
end
|
|
47
|
+
|
|
44
48
|
def date_format(fmt)
|
|
45
49
|
@sheet.date_format = fmt
|
|
46
50
|
end
|
|
@@ -49,6 +53,7 @@ module Worklog
|
|
|
49
53
|
@sheet.hourly_rate = rate
|
|
50
54
|
end
|
|
51
55
|
|
|
56
|
+
# TODO: error handling
|
|
52
57
|
def read(text)
|
|
53
58
|
instance_eval text
|
|
54
59
|
end
|
|
@@ -10,17 +10,19 @@ module Worklog
|
|
|
10
10
|
# This class represent sheet of tracks collection
|
|
11
11
|
class Sheet
|
|
12
12
|
attr_reader :tracks
|
|
13
|
+
attr_accessor :title
|
|
14
|
+
attr_accessor :author
|
|
13
15
|
attr_accessor :source
|
|
14
16
|
attr_accessor :date_format
|
|
15
17
|
attr_accessor :hourly_rate
|
|
16
|
-
attr_accessor :title
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
def initialize
|
|
20
21
|
@tracks = {}
|
|
21
22
|
@date_format = "%Y-%m-%d"
|
|
22
23
|
@hourly_rate = 0
|
|
23
|
-
@title =
|
|
24
|
+
@title = "Unspecified"
|
|
25
|
+
@author = "Unspecified"
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
# This method adds new track to the sheet
|
|
@@ -60,6 +62,18 @@ module Worklog
|
|
|
60
62
|
end
|
|
61
63
|
end
|
|
62
64
|
|
|
65
|
+
def spent
|
|
66
|
+
@tracks.inject(0) {|sum, (d, t)|
|
|
67
|
+
sum + t.map(&:spent).inject(:+)
|
|
68
|
+
}
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def reward
|
|
72
|
+
@tracks.inject(0) {|sum, (d, t)|
|
|
73
|
+
sum + t.map(&:reward).inject(:+)
|
|
74
|
+
}
|
|
75
|
+
end
|
|
76
|
+
|
|
63
77
|
end
|
|
64
78
|
end
|
|
65
79
|
end
|
data/lib/worklog/printer.rb
CHANGED
|
@@ -10,9 +10,12 @@ module Worklog
|
|
|
10
10
|
super
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
# TODO: header for this/prev month/week
|
|
14
|
-
# TODO: grouping by months if there are more than one
|
|
15
13
|
def print(report, subtitle = "")
|
|
14
|
+
# TODO: provide spec for "no traks found"
|
|
15
|
+
if report[:items].empty?
|
|
16
|
+
puts "No tracks found"
|
|
17
|
+
return
|
|
18
|
+
end
|
|
16
19
|
puts "-= #{report[:title]} #{subtitle} =-"
|
|
17
20
|
puts %w(Date Year Month Week Spent Reward Task).join(?\t)
|
|
18
21
|
report[:items].each do |track|
|
|
@@ -46,11 +49,31 @@ module Worklog
|
|
|
46
49
|
print(super(), subtitle)
|
|
47
50
|
end
|
|
48
51
|
|
|
49
|
-
def this_week
|
|
50
|
-
|
|
52
|
+
def this_week
|
|
53
|
+
subtitle = this_week_title
|
|
54
|
+
print(super(), subtitle)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def prev_week
|
|
58
|
+
subtitle = prev_week_title
|
|
59
|
+
print(super(), subtitle)
|
|
60
|
+
end
|
|
51
61
|
|
|
52
62
|
protected
|
|
53
63
|
|
|
64
|
+
def this_week_title
|
|
65
|
+
today = Date.today
|
|
66
|
+
from = today - (today.wday - 1) % 7
|
|
67
|
+
"from #{from} till #{today}"
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def prev_week_title
|
|
71
|
+
today = Date.today
|
|
72
|
+
from = today - 7 - (today.wday - 1) % 7
|
|
73
|
+
till = from + 6
|
|
74
|
+
"from #{from} till #{till}"
|
|
75
|
+
end
|
|
76
|
+
|
|
54
77
|
def format_spent(spent)
|
|
55
78
|
h = spent / 60
|
|
56
79
|
m = spent % 60
|
data/lib/worklog/services.rb
CHANGED
|
File without changes
|
|
File without changes
|
data/lib/worklog/version.rb
CHANGED
data/user stories.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
% Worklog User Stories
|
|
2
|
+
|
|
3
|
+
# Creating worklog
|
|
4
|
+
|
|
5
|
+
As a User, at any time, I want to create a worklog for any subject, so that I'll have the time spent for the subject recoded.
|
|
6
|
+
|
|
7
|
+
Main success scenario
|
|
8
|
+
|
|
9
|
+
1. The user starts the command-line interface, requests the `new` command, and provides `title` and `author` parameters of the new worklog (`worklog new [SUBJECT] [AUTHOR]`).
|
|
10
|
+
2. The system creates worklog file with provided parameters in the working directory.
|
|
11
|
+
|
|
12
|
+
The new worklog file content
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
title "Worklog"
|
|
16
|
+
author "nvoynov"
|
|
17
|
+
date_format "%Y-%m-%d"
|
|
18
|
+
hourly_rate 20
|
|
19
|
+
|
|
20
|
+
track "2021-07-16", spent: "1h", desc: "creating worklog"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
# Logging time
|
|
24
|
+
|
|
25
|
+
As a User, at any time, I want to record time spent on my tasks, so that I'll have all my efforts recorded. I want to have written down the day, time spent, and task description.
|
|
26
|
+
|
|
27
|
+
## DSL
|
|
28
|
+
|
|
29
|
+
I want to record day logged time by adding appropriate text to my worklog. I think it will be convenient enough write straight into the file without any functions from the system side.
|
|
30
|
+
|
|
31
|
+
## Special hourly rate
|
|
32
|
+
|
|
33
|
+
I want to have the ability to specify the special hourly rate when I work overtime.
|
|
34
|
+
|
|
35
|
+
## Multiple tracks per day
|
|
36
|
+
|
|
37
|
+
I want to have the ability to log several record for one day and by different hourly rates. It must be calculated together by unique date in reporting and combine work descriptions.
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
on "2021-07-16", spent: "4h30m", desc: "working on user stories"
|
|
41
|
+
on "2021-07-16", spent: "2h30m", desc: "working on crawling use case"
|
|
42
|
+
on "2021-07-16", spent: "2h30m", desc: "working on crawling use case", special_rate: 30
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Multiple files per subject
|
|
46
|
+
|
|
47
|
+
I want to have several worklogs for single subject, so that I can keep worklog by months
|
|
48
|
+
|
|
49
|
+
# Getting report
|
|
50
|
+
|
|
51
|
+
As a User, at any time, I want to get reports based on worklogs, so that I can check my total hours and provide reports for my employer or customers.
|
|
52
|
+
|
|
53
|
+
## Base report
|
|
54
|
+
|
|
55
|
+
I want to have a verbose report at the beginning that will have such
|
|
56
|
+
|
|
57
|
+
## Specifying time period
|
|
58
|
+
|
|
59
|
+
When I request the report, I want to specify a period of time for the report in some convenient for me manner like "this week", "this month", "pervious month", etc. I want to have "this month" period by default.
|
|
60
|
+
|
|
61
|
+
## Specifying subject
|
|
62
|
+
|
|
63
|
+
When I work for several projects, I want to request the report for all subjects, or for chosen subject.
|
|
64
|
+
|
|
65
|
+
```markdown
|
|
66
|
+
% Nikolay's timesheet for November 2021
|
|
67
|
+
|
|
68
|
+
Project | Date | Hours | Rate | Description
|
|
69
|
+
------- | ---------- | ------ | ---- | -----------
|
|
70
|
+
Audit | 2021-07-16 | 6h 30m | 20 | working on user stories
|
|
71
|
+
Audit | 2021-07-17 | 8h 00m | 20 | working on user stories
|
|
72
|
+
|
|
73
|
+
Total: 14h 30m, $290
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Grouping and subtotals
|
|
77
|
+
|
|
78
|
+
When I request a report, I want to have the ability to specify data grouping
|
|
79
|
+
|
|
80
|
+
# Exporting reports
|
|
81
|
+
|
|
82
|
+
As a User, at any time, I want to export requested reports in a file to send it through the Internet next, so that I can provide reports for my employer and customers. I want "txt" and "csv" formats to be supported.
|
data/worklog.worklog
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# self promoting worklog example ;)
|
|
2
|
+
|
|
3
|
+
title "Worklog"
|
|
4
|
+
author "nvoynov"
|
|
5
|
+
date_format "%Y-%m-%d" # @see Ruby documentations of Date.strptime
|
|
6
|
+
hourly_rate 0
|
|
7
|
+
|
|
8
|
+
track "2021-07-25", spent: "3h", task: "fixed decorator.prev_week"
|
|
9
|
+
track "2021-07-25", spent: "1h", task: "added user stories and improved README"
|
|
10
|
+
track "2021-07-24", spent: "4h", task: "worklog instead of timelog; released v0.1.0"
|
|
11
|
+
track "2021-07-23", spent: "2h", task: "timelog instead of timesheet"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: worklog
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nikolay Voynov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-07
|
|
11
|
+
date: 2021-08-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -43,6 +43,7 @@ files:
|
|
|
43
43
|
- LICENSE.txt
|
|
44
44
|
- README.md
|
|
45
45
|
- Rakefile
|
|
46
|
+
- TODO.md
|
|
46
47
|
- bin/console
|
|
47
48
|
- bin/setup
|
|
48
49
|
- exe/worklog
|
|
@@ -55,11 +56,13 @@ files:
|
|
|
55
56
|
- lib/worklog/entities/track.rb
|
|
56
57
|
- lib/worklog/printer.rb
|
|
57
58
|
- lib/worklog/services.rb
|
|
58
|
-
- lib/worklog/services/
|
|
59
|
-
- lib/worklog/services/
|
|
59
|
+
- lib/worklog/services/get_worklogs.rb
|
|
60
|
+
- lib/worklog/services/new_worklog.rb
|
|
60
61
|
- lib/worklog/services/service.rb
|
|
61
62
|
- lib/worklog/version.rb
|
|
63
|
+
- user stories.md
|
|
62
64
|
- worklog.gemspec
|
|
65
|
+
- worklog.worklog
|
|
63
66
|
homepage: https://github.com/nvoynov/worklog
|
|
64
67
|
licenses:
|
|
65
68
|
- MIT
|