time-sheet 0.15.0 → 1.0.0
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/lib/time_sheet/time/entry.rb +25 -3
- data/lib/time_sheet/time/parser.rb +13 -17
- data/lib/time_sheet/version.rb +1 -1
- data/time_sheet.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 461fe4226d6a5980fa168c7c918b01b35fb27aebef3110ff25d6d295709c6551
|
4
|
+
data.tar.gz: 830f66bef87e5925b117e32a2e82647736997381a07efe12a8e8151123e7d9cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b99531029582021e5eff7c47a1483e24ad6ceb86b0865c2abd7b6af0496225b9e0f222c958538f073553e6ce5b4e4fe36d8e9ec10d3d2ab9b7ed8e1b83523f7
|
7
|
+
data.tar.gz: 358e04d3c9f16416d451d192ed5ad2a94545ef135250ecb3836ce75d5f551b3295e65b1d44b3a36f9b71ab95386acd466e866e2c27457e61c8ed4b853d311ad5
|
@@ -28,7 +28,8 @@ class TimeSheet::Time::Entry
|
|
28
28
|
def start
|
29
29
|
@start ||= Time.mktime(
|
30
30
|
date.year, date.month, date.day,
|
31
|
-
@data['start']
|
31
|
+
hour_for(@data['start']),
|
32
|
+
minute_for(@data['start'])
|
32
33
|
)
|
33
34
|
end
|
34
35
|
|
@@ -37,10 +38,31 @@ class TimeSheet::Time::Entry
|
|
37
38
|
|
38
39
|
@end ||= Time.mktime(
|
39
40
|
date.year, date.month, date.day,
|
40
|
-
ends_at
|
41
|
+
hour_for(ends_at),
|
42
|
+
minute_for(ends_at)
|
41
43
|
)
|
42
44
|
end
|
43
45
|
|
46
|
+
def hour_for(timish)
|
47
|
+
case timish
|
48
|
+
when Time then timish.hour
|
49
|
+
when DateTime then timish.hour
|
50
|
+
when Integer then timish / 60 / 60
|
51
|
+
else
|
52
|
+
binding.pry
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def minute_for(timish)
|
57
|
+
case timish
|
58
|
+
when Time then timish.min
|
59
|
+
when DateTime then timish.min
|
60
|
+
when Integer then timish / 60 % 60
|
61
|
+
else
|
62
|
+
binding.pry
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
44
66
|
def employee
|
45
67
|
@employee ||= @data['employee'] || (self.prev ? self.prev.employee : 'Me')
|
46
68
|
end
|
@@ -121,7 +143,7 @@ class TimeSheet::Time::Entry
|
|
121
143
|
self.exception = e
|
122
144
|
false
|
123
145
|
rescue StandardError => e
|
124
|
-
binding.pry if
|
146
|
+
binding.pry if TimeSheet.options[:debug]
|
125
147
|
false
|
126
148
|
end
|
127
149
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'roo'
|
2
2
|
require 'httpclient'
|
3
3
|
require 'csv'
|
4
4
|
|
@@ -12,7 +12,7 @@ class TimeSheet::Time::Parser
|
|
12
12
|
results = []
|
13
13
|
@dirs.each do |dir|
|
14
14
|
if File.directory?(dir)
|
15
|
-
results += Dir["#{dir}/**/*.
|
15
|
+
results += Dir["#{dir}/**/*.xlsx"]
|
16
16
|
else
|
17
17
|
results << dir
|
18
18
|
end
|
@@ -38,7 +38,6 @@ class TimeSheet::Time::Parser
|
|
38
38
|
results.sort!
|
39
39
|
results.each do |r|
|
40
40
|
unless r.valid?
|
41
|
-
# byebug
|
42
41
|
raise r.exception, [
|
43
42
|
r.exception.message, ': ',
|
44
43
|
r.data.inspect,
|
@@ -57,28 +56,25 @@ class TimeSheet::Time::Parser
|
|
57
56
|
if f.match(/https:\/\/docs\.google\.com/)
|
58
57
|
parse_google_doc(f)
|
59
58
|
else
|
60
|
-
|
59
|
+
parse_xlsx(f)
|
61
60
|
end
|
62
61
|
end
|
63
62
|
end
|
64
63
|
end
|
65
64
|
|
66
|
-
def
|
65
|
+
def parse_xlsx(filename)
|
67
66
|
results = []
|
68
67
|
|
69
|
-
Spreadsheet.open(filename)
|
70
|
-
|
71
|
-
sheet.
|
72
|
-
|
73
|
-
# lines, perhaps:
|
74
|
-
# break if row[1].nil?
|
75
|
-
next if row.all?{|cell| [nil, ''].include?(cell)}
|
68
|
+
xlsx = Roo::Spreadsheet.open(filename)
|
69
|
+
xlsx.each_with_pagename do |name, sheet|
|
70
|
+
headers = sheet.row(1).to_h{|e| [e, e]}
|
71
|
+
rows = sheet.parse(headers)
|
76
72
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
results <<
|
73
|
+
rows.each do |row|
|
74
|
+
next unless row['start']
|
75
|
+
next if row.values.all?{|v| [nil, ''].include?(v)}
|
76
|
+
|
77
|
+
results << row
|
82
78
|
end
|
83
79
|
end
|
84
80
|
|
data/lib/time_sheet/version.rb
CHANGED
data/time_sheet.gemspec
CHANGED
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time-sheet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Moritz Schepp
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: roo
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|