time-interval 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/Guardfile +14 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +1 -0
- data/lib/time-interval.rb +1 -0
- data/lib/time_interval/duration.rb +78 -0
- data/lib/time_interval/repeating_interval.rb +48 -0
- data/lib/time_interval/time_pair.rb +25 -0
- data/lib/time_interval/time_with_duration.rb +60 -0
- data/lib/time_interval/version.rb +3 -0
- data/lib/time_interval.rb +38 -0
- data/spec/lib/time_interval/repeating_interval_spec.rb +46 -0
- data/spec/lib/time_interval/time_pair_spec.rb +37 -0
- data/spec/lib/time_interval/time_with_duration_spec.rb +35 -0
- data/spec/lib/time_interval_spec.rb +35 -0
- data/spec/spec_helper.rb +18 -0
- data/time_interval.gemspec +27 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bc282ee85bc8d071ecadb4f82421d905378b1232
|
4
|
+
data.tar.gz: 3772192417d37d39090ca4ecff853f8656a67596
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 67679c5a9f001e9935f823fd96b831e1e67e5491d00ac357eb0a846092f8058814020e12fbb3680bb1364be80cd9044298d85931146589324be4efee8135b2cc
|
7
|
+
data.tar.gz: 1dc99d30fd7a1dd70faf76af7ece40524f46e59765d07eab40ff7390813ad60343044c6d34618a32ab0f6309419fa907742673af4f66f42949fcf3edcbdd05a1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
2
|
+
require 'guard/rspec/dsl'
|
3
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
4
|
+
|
5
|
+
# RSpec files
|
6
|
+
rspec = dsl.rspec
|
7
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
8
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
9
|
+
watch(rspec.spec_files)
|
10
|
+
|
11
|
+
# Ruby files
|
12
|
+
ruby = dsl.ruby
|
13
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
14
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Sebastian Edwards
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# TimeInterval
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'time_interval'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install time_interval
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/time_interval/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'time_interval'
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module TimeInterval
|
2
|
+
class Duration
|
3
|
+
def self.parse(duration_str)
|
4
|
+
y = duration_str['Y'] ? duration_str.match(/(\d+)Y/)[1].to_i : 0
|
5
|
+
m = duration_str['M'] ? duration_str.match(/(\d+)M/)[1].to_i : 0
|
6
|
+
w = duration_str['W'] ? duration_str.match(/(\d+)W/)[1].to_i : 0
|
7
|
+
d = duration_str['D'] ? duration_str.match(/(\d+)D/)[1].to_i : 0
|
8
|
+
if duration_str['T']
|
9
|
+
h = duration_str['H'] ? duration_str.match(/T.*(\d+)H/)[1].to_i : 0
|
10
|
+
mi = duration_str['M'] ? duration_str.match(/T.*(\d+)M/)[1].to_i : 0
|
11
|
+
s = duration_str['S'] ? duration_str.match(/T.*(\d+)S/)[1].to_i : 0
|
12
|
+
else
|
13
|
+
h = mi = s = 0
|
14
|
+
end
|
15
|
+
|
16
|
+
new(years: y, months: m, weeks: w, days: d, hours: h, minutes: mi,
|
17
|
+
seconds: s)
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :years, :months, :weeks, :days, :hours, :minutes, :seconds
|
21
|
+
|
22
|
+
def initialize(years: 0, months: 0, weeks: 0, days: 0, hours: 0, minutes: 0,
|
23
|
+
seconds: 0)
|
24
|
+
@years = years
|
25
|
+
@months = months
|
26
|
+
@weeks = weeks
|
27
|
+
@days = days
|
28
|
+
@hours = hours
|
29
|
+
@minutes = minutes
|
30
|
+
@seconds = seconds
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_to(time)
|
34
|
+
time + total_seconds
|
35
|
+
end
|
36
|
+
|
37
|
+
def iso8601
|
38
|
+
string = 'P' + iso8601_date
|
39
|
+
string += iso8601_time unless iso8601_time == 'T'
|
40
|
+
|
41
|
+
string
|
42
|
+
end
|
43
|
+
|
44
|
+
def subtract_from(time)
|
45
|
+
time - total_seconds
|
46
|
+
end
|
47
|
+
|
48
|
+
def present?
|
49
|
+
total_seconds > 0
|
50
|
+
end
|
51
|
+
|
52
|
+
def total_seconds
|
53
|
+
years.years + months.months + weeks.weeks + days.days + hours.hours +
|
54
|
+
minutes.minutes + seconds.seconds
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def iso8601_date
|
60
|
+
string = ''
|
61
|
+
string += "#{years}Y" if years > 0
|
62
|
+
string += "#{months}M" if months > 0
|
63
|
+
string += "#{weeks}W" if weeks > 0
|
64
|
+
string += "#{days}D" if days > 0
|
65
|
+
|
66
|
+
string
|
67
|
+
end
|
68
|
+
|
69
|
+
def iso8601_time
|
70
|
+
string = 'T'
|
71
|
+
string += "#{hours}H" if hours > 0
|
72
|
+
string += "#{minutes}M" if minutes > 0
|
73
|
+
string += "#{seconds}S" if seconds > 0
|
74
|
+
|
75
|
+
string
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module TimeInterval
|
2
|
+
class RepeatingInterval
|
3
|
+
def self.parse(iso8601)
|
4
|
+
recurrence, time_with_duration_string = iso8601.split('/', 2)
|
5
|
+
|
6
|
+
times = if recurrence.match(/^R(\d+)/)
|
7
|
+
Regexp.last_match[1].to_i
|
8
|
+
else
|
9
|
+
Float::INFINITY
|
10
|
+
end
|
11
|
+
|
12
|
+
fail ArgumentError if times == 0
|
13
|
+
|
14
|
+
new TimeWithDuration.parse(time_with_duration_string), times
|
15
|
+
end
|
16
|
+
|
17
|
+
include Enumerable
|
18
|
+
|
19
|
+
attr_reader :length
|
20
|
+
|
21
|
+
def initialize(time_with_duration, times)
|
22
|
+
@time_with_duration = time_with_duration
|
23
|
+
@length = times
|
24
|
+
|
25
|
+
@enumerator = Enumerator::Lazy.new(0...times) do |yielder, i|
|
26
|
+
if i == 0
|
27
|
+
yielder.yield time_with_duration
|
28
|
+
else
|
29
|
+
interval = time_with_duration
|
30
|
+
i.times { interval = interval.step }
|
31
|
+
yielder.yield interval
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def each(&block)
|
37
|
+
@enumerator.each(&block)
|
38
|
+
end
|
39
|
+
|
40
|
+
def iso8601
|
41
|
+
if length == Float::INFINITY
|
42
|
+
"R/#{@time_with_duration.iso8601}"
|
43
|
+
else
|
44
|
+
"R#{length}/#{@time_with_duration.iso8601}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module TimeInterval
|
2
|
+
class TimePair
|
3
|
+
def self.parse(iso8601)
|
4
|
+
halves = iso8601.split('/')
|
5
|
+
|
6
|
+
fail ArgumentError unless halves.length == 2
|
7
|
+
|
8
|
+
start_time, end_time = halves.map { |time| Time.parse time }
|
9
|
+
|
10
|
+
new start_time, end_time
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :start_time
|
14
|
+
attr_reader :end_time
|
15
|
+
|
16
|
+
def initialize(start_time, end_time)
|
17
|
+
@start_time = start_time
|
18
|
+
@end_time = end_time
|
19
|
+
end
|
20
|
+
|
21
|
+
def iso8601
|
22
|
+
"#{start_time.iso8601}/#{end_time.iso8601}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module TimeInterval
|
2
|
+
class TimeWithDuration
|
3
|
+
UNITS = %w(years months weeks days hours minutes seconds).freeze
|
4
|
+
|
5
|
+
def self.parse(iso8601)
|
6
|
+
halves = iso8601.split('/')
|
7
|
+
|
8
|
+
fail ArgumentError unless halves.length == 2
|
9
|
+
|
10
|
+
if halves[0]['P']
|
11
|
+
forwards = false
|
12
|
+
duration = Duration.parse(halves[0])
|
13
|
+
time = halves[1]
|
14
|
+
elsif halves[1]['P']
|
15
|
+
forwards = true
|
16
|
+
duration = Duration.parse(halves[1])
|
17
|
+
time = halves[0]
|
18
|
+
else
|
19
|
+
fail ArgumentError
|
20
|
+
end
|
21
|
+
|
22
|
+
new Time.parse(time), duration, forwards
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_reader :start_time
|
26
|
+
attr_reader :duration
|
27
|
+
|
28
|
+
def initialize(time, duration, forwards = true)
|
29
|
+
@start_time = time
|
30
|
+
@duration = duration
|
31
|
+
@forwards = forwards
|
32
|
+
end
|
33
|
+
|
34
|
+
def end_time
|
35
|
+
if forwards?
|
36
|
+
duration.add_to start_time
|
37
|
+
else
|
38
|
+
duration.subtract_from start_time
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def iso8601
|
43
|
+
if forwards?
|
44
|
+
"#{start_time.iso8601}/#{duration.iso8601}"
|
45
|
+
else
|
46
|
+
"#{duration.iso8601}/#{start_time.iso8601}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def step
|
51
|
+
TimeWithDuration.new end_time, duration, forwards?
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def forwards?
|
57
|
+
@forwards == true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'time_interval/version'
|
2
|
+
|
3
|
+
require 'active_support/all'
|
4
|
+
|
5
|
+
require 'time_interval/duration'
|
6
|
+
require 'time_interval/repeating_interval'
|
7
|
+
require 'time_interval/time_pair'
|
8
|
+
require 'time_interval/time_with_duration'
|
9
|
+
|
10
|
+
module TimeInterval
|
11
|
+
module_function
|
12
|
+
|
13
|
+
def interval?(iso8601)
|
14
|
+
iso8601['/'] == '/'
|
15
|
+
end
|
16
|
+
|
17
|
+
def repeating?(iso8601)
|
18
|
+
!iso8601.match(/^R/).nil?
|
19
|
+
end
|
20
|
+
|
21
|
+
def duration?(iso8601)
|
22
|
+
iso8601['P'] == 'P'
|
23
|
+
end
|
24
|
+
|
25
|
+
def parse(iso8601)
|
26
|
+
if interval? iso8601
|
27
|
+
if repeating?(iso8601) && duration?(iso8601)
|
28
|
+
RepeatingInterval.parse iso8601
|
29
|
+
elsif duration? iso8601
|
30
|
+
TimeWithDuration.parse iso8601
|
31
|
+
else
|
32
|
+
TimePair.parse iso8601
|
33
|
+
end
|
34
|
+
else
|
35
|
+
Time.parse iso8601
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
RSpec.describe RepeatingInterval do
|
2
|
+
describe '.parse' do
|
3
|
+
let(:iso8601) { 'R2/2007-03-01T13:00:00Z/P1M' }
|
4
|
+
|
5
|
+
it 'should create a RepeatingInterval' do
|
6
|
+
result = RepeatingInterval.parse iso8601
|
7
|
+
|
8
|
+
expect(result).to be_a RepeatingInterval
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'iso8601 has a set number of repetitions' do
|
12
|
+
it 'should have correct length' do
|
13
|
+
result = RepeatingInterval.parse iso8601
|
14
|
+
|
15
|
+
expect(result.length).to eq 2
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should enumerate over the repetitions' do
|
19
|
+
result = RepeatingInterval.parse iso8601
|
20
|
+
|
21
|
+
expect(result.first).to be_a TimeWithDuration
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should have correct repetitions' do
|
25
|
+
repeating = RepeatingInterval.parse(iso8601)
|
26
|
+
repetitions = repeating.take(3)
|
27
|
+
|
28
|
+
expect(repetitions[0].start_time).to eq '2007-03-01T13:00:00Z'
|
29
|
+
expect(repetitions[1].start_time).to eq '2007-04-01T13:00:00Z'
|
30
|
+
expect(repetitions[2]).to eq nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#iso8601' do
|
36
|
+
let(:time) { Time.parse('2007-03-01T13:00:00Z') }
|
37
|
+
let(:duration) { Duration.new(months: 2) }
|
38
|
+
let(:time_with_duration) { TimeWithDuration.new time, duration }
|
39
|
+
|
40
|
+
let(:repeating_interval) { RepeatingInterval.new time_with_duration, 4 }
|
41
|
+
|
42
|
+
it 'should return a valid iso8601 time with duration' do
|
43
|
+
expect(repeating_interval.iso8601).to eq 'R4/2007-03-01T13:00:00Z/P2M'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
RSpec.describe TimePair do
|
2
|
+
describe '.parse' do
|
3
|
+
context 'iso8601 is a valid time pair' do
|
4
|
+
let(:iso8601) { '2007-03-01T13:00:00Z/2008-05-11T15:30:00Z' }
|
5
|
+
|
6
|
+
it 'should create a TimePair' do
|
7
|
+
result = TimePair.parse iso8601
|
8
|
+
|
9
|
+
expect(result).to be_a TimePair
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should have correct start_time' do
|
13
|
+
result = TimePair.parse iso8601
|
14
|
+
|
15
|
+
expect(result.start_time).to eq Time.parse('2007-03-01T13:00:00Z')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have correct end_time' do
|
19
|
+
result = TimePair.parse iso8601
|
20
|
+
|
21
|
+
expect(result.end_time).to eq Time.parse('2008-05-11T15:30:00Z')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#iso8601' do
|
27
|
+
let(:first_time) { Time.parse('2007-03-01T13:00:00Z') }
|
28
|
+
let(:last_time) { Time.parse('2008-05-11T15:30:00Z') }
|
29
|
+
let(:time_pair) { TimePair.new first_time, last_time }
|
30
|
+
|
31
|
+
it 'should return a valid iso8601 time pair' do
|
32
|
+
expected = '2007-03-01T13:00:00Z/2008-05-11T15:30:00Z'
|
33
|
+
|
34
|
+
expect(time_pair.iso8601).to eq expected
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
RSpec.describe TimeWithDuration do
|
2
|
+
describe '.parse' do
|
3
|
+
context 'iso8601 is a valid time and duration' do
|
4
|
+
let(:iso8601) { '2007-03-01T13:00:00Z/P1M' }
|
5
|
+
|
6
|
+
it 'should create a TimeWithDuration' do
|
7
|
+
result = TimeWithDuration.parse iso8601
|
8
|
+
|
9
|
+
expect(result).to be_a TimeWithDuration
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should have correct start_time' do
|
13
|
+
result = TimeWithDuration.parse iso8601
|
14
|
+
|
15
|
+
expect(result.start_time).to eq Time.parse('2007-03-01T13:00:00Z')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have correct end_time' do
|
19
|
+
result = TimeWithDuration.parse iso8601
|
20
|
+
|
21
|
+
expect(result.end_time).to eq Time.parse('2007-04-01T13:00:00Z')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#iso8601' do
|
27
|
+
let(:time) { Time.parse('2007-03-01T13:00:00Z') }
|
28
|
+
let(:duration) { Duration.new(months: 2) }
|
29
|
+
let(:time_with_duration) { TimeWithDuration.new time, duration }
|
30
|
+
|
31
|
+
it 'should return a valid iso8601 time with duration' do
|
32
|
+
expect(time_with_duration.iso8601).to eq '2007-03-01T13:00:00Z/P2M'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
RSpec.describe TimeInterval do
|
2
|
+
describe '.parse' do
|
3
|
+
context 'iso8601 is a valid time and duration' do
|
4
|
+
let(:iso8601) { '2007-03-01T13:00:00Z/P1M' }
|
5
|
+
|
6
|
+
it 'should return a TimeWithDuration' do
|
7
|
+
expect(TimeInterval.parse(iso8601)).to be_a TimeWithDuration
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'iso8601 is a valid time pair' do
|
12
|
+
let(:iso8601) { '2007-03-01T13:00:00Z/2008-05-11T15:30:00Z' }
|
13
|
+
|
14
|
+
it 'should return a TimePair' do
|
15
|
+
expect(TimeInterval.parse(iso8601)).to be_a TimePair
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'iso8601 is a valid repeating interval' do
|
20
|
+
let(:iso8601) { 'R/2007-03-01T13:00:00Z/P1M' }
|
21
|
+
|
22
|
+
it 'should return a RepeatingInterval' do
|
23
|
+
expect(TimeInterval.parse(iso8601)).to be_a RepeatingInterval
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'iso8601 is not an interval' do
|
28
|
+
let(:iso8601) { '2007-03-01T13:00:00Z' }
|
29
|
+
|
30
|
+
it 'should return a RepeatingInterval' do
|
31
|
+
expect(TimeInterval.parse(iso8601)).to be_a Time
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
RSpec.configure do |config|
|
2
|
+
config.disable_monkey_patching!
|
3
|
+
config.order = :random
|
4
|
+
|
5
|
+
config.expect_with :rspec do |expectations|
|
6
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
7
|
+
end
|
8
|
+
|
9
|
+
config.mock_with :rspec do |mocks|
|
10
|
+
mocks.verify_partial_doubles = true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'time-interval'
|
15
|
+
|
16
|
+
TimeInterval.constants.each do |const|
|
17
|
+
eval "#{const} = TimeInterval::#{const}"
|
18
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'time_interval/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'time-interval'
|
8
|
+
spec.version = TimeInterval::VERSION
|
9
|
+
spec.authors = ['Sebastian Edwards']
|
10
|
+
spec.email = ['me@sebastianedwards.co.nz']
|
11
|
+
spec.summary = 'Simple library to handle ISO8601 time intervals.'
|
12
|
+
spec.description = ''
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'rspec'
|
24
|
+
spec.add_development_dependency 'guard-rspec'
|
25
|
+
|
26
|
+
spec.add_runtime_dependency 'activesupport'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: time-interval
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sebastian Edwards
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard-rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: activesupport
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: ''
|
84
|
+
email:
|
85
|
+
- me@sebastianedwards.co.nz
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- Gemfile
|
93
|
+
- Guardfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- lib/time-interval.rb
|
98
|
+
- lib/time_interval.rb
|
99
|
+
- lib/time_interval/duration.rb
|
100
|
+
- lib/time_interval/repeating_interval.rb
|
101
|
+
- lib/time_interval/time_pair.rb
|
102
|
+
- lib/time_interval/time_with_duration.rb
|
103
|
+
- lib/time_interval/version.rb
|
104
|
+
- spec/lib/time_interval/repeating_interval_spec.rb
|
105
|
+
- spec/lib/time_interval/time_pair_spec.rb
|
106
|
+
- spec/lib/time_interval/time_with_duration_spec.rb
|
107
|
+
- spec/lib/time_interval_spec.rb
|
108
|
+
- spec/spec_helper.rb
|
109
|
+
- time_interval.gemspec
|
110
|
+
homepage: ''
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.4.5
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: Simple library to handle ISO8601 time intervals.
|
134
|
+
test_files:
|
135
|
+
- spec/lib/time_interval/repeating_interval_spec.rb
|
136
|
+
- spec/lib/time_interval/time_pair_spec.rb
|
137
|
+
- spec/lib/time_interval/time_with_duration_spec.rb
|
138
|
+
- spec/lib/time_interval_spec.rb
|
139
|
+
- spec/spec_helper.rb
|