activerecord-time 0.19.0 → 0.22.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: 38e31e5791113c1c15833344fc7a243a87bacc1f35cc6fdbeb15cbe7edf7daf4
4
- data.tar.gz: 58990d314938ba0786cf4733c1616c50757d5e21cb6e37153b207fff4d5d5b42
3
+ metadata.gz: 871778cc70f4d4da9385d3d38e9d8e5b945e459ffe0e78c7e340b8e12f795ef6
4
+ data.tar.gz: 9d9dfbc6e0256c8b91db7a788ace40cd9ffd583cd5dda8713907545b776ea97f
5
5
  SHA512:
6
- metadata.gz: 0bfd12648f4877017b8296a35dfebca5ae1ac9157bc6d63f35354450b3953a950d6a99fa38d477ffe01bf363b459b3010fe6d0f17589ee744e0b8b4b542c1210
7
- data.tar.gz: fa6e24e7993c666265de8e82dee024f66e18878141d31c5862c0602ba4096854601f81af6253875cf7f81505ceac2de1e932d36dde97423db825ba6943517a29
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,22 +16,15 @@ 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) }
23
23
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
24
24
  gem.require_paths = %w[lib]
25
25
 
26
- gem.add_runtime_dependency 'activerecord', '>=5.1', '<7'
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'
@@ -5,13 +5,13 @@ require 'active_record/connection_adapters/abstract/quoting'
5
5
  module Activerecord
6
6
  module Time
7
7
  module Quoting
8
- def _quote(value)
8
+ def quote(value)
9
9
  return "'#{value}'" if value.is_a?(TimeOfDay)
10
10
 
11
11
  super(value)
12
12
  end
13
13
 
14
- def _type_cast(value)
14
+ def type_cast(value)
15
15
  return value.to_s if value.is_a?(TimeOfDay)
16
16
 
17
17
  super(value)
@@ -20,12 +20,11 @@ module Activerecord
20
20
  end
21
21
  end
22
22
 
23
- # ActiveRecord::ConnectionAdapters::Quoting.prepend Activerecord::Time::Quoting
24
23
  ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend Activerecord::Time::Quoting
25
24
 
26
- module ActiveRecord
27
- module Type
28
- class Time < ActiveModel::Type::Time # :nodoc:
25
+ module Activerecord
26
+ module Time
27
+ module Casting
29
28
  private def cast_value(value)
30
29
  return value.time_of_day if value.is_a?(::DateTime) || value.is_a?(::Time)
31
30
  return value unless value.is_a?(::String)
@@ -36,3 +35,4 @@ module ActiveRecord
36
35
  end
37
36
  end
38
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.19.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}>"
@@ -149,4 +154,8 @@ class TimeOfDay
149
154
  def to_json(*)
150
155
  %("#{self}")
151
156
  end
157
+
158
+ def utc?
159
+ true
160
+ end
152
161
  end
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,63 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.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: 2021-12-16 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
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '5.1'
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: '7'
19
+ version: '7.0'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: '5.1'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '7'
33
- - !ruby/object:Gem::Dependency
34
- name: pg
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '0'
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: '0'
47
- - !ruby/object:Gem::Dependency
48
- name: sqlite3
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
24
+ - - "~>"
52
25
  - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '0'
26
+ version: '7.0'
61
27
  - !ruby/object:Gem::Dependency
62
28
  name: rake
63
29
  requirement: !ruby/object:Gem::Requirement
@@ -154,18 +120,15 @@ files:
154
120
  - ".gitignore"
155
121
  - ".rubocop.yml"
156
122
  - ".rubocop_todo.yml"
157
- - ".travis.yml"
158
123
  - Gemfile
159
124
  - LICENSE
160
125
  - LICENSE.txt
161
126
  - README.md
162
127
  - Rakefile
163
128
  - activerecord-time.gemspec
164
- - gemfiles/ar51.gemfile
165
- - gemfiles/ar52.gemfile
166
- - gemfiles/ar60.gemfile
167
- - gemfiles/ar61.gemfile
168
129
  - gemfiles/common.gemfile
130
+ - gemfiles/gems_ar70.rb
131
+ - gemfiles/gems_ar71.rb
169
132
  - lib/activerecord-time.rb
170
133
  - lib/activerecord-time/extension.rb
171
134
  - lib/activerecord-time/version.rb
@@ -188,14 +151,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
188
151
  requirements:
189
152
  - - ">="
190
153
  - !ruby/object:Gem::Version
191
- version: '2.5'
154
+ version: '3.1'
192
155
  required_rubygems_version: !ruby/object:Gem::Requirement
193
156
  requirements:
194
157
  - - ">="
195
158
  - !ruby/object:Gem::Version
196
159
  version: '0'
197
160
  requirements: []
198
- rubygems_version: 3.2.32
161
+ rubygems_version: 3.5.9
199
162
  signing_key:
200
163
  specification_version: 4
201
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'