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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf2ebf514b240df4079f68fc361938a032b551cd07c1c0b41301e5a6c898d5fe
4
- data.tar.gz: 67c1a7c5b704423e3481114bd3c87dfeedec174fe171aa059bf13d06bf2e877a
3
+ metadata.gz: 23cbed616dd6723ce4a9f1e491c03fb42790b2a94a782280fd8a0457b3d7a479
4
+ data.tar.gz: 6745a0a0cc99c7eaf0b178dfd046e2d002276abc64d27d3568837996bd2b0537
5
5
  SHA512:
6
- metadata.gz: 58c14a99a994505bf4355de93e93974b2c0fe5c2bf99e47c5d21c399ace875f5b8fe3f77b68b0bc50a4587c2b1a9c59e68766c314fdc098e67bb5732a955bf7d
7
- data.tar.gz: 00a5fb23dd17aa30273cee1a0f60f16ec0879af3164583b7ca5893d69246830d7469ba06429ff32683eddbd81bee50ae1bb1b14a7cb042bd9e56e0c36025b10d
6
+ metadata.gz: e02167b7c6d880e9eaf6b90f47233427a76e467697fdab0cf0ba6147a36509752806024643bb38d3370b079f9c050b31029de5d744ad9f0aaa0af34c547b1111
7
+ data.tar.gz: 96d82e5c55532ae8d78a073e7085a3a64dd321bb0cb4ad77b11dc622cdfd1a0adeda642cf399afbc24ee0e0a6a12813407fad7c5d35a28462474e426ebe996c2
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
 
2
2
  .idea/
3
3
  *.gem
4
- assets/
4
+ assets/
5
+ *.txt
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 to use
12
+ How it works
13
13
  ------------
14
- Create a file named timesheet.rb on your root folder.
15
14
 
16
- $ touch timesheet.rb
15
+ Given 3 files like these
17
16
 
18
- Create a folder named "assets" on the root folder of your project
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
- Then put your .txt files on assets folder.
20
+ ## Timesheet
28
21
 
29
- In your timesheet.rb file:
30
-
31
- require 'txt_timesheet'
22
+ morning: 09:13
23
+ brb lunch: 12:03
24
+ back: 13:56
25
+ leaving: 20:53
32
26
 
33
- timesheetObject = Txt_timesheet.new
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
- timesheetObject.run
41
+ ## Daily report
36
42
 
37
- Then, run timesheet.rb and pass the files as parameters:
43
+ Leaving:
38
44
 
39
- $ timesheet.rb file1.txt file2.txt file3.txt
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.rb file1.txt file2.txt file3.txt
65
+ $ timesheet file1.txt file2.txt file3.txt
46
66
 
47
67
  REPORT:
48
68
  file1.txt: 09:47 hours
data/bin/timesheet ADDED
@@ -0,0 +1,9 @@
1
+
2
+ #!/usr/bin/env ruby
3
+
4
+ $LOAD_PATH.unshift("#{__dir__}/../lib")
5
+
6
+ require 'txt_timesheet'
7
+
8
+ initialize = TxtTimesheet.new
9
+ initialize.run
data/lib/txt_timesheet.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Trata arquivos passados como parametro e calcula o total de horas trabalhadas
3
+ # Treat past files as a parameter and calculate total hours worked
4
4
  class TxtTimesheet
5
5
  def convert(par)
6
- ### Converte o tempo trabalhado para o formato hh:mm
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
- ## Adiciona o 0 para manter o formato hh:mm
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
- #### Percorre todos os arquivos na linha de comando
24
+ #### Receive all files indicated on the command line
25
25
  ARGV.each do |a|
26
26
  sum_time = 0
27
- i = 0
27
+ index = 0
28
28
  files = a
29
- file = "assets/#{a}"
29
+ file = a.to_s
30
30
  content_file = File.open(file)
31
- i_count = 0
31
+ input_count = 0
32
32
  time = []
33
- time_to_min = []
33
+ time_in_min = []
34
34
 
35
- ### Percorre todas as linhas do arquivo de entrada para extrair os dados
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
- i += 1
43
+ index += 1
44
44
  end
45
- i_count = time.count - i_count # Conta registros em cada arquivo
45
+ input_count = time.count - input_count # count records in each file
46
46
  content_file.close
47
47
  ###
48
48
 
49
- ### itera pelo array de strings e converte para inteiros
50
- i = 0
51
- inteiro = []
52
- i_parse_int = i_count * 2
53
- time.each do |a|
54
- a = a.split(':')
55
- a.each do |b|
56
- inteiro.push(b.to_i)
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
- ### Converte para minutos
62
- while i < i_parse_int
63
- hrs = inteiro[i]
64
- hrs *= 60
65
- hrs += inteiro[i + 1]
66
- time_to_min.push(hrs)
67
- i += 2
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
- i = 0
73
- while i < i_count
74
- sum_time = time_to_min[i + 1] - time_to_min[i] + sum_time
75
- i += 2
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
 
@@ -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.3"
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 = "exe"
23
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
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.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elvis Serrão
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-14 00:00:00.000000000 Z
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
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper