forty_time 0.0.3 → 0.0.4
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
- data/.rubocop.yml +19 -0
- data/Gemfile +6 -3
- data/Gemfile.lock +19 -1
- data/Rakefile +9 -3
- data/bin/console +4 -3
- data/lib/forty_time.rb +21 -9
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78c83da48923ac51635904a0e352188c594e045ee35939aa36789f84891665b3
|
4
|
+
data.tar.gz: 8aac8b9f2370591e9399e7b22d0c342d406f89e06ec6ca9e576041bbbd850750
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd574595c58d6dece0a7b9f35d8cefe8d28b646c1b1957a6c5101a836140da1e0dd9b213db33ff37fe7853f1ef4d9a29b9bc23faf41a58e95f0be13cd9da132e
|
7
|
+
data.tar.gz: 2d5f14df831f55d454fc10b1f9b8cd91c7635c0763013ec4943d64f57a1ff8198223b68bac2f4f734a4e14b1e3047746412075442f50f0d55d0a456da615c1eb
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Layout/LineLength:
|
2
|
+
Exclude:
|
3
|
+
- 'forty_time.gemspec'
|
4
|
+
|
5
|
+
Metrics/BlockLength:
|
6
|
+
Exclude:
|
7
|
+
- 'spec/**/*'
|
8
|
+
|
9
|
+
Style/Documentation:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Style/HashEachMethods:
|
13
|
+
Enabled: true
|
14
|
+
|
15
|
+
Style/HashTransformKeys:
|
16
|
+
Enabled: true
|
17
|
+
|
18
|
+
Style/HashTransformValues:
|
19
|
+
Enabled: true
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
forty_time (0.0.
|
4
|
+
forty_time (0.0.3)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
ast (2.4.0)
|
9
10
|
diff-lcs (1.3)
|
11
|
+
jaro_winkler (1.5.4)
|
12
|
+
parallel (1.19.1)
|
13
|
+
parser (2.7.0.5)
|
14
|
+
ast (~> 2.4.0)
|
15
|
+
rainbow (3.0.0)
|
10
16
|
rake (12.3.3)
|
17
|
+
rexml (3.2.4)
|
11
18
|
rspec (3.9.0)
|
12
19
|
rspec-core (~> 3.9.0)
|
13
20
|
rspec-expectations (~> 3.9.0)
|
@@ -21,6 +28,16 @@ GEM
|
|
21
28
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
29
|
rspec-support (~> 3.9.0)
|
23
30
|
rspec-support (3.9.2)
|
31
|
+
rubocop (0.80.1)
|
32
|
+
jaro_winkler (~> 1.5.1)
|
33
|
+
parallel (~> 1.10)
|
34
|
+
parser (>= 2.7.0.1)
|
35
|
+
rainbow (>= 2.2.2, < 4.0)
|
36
|
+
rexml
|
37
|
+
ruby-progressbar (~> 1.7)
|
38
|
+
unicode-display_width (>= 1.4.0, < 1.7)
|
39
|
+
ruby-progressbar (1.10.1)
|
40
|
+
unicode-display_width (1.6.1)
|
24
41
|
|
25
42
|
PLATFORMS
|
26
43
|
ruby
|
@@ -29,6 +46,7 @@ DEPENDENCIES
|
|
29
46
|
forty_time!
|
30
47
|
rake
|
31
48
|
rspec
|
49
|
+
rubocop
|
32
50
|
|
33
51
|
BUNDLED WITH
|
34
52
|
2.1.2
|
data/Rakefile
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
|
7
|
+
desc 'Run RuboCop'
|
8
|
+
RuboCop::RakeTask.new(:rubocop)
|
3
9
|
|
4
10
|
RSpec::Core::RakeTask.new(:spec)
|
5
11
|
|
6
|
-
task :
|
12
|
+
task default: %i[rubocop spec]
|
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'forty_time'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "forty_time"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
data/lib/forty_time.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class FortyTime
|
2
|
-
VERSION =
|
4
|
+
VERSION = '0.0.4'
|
3
5
|
|
4
6
|
class ParseError < StandardError; end
|
5
7
|
|
@@ -9,8 +11,11 @@ class FortyTime
|
|
9
11
|
can_parse_string = input.is_a?(String) && input.match?(/:/)
|
10
12
|
raise ParseError unless can_parse_string
|
11
13
|
|
12
|
-
hours, extra = input.split(
|
14
|
+
hours, extra = input.split(':').map(&:to_i)
|
13
15
|
minutes = hours * 60 + extra
|
16
|
+
|
17
|
+
minutes *= -1 if input[0] == '-'
|
18
|
+
|
14
19
|
new(minutes)
|
15
20
|
end
|
16
21
|
|
@@ -20,20 +25,27 @@ class FortyTime
|
|
20
25
|
@minutes = minutes
|
21
26
|
end
|
22
27
|
|
23
|
-
def +(
|
24
|
-
result = @minutes +
|
28
|
+
def +(other)
|
29
|
+
result = @minutes + other.minutes
|
25
30
|
FortyTime.new(result)
|
26
31
|
end
|
27
32
|
|
28
|
-
def -(
|
29
|
-
result = @minutes -
|
33
|
+
def -(other)
|
34
|
+
result = @minutes - other.minutes
|
30
35
|
FortyTime.new(result)
|
31
36
|
end
|
32
37
|
|
33
38
|
def to_s
|
34
|
-
hours = @minutes / 60
|
35
|
-
extra = @minutes - hours * 60
|
39
|
+
hours = (@minutes / 60.0).to_i
|
40
|
+
extra = (@minutes - hours * 60.0).to_i
|
41
|
+
|
42
|
+
if @minutes.negative?
|
43
|
+
hours *= -1
|
44
|
+
extra *= -1
|
45
|
+
hours = "-#{hours}"
|
46
|
+
end
|
47
|
+
|
36
48
|
extra = "0#{extra}" if extra < 10
|
37
|
-
[hours, extra].join(
|
49
|
+
[hours, extra].join(':')
|
38
50
|
end
|
39
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forty_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Allured
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This gem helps one go between intergers and strings to represent time
|
14
14
|
amounts.
|
@@ -20,6 +20,7 @@ extra_rdoc_files: []
|
|
20
20
|
files:
|
21
21
|
- ".gitignore"
|
22
22
|
- ".rspec"
|
23
|
+
- ".rubocop.yml"
|
23
24
|
- Gemfile
|
24
25
|
- Gemfile.lock
|
25
26
|
- LICENSE.txt
|