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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78c83da48923ac51635904a0e352188c594e045ee35939aa36789f84891665b3
4
- data.tar.gz: 8aac8b9f2370591e9399e7b22d0c342d406f89e06ec6ca9e576041bbbd850750
3
+ metadata.gz: 5eebf2c2163cdc4686dda95809e101dbe09c3f62f788f1900b4caf113cdc54f1
4
+ data.tar.gz: 3d15e412a3a64bde7ea1e459f202367dbebe7a60c5fcb6f039483e0bb9a867c7
5
5
  SHA512:
6
- metadata.gz: fd574595c58d6dece0a7b9f35d8cefe8d28b646c1b1957a6c5101a836140da1e0dd9b213db33ff37fe7853f1ef4d9a29b9bc23faf41a58e95f0be13cd9da132e
7
- data.tar.gz: 2d5f14df831f55d454fc10b1f9b8cd91c7635c0763013ec4943d64f57a1ff8198223b68bac2f4f734a4e14b1e3047746412075442f50f0d55d0a456da615c1eb
6
+ metadata.gz: 41c4cfc5ebd6a1f80bdfbba808ff588cb7bbe8f6cd602b5c8d27280565e8af70fd20a908db196e7428707f7bd0021c518642d532c0795bd187030f483252bbcf
7
+ data.tar.gz: 5f781c8e7b4489a6122438dad52e9655019e7c41df1ef379cb717a9c9cb964c61e5d2326eb5455bd9205c60ead2b0a0e5d24f1765175b5dd4409cf9ac599441c
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
- --format documentation
2
1
  --color
3
- --require spec_helper
2
+ --order random
data/.rubocop.yml CHANGED
@@ -1,3 +1,11 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ SuggestExtensions: false
4
+ TargetRubyVersion: 3.1.0
5
+
6
+ Gemspec/RequiredRubyVersion:
7
+ Enabled: false
8
+
1
9
  Layout/LineLength:
2
10
  Exclude:
3
11
  - 'forty_time.gemspec'
data/Gemfile.lock CHANGED
@@ -1,43 +1,46 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- forty_time (0.0.3)
4
+ forty_time (0.0.8)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- ast (2.4.0)
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)
16
- rake (12.3.3)
17
- rexml (3.2.4)
18
- rspec (3.9.0)
19
- rspec-core (~> 3.9.0)
20
- rspec-expectations (~> 3.9.0)
21
- rspec-mocks (~> 3.9.0)
22
- rspec-core (3.9.1)
23
- rspec-support (~> 3.9.1)
24
- rspec-expectations (3.9.1)
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.9.0)
27
- rspec-mocks (3.9.1)
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.9.0)
30
- rspec-support (3.9.2)
31
- rubocop (0.80.1)
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 (>= 2.7.0.1)
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, < 1.7)
39
- ruby-progressbar (1.10.1)
40
- unicode-display_width (1.6.1)
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.1.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.3.0')
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'
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
- hours, extra = input.split(':').map(&:to_i)
15
- minutes = hours * 60 + extra
15
+ minutes = parse_string(input)
16
+ new(minutes)
17
+ end
16
18
 
17
- minutes *= -1 if input[0] == '-'
19
+ def self.parse_string(string)
20
+ hours, extra = string.split(':').map(&:to_i)
21
+ extra *= -1 if string[0] == '-'
18
22
 
19
- new(minutes)
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'
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ class NullFortyTime < FortyTime
4
+ def initialize
5
+ super(0)
6
+ end
7
+
8
+ def value; end
9
+
10
+ def +(other)
11
+ other
12
+ end
13
+
14
+ def -(other)
15
+ other
16
+ end
17
+
18
+ def to_s
19
+ ''
20
+ end
21
+ 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
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: 2020-03-31 00:00:00.000000000 Z
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.3.0
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.0.3
57
+ rubygems_version: 3.3.3
56
58
  signing_key:
57
59
  specification_version: 4
58
60
  summary: Easily work with time