activerecord-time 0.10.1 → 0.12.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
  SHA1:
3
- metadata.gz: b109ca8028703d50b73bfd9a66608c2669e9f913
4
- data.tar.gz: fceb1381dd5c0012c3412225f0ea666a5040b692
3
+ metadata.gz: 877aec8ae6f1cf15a3730b23a0f1c2e6ea1f403c
4
+ data.tar.gz: 1fc6b3270f3a8f2259695e3b3ae13d4f86122421
5
5
  SHA512:
6
- metadata.gz: 2e037eefad7123564ec01170a4af564a5bcb0b8576109088ecaeb76758dc3d499ae15a23d16bf5ba18ff73c9a3b2b8db4f4894a6fcb16d537539ae225b01c12a
7
- data.tar.gz: 10802ff538c716a5bf7aa31668570cddc0c7cbbe91254ea5b9166633bf84d54e9e44f663b34b63dcc8e8b4500c3dea0c2052428cc03794d82d2636827ea7e0c2
6
+ metadata.gz: b0dcf17261de5d998597d32895bc2eeb11f2f749d9d5d829370f2653b2fe8e14daac265b3242f094efaee29aa8daa111b08f774c82865cc80a95845b02dacca3
7
+ data.tar.gz: 15cbb911123ef1a9ddd07ebe6799ea24823e196681203d37c22c598192378fa67edbfb8828efa64993bfb60b7b5784db0c69997de385a6d50abec8bbcb7a1984
@@ -4,13 +4,11 @@ jdk:
4
4
  - oraclejdk8
5
5
  before_install: gem install bundler # TODO(uwe): https://github.com/travis-ci/travis-ci/issues/9383
6
6
  rvm:
7
- # - ruby-2.5.1
7
+ - ruby-2.5.1
8
8
  - ruby-2.4.4
9
9
  - jruby-9.1.17.0
10
10
  - ruby-2.3.7
11
11
  - ruby-2.2.10
12
- - ruby-head
13
- - jruby-head
14
12
  gemfile:
15
13
  - gemfiles/ar52.gemfile
16
14
  - gemfiles/ar51.gemfile
@@ -22,8 +20,6 @@ env:
22
20
  - JRUBY_OPTS="--dev --debug" ADAPTER="sqlite3"
23
21
  matrix:
24
22
  allow_failures:
25
- - rvm: ruby-head
26
- gemfile: gemfiles/ar42.gemfile
27
23
  - rvm: jruby-9.1.17.0
28
24
  gemfile: gemfiles/ar52.gemfile
29
25
  - rvm: jruby-9.1.17.0
@@ -33,6 +29,8 @@ matrix:
33
29
  - rvm: jruby-9.1.17.0
34
30
  gemfile: gemfiles/ar42.gemfile
35
31
  exclude:
32
+ - rvm: ruby-2.5.1
33
+ env: JRUBY_OPTS="--dev --debug" ADAPTER="derby"
36
34
  - rvm: ruby-2.4.4
37
35
  env: JRUBY_OPTS="--dev --debug" ADAPTER="derby"
38
36
  - rvm: ruby-2.3.7
@@ -3,16 +3,8 @@ require 'active_record/version'
3
3
  require 'time_of_day'
4
4
  require 'time_of_day/core_ext'
5
5
 
6
- # TODO(uwe): Simplify when we stop supporting ActiveRecord 3.2
7
- if ActiveRecord::VERSION::MAJOR < 3 ||
8
- (ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR < 2)
9
- raise 'activerecord-time only supports ActiveRecord 3.2.21 or later'
10
- # TODO(uwe): Simplify when we stop supporting ActiveRecord 4.0 and 4.1
11
- elsif ActiveRecord::VERSION::MAJOR == 3 ||
12
- (ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR <= 1)
13
- require 'activerecord-time/extension_until_4_1'
14
6
  # TODO(uwe): Simplify when we stop supporting ActiveRecord 4.2
15
- elsif ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR >= 2
7
+ if ActiveRecord::VERSION::MAJOR == 4 && ActiveRecord::VERSION::MINOR >= 2
16
8
  require 'activerecord-time/extension_4_2'
17
9
  elsif ActiveRecord.gem_version >= Gem::Version.new('5.0.0')
18
10
  require 'activerecord-time/extension_5_0'
@@ -1,5 +1,5 @@
1
1
  module Activerecord
2
2
  module Time
3
- VERSION = '0.10.1'.freeze
3
+ VERSION = '0.12.0'.freeze
4
4
  end
5
5
  end
@@ -49,6 +49,14 @@ class TimeOfDay
49
49
  [hours.to_i, minutes.to_i, seconds.to_i]
50
50
  end
51
51
 
52
+ def acts_like_time?
53
+ true
54
+ end
55
+
56
+ def in_time_zone(*)
57
+ self
58
+ end
59
+
52
60
  def on(date)
53
61
  Time.local(date.year, date.month, date.day, hour, minute, second) # rubocop: disable Rails/TimeZone
54
62
  end
@@ -6,6 +6,12 @@ class Time
6
6
  end
7
7
  end
8
8
 
9
+ class ActiveSupport::TimeWithZone
10
+ def time_of_day
11
+ TimeOfDay.new(hour, min, sec)
12
+ end
13
+ end
14
+
9
15
  class Date
10
16
  def at(time_of_day)
11
17
  time_of_day = TimeOfDay.parse(time_of_day) if time_of_day.is_a?(String)
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.10.1
4
+ version: 0.12.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: 2018-05-04 00:00:00.000000000 Z
11
+ date: 2018-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -144,7 +144,6 @@ files:
144
144
  - lib/activerecord-time.rb
145
145
  - lib/activerecord-time/extension_4_2.rb
146
146
  - lib/activerecord-time/extension_5_0.rb
147
- - lib/activerecord-time/extension_until_4_1.rb
148
147
  - lib/activerecord-time/version.rb
149
148
  - lib/time_of_day.rb
150
149
  - lib/time_of_day/core_ext.rb
@@ -1,71 +0,0 @@
1
- require 'active_record/connection_adapters/abstract/quoting'
2
-
3
- module ActiveRecord
4
- module ConnectionAdapters
5
- module Quoting
6
- def quote_with_time_of_day(value, column = nil)
7
- if column && column.type == :time && value.is_a?(Integer)
8
- value = TimeOfDay.new(value / 3600, (value % 3600) / 60, value % 60)
9
- end
10
- return "'#{value.to_s(:db)}'" if value.is_a?(TimeOfDay)
11
- quote_without_time_of_day(value, column)
12
- end
13
-
14
- alias_method_chain :quote, :time_of_day
15
-
16
- def type_cast_with_time_of_day(value, column)
17
- return value.to_s if value.is_a?(TimeOfDay)
18
- type_cast_without_time_of_day(value, column)
19
- end
20
-
21
- alias_method_chain :type_cast, :time_of_day
22
- end
23
- end
24
- end
25
-
26
- module Activerecord
27
- module Time
28
- module DummyTime
29
- def klass
30
- return TimeOfDay if type == :time
31
- super
32
- end
33
-
34
- module ClassMethods
35
- def string_to_dummy_time(value)
36
- return value if value.is_a? TimeOfDay
37
- return value.time_of_day if value.is_a? ::Time
38
- return nil if value.empty?
39
- TimeOfDay.parse(value)
40
- end
41
- end
42
-
43
- def self.prepended(base)
44
- class << base
45
- prepend ClassMethods
46
- end
47
- end
48
- end
49
- end
50
- end
51
-
52
- ActiveRecord::ConnectionAdapters::Column.prepend Activerecord::Time::DummyTime
53
-
54
- module Arel
55
- module Visitors
56
- class Visitor
57
- # rubocop: disable Naming/MethodName
58
- # TODO(uwe): Simplify when we stop support for AR < 5
59
- if Gem::Version.new(Arel::VERSION) >= Gem::Version.new('5.0.0')
60
- def visit_TimeOfDay(object, _collector)
61
- "'#{object.to_s(:db)}'"
62
- end
63
- else
64
- def visit_TimeOfDay(object)
65
- "'#{object.to_s(:db)}'"
66
- end
67
- end
68
- # rubocop: enable Naming/MethodName
69
- end
70
- end
71
- end