forty_time 0.0.4 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -2
- data/.rubocop.yml +8 -0
- data/Gemfile.lock +31 -28
- data/forty_time.gemspec +3 -2
- data/lib/forty_time.rb +14 -6
- data/lib/null_forty_time.rb +21 -0
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eebf2c2163cdc4686dda95809e101dbe09c3f62f788f1900b4caf113cdc54f1
|
4
|
+
data.tar.gz: 3d15e412a3a64bde7ea1e459f202367dbebe7a60c5fcb6f039483e0bb9a867c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41c4cfc5ebd6a1f80bdfbba808ff588cb7bbe8f6cd602b5c8d27280565e8af70fd20a908db196e7428707f7bd0021c518642d532c0795bd187030f483252bbcf
|
7
|
+
data.tar.gz: 5f781c8e7b4489a6122438dad52e9655019e7c41df1ef379cb717a9c9cb964c61e5d2326eb5455bd9205c60ead2b0a0e5d24f1765175b5dd4409cf9ac599441c
|
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,43 +1,46 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
forty_time (0.0.
|
4
|
+
forty_time (0.0.8)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
ast (2.4.
|
10
|
-
diff-lcs (1.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
rexml (3.2.
|
18
|
-
rspec (3.
|
19
|
-
rspec-core (~> 3.
|
20
|
-
rspec-expectations (~> 3.
|
21
|
-
rspec-mocks (~> 3.
|
22
|
-
rspec-core (3.
|
23
|
-
rspec-support (~> 3.
|
24
|
-
rspec-expectations (3.
|
9
|
+
ast (2.4.2)
|
10
|
+
diff-lcs (1.5.0)
|
11
|
+
parallel (1.21.0)
|
12
|
+
parser (3.1.0.0)
|
13
|
+
ast (~> 2.4.1)
|
14
|
+
rainbow (3.1.1)
|
15
|
+
rake (13.0.6)
|
16
|
+
regexp_parser (2.2.0)
|
17
|
+
rexml (3.2.5)
|
18
|
+
rspec (3.10.0)
|
19
|
+
rspec-core (~> 3.10.0)
|
20
|
+
rspec-expectations (~> 3.10.0)
|
21
|
+
rspec-mocks (~> 3.10.0)
|
22
|
+
rspec-core (3.10.1)
|
23
|
+
rspec-support (~> 3.10.0)
|
24
|
+
rspec-expectations (3.10.2)
|
25
25
|
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
-
rspec-support (~> 3.
|
27
|
-
rspec-mocks (3.
|
26
|
+
rspec-support (~> 3.10.0)
|
27
|
+
rspec-mocks (3.10.2)
|
28
28
|
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
-
rspec-support (~> 3.
|
30
|
-
rspec-support (3.
|
31
|
-
rubocop (
|
32
|
-
jaro_winkler (~> 1.5.1)
|
29
|
+
rspec-support (~> 3.10.0)
|
30
|
+
rspec-support (3.10.3)
|
31
|
+
rubocop (1.24.1)
|
33
32
|
parallel (~> 1.10)
|
34
|
-
parser (>=
|
33
|
+
parser (>= 3.0.0.0)
|
35
34
|
rainbow (>= 2.2.2, < 4.0)
|
35
|
+
regexp_parser (>= 1.8, < 3.0)
|
36
36
|
rexml
|
37
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
37
38
|
ruby-progressbar (~> 1.7)
|
38
|
-
unicode-display_width (>= 1.4.0, <
|
39
|
-
|
40
|
-
|
39
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
40
|
+
rubocop-ast (1.15.1)
|
41
|
+
parser (>= 3.0.1.1)
|
42
|
+
ruby-progressbar (1.11.0)
|
43
|
+
unicode-display_width (2.1.0)
|
41
44
|
|
42
45
|
PLATFORMS
|
43
46
|
ruby
|
@@ -49,4 +52,4 @@ DEPENDENCIES
|
|
49
52
|
rubocop
|
50
53
|
|
51
54
|
BUNDLED WITH
|
52
|
-
2.
|
55
|
+
2.3.4
|
data/forty_time.gemspec
CHANGED
@@ -12,11 +12,12 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = 'This gem helps one go between intergers and strings to represent time amounts.'
|
13
13
|
spec.homepage = 'https://www.fortyeven.com/'
|
14
14
|
spec.license = 'MIT'
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.6.5')
|
16
16
|
|
17
|
+
spec.metadata['changelog_uri'] = 'https://github.com/verynicecode/forty-time-management/blob/master/ruby/CHANGELOG.md'
|
17
18
|
spec.metadata['homepage_uri'] = spec.homepage
|
19
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
18
20
|
spec.metadata['source_code_uri'] = 'https://github.com/verynicecode/forty-time-management'
|
19
|
-
spec.metadata['changelog_uri'] = 'https://github.com/verynicecode/forty-time-management/blob/master/ruby/CHANGELOG.md'
|
20
21
|
|
21
22
|
# Specify which files should be added to the gem when it is released.
|
22
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
data/lib/forty_time.rb
CHANGED
@@ -1,26 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class FortyTime
|
4
|
-
VERSION = '0.0.
|
4
|
+
VERSION = '0.0.8'
|
5
5
|
|
6
6
|
class ParseError < StandardError; end
|
7
7
|
|
8
8
|
def self.parse(input)
|
9
|
+
return NullFortyTime.new if input.nil? || input == ''
|
9
10
|
return new(input) if input.is_a? Integer
|
10
11
|
|
11
12
|
can_parse_string = input.is_a?(String) && input.match?(/:/)
|
12
13
|
raise ParseError unless can_parse_string
|
13
14
|
|
14
|
-
|
15
|
-
minutes
|
15
|
+
minutes = parse_string(input)
|
16
|
+
new(minutes)
|
17
|
+
end
|
16
18
|
|
17
|
-
|
19
|
+
def self.parse_string(string)
|
20
|
+
hours, extra = string.split(':').map(&:to_i)
|
21
|
+
extra *= -1 if string[0] == '-'
|
18
22
|
|
19
|
-
|
23
|
+
(hours * 60) + extra
|
20
24
|
end
|
21
25
|
|
22
26
|
attr_accessor :minutes
|
23
27
|
|
28
|
+
alias value minutes
|
29
|
+
|
24
30
|
def initialize(minutes)
|
25
31
|
@minutes = minutes
|
26
32
|
end
|
@@ -37,7 +43,7 @@ class FortyTime
|
|
37
43
|
|
38
44
|
def to_s
|
39
45
|
hours = (@minutes / 60.0).to_i
|
40
|
-
extra = (@minutes - hours * 60.0).to_i
|
46
|
+
extra = (@minutes - (hours * 60.0)).to_i
|
41
47
|
|
42
48
|
if @minutes.negative?
|
43
49
|
hours *= -1
|
@@ -49,3 +55,5 @@ class FortyTime
|
|
49
55
|
[hours, extra].join(':')
|
50
56
|
end
|
51
57
|
end
|
58
|
+
|
59
|
+
require_relative './null_forty_time'
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Allured
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-17 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.
|
@@ -30,13 +30,15 @@ files:
|
|
30
30
|
- bin/setup
|
31
31
|
- forty_time.gemspec
|
32
32
|
- lib/forty_time.rb
|
33
|
+
- lib/null_forty_time.rb
|
33
34
|
homepage: https://www.fortyeven.com/
|
34
35
|
licenses:
|
35
36
|
- MIT
|
36
37
|
metadata:
|
38
|
+
changelog_uri: https://github.com/verynicecode/forty-time-management/blob/master/ruby/CHANGELOG.md
|
37
39
|
homepage_uri: https://www.fortyeven.com/
|
40
|
+
rubygems_mfa_required: 'true'
|
38
41
|
source_code_uri: https://github.com/verynicecode/forty-time-management
|
39
|
-
changelog_uri: https://github.com/verynicecode/forty-time-management/blob/master/ruby/CHANGELOG.md
|
40
42
|
post_install_message:
|
41
43
|
rdoc_options: []
|
42
44
|
require_paths:
|
@@ -45,14 +47,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
45
47
|
requirements:
|
46
48
|
- - ">="
|
47
49
|
- !ruby/object:Gem::Version
|
48
|
-
version: 2.
|
50
|
+
version: 2.6.5
|
49
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
52
|
requirements:
|
51
53
|
- - ">="
|
52
54
|
- !ruby/object:Gem::Version
|
53
55
|
version: '0'
|
54
56
|
requirements: []
|
55
|
-
rubygems_version: 3.
|
57
|
+
rubygems_version: 3.3.3
|
56
58
|
signing_key:
|
57
59
|
specification_version: 4
|
58
60
|
summary: Easily work with time
|