activerecord-time 0.17.0 → 0.18.0

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: a78f054f0473a1a0adb90af5ae3395b847bdd06cfb9d564a67f595a8e90d0c6f
4
- data.tar.gz: feca115e76f76ab8d2b5734ac2c5e89a8d3fca0eb12930b1c12a9a512f24df1c
3
+ metadata.gz: 80b52c52ad34414185dbadd7b54be0d7dbfc2b9be326581d7102fe1ce713eff2
4
+ data.tar.gz: '04965d38dce4fa1a2510725f4626f7796d2e23e0a7a9597535f6b212b8058b46'
5
5
  SHA512:
6
- metadata.gz: 3936ced2f21a9d38cb4578789a952917a90f20365caccbb58e1bfd9a280a6b551a4dd8cc672208a04466311971158a480d20cdf88a60939eb2538f85360f0d97
7
- data.tar.gz: 1fc524b519c6a4ca3bec14f8c73976df8ff111856d1834d1da31ad81f9b2ffe967fa0829a81b01c1dbd05b42144ebf33694c76570e4b88529ebf088f1370b02b
6
+ metadata.gz: cf3f7975838214c58b8c7970c3951b1be99f14b1dea449f30c1ab63370ab196cc352fff4dde07c99d848f04e49e3f9d9ca1c148545e457a9293100fab97cd7bb
7
+ data.tar.gz: a64a1dd1ffccccf70699318117503f67841f59b4c54e8c36f8d7fadd01169130a921a027e8800f6173b3387487b54d08c6ca0a91749b0c679d39274b0f6fd921
data/.rubocop.yml CHANGED
@@ -5,7 +5,6 @@ require:
5
5
  - rubocop-rake
6
6
 
7
7
  AllCops:
8
- TargetRubyVersion: 2.4
9
8
  DisplayCopNames: true
10
9
  DisplayStyleGuide: true
11
10
  NewCops: enable
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2021-02-02 13:29:03 UTC using RuboCop version 1.9.1.
3
+ # on 2021-11-25 10:12:00 UTC using RuboCop version 1.23.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -26,12 +26,12 @@ Metrics/AbcSize:
26
26
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
27
27
  # IgnoredMethods: refine
28
28
  Metrics/BlockLength:
29
- Max: 26
29
+ Max: 28
30
30
 
31
31
  # Offense count: 2
32
32
  # Configuration parameters: CountComments, CountAsOne.
33
33
  Metrics/ClassLength:
34
- Max: 176
34
+ Max: 174
35
35
 
36
36
  # Offense count: 1
37
37
  # Configuration parameters: IgnoredMethods.
@@ -41,7 +41,7 @@ Metrics/CyclomaticComplexity:
41
41
  # Offense count: 3
42
42
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
43
43
  Metrics/MethodLength:
44
- Max: 15
44
+ Max: 13
45
45
 
46
46
  # Offense count: 1
47
47
  # Configuration parameters: IgnoredMethods.
@@ -49,7 +49,7 @@ Metrics/PerceivedComplexity:
49
49
  Max: 11
50
50
 
51
51
  # Offense count: 2
52
- # Configuration parameters: EnforcedStyle.
52
+ # Configuration parameters: EnforcedStyle, AllowToTime.
53
53
  # SupportedStyles: strict, flexible
54
54
  Rails/Date:
55
55
  Exclude:
@@ -105,6 +105,7 @@ Style/OptionalBooleanParameter:
105
105
 
106
106
  # Offense count: 5
107
107
  # Cop supports --auto-correct.
108
+ # Configuration parameters: Mode.
108
109
  Style/StringConcatenation:
109
110
  Exclude:
110
111
  - 'test/test_helper.rb'
data/.travis.yml CHANGED
@@ -4,13 +4,15 @@ cache: bundler
4
4
  services:
5
5
  - postgresql
6
6
  jdk:
7
- - openjdk
7
+ - openjdk11
8
8
  rvm:
9
+ - ruby-3.0
9
10
  - ruby-2.7
10
11
  - ruby-2.6
11
12
  - ruby-2.5
12
13
  - jruby
13
14
  gemfile:
15
+ - gemfiles/ar61.gemfile
14
16
  - gemfiles/ar60.gemfile
15
17
  - gemfiles/ar52.gemfile
16
18
  - gemfiles/ar51.gemfile
@@ -32,7 +32,6 @@ Gem::Specification.new do |gem|
32
32
  gem.add_development_dependency 'pg'
33
33
  gem.add_development_dependency 'sqlite3'
34
34
  end
35
- gem.add_development_dependency 'minitest-reporters'
36
35
  gem.add_development_dependency 'rake'
37
36
  gem.add_development_dependency 'rubocop'
38
37
  gem.add_development_dependency 'rubocop-performance'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Activerecord
4
4
  module Time
5
- VERSION = '0.17.0'
5
+ VERSION = '0.18.0'
6
6
  end
7
7
  end
data/lib/time_of_day.rb CHANGED
@@ -87,9 +87,15 @@ class TimeOfDay
87
87
  end
88
88
 
89
89
  def -(other)
90
- raise "Illegal argument: #{other.inspect}" unless other.is_a? Numeric
91
-
92
- self.+(-other)
90
+ if other.is_a?(TimeOfDay)
91
+ t1 = Time.local(0, 1, 1, hour, minute, second) # rubocop: disable Rails/TimeZone
92
+ t2 = Time.local(0, 1, 1, other.hour, other.minute, other.second) # rubocop: disable Rails/TimeZone
93
+ (t1 - t2).seconds
94
+ elsif other.is_a?(Numeric)
95
+ self.+(-other)
96
+ else
97
+ raise "Illegal argument: #{other.inspect}"
98
+ end
93
99
  end
94
100
 
95
101
  def <=>(other)
data/test/test_helper.rb CHANGED
@@ -6,8 +6,6 @@ RAILS_ROOT = File.dirname(__FILE__)
6
6
  require 'rubygems'
7
7
  require 'bundler/setup'
8
8
  require 'minitest/autorun'
9
- require 'minitest/reporters'
10
- MiniTest::Reporters.use!
11
9
 
12
10
  require 'active_record'
13
11
  require 'activerecord-time'
@@ -142,6 +142,16 @@ class TimeOfDayTest < Minitest::Test
142
142
  assert_equal 59, tod.second
143
143
  end
144
144
 
145
+ def test_minus_tod
146
+ tod1 = TimeOfDay.new(12, 0, 29)
147
+ tod2 = TimeOfDay.new(13, 30, 59)
148
+ duration = tod2 - tod1
149
+
150
+ assert_equal 1, duration.in_hours.to_i
151
+ assert_equal 30, duration.in_minutes.to_i % 60
152
+ assert_equal 30, duration.in_seconds % 60
153
+ end
154
+
145
155
  def test_equality
146
156
  tod1 = TimeOfDay.new(12, 0, 5)
147
157
  tod2 = TimeOfDay.new(12, 0, 5)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uwe Kubosch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-02 00:00:00.000000000 Z
11
+ date: 2021-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -58,20 +58,6 @@ dependencies:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
- - !ruby/object:Gem::Dependency
62
- name: minitest-reporters
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '0'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
61
  - !ruby/object:Gem::Dependency
76
62
  name: rake
77
63
  requirement: !ruby/object:Gem::Requirement
@@ -211,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
197
  - !ruby/object:Gem::Version
212
198
  version: '0'
213
199
  requirements: []
214
- rubygems_version: 3.2.3
200
+ rubygems_version: 3.2.22
215
201
  signing_key:
216
202
  specification_version: 4
217
203
  summary: A handler for storing TimeOfDay objects in ActiveRecord objects as sql time