tod 1.4.0 → 1.5.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: 859e21d92e38e6ed8e88f2ccde4ba7b65ece6386
4
- data.tar.gz: 7e329ea20c81ffb0cd5018d4cd008f4e257a9cfc
3
+ metadata.gz: cb8660843c84b0445056017a9e55c4e24a26759d
4
+ data.tar.gz: af34e5365fdcc5fed74129ffcf1c46dd5476414a
5
5
  SHA512:
6
- metadata.gz: f7cff04a19eaca1af690f985541192e0070e6a5e0a11b25a5ed03ac10f149180f3e3df9ff19bdb55a58fe9f39878c2fb987313f42b202a8ec73f323306167240
7
- data.tar.gz: 60a3e8f699de9196d90c1d99027b8cd9e6f6c3c4b6d4f3259455439ddaa15b0d9203ea8af53c91bbe4a6a6d238e3d71af1757e7d765a3e6790af470ea8501a48
6
+ metadata.gz: 091d891b412086559a229fa04407f200315b01fc39f0a79c7305a0847b865f8d4e20252d53fe77bd0f1290d1b0cceea31f90d681f00a1bb8a39c2f2bd3942ea8
7
+ data.tar.gz: f29c38d109354008fad673e1ad7c3afcb78510992c70f96b4bfe8aab512a3b132e8d6a6674e185aa8aed4ae46dec39ae44cfb840169d82459543a3b38ed8de1c
@@ -1,9 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.2.0
4
+ - 2.1.5
3
5
  - 2.0.0
4
6
  - 1.9.3
5
7
  gemfile:
6
- - gemfiles/3.0.gemfile
7
- - gemfiles/3.1.gemfile
8
8
  - gemfiles/3.2.gemfile
9
9
  - gemfiles/4.0.gemfile
10
+ - gemfiles/4.1.gemfile
11
+ - gemfiles/4.2.gemfile
@@ -0,0 +1,37 @@
1
+ # 1.5.0 (January 15, 2015)
2
+
3
+ * Fix: return nil unless other is comparable (Peter Yates)
4
+ * Parse "noon" as "12pm" and "midnight" as "12am" (Michael Righi)
5
+
6
+ # 1.4.0 (April 3, 2014)
7
+
8
+ * Add try_parse (Stuart Olivera)
9
+ * Add parse? (Stuart Olivera)
10
+
11
+ # 1.3.0 (December 9, 2013)
12
+
13
+ * Add Shift class (Pablo Russo)
14
+
15
+ # 1.2.2 (November 16, 2013)
16
+
17
+ * Fix dumping nil or empty string to PostgreSQL time column (Maik Arnold)
18
+
19
+ # 1.2.1 (September 30, 2013)
20
+
21
+ * Added DateTime#to_time_of_day (Jonathan Pares)
22
+
23
+ # 1.2.0 (July 16, 2013)
24
+
25
+ * Added ActiveRecord TimeOfDay serialization to time column (Maxim-Filimonov)
26
+
27
+ # 1.1.1 (April 12, 2013)
28
+
29
+ * Added to_i and from_i as aliases of second_of_day and from_second_of_day (Johnny Shields)
30
+
31
+ # 1.1.0 (February 13, 2013)
32
+
33
+ * Added Rails time zone support
34
+
35
+ # 1.0.0 (December 29, 2010)
36
+
37
+ * Initial Release
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tod (1.3.0)
4
+ tod (1.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -44,6 +44,8 @@ are all optional.
44
44
  TimeOfDay.parse "3:25:58" # => 03:25:58
45
45
  TimeOfDay.parse "515p" # => 17:15:00
46
46
  TimeOfDay.parse "151253" # => 15:12:53
47
+ TimeOfDay.parse "noon" # => 12:00:00
48
+ TimeOfDay.parse "midnight" # => 00:00:00
47
49
 
48
50
  TimeOfDay.parse raises an ArgumentError is the argument to parse is not
49
51
  parsable. TimeOfDay.try_parse will instead return nil if the argument is not
@@ -158,47 +160,11 @@ order.time # => 09:30:00
158
160
  Compatibility
159
161
  =============
160
162
 
161
- [![Build Status](https://travis-ci.org/JackC/tod.png)](https://travis-ci.org/JackC/tod)
163
+ [![Build Status](https://travis-ci.org/jackc/tod.png)](https://travis-ci.org/jackc/tod)
162
164
 
163
- Tod is compatible with Ruby 1.9.3 and 2.0.0 and Rails 3.0, 3.1, 3.2, and 4.0.
165
+ Tod is compatible with Ruby 1.9.3, 2.0.0, 2.1.8, and 2.2.0. It is tested against Rails 3.2, 4.0, 4.1, 4.2.
164
166
 
165
167
 
166
- History
167
- =======
168
-
169
- ## 1.4.0 (April 3, 2014)
170
-
171
- * Add try_parse (Stuart Olivera)
172
- * Add parse? (Stuart Olivera)
173
-
174
- ## 1.3.0 (December 9, 2013)
175
-
176
- * Add Shift class (Pablo Russo)
177
-
178
- ## 1.2.2 (November 16, 2013)
179
-
180
- * Fix dumping nil or empty string to PostgreSQL time column (Maik Arnold)
181
-
182
- ## 1.2.1 (September 30, 2013)
183
-
184
- * Added DateTime#to_time_of_day (Jonathan Pares)
185
-
186
- ## 1.2.0 (July 16, 2013)
187
-
188
- * Added ActiveRecord TimeOfDay serialization to time column (Maxim-Filimonov)
189
-
190
- ## 1.1.1 (April 12, 2013)
191
-
192
- * Added to_i and from_i as aliases of second_of_day and from_second_of_day (Johnny Shields)
193
-
194
- ## 1.1.0 (February 13, 2013)
195
-
196
- * Added Rails time zone support
197
-
198
- ## 1.0.0 (December 29, 2010)
199
-
200
- * Initial Release
201
-
202
168
  License
203
169
  =======
204
170
 
@@ -1,6 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "activerecord", "~> 3.0.20"
4
- gem "i18n"
3
+ gem "activerecord", "~> 4.1.8"
5
4
 
6
5
  gemspec :path=>"../"
@@ -1,6 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "activerecord", "~> 3.1.12"
4
- gem "i18n"
3
+ gem "activerecord", "~> 4.2.0"
5
4
 
6
5
  gemspec :path=>"../"
@@ -33,6 +33,11 @@ module Tod
33
33
  \z
34
34
  /x
35
35
 
36
+ WORDS = {
37
+ "noon" => "12pm",
38
+ "midnight" => "12am"
39
+ }
40
+
36
41
  NUM_SECONDS_IN_DAY = 86400
37
42
  NUM_SECONDS_IN_HOUR = 3600
38
43
  NUM_SECONDS_IN_MINUTE = 60
@@ -52,6 +57,7 @@ module Tod
52
57
  end
53
58
 
54
59
  def <=>(other)
60
+ return unless other.respond_to?(:second_of_day)
55
61
  @second_of_day <=> other.second_of_day
56
62
  end
57
63
 
@@ -124,6 +130,7 @@ module Tod
124
130
  tod_string = tod_string.to_s
125
131
  tod_string = tod_string.strip
126
132
  tod_string = tod_string.downcase
133
+ tod_string = WORDS[tod_string] || tod_string
127
134
  if PARSE_24H_REGEX =~ tod_string || PARSE_12H_REGEX =~ tod_string
128
135
  hour, minute, second, a_or_p = $1.to_i, $2.to_i, $3.to_i, $4
129
136
  if hour == 12 && a_or_p == "a"
@@ -166,4 +173,4 @@ module Tod
166
173
  end
167
174
  end
168
175
  end
169
- end
176
+ end
@@ -1,3 +1,3 @@
1
1
  module Tod
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -32,5 +32,17 @@ class TimeOfDayConversionTest < Test::Unit::TestCase
32
32
 
33
33
  assert_equal(tod, TimeOfDay.new(12, 01, 02))
34
34
  end
35
+ should "parse 'noon'" do
36
+ t = "noon"
37
+ tod = TimeOfDay(t)
38
+
39
+ assert_equal(tod, TimeOfDay.new(12, 00, 00))
40
+ end
41
+ should "parse 'midnight'" do
42
+ t = "midnight"
43
+ tod = TimeOfDay(t)
44
+
45
+ assert_equal(tod, TimeOfDay.new(0, 00, 00))
46
+ end
35
47
 
36
48
  end
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "https://github.com/JackC/tod"
12
12
  s.summary = %q{Supplies TimeOfDay and Shift class}
13
13
  s.description = %q{Supplies TimeOfDay and Shift class that includes parsing, strftime, comparison, and arithmetic.}
14
+ s.license = 'MIT'
14
15
 
15
16
  s.add_development_dependency "test-unit"
16
17
  s.add_development_dependency "shoulda"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tod
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Christensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-03 00:00:00.000000000 Z
11
+ date: 2015-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit
@@ -118,15 +118,16 @@ extra_rdoc_files: []
118
118
  files:
119
119
  - ".gitignore"
120
120
  - ".travis.yml"
121
+ - CHANGELOG.md
121
122
  - Gemfile
122
123
  - Gemfile.lock
123
124
  - MIT-LICENSE
124
125
  - README.markdown
125
126
  - Rakefile
126
- - gemfiles/3.0.gemfile
127
- - gemfiles/3.1.gemfile
128
127
  - gemfiles/3.2.gemfile
129
128
  - gemfiles/4.0.gemfile
129
+ - gemfiles/4.1.gemfile
130
+ - gemfiles/4.2.gemfile
130
131
  - lib/tod.rb
131
132
  - lib/tod/conversions.rb
132
133
  - lib/tod/date.rb
@@ -147,7 +148,8 @@ files:
147
148
  - test/tod/time_test.rb
148
149
  - tod.gemspec
149
150
  homepage: https://github.com/JackC/tod
150
- licenses: []
151
+ licenses:
152
+ - MIT
151
153
  metadata: {}
152
154
  post_install_message:
153
155
  rdoc_options: []
@@ -165,18 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
167
  version: '0'
166
168
  requirements: []
167
169
  rubyforge_project:
168
- rubygems_version: 2.2.2
170
+ rubygems_version: 2.4.5
169
171
  signing_key:
170
172
  specification_version: 4
171
173
  summary: Supplies TimeOfDay and Shift class
172
- test_files:
173
- - test/support/active_record.rb
174
- - test/test_helper.rb
175
- - test/tod/a_a_a_time_of_day_time_zone_without_active_support_test.rb
176
- - test/tod/conversion_test.rb
177
- - test/tod/date_test.rb
178
- - test/tod/shift_test.rb
179
- - test/tod/time_of_day_serializable_attribute_test.rb
180
- - test/tod/time_of_day_test.rb
181
- - test/tod/time_of_day_time_zone_with_active_support_test.rb
182
- - test/tod/time_test.rb
174
+ test_files: []