txt_timesheet 1.1.7 → 1.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/.travis.yml +6 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +34 -0
- data/LICENSE.txt +21 -0
- data/README.md +72 -0
- data/Rakefile +6 -0
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/bin/timesheet +7 -8
- data/lib/txt_timesheet/version.rb +3 -3
- data/lib/txt_timesheet.rb +88 -84
- data/txt_timesheet.gemspec +29 -0
- metadata +10 -3
- data/lib/txt_timesheet/convert.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4e57aac820c74b568ed62205923a8e00fc3429169903ff9ded7de7a4efbe547
|
4
|
+
data.tar.gz: ec3f89bd48806cac96cc4c8ace73b2df23a43d305abcbc6af91bde46dcdfbc59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cb6f486356d4b40f6545cc408b069a88028cbcab33bf77660b5c52b0371dd127388016fd0ea8ff20f8ef1cdb239e5c84277d6882005fc75d3797cbb0076e3d8
|
7
|
+
data.tar.gz: bd7dd852d120dc1b78782c158f80c8b089679964163e91a003539c5442d3aa1711a323814a0b4897010964d62cd6d7b9cf97d6a3fda9eec0768267e31e9731d5
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
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/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Elvis Serrão
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
Txt-timesheet [![Gem Version](https://badge.fury.io/rb/txt_timesheet.svg)](https://badge.fury.io/rb/txt_timesheet)
|
4
|
+
====================
|
5
|
+
|
6
|
+
Timesheet calculator for .txt files.
|
7
|
+
|
8
|
+
Installation
|
9
|
+
------------
|
10
|
+
gem install txt_timesheet
|
11
|
+
|
12
|
+
How it works
|
13
|
+
------------
|
14
|
+
|
15
|
+
Given 3 files like these
|
16
|
+
|
17
|
+
`file1.txt`:
|
18
|
+
|
19
|
+
|
20
|
+
## Timesheet
|
21
|
+
|
22
|
+
morning: 09:13
|
23
|
+
brb lunch: 12:03
|
24
|
+
back: 13:56
|
25
|
+
leaving: 20:53
|
26
|
+
|
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
|
40
|
+
|
41
|
+
## Daily report
|
42
|
+
|
43
|
+
Leaving:
|
44
|
+
|
45
|
+
`file3.txt`:
|
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
|
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
|
61
|
+
|
62
|
+
|
63
|
+
Your output should be like this:
|
64
|
+
|
65
|
+
$ timesheet file1.txt file2.txt file3.txt
|
66
|
+
|
67
|
+
REPORT:
|
68
|
+
file1.txt: 09:47 hours
|
69
|
+
file2.txt: 09:09 hours
|
70
|
+
file3.txt: 07:19 hours
|
71
|
+
Total Hours: 26:15 hours
|
72
|
+
|
data/Rakefile
ADDED
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "txt_timesheet"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "txt_timesheet"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
data/bin/timesheet
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
cli = TxtTimesheet.new
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift("#{__dir__}/../lib")
|
4
|
+
|
5
|
+
require 'txt_timesheet'
|
6
|
+
|
7
|
+
cli = TxtTimesheet.new
|
9
8
|
cli.run
|
@@ -1,3 +1,3 @@
|
|
1
|
-
module TxtTimesheet
|
2
|
-
VERSION = "1.1.
|
3
|
-
end
|
1
|
+
module TxtTimesheet
|
2
|
+
VERSION = "1.1.8"
|
3
|
+
end
|
data/lib/txt_timesheet.rb
CHANGED
@@ -1,84 +1,88 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
###
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Treat past files as a parameter and calculate total hours worked
|
4
|
+
class TxtTimesheet
|
5
|
+
|
6
|
+
def convert(time_in_minutes)
|
7
|
+
### Convert working time to hh:mm format
|
8
|
+
hours = time_in_minutes / 60
|
9
|
+
minutes = time_in_minutes - hours * 60
|
10
|
+
## Add 0 to keep hh: mm format
|
11
|
+
"%02d:%02d" % [hours, minutes]
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
time_regex = /(?<hours>\d+)\:(?<minutes>\d+)/
|
16
|
+
total_time = 0
|
17
|
+
|
18
|
+
puts 'REPORT:'
|
19
|
+
#### Receive all files indicated on the command line
|
20
|
+
ARGV.each do |a|
|
21
|
+
sum_time = 0
|
22
|
+
index = 0
|
23
|
+
files = a
|
24
|
+
file = a.to_s
|
25
|
+
content_file = File.open(file)
|
26
|
+
input_count = 0
|
27
|
+
time = []
|
28
|
+
time_in_min = []
|
29
|
+
|
30
|
+
### Read all lines from the input file to extract data
|
31
|
+
until content_file.eof?
|
32
|
+
line = content_file.gets.chomp
|
33
|
+
next unless time_regex.match(line)
|
34
|
+
|
35
|
+
hours = time_regex.match(line)[:hours]
|
36
|
+
minutes = time_regex.match(line)[:minutes]
|
37
|
+
time.push(hours + ':' + minutes)
|
38
|
+
index += 1
|
39
|
+
end
|
40
|
+
input_count = time.count - input_count # count records in each file
|
41
|
+
content_file.close
|
42
|
+
###
|
43
|
+
|
44
|
+
### iterates over string array and converts to integers
|
45
|
+
index = 0
|
46
|
+
integer = []
|
47
|
+
i_parse_int = input_count * 2
|
48
|
+
time.each do |entry_time|
|
49
|
+
entry_time = entry_time.split(':')
|
50
|
+
entry_time.each do |entry_time_to_integer|
|
51
|
+
integer.push(entry_time_to_integer.to_i)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
###
|
55
|
+
|
56
|
+
### Converts to minutes
|
57
|
+
while index < i_parse_int
|
58
|
+
time_to_min = integer[index]
|
59
|
+
time_to_min *= 60
|
60
|
+
time_to_min += integer[index + 1]
|
61
|
+
time_in_min.push(time_to_min)
|
62
|
+
index += 2
|
63
|
+
end
|
64
|
+
###
|
65
|
+
|
66
|
+
### Calculates worked time in minutes
|
67
|
+
index = 0
|
68
|
+
while index < input_count
|
69
|
+
sum_time = time_in_min[index + 1] - time_in_min[index] + sum_time
|
70
|
+
index += 2
|
71
|
+
end
|
72
|
+
###
|
73
|
+
|
74
|
+
time_file = convert(sum_time)
|
75
|
+
print "#{files}: #{time_file} hours\n"
|
76
|
+
###
|
77
|
+
|
78
|
+
total_time += sum_time # Acumulates the worked time of each file
|
79
|
+
end
|
80
|
+
|
81
|
+
time_file = convert(total_time)
|
82
|
+
|
83
|
+
puts "Total Hours: #{time_file} hours\n"
|
84
|
+
###
|
85
|
+
|
86
|
+
####
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative 'lib/txt_timesheet/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "txt_timesheet"
|
5
|
+
spec.version = TxtTimesheet::VERSION
|
6
|
+
spec.authors = ["Elvis Serrão"]
|
7
|
+
spec.email = ["elvis.serrao1@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{Calculate Timesheet.}
|
10
|
+
spec.description = %q{Receive n files as command line parameters, parse these files and than, calculates how many hours has been worked .}
|
11
|
+
spec.homepage = "https://elvisserrao.github.io/"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
spec.metadata = {
|
16
|
+
'homepage_uri' => 'https://elvisserrao.github.io/',
|
17
|
+
'source_code_uri' => 'https://github.com/elvisserrao/txt-timesheet'
|
18
|
+
}
|
19
|
+
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "bin"
|
27
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elvis Serrão
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-02 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 .
|
@@ -21,12 +21,19 @@ executables:
|
|
21
21
|
extensions: []
|
22
22
|
extra_rdoc_files: []
|
23
23
|
files:
|
24
|
+
- ".gitignore"
|
25
|
+
- ".travis.yml"
|
26
|
+
- Gemfile
|
27
|
+
- Gemfile.lock
|
28
|
+
- LICENSE.txt
|
29
|
+
- README.md
|
30
|
+
- Rakefile
|
24
31
|
- bin/console
|
25
32
|
- bin/setup
|
26
33
|
- bin/timesheet
|
27
34
|
- lib/txt_timesheet.rb
|
28
|
-
- lib/txt_timesheet/convert.rb
|
29
35
|
- lib/txt_timesheet/version.rb
|
36
|
+
- txt_timesheet.gemspec
|
30
37
|
homepage: https://elvisserrao.github.io/
|
31
38
|
licenses:
|
32
39
|
- MIT
|