time_frame 0.0.3 → 0.0.4
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 +4 -4
- data/lib/time_frame.rb +1 -3
- data/lib/time_frame/time_frame_uniter.rb +1 -2
- data/lib/time_frame/version.rb +1 -1
- data/spec/time_range_spec.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be841fe7816dbb5c85074a9ba9bef9b7cc477705
|
4
|
+
data.tar.gz: a85edb9a79a5c3c46ea1b7ab9c1b078be45f4cda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af9f71e80444f81d744846cdf8542ef9b667a839c70f190500da282253220470bb32e2c0ff4211584dc4566fe4b955add8827854b84d36e01e2d812743613118
|
7
|
+
data.tar.gz: 1290ca3e9e1b0cb87934095cbff08319a34be33845abaa460a3682b016548013b6b06c7556487bd1c186987e6927f687dda32532c79bddbdf0ff76dd3496a891
|
data/lib/time_frame.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
+
require 'active_support'
|
1
2
|
require 'active_support/core_ext'
|
2
3
|
|
3
|
-
# Avoid i18n deprecation warning
|
4
|
-
I18n.enforce_available_locales = false
|
5
|
-
|
6
4
|
require 'time_frame/time_frame_splitter'
|
7
5
|
require 'time_frame/time_frame_covered'
|
8
6
|
require 'time_frame/time_frame_overlaps'
|
@@ -9,14 +9,13 @@ class TimeFrame
|
|
9
9
|
|
10
10
|
def unite
|
11
11
|
frames = @sorted ? @time_frames : @time_frames.sort_by(&:min)
|
12
|
-
frames.
|
12
|
+
frames.each_with_object([]) do |frame, result|
|
13
13
|
last_frame = result.last
|
14
14
|
if last_frame && last_frame.cover?(frame.min)
|
15
15
|
result[-1] = TimeFrame.new(min: last_frame.min, max: frame.max)
|
16
16
|
else
|
17
17
|
result << frame
|
18
18
|
end
|
19
|
-
result
|
20
19
|
end
|
21
20
|
end
|
22
21
|
end
|
data/lib/time_frame/version.rb
CHANGED
data/spec/time_range_spec.rb
CHANGED
@@ -4,6 +4,11 @@ describe TimeFrame do
|
|
4
4
|
let(:time) { Time.zone.local(2012) }
|
5
5
|
let(:duration) { 2.hours }
|
6
6
|
|
7
|
+
before do
|
8
|
+
# Avoid i18n deprecation warning
|
9
|
+
I18n.enforce_available_locales = true
|
10
|
+
end
|
11
|
+
|
7
12
|
describe '#initialize' do
|
8
13
|
context 'when given two times' do
|
9
14
|
context 'and min is smaller than max' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_frame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Derichs
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-05-
|
13
|
+
date: 2014-05-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|