activerecord-time 0.3.0 → 0.3.14

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: c8de8d80f318e113ff121248a76f69f6f0a5773f
4
- data.tar.gz: 66a667a4adb6325e81d65786fd8faf97c62d7775
3
+ metadata.gz: bf7bd87897ba45fafd55442761573cbbf5c5ad12
4
+ data.tar.gz: 2e432fb8826089f68847933383c00ec298d4cbca
5
5
  SHA512:
6
- metadata.gz: a2d38d767ee3e5a1550e78750e5c7417704bbb8aa74ab026bb1b0e5b8a8a25092472d28c3057b761870c73e62ce43a985d30f492d4f34f97ce91d2fcd3ecdd88
7
- data.tar.gz: 6e1a694bc9c45bdff91664e3e9e3ea93f83f249b0b798a867c3a81942f2fb90717ad599e7f79c0d27fcf260dfc5c711f2ba8579111f9dd24f4fdf516d58b03ca
6
+ metadata.gz: 89ca7c611a9372e71d8f4ac65130a1d842d1a304b28afc2f942557cf6e73cfd92846cdd4aa416c13efe9c481936c42778a0fe6439dff30508fcb0f3cf59bcb81
7
+ data.tar.gz: 711db65a5a4f5c75a8be62229a74251030054a65b5647230d0779077f867d10377dcf50a7b1a333f165eb7802c670dd1e70347716c918853c8a734a24eb33a29
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ *~
1
2
  :memory:
2
3
  debug.log
3
4
  *.gem
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
4
+ - "2.0.0"
5
+ - "2.1.5"
6
+ - ruby-head
7
+ - jruby-19mode
8
+ - jruby-head
data/README.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # activerecord-time
2
2
 
3
- A handler for storing TimeOfDay objects in ActiveRecord objects as sql time values.
3
+ [![Build Status](https://travis-ci.org/donv/activerecord-time.svg)](https://travis-ci.org/donv/activerecord-time)
4
+
5
+ A handler for storing TimeOfDay objects in ActiveRecord objects as SQL time values.
6
+
7
+ Also adds load/dump of TimeOfDay objects to and from YAML streams, so you can use
8
+ them in fixtures.
9
+
10
+ The gem supports MRI and JRuby at Ruby language level 1.9.3 and later.
4
11
 
5
12
  ## Installation
6
13
 
@@ -24,7 +31,7 @@ TimeOfDay objects.
24
31
  ```Ruby
25
32
  create_table :schedules do |t|
26
33
  ...
27
- t.column :start_at, :time
34
+ t.time :start_at
28
35
  ...
29
36
  end
30
37
  ```
@@ -12,6 +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
16
 
16
17
  gem.files = `git ls-files`.split($/)
17
18
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
@@ -1,28 +1,5 @@
1
1
  require 'active_record/connection_adapters/abstract/quoting'
2
2
 
3
- module ActiveRecord
4
- module ConnectionAdapters
5
- class Column
6
- # FIXME(uwe): Not necessary?
7
- def klass_with_time_of_day
8
- return TimeOfDay if :time === type
9
- klass_without_time_of_day
10
- end
11
-
12
- alias_method_chain :klass, :time_of_day
13
- # EMXIF
14
-
15
- # FIXME(uwe): Not necessary?
16
- def self.string_to_dummy_time(string)
17
- return string if string.is_a? TimeOfDay
18
- return nil if string.empty?
19
- TimeOfDay.parse(string)
20
- end
21
- # EMXIF
22
-
23
- end
24
- end
25
- end
26
3
  module ActiveRecord
27
4
  module ConnectionAdapters # :nodoc:
28
5
  module Quoting
@@ -1,5 +1,5 @@
1
1
  module Activerecord
2
2
  module Time
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.14'
4
4
  end
5
5
  end
data/lib/time_of_day.rb CHANGED
@@ -1,12 +1,6 @@
1
1
  require 'yaml'
2
2
 
3
3
  class TimeOfDay
4
- # FIXME(uwe): Not necessary?
5
- def to_yaml_type
6
- '!tag:yaml.org,2002:time'
7
- end
8
- # EMXIF
9
-
10
4
  attr_accessor :hour # 0 - 23
11
5
  attr_accessor :minute # 0 - 59
12
6
  attr_accessor :second # 0 - 59
@@ -18,12 +12,10 @@ class TimeOfDay
18
12
  @hour, @minute, @second = hour, minute, second
19
13
  end
20
14
 
21
- # FIXME(uwe): Not necessary?
22
15
  def init_with(coder)
23
16
  parts = self.class.parse_parts(coder.scalar)
24
17
  initialize(*parts)
25
18
  end
26
- # EMXIF
27
19
 
28
20
  def self.now
29
21
  Time.now.time_of_day
@@ -34,13 +26,11 @@ class TimeOfDay
34
26
  self.new(*parse_parts(string))
35
27
  end
36
28
 
37
- # FIXME(uwe): Not necessary?
38
29
  def self.parse_parts(string)
39
30
  string.strip!
40
31
  raise "Illegal time format: '#{string}'" unless string =~ /^(\d{1,2}):?(\d{2})?(?::(\d{1,2}))?$/
41
32
  [$1.to_i, $2.to_i, $3.to_i]
42
33
  end
43
- # EMXIF
44
34
 
45
35
  def on(date)
46
36
  Time.local(date.year, date.month, date.day, hour, minute, second)
@@ -99,23 +89,11 @@ class TimeOfDay
99
89
  end
100
90
  end
101
91
 
102
- # FIXME(uwe): Not necessary?
103
- def self.yaml_new(klass, tag, val)
104
- if String === val
105
- self.parse val
106
- else
107
- raise YAML::TypeError, 'Invalid Time: ' + val.inspect
108
- end
109
- end
110
- # EMXIF
111
-
112
- # FIXME(uwe): Not necessary?
113
92
  def to_yaml(opts = {})
114
93
  YAML::quick_emit(nil, opts) do |out|
115
94
  out.scalar('tag:yaml.org,2002:time', self.to_s, :plain)
116
95
  end
117
96
  end
118
- # EMXIF
119
97
 
120
98
  end
121
99
 
data/matrix_test.sh ADDED
@@ -0,0 +1,13 @@
1
+ #!/bin/bash -el
2
+
3
+ echo
4
+ rvm use ruby
5
+ rake
6
+
7
+ echo
8
+ rvm use jruby
9
+ rake
10
+
11
+ echo -e "\033[0;32m"
12
+ echo -e " TESTS PASSED OK!"
13
+ echo -e "\033[0m"
data/test/test_helper.rb CHANGED
@@ -2,6 +2,7 @@ $:.unshift(File.dirname(__FILE__) + '/../lib')
2
2
  RAILS_ROOT = File.dirname(__FILE__)
3
3
 
4
4
  require 'rubygems'
5
+ require 'bundler/setup'
5
6
  require 'minitest/autorun'
6
7
  require 'minitest/reporters'
7
8
  MiniTest::Reporters.use!
@@ -25,13 +25,13 @@ class TimeOfDayTest < Minitest::Test
25
25
  end
26
26
 
27
27
  def test_yaml_load
28
- hash = YAML.load("start_at: !!time 12:34:56")
28
+ hash = YAML.load('start_at: !!time 12:34:56')
29
29
  assert_equal({'start_at' => TimeOfDay.parse('12:34:56')}, hash)
30
30
  end
31
31
 
32
32
  def test_yaml_dump
33
33
  string = YAML.dump({'start_at' => TimeOfDay.parse('12:34:56')})
34
- assert_equal("---\nstart_at: !!time 12:34:56\n", string)
34
+ assert_match /---\nstart_at: !!time '?12:34:56'?\n/, string
35
35
  end
36
36
 
37
37
  def test_activerecord
metadata CHANGED
@@ -1,95 +1,94 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uwe Kubosch
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: activerecord
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - ">="
16
+ - - '>='
18
17
  - !ruby/object:Gem::Version
19
18
  version: '0'
20
- type: :runtime
19
+ name: activerecord
21
20
  prerelease: false
21
+ type: :runtime
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: pg
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
- - - ">="
30
+ - - '>='
32
31
  - !ruby/object:Gem::Version
33
32
  version: '0'
34
- type: :development
33
+ name: activerecord-jdbcpostgresql-adapter
35
34
  prerelease: false
35
+ type: :development
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: sqlite3
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
- - - ">="
44
+ - - '>='
46
45
  - !ruby/object:Gem::Version
47
46
  version: '0'
48
- type: :development
47
+ name: activerecord-jdbcsqlite3-adapter
49
48
  prerelease: false
49
+ type: :development
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: minitest-reporters
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
- - - ">="
58
+ - - '>='
60
59
  - !ruby/object:Gem::Version
61
60
  version: '0'
62
- type: :development
61
+ name: minitest-reporters
63
62
  prerelease: false
63
+ type: :development
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rake
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
- - - ">="
72
+ - - '>='
74
73
  - !ruby/object:Gem::Version
75
74
  version: '0'
76
- type: :development
75
+ name: rake
77
76
  prerelease: false
77
+ type: :development
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- description: A handler for storing TimeOfDay objects in ActiveRecord objects as sql
84
- time values.
83
+ description: A handler for storing TimeOfDay objects in ActiveRecord objects as sql time values.
85
84
  email:
86
85
  - uwe@kubosch.no
87
86
  executables: []
88
87
  extensions: []
89
88
  extra_rdoc_files: []
90
89
  files:
91
- - ".gitignore"
92
- - ".travis"
90
+ - .gitignore
91
+ - .travis.yml
93
92
  - Gemfile
94
93
  - LICENSE
95
94
  - LICENSE.txt
@@ -101,6 +100,7 @@ files:
101
100
  - lib/activerecord-time/extension_mri.rb
102
101
  - lib/activerecord-time/version.rb
103
102
  - lib/time_of_day.rb
103
+ - matrix_test.sh
104
104
  - test/database.yml
105
105
  - test/schema.rb
106
106
  - test/test_helper.rb
@@ -109,27 +109,26 @@ homepage: https://github.com/donv/activerecord-time
109
109
  licenses:
110
110
  - MIT
111
111
  metadata: {}
112
- post_install_message:
112
+ post_install_message:
113
113
  rdoc_options: []
114
114
  require_paths:
115
115
  - lib
116
116
  required_ruby_version: !ruby/object:Gem::Requirement
117
117
  requirements:
118
- - - ">="
118
+ - - '>='
119
119
  - !ruby/object:Gem::Version
120
- version: '0'
120
+ version: 1.9.3
121
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - ">="
123
+ - - '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
- rubyforge_project:
128
- rubygems_version: 2.4.3
129
- signing_key:
127
+ rubyforge_project:
128
+ rubygems_version: 2.1.9
129
+ signing_key:
130
130
  specification_version: 4
131
- summary: A handler for storing TimeOfDay objects in ActiveRecord objects as sql time
132
- values.
131
+ summary: A handler for storing TimeOfDay objects in ActiveRecord objects as sql time values.
133
132
  test_files:
134
133
  - test/database.yml
135
134
  - test/schema.rb
data/.travis DELETED
@@ -1,5 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - "1.9.3"
4
- - jruby-19mode # JRuby in 1.9 mode
5
- - rbx