activerecord-time 0.7.0 → 0.8.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
  SHA1:
3
- metadata.gz: f3377582c4b69bbaffdfb4b2147c4c9fedd6bd87
4
- data.tar.gz: e871b6b116bd17436c0b1f27e1ead868ccafb692
3
+ metadata.gz: 1dd3abdb57563a7a23de8e40e0e23d4413c80053
4
+ data.tar.gz: 4c43da1a4b7ad61c534ee949a8b90407d81d5363
5
5
  SHA512:
6
- metadata.gz: 672aa67786ca42da38a78fd79f036c0954c43aedc186c767321e42ad9d56dddc931d557d709f8879a39d5311c66594937117da99a4bdfad27460f12bee0ce367
7
- data.tar.gz: ec625e4fd2eb0ef826a0304a71de12177a39fac32ec71fc6f948e20fa110cd3820dc93a32812c0f0f37e4215ac050a8c05d54cf861e65cdc5e505899c3137509
6
+ metadata.gz: '091eb06ba8c9c8d5cc3c700a98c915be578703c09b357f9ea86f00ddc9f4b23e6048bb12e7eff2e40537d7eb9ab98a8fbf496bfca7e3c3e1db07cf7ed1e451a0'
7
+ data.tar.gz: 5898cf0e03e049d9ca0d4a88f7a4baba78f4dd5c3533c5b167ee8e2943c1adb55943e3c2e8cf2287638a65553bca161ff79c4db2e260255c15ebb8b061a37dc8
data/.rubocop.yml CHANGED
@@ -13,6 +13,9 @@ AllCops:
13
13
  Rails:
14
14
  Enabled: true
15
15
 
16
+ Security/YAMLLoad:
17
+ Enabled: false
18
+
16
19
  Style/Documentation:
17
20
  Enabled: false
18
21
 
data/.travis.yml CHANGED
@@ -4,8 +4,9 @@ jdk:
4
4
  - oraclejdk8
5
5
  before_install: gem query -i -n ^bundler$ >/dev/null || gem install bundler
6
6
  rvm:
7
+ - ruby-2.4.0
8
+ - jruby-9.1.7.0
7
9
  - ruby-2.3.3
8
- - jruby-9.1.6.0
9
10
  - ruby-2.2.6
10
11
  - ruby-2.1.9
11
12
  - ruby-head
@@ -28,5 +29,9 @@ matrix:
28
29
  gemfile: gemfiles/ar41.gemfile
29
30
  - rvm: ruby-head
30
31
  gemfile: gemfiles/ar32.gemfile
32
+ - rvm: ruby-2.4.0
33
+ gemfile: gemfiles/ar41.gemfile
34
+ - rvm: ruby-2.4.0
35
+ gemfile: gemfiles/ar32.gemfile
31
36
  - rvm: ruby-2.1.9
32
37
  gemfile: gemfiles/ar50.gemfile
data/README.md CHANGED
@@ -9,12 +9,12 @@ them in fixtures.
9
9
 
10
10
  Also adds JSON encode/decode.
11
11
 
12
- The gem supports MRI and JRuby at Ruby language level 1.9.3 and later. Other
12
+ The gem supports MRI and JRuby at Ruby language level 2.1.9 and later. Other
13
13
  Ruby implementations may work.
14
14
 
15
15
  ActiveRecord 3.2 and later supported.
16
16
 
17
- Ruby 1.9.3 to 2.3.1 supported, including JRuby.
17
+ Ruby 2.1.9 to 2.4.0 supported, including JRuby.
18
18
 
19
19
 
20
20
  ## Installation
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.summary = %q{A handler for storing TimeOfDay objects in ActiveRecord objects as sql time values.}
13
13
  gem.homepage = 'https://github.com/donv/activerecord-time'
14
14
  gem.license = 'MIT'
15
- gem.required_ruby_version = '>= 1.9.3'
15
+ gem.required_ruby_version = '>= 2.1'
16
16
 
17
17
  gem.files = `git ls-files`.split($/)
18
18
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
@@ -9,13 +9,13 @@ GEM
9
9
  activesupport (= 3.2.22.5)
10
10
  arel (~> 3.0.2)
11
11
  tzinfo (~> 0.3.29)
12
- activerecord-jdbc-adapter (1.3.21)
12
+ activerecord-jdbc-adapter (1.3.22)
13
13
  activerecord (>= 2.2)
14
- activerecord-jdbcpostgresql-adapter (1.3.21)
15
- activerecord-jdbc-adapter (~> 1.3.21)
14
+ activerecord-jdbcpostgresql-adapter (1.3.22)
15
+ activerecord-jdbc-adapter (~> 1.3.22)
16
16
  jdbc-postgres (>= 9.1)
17
- activerecord-jdbcsqlite3-adapter (1.3.21)
18
- activerecord-jdbc-adapter (~> 1.3.21)
17
+ activerecord-jdbcsqlite3-adapter (1.3.22)
18
+ activerecord-jdbc-adapter (~> 1.3.22)
19
19
  jdbc-sqlite3 (>= 3.7.2, < 3.9)
20
20
  activesupport (3.2.22.5)
21
21
  i18n (~> 0.6, >= 0.6.4)
@@ -24,13 +24,13 @@ GEM
24
24
  arel (3.0.3)
25
25
  builder (3.0.4)
26
26
  docile (1.1.5)
27
- i18n (0.7.0)
27
+ i18n (0.8.0)
28
28
  jdbc-postgres (9.4.1206)
29
29
  jdbc-sqlite3 (3.8.11.2)
30
- json (2.0.2)
31
- json (2.0.2-java)
30
+ json (2.0.3)
31
+ json (2.0.3-java)
32
32
  minitest (5.10.1)
33
- minitest-reporters (1.1.13)
33
+ minitest-reporters (1.1.14)
34
34
  ansi
35
35
  builder
36
36
  minitest (>= 5.0)
@@ -39,12 +39,12 @@ GEM
39
39
  pg (0.19.0)
40
40
  rake (12.0.0)
41
41
  ruby-progressbar (1.8.1)
42
- simplecov (0.12.0)
42
+ simplecov (0.13.0)
43
43
  docile (~> 1.1.0)
44
44
  json (>= 1.8, < 3)
45
45
  simplecov-html (~> 0.10.0)
46
46
  simplecov-html (0.10.0)
47
- sqlite3 (1.3.12)
47
+ sqlite3 (1.3.13)
48
48
  tzinfo (0.3.52)
49
49
 
50
50
  PLATFORMS
@@ -63,4 +63,4 @@ DEPENDENCIES
63
63
  sqlite3
64
64
 
65
65
  BUNDLED WITH
66
- 1.13.6
66
+ 1.13.7
@@ -10,13 +10,13 @@ GEM
10
10
  activesupport (= 4.0.13)
11
11
  arel (~> 4.0.0)
12
12
  activerecord-deprecated_finders (1.0.4)
13
- activerecord-jdbc-adapter (1.3.21)
13
+ activerecord-jdbc-adapter (1.3.22)
14
14
  activerecord (>= 2.2)
15
- activerecord-jdbcpostgresql-adapter (1.3.21)
16
- activerecord-jdbc-adapter (~> 1.3.21)
15
+ activerecord-jdbcpostgresql-adapter (1.3.22)
16
+ activerecord-jdbc-adapter (~> 1.3.22)
17
17
  jdbc-postgres (>= 9.1)
18
- activerecord-jdbcsqlite3-adapter (1.3.21)
19
- activerecord-jdbc-adapter (~> 1.3.21)
18
+ activerecord-jdbcsqlite3-adapter (1.3.22)
19
+ activerecord-jdbc-adapter (~> 1.3.22)
20
20
  jdbc-sqlite3 (>= 3.7.2, < 3.9)
21
21
  activesupport (4.0.13)
22
22
  i18n (~> 0.6, >= 0.6.9)
@@ -28,12 +28,12 @@ GEM
28
28
  arel (4.0.2)
29
29
  builder (3.1.4)
30
30
  docile (1.1.5)
31
- hashie (3.4.6)
32
- i18n (0.7.0)
31
+ hashie (3.5.3)
32
+ i18n (0.8.0)
33
33
  jdbc-postgres (9.4.1206)
34
34
  jdbc-sqlite3 (3.8.11.2)
35
- json (2.0.2)
36
- json (2.0.2-java)
35
+ json (2.0.3)
36
+ json (2.0.3-java)
37
37
  minitest (4.7.5)
38
38
  minitest-reporters (0.14.24)
39
39
  ansi
@@ -42,15 +42,15 @@ GEM
42
42
  powerbar
43
43
  multi_json (1.12.1)
44
44
  pg (0.19.0)
45
- powerbar (1.0.17)
45
+ powerbar (1.0.18)
46
46
  hashie (>= 1.1.0)
47
47
  rake (12.0.0)
48
- simplecov (0.12.0)
48
+ simplecov (0.13.0)
49
49
  docile (~> 1.1.0)
50
50
  json (>= 1.8, < 3)
51
51
  simplecov-html (~> 0.10.0)
52
52
  simplecov-html (0.10.0)
53
- sqlite3 (1.3.12)
53
+ sqlite3 (1.3.13)
54
54
  thread_safe (0.3.5)
55
55
  thread_safe (0.3.5-java)
56
56
  tzinfo (0.3.52)
@@ -71,4 +71,4 @@ DEPENDENCIES
71
71
  sqlite3
72
72
 
73
73
  BUNDLED WITH
74
- 1.13.6
74
+ 1.13.7
@@ -8,13 +8,13 @@ GEM
8
8
  activemodel (= 4.2.7.1)
9
9
  activesupport (= 4.2.7.1)
10
10
  arel (~> 6.0)
11
- activerecord-jdbc-adapter (1.3.21)
11
+ activerecord-jdbc-adapter (1.3.22)
12
12
  activerecord (>= 2.2)
13
- activerecord-jdbcpostgresql-adapter (1.3.21)
14
- activerecord-jdbc-adapter (~> 1.3.21)
13
+ activerecord-jdbcpostgresql-adapter (1.3.22)
14
+ activerecord-jdbc-adapter (~> 1.3.22)
15
15
  jdbc-postgres (>= 9.1)
16
- activerecord-jdbcsqlite3-adapter (1.3.21)
17
- activerecord-jdbc-adapter (~> 1.3.21)
16
+ activerecord-jdbcsqlite3-adapter (1.3.22)
17
+ activerecord-jdbc-adapter (~> 1.3.22)
18
18
  jdbc-sqlite3 (>= 3.7.2, < 3.9)
19
19
  activesupport (4.2.7.1)
20
20
  i18n (~> 0.7)
@@ -23,16 +23,16 @@ GEM
23
23
  thread_safe (~> 0.3, >= 0.3.4)
24
24
  tzinfo (~> 1.1)
25
25
  ansi (1.5.0)
26
- arel (6.0.3)
27
- builder (3.2.2)
26
+ arel (6.0.4)
27
+ builder (3.2.3)
28
28
  docile (1.1.5)
29
- i18n (0.7.0)
29
+ i18n (0.8.0)
30
30
  jdbc-postgres (9.4.1206)
31
31
  jdbc-sqlite3 (3.8.11.2)
32
- json (1.8.3)
33
- json (1.8.3-java)
32
+ json (1.8.6)
33
+ json (1.8.6-java)
34
34
  minitest (5.10.1)
35
- minitest-reporters (1.1.13)
35
+ minitest-reporters (1.1.14)
36
36
  ansi
37
37
  builder
38
38
  minitest (>= 5.0)
@@ -40,12 +40,12 @@ GEM
40
40
  pg (0.19.0)
41
41
  rake (12.0.0)
42
42
  ruby-progressbar (1.8.1)
43
- simplecov (0.12.0)
43
+ simplecov (0.13.0)
44
44
  docile (~> 1.1.0)
45
45
  json (>= 1.8, < 3)
46
46
  simplecov-html (~> 0.10.0)
47
47
  simplecov-html (0.10.0)
48
- sqlite3 (1.3.12)
48
+ sqlite3 (1.3.13)
49
49
  thread_safe (0.3.5)
50
50
  thread_safe (0.3.5-java)
51
51
  tzinfo (1.2.2)
@@ -67,4 +67,4 @@ DEPENDENCIES
67
67
  sqlite3
68
68
 
69
69
  BUNDLED WITH
70
- 1.13.6
70
+ 1.13.7
@@ -30,15 +30,15 @@ GEM
30
30
  tzinfo (~> 1.1)
31
31
  ansi (1.5.0)
32
32
  arel (7.1.4)
33
- builder (3.2.2)
34
- concurrent-ruby (1.0.3)
35
- concurrent-ruby (1.0.3-java)
33
+ builder (3.2.3)
34
+ concurrent-ruby (1.0.4)
35
+ concurrent-ruby (1.0.4-java)
36
36
  docile (1.1.5)
37
- i18n (0.7.0)
38
- json (2.0.2)
39
- json (2.0.2-java)
37
+ i18n (0.8.0)
38
+ json (2.0.3)
39
+ json (2.0.3-java)
40
40
  minitest (5.10.1)
41
- minitest-reporters (1.1.13)
41
+ minitest-reporters (1.1.14)
42
42
  ansi
43
43
  builder
44
44
  minitest (>= 5.0)
@@ -46,12 +46,12 @@ GEM
46
46
  pg (0.19.0)
47
47
  rake (12.0.0)
48
48
  ruby-progressbar (1.8.1)
49
- simplecov (0.12.0)
49
+ simplecov (0.13.0)
50
50
  docile (~> 1.1.0)
51
51
  json (>= 1.8, < 3)
52
52
  simplecov-html (~> 0.10.0)
53
53
  simplecov-html (0.10.0)
54
- sqlite3 (1.3.12)
54
+ sqlite3 (1.3.13)
55
55
  thread_safe (0.3.5)
56
56
  thread_safe (0.3.5-java)
57
57
  tzinfo (1.2.2)
@@ -75,4 +75,4 @@ DEPENDENCIES
75
75
  sqlite3
76
76
 
77
77
  BUNDLED WITH
78
- 1.13.6
78
+ 1.13.7
@@ -1,5 +1,5 @@
1
1
  module Activerecord
2
2
  module Time
3
- VERSION = '0.7.0'.freeze
3
+ VERSION = '0.8.0'.freeze
4
4
  end
5
5
  end
data/lib/time_of_day.rb CHANGED
@@ -2,6 +2,8 @@ require 'yaml'
2
2
 
3
3
  # rubocop: disable Rails/TimeZone, Rails/Date
4
4
  class TimeOfDay
5
+ include Comparable
6
+
5
7
  attr_accessor :hour # 0 - 23
6
8
  attr_accessor :minute # 0 - 59
7
9
  attr_accessor :second # 0 - 59
@@ -9,7 +11,7 @@ class TimeOfDay
9
11
  def initialize(hour, minute = 0, second = 0)
10
12
  raise "Invalid hour: #{hour}" unless hour >= 0 && hour <= 23
11
13
  raise "Invalid minute: #{minute}" unless minute >= 0 && minute <= 59
12
- raise "Invalid second: #{second}" unless second >= 0 && hour <= 59
14
+ raise "Invalid second: #{second}" unless second >= 0 && second <= 59
13
15
  @hour, @minute, @second = hour, minute, second
14
16
  end
15
17
 
@@ -55,32 +57,15 @@ class TimeOfDay
55
57
  end
56
58
 
57
59
  def <=>(other)
58
- [@hour, @minute, @second] <=> [other.hour, other.minute, other.second]
59
- end
60
-
61
- def ==(other)
62
- return false unless other.is_a? TimeOfDay
63
- (self <=> other) == 0
64
- end
65
-
66
- def <(other)
67
- return false unless other.is_a? TimeOfDay
68
- (self <=> other) < 0
69
- end
60
+ other_tod = if other.is_a?(TimeOfDay)
61
+ other
62
+ elsif other.respond_to?(:time_of_day)
63
+ other.time_of_day
64
+ else
65
+ other
66
+ end
70
67
 
71
- def <=(other)
72
- return false unless other.is_a? TimeOfDay
73
- (self <=> other) <= 0
74
- end
75
-
76
- def >(other)
77
- return false unless other.is_a? TimeOfDay
78
- (self <=> other) > 0
79
- end
80
-
81
- def >=(other)
82
- return false unless other.is_a? TimeOfDay
83
- (self <=> other) >= 0
68
+ to_a <=> [other_tod.hour, other_tod.minute, other_tod.second]
84
69
  end
85
70
 
86
71
  def strftime(format)
@@ -89,10 +74,16 @@ class TimeOfDay
89
74
 
90
75
  def to_s(with_seconds = true)
91
76
  if with_seconds
92
- '%02d:%02d:%02d' % [@hour, @minute, @second]
77
+ '%02d:%02d:%02d' % to_a
93
78
  else
94
79
  '%02d:%02d' % [@hour, @minute]
95
80
  end
81
+ rescue
82
+ "#{@hour.inspect}:#{@minute.inspect}:#{@second.inspect}"
83
+ end
84
+
85
+ def to_a
86
+ [@hour, @minute, @second]
96
87
  end
97
88
 
98
89
  def to_json(*)
data/matrix_test.rb CHANGED
@@ -7,8 +7,34 @@ update_gemfiles = ARGV.delete('--update')
7
7
  require 'yaml'
8
8
  travis = YAML.load(File.read('.travis.yml'))
9
9
 
10
+ def run_script(ruby, env, gemfile)
11
+ env.scan(/\b(?<key>[A-Z_]+)="(?<value>.+?)"/) do |key, value|
12
+ ENV[key] = value
13
+ end
14
+ puts '*' * 80
15
+ puts "Testing #{ruby} #{gemfile} #{env}"
16
+ puts
17
+ system("chruby-exec #{ruby} -- bundle exec rake") || exit(1)
18
+ puts '*' * 80
19
+ end
20
+
21
+ def use_gemfile(ruby, gemfile, update_gemfiles)
22
+ puts '$' * 80
23
+ puts "Testing #{gemfile}"
24
+ puts
25
+ ENV['BUNDLE_GEMFILE'] = gemfile
26
+ if update_gemfiles
27
+ system "chruby-exec #{ruby} -- bundle update"
28
+ else
29
+ system "chruby-exec #{ruby} -- bundle check || chruby-exec #{ruby} -- bundle install"
30
+ end || exit(1)
31
+ yield
32
+ puts "Testing #{gemfile} OK"
33
+ puts '$' * 80
34
+ end
35
+
10
36
  travis['rvm'].each do |ruby|
11
- next if ruby =~ /head/
37
+ next if ruby =~ /head/ # ruby-install does not support HEAD installation
12
38
  puts '#' * 80
13
39
  puts "Testing #{ruby}"
14
40
  puts
@@ -16,31 +42,16 @@ travis['rvm'].each do |ruby|
16
42
  bundler_gem_check_cmd = "chruby-exec #{ruby} -- gem query -i -n bundler >/dev/null"
17
43
  system "#{bundler_gem_check_cmd} || chruby-exec #{ruby} -- gem install bundler" || exit(1)
18
44
  travis['gemfile'].each do |gemfile|
19
- if travis['matrix']['exclude'].any? { |f| f['rvm'] == ruby && f['gemfile'] == gemfile }
45
+ if (travis['matrix']['exclude'].to_a + travis['matrix']['allowed_failures'].to_a)
46
+ .any? { |f| f['rvm'] == ruby && f['gemfile'] == gemfile }
20
47
  puts 'Skipping known failure.'
21
48
  next
22
49
  end
23
- puts '$' * 80
24
- puts "Testing #{gemfile}"
25
- puts
26
- ENV['BUNDLE_GEMFILE'] = gemfile
27
- if update_gemfiles
28
- system "chruby-exec #{ruby} -- bundle update"
29
- else
30
- system "chruby-exec #{ruby} -- bundle check || chruby-exec #{ruby} -- bundle install"
31
- end || exit(1)
32
- travis['env'].each do |env|
33
- env.scan(/\b(?<key>[A-Z_]+)="(?<value>.+?)"/) do |key, value|
34
- ENV[key] = value
50
+ use_gemfile(ruby, gemfile, update_gemfiles) do
51
+ travis['env'].each do |env|
52
+ run_script(ruby, env, gemfile)
35
53
  end
36
- puts '*' * 80
37
- puts "Testing #{ruby} #{gemfile} #{env}"
38
- puts
39
- system "chruby-exec #{ruby} -- bundle exec rake" || exit(1)
40
- puts '*' * 80
41
54
  end
42
- puts "Testing #{gemfile} OK"
43
- puts '$' * 80
44
55
  end
45
56
  puts "Testing #{ruby} OK"
46
57
  puts '#' * 80
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.7.0
4
+ version: 0.8.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: 2016-12-23 00:00:00.000000000 Z
11
+ date: 2017-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -166,7 +166,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
166
  requirements:
167
167
  - - ">="
168
168
  - !ruby/object:Gem::Version
169
- version: 1.9.3
169
+ version: '2.1'
170
170
  required_rubygems_version: !ruby/object:Gem::Requirement
171
171
  requirements:
172
172
  - - ">="
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  version: '0'
175
175
  requirements: []
176
176
  rubyforge_project:
177
- rubygems_version: 2.5.1
177
+ rubygems_version: 2.6.8
178
178
  signing_key:
179
179
  specification_version: 4
180
180
  summary: A handler for storing TimeOfDay objects in ActiveRecord objects as sql time