activerecord-time 0.20.0 → 0.22.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4fd61f3d4336ca6066bf7c370cc9b6ef79197a8a223c90c5988df700f4766f7
4
- data.tar.gz: 0c718820286900bcb68d4ca0a7fbcf138d9f2333335ef8a136e81421fb67f894
3
+ metadata.gz: 871778cc70f4d4da9385d3d38e9d8e5b945e459ffe0e78c7e340b8e12f795ef6
4
+ data.tar.gz: 9d9dfbc6e0256c8b91db7a788ace40cd9ffd583cd5dda8713907545b776ea97f
5
5
  SHA512:
6
- metadata.gz: 0b6cdf1f3d47679076e9e20ff5504ddd1b0322508e76431d7e27050f0d6b9e0cdddaef424cc3eb70cebbd4dda78fde8240864737ae011b1b402f42446a377bf4
7
- data.tar.gz: 0a3a67c6781ca27f19ca9814835f44389756625d13c69be4ca291c09e69fb602b33a05927af0b860a5c21814a1856473b3a7f5cc79e26b915c2fcbc89d3ca151
6
+ metadata.gz: 9965445d6ca087fe9e860b75be161f3ecf22c949d7c44c5c521e5d50938f8d7cb7f9f15af1972766f753c5b1abe748eae4a51a99d57ef12be786cca5c322a347
7
+ data.tar.gz: 6662a72e566791c18d8439685f1202e12a7ed32ac60917cc1aa64384e1de53ea6ed5b89cb73f5091435ebe5656eaeb16c0466eb01d073eccd2196f9adc5c13f3
@@ -1,14 +1,5 @@
1
1
  name: Test
2
2
  on:
3
- workflow_dispatch:
4
- inputs:
5
- logLevel:
6
- description: 'Log level'
7
- required: true
8
- default: 'warning'
9
- tags:
10
- description: 'Test scenario tags'
11
- required: false
12
3
  push:
13
4
  branches: [ master ]
14
5
  pull_request:
@@ -27,12 +18,12 @@ jobs:
27
18
  - uses: actions/checkout@v2
28
19
  - uses: ruby/setup-ruby@v1
29
20
  with:
30
- ruby-version: '3.0'
21
+ ruby-version: '3.3'
31
22
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
32
23
  - name: Rubocop
33
24
  run: bundle exec rubocop --auto-correct-all
34
25
  Test:
35
- runs-on: ubuntu-20.04
26
+ runs-on: ubuntu-latest
36
27
  services:
37
28
  postgres:
38
29
  image: postgres
@@ -46,19 +37,15 @@ jobs:
46
37
  fail-fast: false
47
38
  matrix:
48
39
  # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
49
- ruby: [ 2.6, 2.7, '3.0', jruby, truffleruby ]
50
- gemfile: [ ar61, ar60, ar52, ar51 ]
40
+ ruby: [ 3.3, 3.2, 3.1, jruby, truffleruby ]
41
+ gemfile: [ ar71, ar70 ]
51
42
  adapter: [ postgresql, sqlite3 ]
52
43
  exclude:
53
- - ruby: '3.0'
54
- gemfile: ar52
55
- - ruby: '3.0'
56
- gemfile: ar51
57
44
  - ruby: jruby
58
- adapter: sqlite3
45
+ - ruby: truffleruby
59
46
  env:
60
47
  ADAPTER: ${{ matrix.adapter }}
61
- BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
48
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/gems_${{ matrix.gemfile }}.rb
62
49
  steps:
63
50
  - uses: actions/checkout@v2
64
51
  - uses: ruby/setup-ruby@v1
data/.gitignore CHANGED
@@ -8,7 +8,7 @@ debug.log
8
8
  .DS_Store
9
9
  .idea
10
10
  .yardoc
11
- Gemfile.lock
11
+ *.lock
12
12
  InstalledFiles
13
13
  _yardoc
14
14
  coverage
@@ -16,7 +16,6 @@ doc/
16
16
  lib/bundler/man
17
17
  pkg
18
18
  rdoc
19
- spec/reports
20
19
  test/test.log
21
20
  test/tmp
22
21
  test/version_tmp
data/.rubocop.yml CHANGED
@@ -58,7 +58,7 @@ Rails:
58
58
 
59
59
  Security/Eval:
60
60
  Exclude:
61
- - 'gemfiles/*.gemfile'
61
+ - 'gemfiles/gems_*.rb'
62
62
 
63
63
  Style/Documentation:
64
64
  Enabled: false
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-11-25 11:12:32 UTC using RuboCop version 1.23.0.
3
+ # on 2024-04-28 21:09:41 UTC using RuboCop version 1.63.4.
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
@@ -17,38 +17,33 @@ Lint/DuplicateBranch:
17
17
  Exclude:
18
18
  - 'lib/time_of_day.rb'
19
19
 
20
- # Offense count: 3
21
- # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
20
+ # Offense count: 4
21
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
22
22
  Metrics/AbcSize:
23
- Max: 31
24
-
25
- # Offense count: 1
26
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
27
- # IgnoredMethods: refine
28
- Metrics/BlockLength:
29
- Max: 28
23
+ Max: 32
30
24
 
31
25
  # Offense count: 2
32
26
  # Configuration parameters: CountComments, CountAsOne.
33
27
  Metrics/ClassLength:
34
- Max: 184
28
+ Max: 189
35
29
 
36
- # Offense count: 1
37
- # Configuration parameters: IgnoredMethods.
30
+ # Offense count: 2
31
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
38
32
  Metrics/CyclomaticComplexity:
39
33
  Max: 10
40
34
 
41
35
  # Offense count: 3
42
- # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
36
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
43
37
  Metrics/MethodLength:
44
38
  Max: 13
45
39
 
46
- # Offense count: 1
47
- # Configuration parameters: IgnoredMethods.
40
+ # Offense count: 2
41
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
48
42
  Metrics/PerceivedComplexity:
49
43
  Max: 11
50
44
 
51
45
  # Offense count: 2
46
+ # This cop supports unsafe autocorrection (--autocorrect-all).
52
47
  # Configuration parameters: EnforcedStyle, AllowToTime.
53
48
  # SupportedStyles: strict, flexible
54
49
  Rails/Date:
@@ -56,32 +51,31 @@ Rails/Date:
56
51
  - 'lib/time_of_day.rb'
57
52
 
58
53
  # Offense count: 1
59
- # Cop supports --auto-correct.
54
+ # This cop supports unsafe autocorrection (--autocorrect-all).
60
55
  Rails/WhereEquals:
61
56
  Exclude:
62
57
  - 'test/time_of_day_test.rb'
63
58
 
64
59
  # Offense count: 1
65
- # Cop supports --auto-correct.
60
+ # This cop supports safe autocorrection (--autocorrect).
66
61
  Rails/WhereNot:
67
62
  Exclude:
68
63
  - 'test/time_of_day_test.rb'
69
64
 
70
- # Offense count: 2
71
- # Cop supports --auto-correct.
72
- Security/YAMLLoad:
65
+ # Offense count: 1
66
+ Security/CompoundHash:
73
67
  Exclude:
74
- - 'test/test_helper.rb'
75
- - 'test/time_of_day_test.rb'
68
+ - 'lib/time_of_day.rb'
76
69
 
77
70
  # Offense count: 1
71
+ # This cop supports unsafe autocorrection (--autocorrect-all).
78
72
  # Configuration parameters: AllowModifiersOnSymbols.
79
73
  # SupportedStyles: inline, group
80
74
  Style/AccessModifierDeclarations:
81
75
  EnforcedStyle: inline
82
76
 
83
77
  # Offense count: 3
84
- # Cop supports --auto-correct.
78
+ # This cop supports safe autocorrection (--autocorrect).
85
79
  # Configuration parameters: EnforcedStyle.
86
80
  # SupportedStyles: separated, grouped
87
81
  Style/AccessorGrouping:
@@ -89,7 +83,7 @@ Style/AccessorGrouping:
89
83
  - 'lib/time_of_day.rb'
90
84
 
91
85
  # Offense count: 1
92
- # Cop supports --auto-correct.
86
+ # This cop supports unsafe autocorrection (--autocorrect-all).
93
87
  # Configuration parameters: EnforcedStyle.
94
88
  # SupportedStyles: nested, compact
95
89
  Style/ClassAndModuleChildren:
@@ -104,7 +98,7 @@ Style/OptionalBooleanParameter:
104
98
  - 'lib/time_of_day.rb'
105
99
 
106
100
  # Offense count: 5
107
- # Cop supports --auto-correct.
101
+ # This cop supports unsafe autocorrection (--autocorrect-all).
108
102
  # Configuration parameters: Mode.
109
103
  Style/StringConcatenation:
110
104
  Exclude:
data/Gemfile CHANGED
@@ -5,4 +5,6 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in activerecord-time.gemspec
6
6
  gemspec
7
7
 
8
+ eval File.read("#{__dir__}/gemfiles/common.gemfile") # rubocop:disable Security/Eval
9
+
8
10
  gem 'activerecord', ENV['AR_VERSION'] if ENV['AR_VERSION']
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.summary = 'A handler for storing TimeOfDay objects in ActiveRecord objects as sql time values.'
17
17
  gem.homepage = 'https://github.com/donv/activerecord-time'
18
18
  gem.license = 'MIT'
19
- gem.required_ruby_version = '>= 2.5'
19
+ gem.required_ruby_version = '>= 3.1'
20
20
 
21
21
  gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
22
22
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
@@ -25,13 +25,6 @@ Gem::Specification.new do |gem|
25
25
 
26
26
  gem.add_runtime_dependency 'activerecord', '~>7.0'
27
27
 
28
- if defined? JRUBY_VERSION
29
- gem.add_development_dependency 'activerecord-jdbcpostgresql-adapter'
30
- gem.add_development_dependency 'activerecord-jdbcsqlite3-adapter'
31
- else
32
- gem.add_development_dependency 'pg'
33
- gem.add_development_dependency 'sqlite3'
34
- end
35
28
  gem.add_development_dependency 'rake'
36
29
  gem.add_development_dependency 'rubocop'
37
30
  gem.add_development_dependency 'rubocop-performance'
@@ -1,32 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- unless defined?(SKIP_JRUBY)
4
- platform :jruby do
5
- if defined?(RAILS_5)
6
- git_source(:github) do |repo_name|
7
- repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
8
- "https://github.com/#{repo_name}.git"
9
- end
10
- gem 'activerecord-jdbc-adapter', github: 'jruby/activerecord-jdbc-adapter'
11
- gem 'activerecord-jdbcderby-adapter', github: 'jruby/activerecord-jdbc-adapter'
12
- gem 'activerecord-jdbcpostgresql-adapter', github: 'jruby/activerecord-jdbc-adapter'
13
- gem 'activerecord-jdbcsqlite3-adapter', github: 'jruby/activerecord-jdbc-adapter'
14
- gem 'jdbc-postgres', github: 'jruby/activerecord-jdbc-adapter'
15
- gem 'jdbc-sqlite3', github: 'jruby/activerecord-jdbc-adapter'
16
- else
17
- # rubocop: disable Bundler/DuplicatedGem
18
- gem 'activerecord-jdbc-adapter'
19
- gem 'activerecord-jdbcderby-adapter'
20
- gem 'activerecord-jdbcpostgresql-adapter'
21
- gem 'activerecord-jdbcsqlite3-adapter'
22
- # rubocop: enable Bundler/DuplicatedGem
23
- end
24
- end
25
- end
26
-
27
3
  platform :ruby do
28
4
  gem 'pg'
29
- gem 'sqlite3'
5
+ gem 'sqlite3', '<2'
30
6
  end
31
7
 
32
8
  gem 'minitest-reporters'
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ eval File.read("#{File.dirname __FILE__}/common.gemfile")
4
+
5
+ platform :jruby do
6
+ # gem 'activerecord-jdbc-adapter'
7
+ # gem 'activerecord-jdbcderby-adapter'
8
+ gem 'activerecord-jdbcpostgresql-adapter'
9
+ gem 'activerecord-jdbcsqlite3-adapter'
10
+ end
11
+
12
+ gem 'activerecord', '~>7.0.0'
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ eval File.read("#{File.dirname __FILE__}/common.gemfile")
4
+
5
+ platform :jruby do
6
+ git_source(:github) do |repo_name|
7
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
8
+ "https://github.com/#{repo_name}.git"
9
+ end
10
+ gem 'activerecord-jdbc-adapter', github: 'jruby/activerecord-jdbc-adapter'
11
+ # gem 'activerecord-jdbcderby-adapter', github: 'jruby/activerecord-jdbc-adapter'
12
+ gem 'activerecord-jdbcpostgresql-adapter', github: 'jruby/activerecord-jdbc-adapter'
13
+ gem 'activerecord-jdbcsqlite3-adapter', github: 'jruby/activerecord-jdbc-adapter'
14
+ gem 'jdbc-postgres', github: 'jruby/activerecord-jdbc-adapter'
15
+ gem 'jdbc-sqlite3', github: 'jruby/activerecord-jdbc-adapter'
16
+ end
17
+
18
+ gem 'activerecord', '~>7.1.0'
@@ -20,11 +20,11 @@ module Activerecord
20
20
  end
21
21
  end
22
22
 
23
- ActiveRecord::ConnectionAdapters::Quoting.prepend Activerecord::Time::Quoting
23
+ ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend Activerecord::Time::Quoting
24
24
 
25
- module ActiveRecord
26
- module Type
27
- class Time < ActiveModel::Type::Time # :nodoc:
25
+ module Activerecord
26
+ module Time
27
+ module Casting
28
28
  private def cast_value(value)
29
29
  return value.time_of_day if value.is_a?(::DateTime) || value.is_a?(::Time)
30
30
  return value unless value.is_a?(::String)
@@ -35,3 +35,4 @@ module ActiveRecord
35
35
  end
36
36
  end
37
37
  end
38
+ ActiveRecord::Type::Time.prepend Activerecord::Time::Casting
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Activerecord
4
4
  module Time
5
- VERSION = '0.20.0'
5
+ VERSION = '0.22.0'
6
6
  end
7
7
  end
@@ -8,6 +8,7 @@ class Time
8
8
  end
9
9
  end
10
10
 
11
+ require 'date'
11
12
  class DateTime
12
13
  def time_of_day
13
14
  TimeOfDay.new(hour, min, sec)
data/lib/time_of_day.rb CHANGED
@@ -9,32 +9,6 @@ class TimeOfDay
9
9
  attr_accessor :minute # 0 - 59
10
10
  attr_accessor :second # 0 - 59
11
11
 
12
- def initialize(hour, minute = 0, second = 0)
13
- if hour == 24
14
- unless minute == 0 && second == 0
15
- raise "Invalid TimeOfDay. #{hour}:#{minute}:#{second} given, but highest allowed value is 24:00:00"
16
- end
17
- else
18
- raise "Invalid hour: #{hour}" unless hour >= 0 && hour <= 23
19
- end
20
- raise "Invalid minute: #{minute}" unless minute >= 0 && minute <= 59
21
- raise "Invalid second: #{second}" unless second >= 0 && second <= 59
22
-
23
- @hour = hour
24
- @minute = minute
25
- @second = second
26
- end
27
-
28
- def init_with(coder)
29
- parts = self.class.parse_parts(coder.scalar)
30
- initialize(*parts)
31
- end
32
-
33
- def encode_with(coder)
34
- coder.tag = 'tag:yaml.org,2002:time'
35
- coder.scalar = to_s
36
- end
37
-
38
12
  def self.now
39
13
  Time.now.time_of_day # rubocop: disable Rails/TimeZone
40
14
  end
@@ -62,8 +36,30 @@ class TimeOfDay
62
36
  [hours.to_i, minutes.to_i, seconds.to_i]
63
37
  end
64
38
 
65
- def acts_like_time?
66
- true
39
+ def initialize(hour, minute = 0, second = 0)
40
+ if hour == 24
41
+ unless minute == 0 && second == 0
42
+ raise "Invalid TimeOfDay. #{hour}:#{minute}:#{second} given, but highest allowed value is 24:00:00"
43
+ end
44
+ else
45
+ raise "Invalid hour: #{hour}" unless hour >= 0 && hour <= 23
46
+ end
47
+ raise "Invalid minute: #{minute}" unless minute >= 0 && minute <= 59
48
+ raise "Invalid second: #{second}" unless second >= 0 && second <= 59
49
+
50
+ @hour = hour
51
+ @minute = minute
52
+ @second = second
53
+ end
54
+
55
+ def init_with(coder)
56
+ parts = self.class.parse_parts(coder.scalar)
57
+ initialize(*parts)
58
+ end
59
+
60
+ def encode_with(coder)
61
+ coder.tag = 'tag:yaml.org,2002:time'
62
+ coder.scalar = to_s
67
63
  end
68
64
 
69
65
  def in_time_zone(*)
@@ -78,6 +74,14 @@ class TimeOfDay
78
74
  Time.local(date.year, date.month, date.day, hour, minute, second) # rubocop: disable Rails/TimeZone
79
75
  end
80
76
 
77
+ def change(*)
78
+ self
79
+ end
80
+
81
+ def year
82
+ 2000
83
+ end
84
+
81
85
  def +(other)
82
86
  raise "Illegal argument: #{other.inspect}" unless other.is_a? Numeric
83
87
 
@@ -93,7 +97,7 @@ class TimeOfDay
93
97
  t2 = Time.local(0, 1, 1, other.hour, other.minute, other.second) # rubocop: disable Rails/TimeZone
94
98
  (t1 - t2).seconds
95
99
  when Numeric
96
- self.+(-other)
100
+ self + -other
97
101
  else
98
102
  raise "Illegal argument: #{other.inspect}"
99
103
  end
@@ -137,6 +141,7 @@ class TimeOfDay
137
141
  rescue
138
142
  "#{@hour.inspect}:#{@minute.inspect}:#{@second.inspect}"
139
143
  end
144
+ alias to_fs to_s
140
145
 
141
146
  def inspect
142
147
  "#<#{self.class} hour=#{@hour}, minute=#{@minute}, second=#{@second}>"
data/matrix_test.rb CHANGED
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env ruby -w
2
2
  # frozen_string_literal: true
3
3
 
4
- system('rubocop --auto-correct') || exit(1)
4
+ system('rubocop --autocorrect-all') || exit(1)
5
5
 
6
6
  update_gemfiles = ARGV.delete('--update')
7
7
 
8
8
  require 'yaml'
9
- travis = YAML.safe_load(File.read('.travis.yml'))
9
+ actions = YAML.safe_load_file('.github/workflows/test.yml')
10
10
 
11
11
  def run_script(ruby, env, gemfile)
12
- env.scan(/\b(?<key>[A-Z_]+)="(?<value>.+?)"/) do |key, value|
13
- ENV[key] = value
12
+ env.each do |key, value|
13
+ ENV[key.to_s] = value
14
14
  end
15
15
  puts '*' * 80
16
16
  puts "Testing #{ruby} #{gemfile} #{env}"
@@ -24,10 +24,9 @@ def use_gemfile(ruby, gemfile, update_gemfiles)
24
24
  puts '$' * 80
25
25
  puts "Testing #{gemfile}"
26
26
  puts
27
- ENV['BUNDLE_GEMFILE'] = gemfile
28
- system "chruby-exec #{ruby} -- bundle -v"
27
+ ENV['BUNDLE_GEMFILE'] = "gemfiles/gems_#{gemfile}.rb"
29
28
  if update_gemfiles
30
- system "chruby-exec #{ruby} -- bundle update"
29
+ system "chruby-exec #{ruby} -- bundle update && chruby-exec #{ruby} -- bundle update --bundler"
31
30
  else
32
31
  system "chruby-exec #{ruby} -- bundle check || chruby-exec #{ruby} -- bundle install"
33
32
  end || exit(1)
@@ -36,39 +35,42 @@ def use_gemfile(ruby, gemfile, update_gemfiles)
36
35
  puts '$' * 80
37
36
  end
38
37
 
39
- bad_variants = (travis.dig('matrix', 'exclude').to_a + travis.dig('matrix', 'allow_failures').to_a)
40
-
41
- travis['env']['global'].each do |env|
42
- env.scan(/\b(?<key>[A-Z_]+)="(?<value>.+?)"/) do |key, value|
43
- ENV[key] = value
38
+ def bad_variant?(bad_variants, ruby, gemfile = nil, adapter = nil)
39
+ bad_variants.find do |f|
40
+ !(ruby.nil? ^ f['ruby'].nil?) && f['ruby'] == ruby &&
41
+ !(gemfile.nil? ^ f['gemfile'].nil?) && f['gemfile'] == gemfile &&
42
+ !(adapter.nil? ^ f['adapter'].nil?) && f['adapter'] == adapter
44
43
  end
45
44
  end
46
45
 
47
- travis['rvm'].each do |ruby|
48
- next if /head/.match?(ruby) # ruby-install does not support HEAD installation
46
+ actions['env'].each do |key, value|
47
+ ENV[key] = value
48
+ end
49
+
50
+ matrix = actions['jobs']['Test']['strategy']['matrix']
51
+ bad_variants = matrix['exclude']
52
+
53
+ matrix['ruby'].each do |ruby|
54
+ next if bad_variant?(bad_variants, ruby)
49
55
 
50
56
  puts '#' * 80
51
57
  puts "Testing #{ruby}"
52
58
  puts
53
- system "ruby-install --no-reinstall #{ruby}" || exit(1)
54
- bundler_version = '1.17.2'
55
- gem_cmd = "chruby-exec #{ruby} -- gem"
56
- system "#{gem_cmd} uninstall --force --all --version '!=#{bundler_version}' bundler"
57
- bundler_gem_check_cmd = "#{gem_cmd} query -i -n '^bundler$' -v '#{bundler_version}' >/dev/null"
58
- bundler_install_cmd = "#{gem_cmd} install bundler -v '#{bundler_version}'"
59
- system "#{bundler_gem_check_cmd} || #{bundler_install_cmd}" || exit(1)
60
- travis['gemfile'].each do |gemfile|
61
- use_gemfile(ruby, gemfile, update_gemfiles) do
62
- travis['env']['matrix'].each do |env|
63
- bad_variant = bad_variants.any? do |f|
64
- (f['rvm'].nil? || f['rvm'] == ruby) &&
65
- (f['gemfile'].nil? || f['gemfile'] == gemfile) && (f['env'].nil? || f['env'] == env)
66
- end
67
- if bad_variant
68
- puts 'Skipping known failure.'
69
- next
59
+ Bundler.with_unbundled_env do
60
+ system("ruby-install --no-reinstall #{ruby}") || exit(1)
61
+ matrix['gemfile'].each do |gemfile|
62
+ next if bad_variant?(bad_variants, ruby, gemfile)
63
+
64
+ use_gemfile(ruby, gemfile, update_gemfiles) do
65
+ matrix['adapter'].each do |adapter|
66
+ next if bad_variant?(bad_variants, ruby, gemfile, adapter)
67
+
68
+ puts '-' * 80
69
+ puts "Testing #{adapter}"
70
+ puts
71
+
72
+ run_script(ruby, { ADAPTER: adapter }, gemfile)
70
73
  end
71
- run_script(ruby, env, gemfile)
72
74
  end
73
75
  end
74
76
  end
data/test/test_helper.rb CHANGED
@@ -19,7 +19,7 @@ if defined?(Rake) && (RUBY_ENGINE != 'jruby' || org.jruby.RubyInstanceConfig.FUL
19
19
  end
20
20
 
21
21
  FileUtils.rm_rf File.expand_path(':memory:', File.dirname(__FILE__))
22
- config = YAML.load(File.read(File.dirname(__FILE__) + '/database.yml'))
22
+ config = YAML.load_file(File.dirname(__FILE__) + '/database.yml')
23
23
  ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + '/test.log')
24
24
  adapter = ENV['ADAPTER'] || 'sqlite3'
25
25
  if adapter != 'sqlite3'
@@ -81,7 +81,11 @@ class TimeOfDayTest < Minitest::Test
81
81
  end
82
82
 
83
83
  def test_yaml_load
84
- hash = YAML.load('start_at: !!time 12:34:56')
84
+ hash = if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.1')
85
+ YAML.load('start_at: !!time 12:34:56')
86
+ else
87
+ YAML.load('start_at: !!time 12:34:56', permitted_classes: [:TimeOfDay])
88
+ end
85
89
  assert_equal({ 'start_at' => TimeOfDay.parse('12:34:56') }, hash)
86
90
  end
87
91
 
@@ -95,8 +99,9 @@ class TimeOfDayTest < Minitest::Test
95
99
  end
96
100
 
97
101
  def test_activerecord
98
- Event.create! name: 'Bored meeting', start_at: @twelve_o_clock
102
+ t0 = Event.create! name: 'Bored meeting', start_at: @twelve_o_clock
99
103
  t = Event.where(start_at: '12:00:00').first
104
+ assert_equal t0, t
100
105
  assert_equal TimeOfDay, t.start_at.class
101
106
  assert_equal t, Event.where(start_at: @twelve_o_clock).first
102
107
  assert_equal t, Event.where('start_at = ?', @twelve_o_clock).first
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.20.0
4
+ version: 0.22.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: 2022-03-22 00:00:00.000000000 Z
11
+ date: 2024-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -24,34 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '7.0'
27
- - !ruby/object:Gem::Dependency
28
- name: pg
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: sqlite3
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: rake
57
29
  requirement: !ruby/object:Gem::Requirement
@@ -148,18 +120,15 @@ files:
148
120
  - ".gitignore"
149
121
  - ".rubocop.yml"
150
122
  - ".rubocop_todo.yml"
151
- - ".travis.yml"
152
123
  - Gemfile
153
124
  - LICENSE
154
125
  - LICENSE.txt
155
126
  - README.md
156
127
  - Rakefile
157
128
  - activerecord-time.gemspec
158
- - gemfiles/ar51.gemfile
159
- - gemfiles/ar52.gemfile
160
- - gemfiles/ar60.gemfile
161
- - gemfiles/ar61.gemfile
162
129
  - gemfiles/common.gemfile
130
+ - gemfiles/gems_ar70.rb
131
+ - gemfiles/gems_ar71.rb
163
132
  - lib/activerecord-time.rb
164
133
  - lib/activerecord-time/extension.rb
165
134
  - lib/activerecord-time/version.rb
@@ -182,14 +151,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
151
  requirements:
183
152
  - - ">="
184
153
  - !ruby/object:Gem::Version
185
- version: '2.5'
154
+ version: '3.1'
186
155
  required_rubygems_version: !ruby/object:Gem::Requirement
187
156
  requirements:
188
157
  - - ">="
189
158
  - !ruby/object:Gem::Version
190
159
  version: '0'
191
160
  requirements: []
192
- rubygems_version: 3.3.7
161
+ rubygems_version: 3.5.9
193
162
  signing_key:
194
163
  specification_version: 4
195
164
  summary: A handler for storing TimeOfDay objects in ActiveRecord objects as sql time
data/.travis.yml DELETED
@@ -1,29 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
- services:
5
- - postgresql
6
- jdk:
7
- - openjdk11
8
- rvm:
9
- - ruby-3.0
10
- - ruby-2.7
11
- - ruby-2.6
12
- - ruby-2.5
13
- - jruby
14
- gemfile:
15
- - gemfiles/ar61.gemfile
16
- - gemfiles/ar60.gemfile
17
- - gemfiles/ar52.gemfile
18
- - gemfiles/ar51.gemfile
19
- env:
20
- global:
21
- - JRUBY_OPTS="--dev --debug"
22
- matrix:
23
- - ADAPTER="postgresql"
24
- - ADAPTER="sqlite3"
25
- matrix:
26
- allow_failures:
27
- - rvm: jruby
28
- env: ADAPTER="sqlite3"
29
- - rvm: ruby-2.7
@@ -1,3 +0,0 @@
1
- eval File.read("#{File.dirname __FILE__}/common.gemfile")
2
-
3
- gem 'activerecord', '~>5.1.1'
@@ -1,3 +0,0 @@
1
- eval File.read("#{File.dirname __FILE__}/common.gemfile")
2
-
3
- gem 'activerecord', '~>5.2.0'
@@ -1,3 +0,0 @@
1
- eval File.read("#{File.dirname __FILE__}/common.gemfile")
2
-
3
- gem 'activerecord', '~>6.0.0'
@@ -1,3 +0,0 @@
1
- eval File.read("#{File.dirname __FILE__}/common.gemfile")
2
-
3
- gem 'activerecord', '~>6.1.0'