punched 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/punched +13 -4
- data/lib/punchcard.rb +7 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c11e735e75e510009cdd02e3966362587174661a
|
4
|
+
data.tar.gz: 73395dc375aced17abbaad5698b26eb384ad3675
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ab915be0d34843bb5a588b49b88e9921ebfc21892d6bb3ab5350a1ce7f382935bff00393493956f049b434b507a5c59f722f6c61ef53d73a0cf175ba100e288
|
7
|
+
data.tar.gz: 51a5575c46bd9cc2e7e731de35fd0bdfdcf5408aa08c5108dafa3503791e553f05effa61da3c986aa776f2a6d95d46ed107eeedddc95ad52cc66722206c4caaa
|
data/bin/punched
CHANGED
@@ -24,10 +24,19 @@ def usage
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def all action
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
require 'csv'
|
28
|
+
require 'date'
|
29
|
+
puts ["project","status","last active on","total duration","hourly rate","earnings"].to_csv if action == 'csv'
|
30
|
+
puts Dir[PunchCard::SETTINGS_DIR+'/*'].map { |file|
|
31
|
+
data = CSV.parse(`ruby #{__FILE__} #{action} '#{File.basename(file)}'`).first
|
32
|
+
last_activity = !data[2].empty? ? DateTime.parse(data[2]).to_time.to_i : 0
|
33
|
+
data.push(last_activity)
|
34
|
+
data
|
35
|
+
}.sort { |a, b|
|
36
|
+
a.last <=> b.last
|
37
|
+
}.reverse.map { |row|
|
38
|
+
row[0...-1]
|
39
|
+
}.map(&:to_csv).join
|
31
40
|
end
|
32
41
|
|
33
42
|
if ARGV.first == 'all'
|
data/lib/punchcard.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
# (c) 2017 by philipp staender
|
1
|
+
# (c) 2017-2018 by philipp staender
|
2
|
+
|
3
|
+
require 'date'
|
2
4
|
|
3
5
|
class PunchCardError < StandardError;
|
4
6
|
end
|
@@ -9,7 +11,7 @@ class PunchCard
|
|
9
11
|
HOURLY_RATE_PATTERN = /^\s*(\d+)([^\d]+)*\s*/i
|
10
12
|
TIME_POINT_PATTERN = /^(\d+)((\-)(\d+))*$/
|
11
13
|
META_KEY_PATTERN = /^([a-zA-Z0-9]+)\:\s*(.*)$/
|
12
|
-
VERSION = '0.
|
14
|
+
VERSION = '0.2.0'
|
13
15
|
|
14
16
|
attr_accessor :project
|
15
17
|
|
@@ -87,18 +89,20 @@ class PunchCard
|
|
87
89
|
project_exists_or_stop!
|
88
90
|
find_or_make_file
|
89
91
|
durations = []
|
92
|
+
last_activity = nil
|
90
93
|
project_data.map do |line|
|
91
94
|
points = line_to_time_points(line)
|
92
95
|
if points
|
93
96
|
starttime = points[0]
|
94
97
|
endtime = points[1] || timestamp
|
98
|
+
last_activity = points[1] || points[0]
|
95
99
|
durations.push duration(starttime, endtime)
|
96
100
|
end
|
97
101
|
end
|
98
102
|
'"'+[
|
99
103
|
@project,
|
100
104
|
running_status,
|
101
|
-
self.class.format_time(
|
105
|
+
last_activity ? self.class.format_time(Time.at(last_activity).to_datetime) : '',
|
102
106
|
humanized_total,
|
103
107
|
hourly_rate ? hourly_rate[:hourlyRate].to_s + " #{hourly_rate[:currency]}" : '',
|
104
108
|
hourly_rate ? (hourly_rate[:hourlyRate] * total / 3600.0).round(2).to_s + " #{hourly_rate[:currency]}" : '',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: punched
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipp Staender
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Minimal time tracking tool for cli
|
14
14
|
email:
|
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
47
|
version: '0'
|
48
48
|
requirements: []
|
49
49
|
rubyforge_project: punched
|
50
|
-
rubygems_version: 2.
|
50
|
+
rubygems_version: 2.5.2
|
51
51
|
signing_key:
|
52
52
|
specification_version: 4
|
53
53
|
summary: Punchcard Timetracker
|