timeframe 0.1.0 → 0.1.1
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.
- data/.document +5 -5
- data/.gitignore +2 -1
- data/Gemfile +6 -2
- data/LICENSE +20 -20
- data/README.markdown +42 -0
- data/Rakefile +2 -12
- data/lib/timeframe.rb +34 -6
- data/lib/timeframe/iso_8601.rb +93 -0
- data/lib/timeframe/version.rb +1 -1
- data/spec/timeframe_spec.rb +63 -6
- data/timeframe.gemspec +0 -3
- metadata +48 -117
- data/README.rdoc +0 -17
data/.document
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
README.
|
|
2
|
-
lib/**/*.rb
|
|
3
|
-
bin/*
|
|
4
|
-
features/**/*.feature
|
|
5
|
-
LICENSE
|
|
1
|
+
README.markdown
|
|
2
|
+
lib/**/*.rb
|
|
3
|
+
bin/*
|
|
4
|
+
features/**/*.feature
|
|
5
|
+
LICENSE
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/LICENSE
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
Copyright (c) 2009 Andy Rossmeissl
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
-
a copy of this software and associated documentation files (the
|
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
-
the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be
|
|
12
|
-
included in all copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
Copyright (c) 2009 Andy Rossmeissl
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# timeframe
|
|
2
|
+
|
|
3
|
+
A Ruby class for describing and interacting with timeframes.
|
|
4
|
+
|
|
5
|
+
## Based on ISO 8601
|
|
6
|
+
|
|
7
|
+
As [documented by wikipedia](http://en.wikipedia.org/wiki/ISO_8601#Time_intervals), time intervals are like:
|
|
8
|
+
|
|
9
|
+
1. Start and end, such as `2007-03-01T13:00:00Z/2008-05-11T15:30:00Z`
|
|
10
|
+
2. Start and duration, such as `2007-03-01T13:00:00Z/P1Y2M10DT2H30M`
|
|
11
|
+
3. Duration and end, such as `P1Y2M10DT2H30M/2008-05-11T15:30:00Z`
|
|
12
|
+
4. Duration only, such as `P1Y2M10DT2H30M`, with additional context information [not supported]
|
|
13
|
+
|
|
14
|
+
or more simply
|
|
15
|
+
|
|
16
|
+
<start>/<end>
|
|
17
|
+
<start>/<duration>
|
|
18
|
+
<duration>/<end>
|
|
19
|
+
<duration> [not supported]
|
|
20
|
+
|
|
21
|
+
## Precision
|
|
22
|
+
|
|
23
|
+
Currently the end result is precise to 1 day, so these are the same:
|
|
24
|
+
|
|
25
|
+
* `2007-03-01T00:00:00Z/2008-05-11T00:00:00Z`
|
|
26
|
+
* `2007-03-01/2008-05-11`
|
|
27
|
+
|
|
28
|
+
This may change in the future.
|
|
29
|
+
|
|
30
|
+
## Documentation
|
|
31
|
+
|
|
32
|
+
http://rdoc.info/projects/rossmeissl/timeframe
|
|
33
|
+
|
|
34
|
+
## Acknowledgements
|
|
35
|
+
|
|
36
|
+
The good parts of Timeframe all came from the gentlemen at Fingertips[http://fngtps.com].
|
|
37
|
+
|
|
38
|
+
Thanks to @artemk for https://github.com/rossmeissl/timeframe/pull/5
|
|
39
|
+
|
|
40
|
+
## Copyright
|
|
41
|
+
|
|
42
|
+
Copyright (c) 2012 Andy Rossmeissl, Seamus Abshere
|
data/Rakefile
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
# must be included before rubygems or bundler
|
|
2
|
-
if ENV['TIMEFRAME_HOME_RUN'] == 'true'
|
|
3
|
-
require 'home_run'
|
|
4
|
-
end
|
|
5
|
-
|
|
6
1
|
require 'bundler'
|
|
7
2
|
Bundler::GemHelper.install_tasks
|
|
8
3
|
|
|
@@ -17,10 +12,5 @@ end
|
|
|
17
12
|
|
|
18
13
|
task :default => :test
|
|
19
14
|
|
|
20
|
-
require '
|
|
21
|
-
|
|
22
|
-
rdoc.rdoc_dir = 'rdoc'
|
|
23
|
-
rdoc.title = "timeframe"
|
|
24
|
-
rdoc.rdoc_files.include('README*')
|
|
25
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
26
|
-
end
|
|
15
|
+
require 'yard'
|
|
16
|
+
YARD::Rake::YardocTask.new
|
data/lib/timeframe.rb
CHANGED
|
@@ -3,6 +3,8 @@ require 'multi_json'
|
|
|
3
3
|
require 'active_support/version'
|
|
4
4
|
require 'active_support/core_ext' if ActiveSupport::VERSION::MAJOR >= 3
|
|
5
5
|
|
|
6
|
+
require 'timeframe/iso_8601'
|
|
7
|
+
|
|
6
8
|
# Encapsulates a timeframe between two dates. The dates provided to the class are always until the last date. That means
|
|
7
9
|
# that the last date is excluded.
|
|
8
10
|
#
|
|
@@ -43,8 +45,14 @@ class Timeframe
|
|
|
43
45
|
# Construct a new Timeframe by parsing an ISO 8601 time interval string
|
|
44
46
|
# http://en.wikipedia.org/wiki/ISO_8601#Time_intervals
|
|
45
47
|
def from_iso8601(str)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
delimiter = str.include?('/') ? '/' : '--'
|
|
49
|
+
a_raw, b_raw = str.split delimiter
|
|
50
|
+
if a_raw.blank? or b_raw.blank?
|
|
51
|
+
raise ArgumentError, "Interval must be specified according to ISO 8601 <start>/<end>, <start>/<duration>, or <duration>/<end>."
|
|
52
|
+
end
|
|
53
|
+
a = Iso8601::A.new a_raw
|
|
54
|
+
b = Iso8601::B.new b_raw
|
|
55
|
+
new a.to_time(b), b.to_time(a)
|
|
48
56
|
end
|
|
49
57
|
|
|
50
58
|
# Construct a new Timeframe from a hash with keys startDate and endDate
|
|
@@ -68,14 +76,14 @@ class Timeframe
|
|
|
68
76
|
when ::String
|
|
69
77
|
str = input.strip
|
|
70
78
|
if str.start_with?('{')
|
|
71
|
-
from_hash
|
|
79
|
+
from_hash MultiJson.decode(str)
|
|
72
80
|
elsif input =~ /\A\d\d\d\d\z/
|
|
73
81
|
from_year input
|
|
74
82
|
else
|
|
75
83
|
from_iso8601 str
|
|
76
84
|
end
|
|
77
85
|
else
|
|
78
|
-
raise
|
|
86
|
+
raise ArgumentError, "Must be String or Hash"
|
|
79
87
|
end
|
|
80
88
|
end
|
|
81
89
|
alias :interval :parse
|
|
@@ -256,7 +264,7 @@ class Timeframe
|
|
|
256
264
|
b = timeframes.collect(&:start_date) + [ end_date ]
|
|
257
265
|
|
|
258
266
|
a.zip(b).map do |gap|
|
|
259
|
-
Timeframe.new(*gap
|
|
267
|
+
Timeframe.new(*gap) if gap[1] > gap[0]
|
|
260
268
|
end.compact
|
|
261
269
|
end
|
|
262
270
|
|
|
@@ -284,7 +292,27 @@ class Timeframe
|
|
|
284
292
|
end
|
|
285
293
|
alias :to_s :iso8601
|
|
286
294
|
alias :to_param :iso8601
|
|
287
|
-
|
|
295
|
+
|
|
296
|
+
def dates
|
|
297
|
+
dates = []
|
|
298
|
+
cursor = start_date
|
|
299
|
+
while cursor < end_date
|
|
300
|
+
dates << cursor
|
|
301
|
+
cursor = cursor.succ
|
|
302
|
+
end
|
|
303
|
+
dates
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def first_days_of_months
|
|
307
|
+
dates = []
|
|
308
|
+
cursor = start_date.beginning_of_month
|
|
309
|
+
while cursor < end_date
|
|
310
|
+
dates << cursor
|
|
311
|
+
cursor = cursor >> 1
|
|
312
|
+
end
|
|
313
|
+
dates
|
|
314
|
+
end
|
|
315
|
+
|
|
288
316
|
# Deprecated
|
|
289
317
|
def from # :nodoc:
|
|
290
318
|
@start_date
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
class Timeframe
|
|
2
|
+
module Iso8601
|
|
3
|
+
# Internal use.
|
|
4
|
+
#
|
|
5
|
+
# Parses a duration like 'P1Y2M4DT3H4M2S'
|
|
6
|
+
class Duration < ::Struct.new(:date_part, :time_part)
|
|
7
|
+
def seconds
|
|
8
|
+
(y*31_556_926 + m*2_629_743.83 + d*86_400 + h*3_600 + minutes*60 + s).ceil
|
|
9
|
+
end
|
|
10
|
+
private
|
|
11
|
+
def y; @y ||= parse(date_part, :Y); end
|
|
12
|
+
def m; @m ||= parse(date_part, :M); end
|
|
13
|
+
def d; @d ||= parse(date_part, :D); end
|
|
14
|
+
def h; @h ||= parse(time_part, :H); end
|
|
15
|
+
def minutes; @minutes ||= parse(time_part, :M); end
|
|
16
|
+
def s; @s ||= parse(time_part, :S); end
|
|
17
|
+
def parse(part, indicator)
|
|
18
|
+
if part =~ /(\d+)#{indicator.to_s}/
|
|
19
|
+
$1.to_f
|
|
20
|
+
else
|
|
21
|
+
0
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Internal use.
|
|
27
|
+
class Side
|
|
28
|
+
# We add one day because so that it can be excluded per timeframe's conventions.
|
|
29
|
+
EXCLUDED_LAST_DAY = 86_400
|
|
30
|
+
attr_reader :date_part, :time_part
|
|
31
|
+
def to_time(counterpart)
|
|
32
|
+
if date_part.start_with?('P')
|
|
33
|
+
counterpart.resolve_time(self) + resolve_offset + EXCLUDED_LAST_DAY
|
|
34
|
+
else
|
|
35
|
+
resolve_time counterpart
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Internal use.
|
|
41
|
+
#
|
|
42
|
+
# The "A" side of "A/B"
|
|
43
|
+
class A < Side
|
|
44
|
+
def initialize(raw)
|
|
45
|
+
raw = raw.upcase
|
|
46
|
+
@date_part, @time_part = raw.split('T')
|
|
47
|
+
@time_part ||= ''
|
|
48
|
+
end
|
|
49
|
+
def resolve_time(*)
|
|
50
|
+
Time.parse [date_part, time_part].join('T')
|
|
51
|
+
end
|
|
52
|
+
# When A is a period, it counts as a negative offset to B.
|
|
53
|
+
def resolve_offset
|
|
54
|
+
0.0 - Duration.new(date_part, time_part).seconds
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Internal use.
|
|
59
|
+
#
|
|
60
|
+
# The "B" side of "A/B"
|
|
61
|
+
class B < Side
|
|
62
|
+
def initialize(raw)
|
|
63
|
+
raw = raw.upcase
|
|
64
|
+
if raw.include?(':') and not raw.include?('T')
|
|
65
|
+
# it's just a shorthand for time
|
|
66
|
+
@date_part = ''
|
|
67
|
+
@time_part = raw
|
|
68
|
+
else
|
|
69
|
+
@date_part, @time_part = raw.split('T')
|
|
70
|
+
@time_part ||= ''
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
# When shorthand is used, we need to peek at our counterpart (A) in order to steal letters
|
|
74
|
+
# Shorthand can only be used on the B side, and only in <start>/<end> format.
|
|
75
|
+
def resolve_time(counterpart)
|
|
76
|
+
filled_in_date_part = unless date_part.count('-') == 2
|
|
77
|
+
counterpart.date_part[0..(0-date_part.length-1)] + date_part
|
|
78
|
+
else
|
|
79
|
+
date_part
|
|
80
|
+
end
|
|
81
|
+
filled_in_time_part = if time_part.count(':') < 2
|
|
82
|
+
counterpart.time_part[0..(0-time_part.length-1)] + time_part
|
|
83
|
+
else
|
|
84
|
+
time_part
|
|
85
|
+
end
|
|
86
|
+
Time.parse [filled_in_date_part, filled_in_time_part].join('T')
|
|
87
|
+
end
|
|
88
|
+
def resolve_offset
|
|
89
|
+
Duration.new(date_part, time_part).seconds
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
data/lib/timeframe/version.rb
CHANGED
data/spec/timeframe_spec.rb
CHANGED
|
@@ -59,7 +59,7 @@ describe Timeframe do
|
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
describe
|
|
62
|
+
describe :constrained_new do
|
|
63
63
|
let(:start) { Date.parse('2008-02-14') }
|
|
64
64
|
let(:finish) { Date.parse('2008-05-10') }
|
|
65
65
|
let(:constraint_start) { Date.parse('2008-01-01') }
|
|
@@ -108,7 +108,7 @@ describe Timeframe do
|
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
-
describe
|
|
111
|
+
describe :this_year do
|
|
112
112
|
it "should return the current year" do
|
|
113
113
|
Timeframe.this_year.must_equal Timeframe.new(:year => Time.now.year)
|
|
114
114
|
end
|
|
@@ -190,7 +190,7 @@ describe Timeframe do
|
|
|
190
190
|
|
|
191
191
|
describe '#/' do
|
|
192
192
|
it "should return a fraction of another timeframe" do
|
|
193
|
-
(Timeframe.new(:month => 4, :year => 2009) / Timeframe.new(:year => 2009)).must_equal
|
|
193
|
+
(Timeframe.new(:month => 4, :year => 2009) / Timeframe.new(:year => 2009)).must_equal(30.0 / 365.0)
|
|
194
194
|
end
|
|
195
195
|
end
|
|
196
196
|
|
|
@@ -224,10 +224,50 @@ describe Timeframe do
|
|
|
224
224
|
end
|
|
225
225
|
end
|
|
226
226
|
|
|
227
|
-
describe
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
describe :parse do
|
|
228
|
+
describe 'ISO 8601 <start>/<end>' do
|
|
229
|
+
it 'works without time' do
|
|
230
|
+
Timeframe.parse('2007-03-01/2008-05-11').must_equal Timeframe.new(Date.new(2007, 3, 1), Date.new(2008, 5, 11))
|
|
231
|
+
Timeframe.parse('2007-03-01--2008-05-11').must_equal Timeframe.new(Date.new(2007, 3, 1), Date.new(2008, 5, 11))
|
|
232
|
+
end
|
|
233
|
+
it 'works with time' do
|
|
234
|
+
Timeframe.parse('2007-03-01T13:00:00Z/2008-05-11T15:30:00Z').must_equal Timeframe.new(Date.new(2007, 3, 1), Date.new(2008, 5, 11))
|
|
235
|
+
Timeframe.parse('2007-03-01T13:00:00Z--2008-05-11T15:30:00Z').must_equal Timeframe.new(Date.new(2007, 3, 1), Date.new(2008, 5, 11))
|
|
236
|
+
end
|
|
237
|
+
it 'takes shorthand' do
|
|
238
|
+
Timeframe.parse('2007-11-13/15').must_equal Timeframe.new(Date.new(2007, 11, 13), Date.new(2007, 11, 15)) # "2007-11-13/15", i.e. from any time on 2007-11-13 to any time on 2007-11-15
|
|
239
|
+
Timeframe.parse("2008-02-15/03-14").must_equal Timeframe.new(Date.new(2008, 2, 15), Date.new(2008, 3, 14)) # "2008-02-15/2008-03-14"
|
|
240
|
+
Timeframe.parse("2007-12-14T13:30/15:30").must_equal Timeframe.new(Date.new(2007, 12, 14), Date.new(2007, 12, 14)) # "2007-12-14T13:30/2007-12-14T15:30".. imprecise!
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
describe 'ISO 8601 <start>/<duration>' do
|
|
245
|
+
it 'works without time' do
|
|
246
|
+
Timeframe.parse('2007-03-01/P1Y2M10DT2H30M').must_equal Timeframe.new(Date.new(2007, 3, 1), Date.new(2008, 5, 11))
|
|
247
|
+
Timeframe.parse('2007-03-01--P1Y2M10DT2H30M').must_equal Timeframe.new(Date.new(2007, 3, 1), Date.new(2008, 5, 11))
|
|
248
|
+
end
|
|
249
|
+
it 'works with time' do
|
|
250
|
+
Timeframe.parse('2007-03-01T13:00:00Z/P1Y2M10DT2H30M').must_equal Timeframe.new(Date.new(2007, 3, 1), Date.new(2008, 5, 11))
|
|
251
|
+
Timeframe.parse('2007-03-01T13:00:00Z--P1Y2M10DT2H30M').must_equal Timeframe.new(Date.new(2007, 3, 1), Date.new(2008, 5, 11))
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# note that 2008 was a leap year
|
|
256
|
+
describe 'ISO 8601 <duration>/<end>' do
|
|
257
|
+
it 'works with leap years' do
|
|
258
|
+
Timeframe.parse('2007-02-28--P1Y').must_equal Timeframe.new(Date.new(2007, 2, 28), Date.new(2008, 2, 29))
|
|
259
|
+
Timeframe.parse('P1Y--2008-02-29').must_equal Timeframe.new(Date.new(2007, 3, 1), Date.new(2008, 2, 29))
|
|
260
|
+
end
|
|
261
|
+
it 'works without time' do
|
|
262
|
+
Timeframe.parse('P1Y2M10DT2H30M/2008-05-11').must_equal Timeframe.new(Date.new(2007, 3, 2), Date.new(2008, 5, 11))
|
|
263
|
+
Timeframe.parse('P1Y2M10DT2H30M--2008-05-11').must_equal Timeframe.new(Date.new(2007, 3, 2), Date.new(2008, 5, 11))
|
|
264
|
+
end
|
|
265
|
+
it 'works with time' do
|
|
266
|
+
Timeframe.parse('P1Y2M10DT2H30M/2008-05-11T15:30:00Z').must_equal Timeframe.new(Date.new(2007, 3, 3), Date.new(2008, 5, 11))
|
|
267
|
+
Timeframe.parse('P1Y2M10DT2H30M--2008-05-11T15:30:00Z').must_equal Timeframe.new(Date.new(2007, 3, 3), Date.new(2008, 5, 11))
|
|
268
|
+
end
|
|
230
269
|
end
|
|
270
|
+
|
|
231
271
|
it 'understands plain year' do
|
|
232
272
|
plain_year = 2009
|
|
233
273
|
Timeframe.parse(plain_year).must_equal Timeframe.new(:year => plain_year)
|
|
@@ -271,6 +311,23 @@ EOS
|
|
|
271
311
|
Timeframe.new(Date.parse('2008-01-01'), Date.parse('2010-01-01')).to_s.must_equal "2008-01-01/2010-01-01"
|
|
272
312
|
end
|
|
273
313
|
end
|
|
314
|
+
|
|
315
|
+
describe '#dates' do
|
|
316
|
+
it "should enumerate all dates between start and end" do
|
|
317
|
+
dates = Timeframe.new(:year => 2008).dates
|
|
318
|
+
dates.min.must_equal Date.new(2008,1,1)
|
|
319
|
+
dates.max.must_equal Date.new(2008,12,31)
|
|
320
|
+
dates.uniq.length.must_equal 366
|
|
321
|
+
dates.select { |d| d.month == 2 }.length.must_equal 29
|
|
322
|
+
end
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
describe '#first_days_of_months' do
|
|
326
|
+
it "should enumerate all the first days of included months" do
|
|
327
|
+
dates = Timeframe.parse('2011-05-01/2012-02-01').first_days_of_months
|
|
328
|
+
dates.must_equal [Date.new(2011,5,1), Date.new(2011,6,1), Date.new(2011,7,1), Date.new(2011,8,1), Date.new(2011,9,1), Date.new(2011,10,1), Date.new(2011,11,1), Date.new(2011,12,1), Date.new(2012,1,1)]
|
|
329
|
+
end
|
|
330
|
+
end
|
|
274
331
|
|
|
275
332
|
describe "Array#multiple_timeframes_gaps_left_by" do
|
|
276
333
|
it "should raise error if not a Timeframes are going to be merged" do
|
data/timeframe.gemspec
CHANGED
|
@@ -19,9 +19,6 @@ Gem::Specification.new do |s|
|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
20
20
|
s.require_paths = ["lib"]
|
|
21
21
|
|
|
22
|
-
s.add_development_dependency "minitest"
|
|
23
|
-
s.add_development_dependency 'home_run'
|
|
24
|
-
s.add_development_dependency 'rake'
|
|
25
22
|
s.add_runtime_dependency 'activesupport', '>=2.3.5'
|
|
26
23
|
s.add_runtime_dependency 'i18n'
|
|
27
24
|
s.add_runtime_dependency 'multi_json'
|
metadata
CHANGED
|
@@ -1,165 +1,96 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: timeframe
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
prerelease:
|
|
6
|
-
segments:
|
|
7
|
-
- 0
|
|
8
|
-
- 1
|
|
9
|
-
- 0
|
|
10
|
-
version: 0.1.0
|
|
11
6
|
platform: ruby
|
|
12
|
-
authors:
|
|
7
|
+
authors:
|
|
13
8
|
- Andy Rossmeissl
|
|
14
9
|
- Seamus Abshere
|
|
15
10
|
- Derek Kastner
|
|
16
11
|
autorequire:
|
|
17
12
|
bindir: bin
|
|
18
13
|
cert_chain: []
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- !ruby/object:Gem::Dependency
|
|
23
|
-
name: minitest
|
|
24
|
-
prerelease: false
|
|
25
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
|
26
|
-
none: false
|
|
27
|
-
requirements:
|
|
28
|
-
- - ">="
|
|
29
|
-
- !ruby/object:Gem::Version
|
|
30
|
-
hash: 3
|
|
31
|
-
segments:
|
|
32
|
-
- 0
|
|
33
|
-
version: "0"
|
|
34
|
-
type: :development
|
|
35
|
-
version_requirements: *id001
|
|
36
|
-
- !ruby/object:Gem::Dependency
|
|
37
|
-
name: home_run
|
|
38
|
-
prerelease: false
|
|
39
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
|
40
|
-
none: false
|
|
41
|
-
requirements:
|
|
42
|
-
- - ">="
|
|
43
|
-
- !ruby/object:Gem::Version
|
|
44
|
-
hash: 3
|
|
45
|
-
segments:
|
|
46
|
-
- 0
|
|
47
|
-
version: "0"
|
|
48
|
-
type: :development
|
|
49
|
-
version_requirements: *id002
|
|
50
|
-
- !ruby/object:Gem::Dependency
|
|
51
|
-
name: rake
|
|
52
|
-
prerelease: false
|
|
53
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
|
54
|
-
none: false
|
|
55
|
-
requirements:
|
|
56
|
-
- - ">="
|
|
57
|
-
- !ruby/object:Gem::Version
|
|
58
|
-
hash: 3
|
|
59
|
-
segments:
|
|
60
|
-
- 0
|
|
61
|
-
version: "0"
|
|
62
|
-
type: :development
|
|
63
|
-
version_requirements: *id003
|
|
64
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
+
date: 2012-03-07 00:00:00.000000000 Z
|
|
15
|
+
dependencies:
|
|
16
|
+
- !ruby/object:Gem::Dependency
|
|
65
17
|
name: activesupport
|
|
66
|
-
|
|
67
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
|
18
|
+
requirement: &2164797740 !ruby/object:Gem::Requirement
|
|
68
19
|
none: false
|
|
69
|
-
requirements:
|
|
70
|
-
- -
|
|
71
|
-
- !ruby/object:Gem::Version
|
|
72
|
-
hash: 9
|
|
73
|
-
segments:
|
|
74
|
-
- 2
|
|
75
|
-
- 3
|
|
76
|
-
- 5
|
|
20
|
+
requirements:
|
|
21
|
+
- - ! '>='
|
|
22
|
+
- !ruby/object:Gem::Version
|
|
77
23
|
version: 2.3.5
|
|
78
24
|
type: :runtime
|
|
79
|
-
version_requirements: *id004
|
|
80
|
-
- !ruby/object:Gem::Dependency
|
|
81
|
-
name: i18n
|
|
82
25
|
prerelease: false
|
|
83
|
-
|
|
26
|
+
version_requirements: *2164797740
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: i18n
|
|
29
|
+
requirement: &2164797080 !ruby/object:Gem::Requirement
|
|
84
30
|
none: false
|
|
85
|
-
requirements:
|
|
86
|
-
- -
|
|
87
|
-
- !ruby/object:Gem::Version
|
|
88
|
-
|
|
89
|
-
segments:
|
|
90
|
-
- 0
|
|
91
|
-
version: "0"
|
|
31
|
+
requirements:
|
|
32
|
+
- - ! '>='
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: '0'
|
|
92
35
|
type: :runtime
|
|
93
|
-
version_requirements: *id005
|
|
94
|
-
- !ruby/object:Gem::Dependency
|
|
95
|
-
name: multi_json
|
|
96
36
|
prerelease: false
|
|
97
|
-
|
|
37
|
+
version_requirements: *2164797080
|
|
38
|
+
- !ruby/object:Gem::Dependency
|
|
39
|
+
name: multi_json
|
|
40
|
+
requirement: &2164796260 !ruby/object:Gem::Requirement
|
|
98
41
|
none: false
|
|
99
|
-
requirements:
|
|
100
|
-
- -
|
|
101
|
-
- !ruby/object:Gem::Version
|
|
102
|
-
|
|
103
|
-
segments:
|
|
104
|
-
- 0
|
|
105
|
-
version: "0"
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
106
46
|
type: :runtime
|
|
107
|
-
|
|
47
|
+
prerelease: false
|
|
48
|
+
version_requirements: *2164796260
|
|
108
49
|
description: A Ruby class for describing and interacting with timeframes.
|
|
109
|
-
email:
|
|
50
|
+
email:
|
|
110
51
|
- andy@rossmeissl.net
|
|
111
52
|
executables: []
|
|
112
|
-
|
|
113
53
|
extensions: []
|
|
114
|
-
|
|
115
54
|
extra_rdoc_files: []
|
|
116
|
-
|
|
117
|
-
files:
|
|
55
|
+
files:
|
|
118
56
|
- .document
|
|
119
57
|
- .gitignore
|
|
120
58
|
- Gemfile
|
|
121
59
|
- LICENSE
|
|
122
|
-
- README.
|
|
60
|
+
- README.markdown
|
|
123
61
|
- Rakefile
|
|
124
62
|
- lib/timeframe.rb
|
|
125
63
|
- lib/timeframe/core_ext/array.rb
|
|
64
|
+
- lib/timeframe/iso_8601.rb
|
|
126
65
|
- lib/timeframe/version.rb
|
|
127
66
|
- spec/spec_helper.rb
|
|
128
67
|
- spec/timeframe_spec.rb
|
|
129
68
|
- timeframe.gemspec
|
|
130
69
|
homepage: http://github.com/rossmeissl/timeframe
|
|
131
70
|
licenses: []
|
|
132
|
-
|
|
133
71
|
post_install_message:
|
|
134
72
|
rdoc_options: []
|
|
135
|
-
|
|
136
|
-
require_paths:
|
|
73
|
+
require_paths:
|
|
137
74
|
- lib
|
|
138
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
76
|
none: false
|
|
140
|
-
requirements:
|
|
141
|
-
- -
|
|
142
|
-
- !ruby/object:Gem::Version
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
- 0
|
|
146
|
-
version: "0"
|
|
147
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - ! '>='
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '0'
|
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
82
|
none: false
|
|
149
|
-
requirements:
|
|
150
|
-
- -
|
|
151
|
-
- !ruby/object:Gem::Version
|
|
152
|
-
|
|
153
|
-
segments:
|
|
154
|
-
- 0
|
|
155
|
-
version: "0"
|
|
83
|
+
requirements:
|
|
84
|
+
- - ! '>='
|
|
85
|
+
- !ruby/object:Gem::Version
|
|
86
|
+
version: '0'
|
|
156
87
|
requirements: []
|
|
157
|
-
|
|
158
88
|
rubyforge_project: timeframe
|
|
159
|
-
rubygems_version: 1.8.
|
|
89
|
+
rubygems_version: 1.8.15
|
|
160
90
|
signing_key:
|
|
161
91
|
specification_version: 3
|
|
162
92
|
summary: Date intervals
|
|
163
|
-
test_files:
|
|
164
|
-
|
|
93
|
+
test_files:
|
|
94
|
+
- spec/spec_helper.rb
|
|
95
|
+
- spec/timeframe_spec.rb
|
|
165
96
|
has_rdoc:
|
data/README.rdoc
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
= timeframe
|
|
2
|
-
|
|
3
|
-
A Ruby class for describing and interacting with timeframes.
|
|
4
|
-
|
|
5
|
-
== Documentation
|
|
6
|
-
|
|
7
|
-
http://rdoc.info/projects/rossmeissl/timeframe
|
|
8
|
-
|
|
9
|
-
== Acknowledgements
|
|
10
|
-
|
|
11
|
-
The good parts of Timeframe all came from the gentlemen at Fingertips[http://fngtps.com].
|
|
12
|
-
|
|
13
|
-
Thanks to @artemk for https://github.com/rossmeissl/timeframe/pull/5
|
|
14
|
-
|
|
15
|
-
== Copyright
|
|
16
|
-
|
|
17
|
-
Copyright (c) 2010 Andy Rossmeissl.
|