sus 0.7.0 → 0.9.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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bin/sus +11 -4
- data/bin/sus-parallel +4 -5
- data/lib/sus/assertions.rb +137 -59
- data/lib/sus/base.rb +12 -9
- data/lib/sus/be.rb +8 -4
- data/lib/sus/be_within.rb +2 -2
- data/lib/sus/clock.rb +40 -0
- data/lib/sus/config.rb +133 -5
- data/lib/sus/expect.rb +14 -7
- data/lib/sus/file.rb +5 -3
- data/lib/sus/filter.rb +1 -2
- data/lib/sus/it.rb +2 -2
- data/lib/sus/let.rb +4 -4
- data/lib/sus/loader.rb +11 -0
- data/lib/sus/mock.rb +127 -0
- data/lib/sus/output/backtrace.rb +73 -0
- data/lib/sus/output/buffered.rb +38 -17
- data/lib/sus/output/lines.rb +1 -0
- data/lib/sus/output/null.rb +9 -0
- data/lib/sus/output/progress.rb +146 -0
- data/lib/sus/output/text.rb +11 -0
- data/lib/sus/output.rb +10 -4
- data/lib/sus/raise_exception.rb +5 -10
- data/lib/sus/receive.rb +167 -0
- data/lib/sus/registry.rb +5 -1
- data/lib/sus/respond_to.rb +89 -0
- data/lib/sus/version.rb +1 -1
- data/lib/sus.rb +3 -0
- data.tar.gz.sig +0 -0
- metadata +39 -4
- metadata.gz.sig +0 -0
- data/lib/sus/progress.rb +0 -144
data/lib/sus/receive.rb
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
|
2
|
+
require_relative 'respond_to'
|
3
|
+
|
4
|
+
module Sus
|
5
|
+
class Receive
|
6
|
+
CALL_ORIGINAL = Object.new
|
7
|
+
|
8
|
+
def initialize(base, method)
|
9
|
+
@base = base
|
10
|
+
@method = method
|
11
|
+
|
12
|
+
@times = Times.new
|
13
|
+
@arguments = nil
|
14
|
+
@options = nil
|
15
|
+
@block = nil
|
16
|
+
@returning = CALL_ORIGINAL
|
17
|
+
end
|
18
|
+
|
19
|
+
def print(output)
|
20
|
+
output.write("receive ", :variable, @method.to_s, :reset, " ")
|
21
|
+
end
|
22
|
+
|
23
|
+
def with_arguments(*arguments)
|
24
|
+
@arguments = WithArguments.new(arguments)
|
25
|
+
return self
|
26
|
+
end
|
27
|
+
|
28
|
+
def with_options(*options)
|
29
|
+
@options = WithOptions.new(options)
|
30
|
+
return self
|
31
|
+
end
|
32
|
+
|
33
|
+
def with_block
|
34
|
+
@block = WithBlock.new
|
35
|
+
return self
|
36
|
+
end
|
37
|
+
|
38
|
+
def once
|
39
|
+
@times = Times.new(Be.new(:==, 1))
|
40
|
+
end
|
41
|
+
|
42
|
+
def twice
|
43
|
+
@times = Times.new(Be.new(:==, 2))
|
44
|
+
end
|
45
|
+
|
46
|
+
def with_call_count(predicate)
|
47
|
+
@times = Times.new(predicate)
|
48
|
+
end
|
49
|
+
|
50
|
+
def and_return(*returning)
|
51
|
+
if returning.size == 1
|
52
|
+
@returning = returning.first
|
53
|
+
else
|
54
|
+
@returning = returning
|
55
|
+
end
|
56
|
+
return self
|
57
|
+
end
|
58
|
+
|
59
|
+
def validate(mock, assertions, arguments, options, block)
|
60
|
+
@arguments.call(assertions, arguments) if @arguments
|
61
|
+
@options.call(assertions, options) if @options
|
62
|
+
@block.call(assertions, block) if @block
|
63
|
+
end
|
64
|
+
|
65
|
+
def call(assertions, subject)
|
66
|
+
assertions.nested(self) do |assertions|
|
67
|
+
mock = @base.mock(subject)
|
68
|
+
|
69
|
+
called = 0
|
70
|
+
|
71
|
+
if call_original?
|
72
|
+
mock.before(@method) do |*arguments, **options, &block|
|
73
|
+
called += 1
|
74
|
+
|
75
|
+
validate(mock, assertions, arguments, options, block)
|
76
|
+
end
|
77
|
+
else
|
78
|
+
mock.replace(@method) do |*arguments, **options, &block|
|
79
|
+
called += 1
|
80
|
+
|
81
|
+
validate(mock, assertions, arguments, options, block)
|
82
|
+
|
83
|
+
next @returning
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
if @times
|
88
|
+
assertions.defer do
|
89
|
+
@times.call(assertions, called)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def call_original?
|
96
|
+
@returning == CALL_ORIGINAL
|
97
|
+
end
|
98
|
+
|
99
|
+
class WithArguments
|
100
|
+
def initialize(arguments)
|
101
|
+
@arguments = arguments
|
102
|
+
end
|
103
|
+
|
104
|
+
def print(output)
|
105
|
+
output.write("with arguments ", :variable, @arguments.inspect)
|
106
|
+
end
|
107
|
+
|
108
|
+
def call(assertions, subject)
|
109
|
+
assertions.nested(self) do |assertions|
|
110
|
+
Expect.new(assertions, subject).to(Be == @arguments)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
class WithOptions
|
116
|
+
def initialize(options)
|
117
|
+
@options = options
|
118
|
+
end
|
119
|
+
|
120
|
+
def print(output)
|
121
|
+
output.write("with options ", :variable, @options.inspect)
|
122
|
+
end
|
123
|
+
|
124
|
+
def call(assertions, subject)
|
125
|
+
assertions.nested(self) do |assertions|
|
126
|
+
Expect.new(assertions, subject).to(Be.new(:include?, @options))
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
class WithBlock
|
132
|
+
def print(output)
|
133
|
+
output.write("with block")
|
134
|
+
end
|
135
|
+
|
136
|
+
def call(assertions, subject)
|
137
|
+
assertions.nested(self) do |assertions|
|
138
|
+
Expect.new(assertions, subject).not.to(Be == nil)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
class Times
|
144
|
+
ONCE = Be.new(:==, 1)
|
145
|
+
|
146
|
+
def initialize(condition = ONCE)
|
147
|
+
@condition = condition
|
148
|
+
end
|
149
|
+
|
150
|
+
def print(output)
|
151
|
+
output.write("with call count ", @condition)
|
152
|
+
end
|
153
|
+
|
154
|
+
def call(assertions, subject)
|
155
|
+
assertions.nested(self) do |assertions|
|
156
|
+
Expect.new(assertions, subject).to(@condition)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
class Base
|
163
|
+
def receive(method)
|
164
|
+
Receive.new(self, method)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
data/lib/sus/registry.rb
CHANGED
@@ -16,12 +16,16 @@ require_relative 'let'
|
|
16
16
|
module Sus
|
17
17
|
class Registry
|
18
18
|
# Create a top level scope with self as the instance:
|
19
|
-
def initialize(base = Sus.base(
|
19
|
+
def initialize(base = Sus.base(self))
|
20
20
|
@base = base
|
21
21
|
end
|
22
22
|
|
23
23
|
attr :base
|
24
24
|
|
25
|
+
def print(output)
|
26
|
+
output.write("Test Registry")
|
27
|
+
end
|
28
|
+
|
25
29
|
def load(path)
|
26
30
|
@base.file(path)
|
27
31
|
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Sus
|
2
|
+
class RespondTo
|
3
|
+
class WithParameters
|
4
|
+
# @parameter [Array(Symbol)] List of method parameters in the expected order, must include at least all required parameters but can also list optional parameters.
|
5
|
+
def initialize(parameters)
|
6
|
+
@parameters = parameters
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(assertions, subject)
|
10
|
+
parameters = @parameters.dup
|
11
|
+
|
12
|
+
assertions.nested(self) do |assertions|
|
13
|
+
expected_name = parameters.shift
|
14
|
+
|
15
|
+
subject.each do |type, name|
|
16
|
+
case type
|
17
|
+
when :req
|
18
|
+
assertions.assert(name == expected_name, "parameter #{expected_name} is required, but was #{name}")
|
19
|
+
when :opt
|
20
|
+
break if expected_name.nil?
|
21
|
+
assertions.assert(name == expected_name, "parameter #{expected_name} is specified, but was #{name}")
|
22
|
+
else
|
23
|
+
break
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class WithOptions
|
31
|
+
def initialize(options)
|
32
|
+
@options = options
|
33
|
+
end
|
34
|
+
|
35
|
+
def print(output)
|
36
|
+
output.write("with options ", :variable, @options.inspect)
|
37
|
+
end
|
38
|
+
|
39
|
+
def call(assertions, subject)
|
40
|
+
options = {}
|
41
|
+
@options.each{|name| options[name] = nil}
|
42
|
+
|
43
|
+
subject.each do |type, name|
|
44
|
+
options[name] = type
|
45
|
+
end
|
46
|
+
|
47
|
+
assertions.nested(self) do |assertions|
|
48
|
+
options.each do |name, type|
|
49
|
+
assertions.assert(type != nil, "option #{name}: is required")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def initialize(method)
|
56
|
+
@method = method
|
57
|
+
@parameters = nil
|
58
|
+
@options = nil
|
59
|
+
end
|
60
|
+
|
61
|
+
def with_options(*options)
|
62
|
+
@options = WithOptions.new(options)
|
63
|
+
return self
|
64
|
+
end
|
65
|
+
|
66
|
+
def print(output)
|
67
|
+
output.write("respond to ", :variable, @method.to_s, :reset)
|
68
|
+
end
|
69
|
+
|
70
|
+
def call(assertions, subject)
|
71
|
+
assertions.nested(self) do |assertions|
|
72
|
+
condition = subject.respond_to?(@method)
|
73
|
+
assertions.assert(condition, self)
|
74
|
+
|
75
|
+
if condition and (@parameters or @options)
|
76
|
+
parameters = subject.method(@method).parameters
|
77
|
+
@parameters.call(assertions, parameters) if @parameters
|
78
|
+
@options.call(assertions, parameters) if @options
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
class Base
|
85
|
+
def respond_to(method)
|
86
|
+
RespondTo.new(method)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/sus/version.rb
CHANGED
data/lib/sus.rb
CHANGED
data.tar.gz.sig
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
|
14
|
+
ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
|
15
|
+
CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
|
16
|
+
MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
|
17
|
+
MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
|
18
|
+
bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
|
19
|
+
igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
|
20
|
+
9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
|
21
|
+
sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
|
22
|
+
e5AUKRwUuvaUaumAKgPH+4E4oiLXI4T1Ff5Q7xxv6yXvHuYtlMHhYfgNn8iiW8WN
|
23
|
+
XibYXPNP7NtieSQqwR/xM6IRSoyXKuS+ZNGDPUUGk8RoiV/xvVN4LrVm9upSc0ss
|
24
|
+
RZ6qwOQmXCo/lLcDUxJAgG95cPw//sI00tZan75VgsGzSWAOdjQpFM0l4dxvKwHn
|
25
|
+
tUeT3ZsAgt0JnGqNm2Bkz81kG4A2hSyFZTFA8vZGhp+hz+8Q573tAR89y9YJBdYM
|
26
|
+
zp0FM4zwMNEUwgfRzv1tEVVUEXmoFCyhzonUUw4nE4CFu/sE3ffhjKcXcY//qiSW
|
27
|
+
xm4erY3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
|
28
|
+
BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
|
29
|
+
aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
|
30
|
+
aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
|
31
|
+
cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
|
32
|
+
xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
|
33
|
+
c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
|
34
|
+
8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
|
35
|
+
JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
|
36
|
+
eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
|
37
|
+
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
38
|
+
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
39
|
+
-----END CERTIFICATE-----
|
40
|
+
date: 2022-08-21 00:00:00.000000000 Z
|
12
41
|
dependencies: []
|
13
42
|
description:
|
14
43
|
email:
|
@@ -25,6 +54,7 @@ files:
|
|
25
54
|
- lib/sus/base.rb
|
26
55
|
- lib/sus/be.rb
|
27
56
|
- lib/sus/be_within.rb
|
57
|
+
- lib/sus/clock.rb
|
28
58
|
- lib/sus/config.rb
|
29
59
|
- lib/sus/context.rb
|
30
60
|
- lib/sus/describe.rb
|
@@ -37,17 +67,22 @@ files:
|
|
37
67
|
- lib/sus/it.rb
|
38
68
|
- lib/sus/it_behaves_like.rb
|
39
69
|
- lib/sus/let.rb
|
70
|
+
- lib/sus/loader.rb
|
71
|
+
- lib/sus/mock.rb
|
40
72
|
- lib/sus/output.rb
|
73
|
+
- lib/sus/output/backtrace.rb
|
41
74
|
- lib/sus/output/bar.rb
|
42
75
|
- lib/sus/output/buffered.rb
|
43
76
|
- lib/sus/output/lines.rb
|
44
77
|
- lib/sus/output/null.rb
|
78
|
+
- lib/sus/output/progress.rb
|
45
79
|
- lib/sus/output/status.rb
|
46
80
|
- lib/sus/output/text.rb
|
47
81
|
- lib/sus/output/xterm.rb
|
48
|
-
- lib/sus/progress.rb
|
49
82
|
- lib/sus/raise_exception.rb
|
83
|
+
- lib/sus/receive.rb
|
50
84
|
- lib/sus/registry.rb
|
85
|
+
- lib/sus/respond_to.rb
|
51
86
|
- lib/sus/shared.rb
|
52
87
|
- lib/sus/version.rb
|
53
88
|
- lib/sus/with.rb
|
metadata.gz.sig
ADDED
Binary file
|
data/lib/sus/progress.rb
DELETED
@@ -1,144 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
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.
|
22
|
-
|
23
|
-
require_relative 'output/bar'
|
24
|
-
require_relative 'output/status'
|
25
|
-
require_relative 'output/lines'
|
26
|
-
|
27
|
-
module Sus
|
28
|
-
class Progress
|
29
|
-
def self.now
|
30
|
-
::Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
31
|
-
end
|
32
|
-
|
33
|
-
def initialize(output, total = 0, minimum_output_duration: 1.0)
|
34
|
-
@output = output
|
35
|
-
@subject = subject
|
36
|
-
|
37
|
-
@start_time = Progress.now
|
38
|
-
|
39
|
-
if @output.interactive?
|
40
|
-
@bar = Output::Bar.new
|
41
|
-
@lines = Output::Lines.new(@output)
|
42
|
-
@lines[0] = @bar
|
43
|
-
end
|
44
|
-
|
45
|
-
@current = 0
|
46
|
-
@total = total
|
47
|
-
end
|
48
|
-
|
49
|
-
attr :subject
|
50
|
-
attr :current
|
51
|
-
attr :total
|
52
|
-
|
53
|
-
def duration
|
54
|
-
Progress.now - @start_time
|
55
|
-
end
|
56
|
-
|
57
|
-
def progress
|
58
|
-
@current.to_f / @total.to_f
|
59
|
-
end
|
60
|
-
|
61
|
-
def remaining
|
62
|
-
@total - @current
|
63
|
-
end
|
64
|
-
|
65
|
-
def average_duration
|
66
|
-
if @current > 0
|
67
|
-
duration / @current
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def estimated_remaining_time
|
72
|
-
if average_duration = self.average_duration
|
73
|
-
average_duration * remaining
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
# Increase the amont of work done.
|
78
|
-
def increment(amount = 1)
|
79
|
-
@current += amount
|
80
|
-
|
81
|
-
@bar&.update(@current, @total, self.to_s)
|
82
|
-
@lines&.redraw(0)
|
83
|
-
|
84
|
-
return self
|
85
|
-
end
|
86
|
-
|
87
|
-
# Increase the total size of the progress.
|
88
|
-
def expand(amount = 1)
|
89
|
-
@total += amount
|
90
|
-
|
91
|
-
@bar&.update(@current, @total, self.to_s)
|
92
|
-
@lines&.redraw(0)
|
93
|
-
|
94
|
-
return self
|
95
|
-
end
|
96
|
-
|
97
|
-
def report(index, context, state)
|
98
|
-
@lines&.[]=(index+1, Output::Status.new(state, context))
|
99
|
-
|
100
|
-
return self
|
101
|
-
end
|
102
|
-
|
103
|
-
def clear
|
104
|
-
@lines&.clear
|
105
|
-
end
|
106
|
-
|
107
|
-
def to_s
|
108
|
-
if estimated_remaining_time = self.estimated_remaining_time
|
109
|
-
"#{@current}/#{@total} completed in #{formatted_duration(self.duration)}, #{formatted_duration(estimated_remaining_time)} remaining"
|
110
|
-
else
|
111
|
-
"#{@current}/#{@total} completed"
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
private
|
116
|
-
|
117
|
-
def formatted_duration(duration)
|
118
|
-
seconds = duration.floor
|
119
|
-
|
120
|
-
if seconds < 60.0
|
121
|
-
return "#{seconds}s"
|
122
|
-
end
|
123
|
-
|
124
|
-
minutes = (duration / 60.0).floor
|
125
|
-
seconds = (seconds - (minutes * 60)).round
|
126
|
-
|
127
|
-
if minutes < 60.0
|
128
|
-
return "#{minutes}m#{seconds}s"
|
129
|
-
end
|
130
|
-
|
131
|
-
hours = (minutes / 60.0).floor
|
132
|
-
minutes = (minutes - (hours * 60)).round
|
133
|
-
|
134
|
-
if hours < 24.0
|
135
|
-
return "#{hours}h#{minutes}m"
|
136
|
-
end
|
137
|
-
|
138
|
-
days = (hours / 24.0).floor
|
139
|
-
hours = (hours - (days * 24)).round
|
140
|
-
|
141
|
-
return "#{days}d#{hours}h"
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|