txt_timesheet 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +52 -1
- data/lib/txt_timesheet.rb +16 -4
- data/txt_timesheet.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6596a32ce5541ce5f745f3e5e7aa782f7b09a90871c4b32cfd0d81e63d3492b
|
4
|
+
data.tar.gz: ea41caebe92dce71fc6c1c38bd87521288c13307e1279b5b7d583babcf421bc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 745a94696c2cf35c8723eaa69aa8b5e5773266c84d56ce3d0b2bf5172a166896e42de840e54da0bd0413f327b386c387d4ee58b9b448c121b91fd6187e7757c8
|
7
|
+
data.tar.gz: 2af6c19d63885f3a941dcb71aa72c36a7ccf5d8ae7b68614b335ec7cd0a510314ac2bcab5b490f6faf110d5a9150c5375c787943a21edb74a468e1f497d41bb5
|
data/README.md
CHANGED
@@ -1 +1,52 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
|
3
|
+
Txt-timesheet
|
4
|
+
====================
|
5
|
+
|
6
|
+
Timesheet calculator for .txt files.
|
7
|
+
|
8
|
+
Installation
|
9
|
+
------------
|
10
|
+
gem install txt_timesheet
|
11
|
+
|
12
|
+
How to use
|
13
|
+
------------
|
14
|
+
Create a file named timesheet.rb on your root folder.
|
15
|
+
|
16
|
+
$ touch timesheet.rb
|
17
|
+
|
18
|
+
Create a folder named "assets" on the root folder of your project
|
19
|
+
|
20
|
+
$ mkdir assets
|
21
|
+
|
22
|
+
The root folder of your project should look like this:
|
23
|
+
|
24
|
+
$ ls
|
25
|
+
assets/ timesheet.rb
|
26
|
+
|
27
|
+
Then put your .txt files on assets folder.
|
28
|
+
|
29
|
+
In your timesheet.rb file:
|
30
|
+
|
31
|
+
require 'txt_timesheet'
|
32
|
+
|
33
|
+
timesheetObject = Txt_timesheet.new
|
34
|
+
|
35
|
+
timesheetObject.run
|
36
|
+
|
37
|
+
Then, run timesheet.rb and pass the files as parameters:
|
38
|
+
|
39
|
+
$ timesheet.rb file1.txt file2.txt file3.txt
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
Your output should be like this:
|
44
|
+
|
45
|
+
$ timesheet.rb file1.txt file2.txt file3.txt
|
46
|
+
|
47
|
+
REPORT:
|
48
|
+
file1.txt: 09:47 hours
|
49
|
+
file2.txt: 09:09 hours
|
50
|
+
file3.txt: 07:19 hours
|
51
|
+
Total Hours: 26:15 hours
|
52
|
+
|
data/lib/txt_timesheet.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
class Txt_timesheet
|
2
2
|
def run
|
3
3
|
time_regex = /(?<hours>\d{2})\:(?<minutes>\d{2})/
|
4
|
+
total_time = 0
|
4
5
|
|
5
6
|
puts "REPORT:"
|
6
|
-
#### Percorre todos os arquivos na linha de comando
|
7
|
+
#### Percorre todos os arquivos na linha de comando
|
7
8
|
ARGV.each do |a|
|
8
9
|
sum_time = 0
|
9
10
|
i = 0
|
10
11
|
files = a
|
11
|
-
file = "
|
12
|
+
file = "assets/#{a}"
|
12
13
|
content_file = File.open(file)
|
13
14
|
i_count = 0
|
14
15
|
time = []
|
@@ -71,11 +72,22 @@ class Txt_timesheet
|
|
71
72
|
end
|
72
73
|
##
|
73
74
|
|
74
|
-
|
75
|
-
print "#{files}: #{
|
75
|
+
time_file = "#{hours}:#{minutes}"
|
76
|
+
print "#{files}: #{time_file} hours\n"
|
76
77
|
###
|
77
78
|
|
79
|
+
total_time += sum_time # Acumulates the worked time of each file
|
80
|
+
|
78
81
|
end
|
82
|
+
|
83
|
+
### Converts the total worked time
|
84
|
+
hours = total_time/60
|
85
|
+
hours = hours.to_i
|
86
|
+
minutes = total_time - hours * 60
|
87
|
+
puts "Total Hours: #{hours}:#{minutes} hours"
|
88
|
+
###
|
89
|
+
|
90
|
+
|
79
91
|
####
|
80
92
|
end
|
81
93
|
end
|
data/txt_timesheet.gemspec
CHANGED