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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4aa33999fe06c1292cb38c2be25c7b74381c4b00fcff8dd6d2041a2ed729b1e
4
- data.tar.gz: 8ed73d1a6796e363c2992b2288aac63c68faf6ac5de13e95cdd079f474f791bd
3
+ metadata.gz: b6596a32ce5541ce5f745f3e5e7aa782f7b09a90871c4b32cfd0d81e63d3492b
4
+ data.tar.gz: ea41caebe92dce71fc6c1c38bd87521288c13307e1279b5b7d583babcf421bc3
5
5
  SHA512:
6
- metadata.gz: 14017fe1f1a72a78c3ba9217fbc880188ea6c0f9f3422a2670baf9e7c244998e5d81ac7c94bb7b5a3776d957ac3d0f17c813794d39bd3c290b3b52a6e9073072
7
- data.tar.gz: d4fcdc9d69dacde1bdcb86080d67307eac3d3acf5ebd847fdb2d5f0d90dd2a4dc683c1b729582f2f000dd6f0dbe5e00366b37a24dae6ea99a309ac563a2daad4
6
+ metadata.gz: 745a94696c2cf35c8723eaa69aa8b5e5773266c84d56ce3d0b2bf5172a166896e42de840e54da0bd0413f327b386c387d4ee58b9b448c121b91fd6187e7757c8
7
+ data.tar.gz: 2af6c19d63885f3a941dcb71aa72c36a7ccf5d8ae7b68614b335ec7cd0a510314ac2bcab5b490f6faf110d5a9150c5375c787943a21edb74a468e1f497d41bb5
data/README.md CHANGED
@@ -1 +1,52 @@
1
- # txt-timesheet
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 = "#{a}"
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
- time_final = "#{hours}:#{minutes}"
75
- print "#{files}: #{time_final} hours\n"
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
@@ -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.0.0"
5
+ spec.version = "1.1.0"
6
6
  spec.authors = ["Elvis Serrão"]
7
7
  spec.email = ["elvis.serrao1@gmail.com"]
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: txt_timesheet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elvis Serrão