txt_timesheet 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/Gemfile.lock +34 -0
- data/README.md +39 -19
- data/bin/timesheet +9 -0
- data/lib/txt_timesheet.rb +30 -30
- data/txt_timesheet.gemspec +3 -3
- metadata +9 -5
- data/.rspec +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23cbed616dd6723ce4a9f1e491c03fb42790b2a94a782280fd8a0457b3d7a479
|
4
|
+
data.tar.gz: 6745a0a0cc99c7eaf0b178dfd046e2d002276abc64d27d3568837996bd2b0537
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e02167b7c6d880e9eaf6b90f47233427a76e467697fdab0cf0ba6147a36509752806024643bb38d3370b079f9c050b31029de5d744ad9f0aaa0af34c547b1111
|
7
|
+
data.tar.gz: 96d82e5c55532ae8d78a073e7085a3a64dd321bb0cb4ad77b11dc622cdfd1a0adeda642cf399afbc24ee0e0a6a12813407fad7c5d35a28462474e426ebe996c2
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
txt_timesheet (1.1.3)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rake (12.3.2)
|
11
|
+
rspec (3.9.0)
|
12
|
+
rspec-core (~> 3.9.0)
|
13
|
+
rspec-expectations (~> 3.9.0)
|
14
|
+
rspec-mocks (~> 3.9.0)
|
15
|
+
rspec-core (3.9.0)
|
16
|
+
rspec-support (~> 3.9.0)
|
17
|
+
rspec-expectations (3.9.0)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.9.0)
|
20
|
+
rspec-mocks (3.9.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.9.0)
|
23
|
+
rspec-support (3.9.0)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
x64-mingw32
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
rake (~> 12.0)
|
30
|
+
rspec (~> 3.0)
|
31
|
+
txt_timesheet!
|
32
|
+
|
33
|
+
BUNDLED WITH
|
34
|
+
2.1.0.pre.2
|
data/README.md
CHANGED
@@ -9,40 +9,60 @@ Installation
|
|
9
9
|
------------
|
10
10
|
gem install txt_timesheet
|
11
11
|
|
12
|
-
How
|
12
|
+
How it works
|
13
13
|
------------
|
14
|
-
Create a file named timesheet.rb on your root folder.
|
15
14
|
|
16
|
-
|
15
|
+
Given 3 files like these
|
17
16
|
|
18
|
-
|
17
|
+
`file1.txt`:
|
19
18
|
|
20
|
-
$ mkdir assets
|
21
|
-
|
22
|
-
The root folder of your project should look like this:
|
23
|
-
|
24
|
-
$ ls
|
25
|
-
assets/ timesheet.rb
|
26
19
|
|
27
|
-
|
20
|
+
## Timesheet
|
28
21
|
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
morning: 09:13
|
23
|
+
brb lunch: 12:03
|
24
|
+
back: 13:56
|
25
|
+
leaving: 20:53
|
32
26
|
|
33
|
-
|
27
|
+
## What Happened?
|
28
|
+
|
29
|
+
|
30
|
+
`file2.txt`:
|
31
|
+
|
32
|
+
## Timesheet
|
33
|
+
|
34
|
+
morning: 09:59
|
35
|
+
brb lunch: 12:07
|
36
|
+
back: 13:40
|
37
|
+
brb: 18:41
|
38
|
+
back: 20:53
|
39
|
+
leaving: 22:53
|
34
40
|
|
35
|
-
|
41
|
+
## Daily report
|
36
42
|
|
37
|
-
|
43
|
+
Leaving:
|
38
44
|
|
39
|
-
|
45
|
+
`file3.txt`:
|
40
46
|
|
47
|
+
## Timesheet
|
48
|
+
|
49
|
+
morning: 09:45
|
50
|
+
brb lunch: 12:28
|
51
|
+
back: 13:31
|
52
|
+
brb: 18:07
|
53
|
+
back: 23:11
|
54
|
+
leaving: 23:11
|
41
55
|
|
56
|
+
## Daily report
|
57
|
+
|
58
|
+
Leaving:
|
59
|
+
- syncs with Flávia, and with Iago and Arthur
|
60
|
+
- started working on CRM side to create user with password in authenticator
|
42
61
|
|
62
|
+
|
43
63
|
Your output should be like this:
|
44
64
|
|
45
|
-
$ timesheet
|
65
|
+
$ timesheet file1.txt file2.txt file3.txt
|
46
66
|
|
47
67
|
REPORT:
|
48
68
|
file1.txt: 09:47 hours
|
data/bin/timesheet
ADDED
data/lib/txt_timesheet.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# Treat past files as a parameter and calculate total hours worked
|
4
4
|
class TxtTimesheet
|
5
5
|
def convert(par)
|
6
|
-
###
|
6
|
+
### Convert working time to hh:mm format
|
7
7
|
hours = par / 60
|
8
8
|
hours = hours.to_i
|
9
9
|
minutes = par - hours * 60
|
10
|
-
##
|
10
|
+
## Add 0 to keep hh: mm format
|
11
11
|
hours = "0#{hours}" if hours < 10
|
12
12
|
minutes = "0#{minutes}" if minutes < 10
|
13
13
|
|
@@ -21,18 +21,18 @@ class TxtTimesheet
|
|
21
21
|
total_time = 0
|
22
22
|
|
23
23
|
puts 'REPORT:'
|
24
|
-
####
|
24
|
+
#### Receive all files indicated on the command line
|
25
25
|
ARGV.each do |a|
|
26
26
|
sum_time = 0
|
27
|
-
|
27
|
+
index = 0
|
28
28
|
files = a
|
29
|
-
file =
|
29
|
+
file = a.to_s
|
30
30
|
content_file = File.open(file)
|
31
|
-
|
31
|
+
input_count = 0
|
32
32
|
time = []
|
33
|
-
|
33
|
+
time_in_min = []
|
34
34
|
|
35
|
-
###
|
35
|
+
### Read all lines from the input file to extract data
|
36
36
|
until content_file.eof?
|
37
37
|
line = content_file.gets.chomp
|
38
38
|
next unless time_regex.match(line)
|
@@ -40,39 +40,39 @@ class TxtTimesheet
|
|
40
40
|
hours = time_regex.match(line)[:hours]
|
41
41
|
minutes = time_regex.match(line)[:minutes]
|
42
42
|
time.push(hours + ':' + minutes)
|
43
|
-
|
43
|
+
index += 1
|
44
44
|
end
|
45
|
-
|
45
|
+
input_count = time.count - input_count # count records in each file
|
46
46
|
content_file.close
|
47
47
|
###
|
48
48
|
|
49
|
-
###
|
50
|
-
|
51
|
-
|
52
|
-
i_parse_int =
|
53
|
-
time.each do |
|
54
|
-
|
55
|
-
|
56
|
-
|
49
|
+
### iterates over string array and converts to integers
|
50
|
+
index = 0
|
51
|
+
integer = []
|
52
|
+
i_parse_int = input_count * 2
|
53
|
+
time.each do |entry_time|
|
54
|
+
entry_time = entry_time.split(':')
|
55
|
+
entry_time.each do |entry_time_to_integer|
|
56
|
+
integer.push(entry_time_to_integer.to_i)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
###
|
60
60
|
|
61
|
-
###
|
62
|
-
while
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
61
|
+
### Converts to minutes
|
62
|
+
while index < i_parse_int
|
63
|
+
time_to_min = integer[index]
|
64
|
+
time_to_min *= 60
|
65
|
+
time_to_min += integer[index + 1]
|
66
|
+
time_in_min.push(time_to_min)
|
67
|
+
index += 2
|
68
68
|
end
|
69
69
|
###
|
70
70
|
|
71
71
|
### Calcula o tempo trabalhado em minutos
|
72
|
-
|
73
|
-
while
|
74
|
-
sum_time =
|
75
|
-
|
72
|
+
index = 0
|
73
|
+
while index < input_count
|
74
|
+
sum_time = time_in_min[index + 1] - time_in_min[index] + sum_time
|
75
|
+
index += 2
|
76
76
|
end
|
77
77
|
###
|
78
78
|
|
data/txt_timesheet.gemspec
CHANGED
@@ -2,7 +2,7 @@ require_relative 'lib/txt_timesheet/version'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "txt_timesheet"
|
5
|
-
spec.version = "1.1.
|
5
|
+
spec.version = "1.1.4"
|
6
6
|
spec.authors = ["Elvis Serrão"]
|
7
7
|
spec.email = ["elvis.serrao1@gmail.com"]
|
8
8
|
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
20
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
21
|
end
|
22
|
-
spec.bindir = "
|
23
|
-
spec.executables = spec.files.grep(%r{^
|
22
|
+
spec.bindir = "bin"
|
23
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
end
|
metadata
CHANGED
@@ -1,32 +1,36 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: txt_timesheet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elvis Serrão
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Receive n files as command line parameters, parse these files and than,
|
14
14
|
calculates how many hours has been worked .
|
15
15
|
email:
|
16
16
|
- elvis.serrao1@gmail.com
|
17
|
-
executables:
|
17
|
+
executables:
|
18
|
+
- console
|
19
|
+
- setup
|
20
|
+
- timesheet
|
18
21
|
extensions: []
|
19
22
|
extra_rdoc_files: []
|
20
23
|
files:
|
21
24
|
- ".gitignore"
|
22
|
-
- ".rspec"
|
23
25
|
- ".travis.yml"
|
24
26
|
- Gemfile
|
27
|
+
- Gemfile.lock
|
25
28
|
- LICENSE.txt
|
26
29
|
- README.md
|
27
30
|
- Rakefile
|
28
31
|
- bin/console
|
29
32
|
- bin/setup
|
33
|
+
- bin/timesheet
|
30
34
|
- lib/txt_timesheet.rb
|
31
35
|
- lib/txt_timesheet/version.rb
|
32
36
|
- txt_timesheet.gemspec
|
data/.rspec
DELETED