herodot 0.1.5 → 0.1.6

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: e258c2416084f926cfba575ec00e7322687c5f27
4
- data.tar.gz: 2a1ca6076c7d932772890a9411db5ed6d193f56d
3
+ metadata.gz: ebfdde53fd5b240fd01329bb4d91789578a5ce6b
4
+ data.tar.gz: 3fc435c77a76fe726bf8f1966ca35e38f59f4d76
5
5
  SHA512:
6
- metadata.gz: 2503878d39d2b18a2c3aa537268e9e4a7649a9a440bc377017cb0e12c6a169f886d3d7fc91a87ef2e8058835f1081108ed97c02c93844b31747b696e27130434
7
- data.tar.gz: d58e61d8188be9404e7197243115cf28566874761e29f9bc0bdf38b822bb5f9e15754b256e467a55b9b1975cacae135525290c2c031c5733f0bd432a344ca5d0
6
+ metadata.gz: e94626888ca7b234b4f481b91fc8c3ed0b4f2b542fed6b78e21356bff2cf822de36b472d81294a729f8a2063243fa79650ab55b9bc81264839dcdb14f2213520
7
+ data.tar.gz: 924fe536287b0e56d69a038ef3dc8dac20561771a1e59b8bbc42dbd91ebf2c09b2785ef44620ea24f61b420c3e1fdf70db5ed9f7cd90f6a00766a5fa51e37950
data/herodot.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'rubocop'
29
29
  spec.add_development_dependency 'rubocop-rspec'
30
30
  spec.add_development_dependency 'rubocop-bitcrowd'
31
- spec.add_dependency 'pry'
31
+ spec.add_dependency 'rainbow'
32
32
  spec.add_dependency 'terminal-table'
33
33
  spec.add_dependency 'chronic'
34
34
  spec.add_dependency 'commander'
@@ -2,6 +2,9 @@ require 'csv'
2
2
  require 'pry'
3
3
 
4
4
  class Herodot::Parser
5
+ NO_SUCH_FILE = Rainbow('Worklog missing.').red +
6
+ ' Use `herodot track` to track a git repository'\
7
+ ' or `herodot help` to open the man page.'.freeze
5
8
  class << self
6
9
  def parse(range, config)
7
10
  worklog = Herodot::Worklog.new(config)
@@ -12,6 +15,8 @@ class Herodot::Parser
12
15
  worklog.add_entry(time, row[1], row[2]) if time >= from && time <= to
13
16
  end
14
17
  worklog
18
+ rescue Errno::ENOENT
19
+ abort NO_SUCH_FILE
15
20
  end
16
21
 
17
22
  def from_to_from_range(range)
data/lib/herodot/table.rb CHANGED
@@ -2,6 +2,10 @@ require 'terminal-table'
2
2
 
3
3
  class Herodot::Table
4
4
  HEADERS = %w(Project Branch Time).freeze
5
+ EMPTY_WORKLOG_MESSAGE = Rainbow('Not enough entries in the worklog.').red +
6
+ ' On a tracked repository `git checkouts`'\
7
+ ' and `git commits` will add entries.'.freeze
8
+ COLORS = %i(green yellow blue magenta cyan aqua silver aliceblue indianred).freeze
5
9
 
6
10
  class << self
7
11
  def format_time(time_is_seconds)
@@ -13,6 +17,7 @@ class Herodot::Table
13
17
  end
14
18
 
15
19
  def print(worklogs_totals_per_day)
20
+ abort EMPTY_WORKLOG_MESSAGE if worklogs_totals_per_day.empty?
16
21
  Terminal::Table.new(headings: HEADERS) do |table|
17
22
  worklogs_totals_per_day.each do |date, times|
18
23
  table.add_separator
@@ -26,10 +31,14 @@ class Herodot::Table
26
31
 
27
32
  private
28
33
 
34
+ def colorize(project)
35
+ Rainbow(project).color(COLORS[project.chars.map(&:ord).reduce(:+) % COLORS.size])
36
+ end
37
+
29
38
  def print_day(times)
30
39
  times.values.group_by { |log| log[:project] }.flat_map do |_, logs|
31
40
  logs.map do |log|
32
- [log[:project], log[:branch], format_time(log[:time])]
41
+ [colorize(log[:project]), log[:branch], format_time(log[:time])]
33
42
  end
34
43
  end
35
44
  end
@@ -1,3 +1,3 @@
1
1
  module Herodot
2
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.1.6'.freeze
3
3
  end
data/lib/herodot.rb CHANGED
@@ -1,11 +1,11 @@
1
- require 'bundler/setup'
1
+ require 'commander'
2
+ require 'rainbow'
2
3
  require_relative 'herodot/version'
3
4
  require_relative 'herodot/configuration'
4
5
  require_relative 'herodot/worklog'
5
6
  require_relative 'herodot/parser'
6
7
  require_relative 'herodot/commands'
7
8
  require_relative 'herodot/table'
8
- require 'commander'
9
9
 
10
10
  class Herodot::Application
11
11
  include Commander::Methods
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: herodot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - bitcrowd
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-06 00:00:00.000000000 Z
11
+ date: 2017-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: pry
98
+ name: rainbow
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="