edtf 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +3 -2
- data/README.md +15 -12
- data/Rakefile +10 -0
- data/features/step_definitions/edtf_steps.rb +2 -2
- data/lib/edtf.rb +27 -0
- data/lib/edtf/compatibility.rb +11 -0
- data/lib/edtf/seasons.rb +1 -1
- data/lib/edtf/version.rb +1 -1
- metadata +13 -12
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -2,6 +2,7 @@ source :rubygems
|
|
2
2
|
gemspec
|
3
3
|
|
4
4
|
group :debug do
|
5
|
-
gem 'ruby-debug19', :require => 'ruby-debug', :platforms => [:
|
6
|
-
gem 'ruby-debug', :platforms => [:
|
5
|
+
gem 'ruby-debug19', :require => 'ruby-debug', :platforms => [:mri_19]
|
6
|
+
gem 'ruby-debug', :platforms => [:mri_18, :jruby]
|
7
|
+
gem 'rbx-trepanning', :platforms => [:rbx]
|
7
8
|
end
|
data/README.md
CHANGED
@@ -17,6 +17,9 @@ As of EDTF Specification DRAFT, August 4, 2001:
|
|
17
17
|
The following level 2 extensions are currently _not_ supported: 201, 202, 203,
|
18
18
|
204, and 205.
|
19
19
|
|
20
|
+
EDTF-Ruby has been confirmed to work on the following Ruby implementations:
|
21
|
+
1.9.2, 1.8.7, rbx, jruby.
|
22
|
+
|
20
23
|
|
21
24
|
Quickstart
|
22
25
|
----------
|
@@ -44,18 +47,18 @@ given a valid EDTF string the return value will either be an (extended) `Date`,
|
|
44
47
|
=> true
|
45
48
|
> Date.edtf('2003-24').winter?
|
46
49
|
=> true
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
50
|
+
> Date.edtf('196x')
|
51
|
+
=> #<Date: 1960-01-01>...#<Date: 1970-01-01>
|
52
|
+
> Date.edtf('y-17e7').year
|
53
|
+
=> -170000000
|
54
|
+
> d = Date.edtf('1984-06?/2004-08?')
|
55
|
+
> d.from.uncertain?
|
56
|
+
=> true
|
57
|
+
> d.each.to_a.length
|
58
|
+
=> 7367 # days between 1984-06 and 2004-08
|
59
|
+
> Date.edtf('2004-01-01/open').open?
|
60
|
+
=> true
|
61
|
+
|
59
62
|
|
60
63
|
For additional features take a look at the rdoc, source, and rspec examples.
|
61
64
|
|
data/Rakefile
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
lib = File.expand_path('../lib/', __FILE__)
|
2
|
+
$:.unshift lib unless $:.include?(lib)
|
1
3
|
|
2
4
|
require 'rake/clean'
|
5
|
+
require 'edtf/version'
|
6
|
+
|
3
7
|
|
4
8
|
desc 'Generates the parser'
|
5
9
|
task :racc do
|
@@ -16,6 +20,12 @@ task :build => [:racc] do
|
|
16
20
|
system 'gem build edtf.gemspec'
|
17
21
|
end
|
18
22
|
|
23
|
+
task :release => [:build] do
|
24
|
+
system "git tag #{EDTF::VERSION}"
|
25
|
+
system "gem push edtf-#{EDTF::VERSION}.gem"
|
26
|
+
end
|
27
|
+
|
19
28
|
CLEAN.include('lib/edtf/parser.rb')
|
20
29
|
CLEAN.include('lib/edtf/parser.output')
|
21
30
|
CLEAN.include('*.gem')
|
31
|
+
CLEAN.include('**/*.rbc')
|
@@ -43,8 +43,8 @@ Then /^the seconds should be "([^"]*)"$/ do |seconds|
|
|
43
43
|
@edtf.sec.should == seconds.to_i
|
44
44
|
end
|
45
45
|
|
46
|
-
Then /^the duration should range from "([^"]*)" to "([^"]*)"$/ do
|
47
|
-
[@edtf.begin.year.to_s, @edtf.end.year.to_s].should ==
|
46
|
+
Then /^the duration should range from "([^"]*)" to "([^"]*)"$/ do |from,to|
|
47
|
+
[@edtf.begin.year.to_s, @edtf.end.year.to_s].should == [from,to]
|
48
48
|
end
|
49
49
|
|
50
50
|
Then /^the interval should start at "([^"]*)"$/ do |date|
|
data/lib/edtf.rb
CHANGED
@@ -1,6 +1,31 @@
|
|
1
1
|
#--
|
2
2
|
# EDTF-Ruby
|
3
3
|
# Copyright 2011 Sylvester Keil. All rights reserved.
|
4
|
+
#
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
6
|
+
# modification, are permitted provided that the following conditions are met:
|
7
|
+
#
|
8
|
+
# 1. Redistributions of source code must retain the above copyright notice,
|
9
|
+
# this list of conditions and the following disclaimer.
|
10
|
+
#
|
11
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer in the
|
13
|
+
# documentation and/or other materials provided with the distribution.
|
14
|
+
#
|
15
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS
|
16
|
+
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
17
|
+
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
18
|
+
# NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
19
|
+
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
20
|
+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
21
|
+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
22
|
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
23
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
24
|
+
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
25
|
+
#
|
26
|
+
# The views and conclusions contained in the software and documentation are
|
27
|
+
# those of the authors and should not be interpreted as representing official
|
28
|
+
# policies, either expressed or implied, of the copyright holder.
|
4
29
|
#++
|
5
30
|
|
6
31
|
require 'date'
|
@@ -8,6 +33,8 @@ autoload :Rational, 'rational'
|
|
8
33
|
|
9
34
|
require 'forwardable'
|
10
35
|
|
36
|
+
require 'edtf/compatibility'
|
37
|
+
|
11
38
|
require 'edtf/version'
|
12
39
|
require 'edtf/uncertainty'
|
13
40
|
require 'edtf/seasons'
|
data/lib/edtf/seasons.rb
CHANGED
@@ -17,7 +17,7 @@ module EDTF
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
[:first, :second, :third, :fourth].zip(21..24).each do |quarter, code|
|
20
|
+
[:first, :second, :third, :fourth].zip((21..24).to_a).each do |quarter, code|
|
21
21
|
define_method("#{quarter}?") { @season == code }
|
22
22
|
define_method("#{quarter}!") { @season = code }
|
23
23
|
end
|
data/lib/edtf/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edtf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-15 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &2157415200 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.9'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2157415200
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: racc
|
27
|
-
requirement: &
|
27
|
+
requirement: &2157414020 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.4'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2157414020
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: cucumber
|
38
|
-
requirement: &
|
38
|
+
requirement: &2157413420 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '1.0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2157413420
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &2157412820 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '2.6'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2157412820
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: ZenTest
|
60
|
-
requirement: &
|
60
|
+
requirement: &2157412220 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '4.6'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2157412220
|
69
69
|
description: An Extended Date/Time Format (EDTF) Parser for Ruby.
|
70
70
|
email:
|
71
71
|
- http://sylvester.keil.or.at
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- features/step_definitions/edtf_steps.rb
|
91
91
|
- features/support/env.rb
|
92
92
|
- lib/edtf.rb
|
93
|
+
- lib/edtf/compatibility.rb
|
93
94
|
- lib/edtf/date.rb
|
94
95
|
- lib/edtf/extensions.rb
|
95
96
|
- lib/edtf/interval.rb
|