time_of_day_attr 0.0.5 → 0.0.6

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: 984b3d3213e41117ad551b328a807b7bc750e6c7
4
- data.tar.gz: 696fe6fc73ef23a3ed4511491e33e2e393359293
3
+ metadata.gz: 89598098237c1f05d5e43ddd93cab45dd9dac493
4
+ data.tar.gz: 8d777ae07c21629d8ede0408356e864295a5ab83
5
5
  SHA512:
6
- metadata.gz: 5199b76eaf0664a91d071d35772d90fbb477a21a7a7ce764db5f974910b33957e8e30d0fac5176036dd68b8621bba68f1fb057918cc3a74b63e50983a3c84248
7
- data.tar.gz: 39615de096cfdb717464e2152a61feb27bbdaab5f5915bcba36c3a975d8e5e399b775076c75a6fd2eef21469eebb1c18b48aa1f2762f73bfbff13880014a11b8
6
+ metadata.gz: 08051c9d5b9c057fcfed48111cca292b6695815383dd12eb818931f8130fd0805b1621b6961d59d174c215204e516d0fa02a0744079d6f9d1da9c9ac910cb652
7
+ data.tar.gz: 8b3f4cce1f11cb6207aee0d3485774023ce3e25fb4827b28b6a1a82df01789f724d6ef54506cc18cc0025925b59fee7161440f0bb59a901c0aa4bb4bd479db01
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # time_of_day_attr
2
- [![Gem Version](https://badge.fury.io/rb/time_of_day_attr.png)](http://badge.fury.io/rb/time_of_day_attr) [![Code Climate](https://codeclimate.com/github/clemenst/time_of_day_attr.png)](https://codeclimate.com/github/clemenst/time_of_day_attr)
2
+ [![Gem Version](https://badge.fury.io/rb/time_of_day_attr.png)](http://badge.fury.io/rb/time_of_day_attr) [![Code Climate](https://codeclimate.com/github/clemenst/time_of_day_attr.png)](https://codeclimate.com/github/clemenst/time_of_day_attr) [![License](https://img.shields.io/npm/l/express.svg?style=flat)](http://clemenst.mit-license.org)
3
3
 
4
4
  Convert time of day to seconds since midnight and back.
5
5
 
@@ -86,25 +86,4 @@ To get a text field with the converted value:
86
86
 
87
87
  ## License
88
88
 
89
- This project uses MIT-LICENSE
90
-
91
- Copyright 2013 by Clemens Teichmann
92
-
93
- Permission is hereby granted, free of charge, to any person obtaining
94
- a copy of this software and associated documentation files (the
95
- "Software"), to deal in the Software without restriction, including
96
- without limitation the rights to use, copy, modify, merge, publish,
97
- distribute, sublicense, and/or sell copies of the Software, and to
98
- permit persons to whom the Software is furnished to do so, subject to
99
- the following conditions:
100
-
101
- The above copyright notice and this permission notice shall be
102
- included in all copies or substantial portions of the Software.
103
-
104
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
105
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
106
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
107
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
108
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
109
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
110
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
89
+ [MIT](http://clemenst.mit-license.org)
@@ -1,3 +1,3 @@
1
1
  module TimeOfDayAttr
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -17,6 +17,7 @@ module TimeOfDayAttr
17
17
  end
18
18
 
19
19
  def localize(value, options = {})
20
+ return value unless value.respond_to?(:seconds)
20
21
  format = options[:format] || :default
21
22
  format = translate_format(format) if format.is_a?(Symbol)
22
23
  time = Time.now.at_midnight + value.seconds
@@ -24,6 +24,10 @@ class TimeOfDayAttrTest < ActiveSupport::TestCase
24
24
  assert_equal ' 0', TimeOfDayAttr.localize(86400, omit_minutes_at_full_hour: true)
25
25
  end
26
26
 
27
+ test 'localizing nil should return nil' do
28
+ assert_nil TimeOfDayAttr.localize(nil)
29
+ end
30
+
27
31
  test 'time of day attr setter should delocalize value' do
28
32
  business_hour = BusinessHour.new(opening: '9:00', closing: '17:00')
29
33
  assert_equal 32400, business_hour.opening
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_of_day_attr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clemens Teichmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-05 00:00:00.000000000 Z
11
+ date: 2015-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails