txt_timesheet 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 95743e89d67929a47fd07a4528cc45af611e3f95a7e55338f24891e2059ca300
4
+ data.tar.gz: 998d7f114174749f8188d746fafc6ba42dc520371663cb0eb39889ddecbe9f84
5
+ SHA512:
6
+ metadata.gz: 5b959c7d965c086d305af56e9409987e47764b9d96f26e8673a3f0d62c0684b7d807b138a8228c9845d77ca526932b24623668344d9b30db04a21d19f5ecac6e
7
+ data.tar.gz: 80a6f3d97a514307d0668e6f59ccdb57cd13f998513795daa1c37500536bca260abd6f992743b5f70d3dd069de78cd7ae9b1ea2c0d2c0c6d805d183b1dd1ffc3
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+
2
+ .idea/
data/README.md ADDED
@@ -0,0 +1 @@
1
+ # txt-timesheet
data/assets/file1.txt ADDED
@@ -0,0 +1,8 @@
1
+ ## Timesheet
2
+
3
+ morning: 09:13
4
+ brb lunch: 12:03
5
+ back: 13:56
6
+ leaving: 20:53
7
+
8
+ ## What Happened?
data/assets/file2.txt ADDED
@@ -0,0 +1,12 @@
1
+ ## Timesheet
2
+
3
+ morning: 09:59
4
+ brb lunch: 12:07
5
+ back: 13:40
6
+ brb: 18:41
7
+ back: 20:53
8
+ leaving: 22:53
9
+
10
+ ## Daily report
11
+
12
+ Leaving:
data/assets/file3.txt ADDED
@@ -0,0 +1,14 @@
1
+ ## Timesheet
2
+
3
+ morning: 09:45
4
+ brb lunch: 12:28
5
+ back: 13:31
6
+ brb: 18:07
7
+ back: 23:11
8
+ leaving: 23:11
9
+
10
+ ## Daily report
11
+
12
+ Leaving:
13
+ - syncs with Flávia, and with Iago and Arthur
14
+ - started working on CRM side to create user with password in authenticator
@@ -0,0 +1,77 @@
1
+ time_regex = /(?<hours>\d{2})\:(?<minutes>\d{2})/
2
+
3
+ puts "REPORT:"
4
+ #### Percorre todos os arquivos na linha de comando
5
+ ARGV.each do|a|
6
+ sum_time = 0
7
+ i = 0
8
+ files = a
9
+ file = "../assets/#{a}"
10
+ content_file = File.open(file)
11
+ i_count = 0
12
+ time = []
13
+ time_to_min = []
14
+
15
+ ### Percorre todas as linhas do arquivo de entrada para extrair os horários no formato hh:mm
16
+ while ! content_file.eof?
17
+ line = content_file.gets.chomp
18
+ if time_regex.match(line)
19
+ hours = time_regex.match(line)[:hours]
20
+ minutes = time_regex.match(line)[:minutes]
21
+ time.push(hours + ":" + minutes)
22
+ i+=1
23
+ end
24
+ end
25
+ i_count = time.count - i_count # Conta quantas registros tem em cada arquivo
26
+ content_file.close
27
+ ###
28
+
29
+ ### itera pelo array de strings e converte para inteiros
30
+ i = 0
31
+ inteiro = []
32
+ i_parse_int = i_count * 2
33
+ time.each do |a|
34
+ a = a.split(":")
35
+ a.each do |b|
36
+ inteiro.push(b.to_i)
37
+ end
38
+ end
39
+ ###
40
+
41
+ ### Converte cada horário para minutos
42
+ while i < i_parse_int
43
+ hrs = inteiro[i]
44
+ hrs = hrs * 60
45
+ hrs = hrs + inteiro[i+1]
46
+ time_to_min.push(hrs)
47
+ i+=2
48
+ end
49
+ ###
50
+
51
+ ### Calcula o tempo trabalhado em minutos
52
+ i = 0
53
+ while i < i_count
54
+ sum_time = time_to_min[i+1] - time_to_min[i] + sum_time
55
+ i+=2
56
+ end
57
+ ###
58
+
59
+ ### Converte o tempo trabalhado para o formato hh:mm
60
+ hours = sum_time/60
61
+ hours = hours.to_i
62
+ minutes = sum_time - hours * 60
63
+ ## Adiciona o 0 para manter o padrão de 2 algarismos do padrão hh:mm
64
+ if hours < 10
65
+ hours = "0#{hours}"
66
+ end
67
+ if minutes < 10
68
+ minutes = "0#{minutes}"
69
+ end
70
+ ##
71
+
72
+ time_final = "#{hours}:#{minutes}"
73
+ print "#{files}: #{time_final} hours\n"
74
+ ###
75
+
76
+ end
77
+ ####
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: txt_timesheet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Elvis Serrão
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-10-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Receive n files as command line parameters, parse these files and than,
14
+ calculates how many hours has been worked .
15
+ email:
16
+ - elvis.serrao1@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
22
+ - README.md
23
+ - assets/file1.txt
24
+ - assets/file2.txt
25
+ - assets/file3.txt
26
+ - lib/txt_timesheet.rb
27
+ homepage: https://elvisserrao.github.io/
28
+ licenses:
29
+ - MIT
30
+ metadata:
31
+ homepage_uri: https://elvisserrao.github.io/
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.3.0
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ requirements: []
47
+ rubygems_version: 3.0.3
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: Calculate Timesheet.
51
+ test_files: []