herodot 0.1.7 → 0.1.8
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/.travis.yml +1 -0
- data/README.md +7 -0
- data/lib/herodot.rb +6 -3
- data/lib/herodot/commands.rb +2 -2
- data/lib/herodot/{table.rb → output.rb} +15 -2
- data/lib/herodot/parser.rb +11 -5
- data/lib/herodot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29a451b50c5b14cc6e2f1acf802439ce7755932f
|
4
|
+
data.tar.gz: 510e67c25f443cfe889fc5f8b754d3c519dd0b42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3040f3a6f6f29870e5a7f0ceb4993f644919be1e81774b6822a51d7187dd829510763a159bc9096c28390bc51960c1c2e021cbb3ee46922753cabb1251a9270
|
7
|
+
data.tar.gz: 76cd7068583335589940f231424fefe727439cea68073e46bf49961a1bb35259e34da07483666fe4a2ca0e5faf82ffe38726f025d31d354942a8eb3ce24087fa
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Herodot
|
2
2
|
|
3
|
+
[](https://travis-ci.org/bitcrowd/herodot)
|
4
|
+
|
3
5
|
Tracks your work based on git branch checkouts and commits. With herodot every time you switch branches or commit into a branch,
|
4
6
|
the brach name, time and project is logged into a worklog file. Herodot can then parse that worklog file and show you a *rough
|
5
7
|
estimate* on which branch in which folder you worked on and how long. This can aid you with your personal time tracking.
|
@@ -35,6 +37,11 @@ Show worklogs from 19-12-2016
|
|
35
37
|
|
36
38
|
Herodot uses Chronic (https://github.com/mojombo/chronic) under the hood so you can enter anything that chronic supports.
|
37
39
|
|
40
|
+
Instead of a terminal table you can also output into the `json` format:
|
41
|
+
|
42
|
+
$ herodot show -f json
|
43
|
+
$ herodot show -f json last week
|
44
|
+
$ herodot show --format json last week
|
38
45
|
|
39
46
|
Show Help:
|
40
47
|
|
data/lib/herodot.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative 'herodot/configuration'
|
|
5
5
|
require_relative 'herodot/worklog'
|
6
6
|
require_relative 'herodot/parser'
|
7
7
|
require_relative 'herodot/commands'
|
8
|
-
require_relative 'herodot/
|
8
|
+
require_relative 'herodot/output'
|
9
9
|
|
10
10
|
class Herodot::Application
|
11
11
|
include Commander::Methods
|
@@ -45,9 +45,10 @@ class Herodot::Application
|
|
45
45
|
c.syntax = 'herodot show [<time range>]'
|
46
46
|
c.summary = 'Shows worklogs'
|
47
47
|
c.description = SHOW_DESCRIPTION
|
48
|
+
c.option '--format FORMAT', String, 'Uses specific output format (Supported: json)'
|
48
49
|
show_command_examples(c)
|
49
|
-
c.action do |args,
|
50
|
-
Herodot::Commands.show(args, config)
|
50
|
+
c.action do |args, options|
|
51
|
+
Herodot::Commands.show(args, config, options)
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
@@ -57,5 +58,7 @@ class Herodot::Application
|
|
57
58
|
c.example 'Shows last weeks worklogs', 'herodot show last week'
|
58
59
|
c.example 'Shows worklogs for last monday', 'herodot show monday'
|
59
60
|
c.example 'Shows worklogs for 12-12-2016', 'herodot show 12-12-2016'
|
61
|
+
c.example 'Shows last weeks worklogs as json', 'herodot show --format json last week'
|
62
|
+
c.example 'Shows last weeks worklogs as json (short)', 'herodot show -f json last week'
|
60
63
|
end
|
61
64
|
end
|
data/lib/herodot/commands.rb
CHANGED
@@ -9,12 +9,12 @@ class Herodot::Commands
|
|
9
9
|
'echo "$(date);$project;$branch" >> ~/worklog'.freeze
|
10
10
|
DEFAULT_RANGE = 'this week'.freeze
|
11
11
|
|
12
|
-
def self.show(args, config)
|
12
|
+
def self.show(args, config, opts = {})
|
13
13
|
subject = args.empty? ? DEFAULT_RANGE : args.join(' ')
|
14
14
|
range = Chronic.parse(subject, guess: false, context: :past)
|
15
15
|
abort "Date not parsable: #{args.join(' ')}" unless range
|
16
16
|
worklog = Herodot::Parser.parse(range, config)
|
17
|
-
output = Herodot::
|
17
|
+
output = Herodot::Output.print(worklog.totals, opts)
|
18
18
|
puts output
|
19
19
|
end
|
20
20
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'terminal-table'
|
2
|
+
require 'json'
|
2
3
|
|
3
|
-
class Herodot::
|
4
|
+
class Herodot::Output
|
4
5
|
HEADERS = %w(Project Branch Time).freeze
|
5
6
|
EMPTY_WORKLOG_MESSAGE = Rainbow('Not enough entries in the worklog.').red +
|
6
7
|
' On a tracked repository `git checkout`'\
|
@@ -16,7 +17,19 @@ class Herodot::Table
|
|
16
17
|
"#{hours}:#{minutes.to_s.rjust(2, '0')}:#{seconds.to_s.rjust(2, '0')}"
|
17
18
|
end
|
18
19
|
|
19
|
-
def print(worklogs_totals_per_day)
|
20
|
+
def print(worklogs_totals_per_day, opts)
|
21
|
+
return convert_format(worklogs_totals_per_day, opts.format) if opts.format
|
22
|
+
print_table(worklogs_totals_per_day)
|
23
|
+
end
|
24
|
+
|
25
|
+
def convert_format(worklogs_totals_per_day, format)
|
26
|
+
case format
|
27
|
+
when 'json'
|
28
|
+
worklogs_totals_per_day.to_json
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def print_table(worklogs_totals_per_day)
|
20
33
|
abort EMPTY_WORKLOG_MESSAGE if worklogs_totals_per_day.empty?
|
21
34
|
Terminal::Table.new(headings: HEADERS) do |table|
|
22
35
|
worklogs_totals_per_day.each do |date, times|
|
data/lib/herodot/parser.rb
CHANGED
@@ -8,11 +8,7 @@ class Herodot::Parser
|
|
8
8
|
def parse(range, config)
|
9
9
|
worklog = Herodot::Worklog.new(config)
|
10
10
|
from, to = from_to_from_range(range)
|
11
|
-
|
12
|
-
next if row[2] == 'HEAD'
|
13
|
-
time = Time.parse(row[0])
|
14
|
-
worklog.add_entry(time, row[1], row[2]) if time >= from && time <= to
|
15
|
-
end
|
11
|
+
parse_into_worklog(worklog, config.worklog_file, from, to)
|
16
12
|
worklog
|
17
13
|
rescue Errno::ENOENT
|
18
14
|
abort NO_SUCH_FILE
|
@@ -22,5 +18,15 @@ class Herodot::Parser
|
|
22
18
|
return [range, Time.now] unless range.respond_to?(:begin) && range.respond_to?(:end)
|
23
19
|
[range.begin, range.end + 3600]
|
24
20
|
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def parse_into_worklog(worklog, file, from, to)
|
25
|
+
CSV.foreach(file, col_sep: ';') do |row|
|
26
|
+
next if row[2] == 'HEAD'
|
27
|
+
time = Time.parse(row[0])
|
28
|
+
worklog.add_entry(time, row[1], row[2]) if time >= from && time <= to
|
29
|
+
end
|
30
|
+
end
|
25
31
|
end
|
26
32
|
end
|
data/lib/herodot/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: herodot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bitcrowd
|
@@ -174,8 +174,8 @@ files:
|
|
174
174
|
- lib/herodot.rb
|
175
175
|
- lib/herodot/commands.rb
|
176
176
|
- lib/herodot/configuration.rb
|
177
|
+
- lib/herodot/output.rb
|
177
178
|
- lib/herodot/parser.rb
|
178
|
-
- lib/herodot/table.rb
|
179
179
|
- lib/herodot/version.rb
|
180
180
|
- lib/herodot/worklog.rb
|
181
181
|
- post-checkout
|