time-interval 0.0.4 → 0.0.5

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: 19332affedd3c797819348596303bb4acf65afe1
4
- data.tar.gz: de62b70cbd528c98562a9ec1acbef56663d3c925
3
+ metadata.gz: e89712672c6ec5639335d9c1370a78f67030b5c0
4
+ data.tar.gz: 4b7c895953c7c6d1ef260fc043036f655554fe62
5
5
  SHA512:
6
- metadata.gz: 76f88a28295ac79cd0e3e03934b26b432e1084a8b349a238ca7e51d710e0d5b190476f9eb0a4af0b9371ad85e7273c8d0c9dc9482ad7ecc392328804e5ecfdac
7
- data.tar.gz: 087bde9f32c01632a48a792391500ff8b7d981d9c946eea5b68f44049775b3874d4054913a6bca33c058736fb591d94d929ded0f58b219653b4d3dfd264f27e6
6
+ metadata.gz: 100dfbfce1a5415ad1366f69ae58f2d5a81fbd826d393d41e5531ad634c620eb127877b6526ff5e44c078efc33fbeca945151d82c9b60081dd9933463bf8aa70
7
+ data.tar.gz: 50fd4595f04cb6fd2b81599e20454c2aa9897f2e6b159d4ae33ea2bb142e00740f254b01d5d0c826400f5c224ed30ebf8f546bba6cce846aae5a7ab9f882a863
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ script: bundle exec rspec
data/README.md CHANGED
@@ -1,13 +1,46 @@
1
1
  # TimeInterval
2
2
 
3
- TODO: Write a gem description
3
+ [![Build Status](https://travis-ci.org/SebastianEdwards/time-interval.svg?branch=master)](https://travis-ci.org/SebastianEdwards/time-interval)
4
+ [![Code Climate](https://codeclimate.com/github/SebastianEdwards/time-interval/badges/gpa.svg)](https://codeclimate.com/github/SebastianEdwards/time-interval)
5
+
6
+ #### Did you know that the ISO8601 defines time interval standards?
7
+
8
+ Find out all about it here: http://en.wikipedia.org/wiki/ISO_8601#Time_intervals
9
+
10
+ ```ruby
11
+ # A one month period
12
+ interval = TimeInterval.parse "2007-03-01T00:00:00Z/P1M"
13
+ interval.start_time # => 2007-03-01 00:00:00 UTC
14
+ interval.end_time # => 2007-04-01 00:00:00 UTC
15
+
16
+ # A period defined by two time points
17
+ interval = TimeInterval.parse "2007-03-01T00:00:00Z/2007-09-01T00:00:00Z"
18
+ interval.start_time # => 2007-03-01 00:00:00 UTC
19
+ interval.end_time # => 2007-09-01 00:00:00 UTC
20
+
21
+ # A repeating five minute period
22
+ repeating_interval = TimeInterval.parse "R/2007-03-01T00:00:00Z/PT5M"
23
+ periods = repeating_interval.take(100) # => using take due to infinite nature of repeating interval
24
+ periods.last.start_time # => 2007-03-01 08:15:00 UTC
25
+ periods.last.end_time # => 2007-03-01 08:20:00 UTC
26
+
27
+ # A two week period repeated two times
28
+ repeating_interval = TimeInterval.parse "R2/2007-03-01T00:00:00Z/P2W"
29
+ periods = repeating_interval.to_a
30
+ periods.length # => 2
31
+ periods[0].start_time # => 2007-03-01 00:00:00 UTC
32
+ periods[0].end_time # => 2007-03-15 00:00:00 UTC
33
+ periods[1].start_time # => 2007-03-15 00:00:00 UTC
34
+ periods[1].end_time # => 2007-03-29 00:00:00 UTC
35
+ periods[2] # => nil
36
+ ```
4
37
 
5
38
  ## Installation
6
39
 
7
40
  Add this line to your application's Gemfile:
8
41
 
9
42
  ```ruby
10
- gem 'time_interval'
43
+ gem 'time-interval'
11
44
  ```
12
45
 
13
46
  And then execute:
@@ -16,15 +49,19 @@ And then execute:
16
49
 
17
50
  Or install it yourself as:
18
51
 
19
- $ gem install time_interval
52
+ $ gem install time-interval
20
53
 
21
54
  ## Usage
22
55
 
23
- TODO: Write usage instructions here
56
+ `TimeInterval.parse(iso8601)` will parse ISO8601 string into a time, interval, or repeating interval.
57
+
58
+ `TimeInterval.repeating?(iso8601)` will check if ISO8601 string is a repeating interval.
59
+
60
+ `TimeInterval.interval?(iso8601)` will check if ISO8601 string is an interval.
24
61
 
25
62
  ## Contributing
26
63
 
27
- 1. Fork it ( https://github.com/[my-github-username]/time_interval/fork )
64
+ 1. Fork it ( https://github.com/SebastianEdwards/time-interval/fork )
28
65
  2. Create your feature branch (`git checkout -b my-new-feature`)
29
66
  3. Commit your changes (`git commit -am 'Add some feature'`)
30
67
  4. Push to the branch (`git push origin my-new-feature`)
data/Rakefile CHANGED
@@ -1 +1,11 @@
1
1
  require 'bundler/gem_tasks'
2
+
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
9
+ rescue LoadError
10
+ puts 'no rspec available'
11
+ end
data/lib/time_interval.rb CHANGED
@@ -32,7 +32,7 @@ module TimeInterval
32
32
  TimePair.parse iso8601
33
33
  end
34
34
  else
35
- Time.parse iso8601
35
+ TimePair.parse "#{iso8601}/#{iso8601}"
36
36
  end
37
37
  end
38
38
  end
@@ -1,3 +1,3 @@
1
1
  module TimeInterval
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -27,8 +27,11 @@ RSpec.describe TimeInterval do
27
27
  context 'iso8601 is not an interval' do
28
28
  let(:iso8601) { '2007-03-01T13:00:00Z' }
29
29
 
30
- it 'should return a RepeatingInterval' do
31
- expect(TimeInterval.parse(iso8601)).to be_a Time
30
+ it 'should return a TimePair with no duration' do
31
+ parsed = TimeInterval.parse(iso8601)
32
+
33
+ expect(parsed).to be_a TimePair
34
+ expect(parsed.start_time).to eq parsed.end_time
32
35
  end
33
36
  end
34
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time-interval
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Edwards
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-12 00:00:00.000000000 Z
11
+ date: 2015-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,6 +89,7 @@ extra_rdoc_files: []
89
89
  files:
90
90
  - ".gitignore"
91
91
  - ".rspec"
92
+ - ".travis.yml"
92
93
  - Gemfile
93
94
  - Guardfile
94
95
  - LICENSE.txt