fuzzy-date 0.1.7 → 0.2.0
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/demo.rb +60 -1
- data/lib/fuzzy-date.rb +2 -3
- data/lib/fuzzy-date/analyze.rb +15 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c76cd668fdf666c2a3c389eb6654ede8a67ce78c
|
4
|
+
data.tar.gz: 384f9a86a76d423497de05af75952acc6226b150
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f177d19cd1e39645ec975a12035db464f886b350c35bcbb89d1c7f2bb47a68cad4894692dd1a4679e469556a216013383c9257e1ea114c1189bf30f8dfd636b2
|
7
|
+
data.tar.gz: 94b41c11f31e266a3123786a0983dcd0c0883e45bde478a612b92207c001a5d499617b199af0b1a7a8d10d96d15005d8c8bdd2a02faf99021915cb62c4ac0977
|
data/demo.rb
CHANGED
@@ -2,4 +2,63 @@ require( 'rubygems' )
|
|
2
2
|
require( 'fuzzy-date' )
|
3
3
|
|
4
4
|
fuzzy_date = FuzzyDate::parse( '15 March 1971' )
|
5
|
-
|
5
|
+
|
6
|
+
puts "PARSING: #{ fuzzy_date.original }"
|
7
|
+
|
8
|
+
puts "Short date: #{ fuzzy_date.short }"
|
9
|
+
puts "Long date: #{ fuzzy_date.long }"
|
10
|
+
puts "Full date: #{ fuzzy_date.full }"
|
11
|
+
puts "Year: #{ fuzzy_date.year }"
|
12
|
+
puts "Month: #{ fuzzy_date.month }"
|
13
|
+
puts "Day: #{ fuzzy_date.day }"
|
14
|
+
puts "Month name: #{ fuzzy_date.month_name }"
|
15
|
+
puts "Circa: #{ fuzzy_date.circa }"
|
16
|
+
puts "Era: #{ fuzzy_date.era }"
|
17
|
+
|
18
|
+
fuzzy_date = FuzzyDate::parse( '15 March' )
|
19
|
+
|
20
|
+
puts "PARSING: #{ fuzzy_date.original }"
|
21
|
+
|
22
|
+
puts "Short date: #{ fuzzy_date.short }"
|
23
|
+
puts "Long date: #{ fuzzy_date.long }"
|
24
|
+
puts "Full date: #{ fuzzy_date.full }"
|
25
|
+
|
26
|
+
puts "Original date: #{ fuzzy_date.original }"
|
27
|
+
puts "Year: #{ fuzzy_date.year }"
|
28
|
+
puts "Month: #{ fuzzy_date.month }"
|
29
|
+
puts "Day: #{ fuzzy_date.day }"
|
30
|
+
puts "Month name: #{ fuzzy_date.month_name }"
|
31
|
+
puts "Circa: #{ fuzzy_date.circa }"
|
32
|
+
puts "Era: #{ fuzzy_date.era }"
|
33
|
+
|
34
|
+
fuzzy_date = FuzzyDate::parse( 'About March 1971' )
|
35
|
+
|
36
|
+
puts "PARSING: #{ fuzzy_date.original }"
|
37
|
+
|
38
|
+
puts "Short date: #{ fuzzy_date.short }"
|
39
|
+
puts "Long date: #{ fuzzy_date.long }"
|
40
|
+
puts "Full date: #{ fuzzy_date.full }"
|
41
|
+
|
42
|
+
puts "Original date: #{ fuzzy_date.original }"
|
43
|
+
puts "Year: #{ fuzzy_date.year }"
|
44
|
+
puts "Month: #{ fuzzy_date.month }"
|
45
|
+
puts "Day: #{ fuzzy_date.day }"
|
46
|
+
puts "Month name: #{ fuzzy_date.month_name }"
|
47
|
+
puts "Circa: #{ fuzzy_date.circa }"
|
48
|
+
puts "Era: #{ fuzzy_date.era }"
|
49
|
+
|
50
|
+
fuzzy_date = FuzzyDate::parse( '1971 BC' )
|
51
|
+
|
52
|
+
puts "PARSING: #{ fuzzy_date.original }"
|
53
|
+
|
54
|
+
puts "Short date: #{ fuzzy_date.short }"
|
55
|
+
puts "Long date: #{ fuzzy_date.long }"
|
56
|
+
puts "Full date: #{ fuzzy_date.full }"
|
57
|
+
|
58
|
+
puts "Original date: #{ fuzzy_date.original }"
|
59
|
+
puts "Year: #{ fuzzy_date.year }"
|
60
|
+
puts "Month: #{ fuzzy_date.month }"
|
61
|
+
puts "Day: #{ fuzzy_date.day }"
|
62
|
+
puts "Month name: #{ fuzzy_date.month_name }"
|
63
|
+
puts "Circa: #{ fuzzy_date.circa }"
|
64
|
+
puts "Era: #{ fuzzy_date.era }"
|
data/lib/fuzzy-date.rb
CHANGED
@@ -3,10 +3,9 @@ require 'fuzzy-date/variables'
|
|
3
3
|
require 'fuzzy-date/fuzzy-date'
|
4
4
|
|
5
5
|
class FuzzyDate
|
6
|
-
VERSION = '0.
|
6
|
+
VERSION = '0.2.0'
|
7
7
|
|
8
8
|
def self.parse( date, euro = false )
|
9
|
-
|
10
|
-
fuzzy_date.to_hash
|
9
|
+
FuzzyDate.new date, euro
|
11
10
|
end
|
12
11
|
end
|
data/lib/fuzzy-date/analyze.rb
CHANGED
@@ -2,6 +2,8 @@ require 'date'
|
|
2
2
|
|
3
3
|
class FuzzyDate
|
4
4
|
|
5
|
+
attr_reader :short, :full, :long, :original, :fixed, :year, :month, :day, :month_name, :circa, :era
|
6
|
+
|
5
7
|
# *Note*: This is only for single dates - not ranges.
|
6
8
|
#
|
7
9
|
# Possible incoming date formats:
|
@@ -100,7 +102,7 @@ class FuzzyDate
|
|
100
102
|
|
101
103
|
# ----------------------------------------------------------------------
|
102
104
|
|
103
|
-
show_era = ' ' + @date_parts[ :era ]
|
105
|
+
show_era = @date_parts[ :era ] == 'BC' ? ' ' + @date_parts[ :era ] : ''
|
104
106
|
show_circa = @date_parts[ :circa ] == true ? 'About ' : ''
|
105
107
|
|
106
108
|
if year and month and day
|
@@ -123,6 +125,18 @@ class FuzzyDate
|
|
123
125
|
@date_parts[ :full ] = @date_parts[ :long ]
|
124
126
|
end
|
125
127
|
|
128
|
+
@short = @date_parts[ :short ]
|
129
|
+
@long = @date_parts[ :long ]
|
130
|
+
@full = @date_parts[ :full ]
|
131
|
+
@original = @date_parts[ :original ]
|
132
|
+
@fixed = @date_parts[ :fixed ]
|
133
|
+
@year = @date_parts[ :year ]
|
134
|
+
@month = @date_parts[ :month ]
|
135
|
+
@day = @date_parts[ :day ]
|
136
|
+
@month_name = @date_parts[ :month_name ]
|
137
|
+
@circa = @date_parts[ :circa ]
|
138
|
+
@era = @date_parts[ :era ]
|
139
|
+
|
126
140
|
@date_parts
|
127
141
|
|
128
142
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fuzzy-date
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cole
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The fuzzy-date gem provides a way to parse and use incomplete dates,
|
14
14
|
like those found in history or genealogy.
|
@@ -18,13 +18,13 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
- LICENSE
|
22
21
|
- README.md
|
22
|
+
- LICENSE
|
23
23
|
- demo.rb
|
24
24
|
- lib/fuzzy-date.rb
|
25
|
-
- lib/fuzzy-date/analyze.rb
|
26
25
|
- lib/fuzzy-date/fuzzy-date.rb
|
27
26
|
- lib/fuzzy-date/variables.rb
|
27
|
+
- lib/fuzzy-date/analyze.rb
|
28
28
|
homepage: https://github.com/davidcole/fuzzy-date
|
29
29
|
licenses:
|
30
30
|
- MIT
|
@@ -35,17 +35,17 @@ require_paths:
|
|
35
35
|
- lib
|
36
36
|
required_ruby_version: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
requirements: []
|
47
47
|
rubyforge_project:
|
48
|
-
rubygems_version: 2.
|
48
|
+
rubygems_version: 2.0.3
|
49
49
|
signing_key:
|
50
50
|
specification_version: 4
|
51
51
|
summary: Provides a way to use partial and incomplete dates.
|