chronic18n 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/chronic18n.gemspec +69 -0
- data/lib/chronic18n/dics/es.yml +127 -0
- data/lib/chronic18n/dics/it.yml +109 -0
- data/lib/chronic18n/dics/pt.yml +133 -0
- data/lib/chronic18n/translator.rb +20 -0
- data/lib/chronic18n.rb +13 -0
- data/spec/chronic18n/en_spec.rb +10 -0
- data/spec/chronic18n/es_spec.rb +30 -0
- data/spec/chronic18n/it_spec.rb +30 -0
- data/spec/chronic18n/pt_spec.rb +38 -0
- data/spec/chronic18n_spec.rb +7 -0
- data/spec/spec_helper.rb +9 -0
- metadata +116 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Marcos Piccinini
|
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.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= chronic18n
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Marcos Piccinini. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "chronic18n"
|
8
|
+
gem.summary = %Q{i18n chronic}
|
9
|
+
gem.description = %Q{One 'way' to i18n chronic}
|
10
|
+
gem.email = "x@nofxx.com"
|
11
|
+
gem.homepage = "http://github.com/nofxx/chronic18n"
|
12
|
+
gem.authors = ["Marcos Piccinini"]
|
13
|
+
gem.add_dependency "chronic", ">= 0.2.3"
|
14
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
# require 'rspec/rake/spectask'
|
23
|
+
# Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
# spec.libs << 'lib' << 'spec'
|
25
|
+
# spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
# end
|
27
|
+
|
28
|
+
# Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
+
# spec.libs << 'lib' << 'spec'
|
30
|
+
# spec.pattern = 'spec/**/*_spec.rb'
|
31
|
+
# spec.rcov = true
|
32
|
+
# end
|
33
|
+
|
34
|
+
# task :spec => :check_dependencies
|
35
|
+
|
36
|
+
# task :default => :spec
|
37
|
+
|
38
|
+
require 'rake/rdoctask'
|
39
|
+
Rake::RDocTask.new do |rdoc|
|
40
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
+
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = "chronic18n #{version}"
|
44
|
+
rdoc.rdoc_files.include('README*')
|
45
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
data/chronic18n.gemspec
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{chronic18n}
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Marcos Piccinini"]
|
12
|
+
s.date = %q{2010-06-14}
|
13
|
+
s.description = %q{One 'way' to i18n chronic}
|
14
|
+
s.email = %q{x@nofxx.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"chronic18n.gemspec",
|
27
|
+
"lib/chronic18n.rb",
|
28
|
+
"lib/chronic18n/dics/es.yml",
|
29
|
+
"lib/chronic18n/dics/it.yml",
|
30
|
+
"lib/chronic18n/dics/pt.yml",
|
31
|
+
"lib/chronic18n/translator.rb",
|
32
|
+
"spec/chronic18n/en_spec.rb",
|
33
|
+
"spec/chronic18n/es_spec.rb",
|
34
|
+
"spec/chronic18n/it_spec.rb",
|
35
|
+
"spec/chronic18n/pt_spec.rb",
|
36
|
+
"spec/chronic18n_spec.rb",
|
37
|
+
"spec/spec_helper.rb"
|
38
|
+
]
|
39
|
+
s.homepage = %q{http://github.com/nofxx/chronic18n}
|
40
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
41
|
+
s.require_paths = ["lib"]
|
42
|
+
s.rubygems_version = %q{1.3.7}
|
43
|
+
s.summary = %q{i18n chronic}
|
44
|
+
s.test_files = [
|
45
|
+
"spec/spec_helper.rb",
|
46
|
+
"spec/chronic18n/es_spec.rb",
|
47
|
+
"spec/chronic18n/en_spec.rb",
|
48
|
+
"spec/chronic18n/pt_spec.rb",
|
49
|
+
"spec/chronic18n/it_spec.rb",
|
50
|
+
"spec/chronic18n_spec.rb"
|
51
|
+
]
|
52
|
+
|
53
|
+
if s.respond_to? :specification_version then
|
54
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
55
|
+
s.specification_version = 3
|
56
|
+
|
57
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
58
|
+
s.add_runtime_dependency(%q<chronic>, [">= 0.2.3"])
|
59
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<chronic>, [">= 0.2.3"])
|
62
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
63
|
+
end
|
64
|
+
else
|
65
|
+
s.add_dependency(%q<chronic>, [">= 0.2.3"])
|
66
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
@@ -0,0 +1,127 @@
|
|
1
|
+
:es:
|
2
|
+
# Misc
|
3
|
+
manana: morning
|
4
|
+
mañana: morning
|
5
|
+
tarde: afternoon
|
6
|
+
noche: night
|
7
|
+
alba: night
|
8
|
+
el: this
|
9
|
+
primero: first
|
10
|
+
primera: first
|
11
|
+
tercero: third
|
12
|
+
tercera: third
|
13
|
+
cuarto: fourth
|
14
|
+
quinto: fifth
|
15
|
+
sexto: sixth
|
16
|
+
septimo: seventh
|
17
|
+
octavo: eighth
|
18
|
+
noveno: nineth
|
19
|
+
|
20
|
+
# Common
|
21
|
+
manana: tomorrow
|
22
|
+
mañana: tomorrow
|
23
|
+
ayer: yeasterdayt
|
24
|
+
proximo: next
|
25
|
+
próximo: next
|
26
|
+
próxima: next
|
27
|
+
proxima: next
|
28
|
+
pasado: last
|
29
|
+
ultimo: last
|
30
|
+
último: last
|
31
|
+
ultima: last
|
32
|
+
última: last
|
33
|
+
hoy: today
|
34
|
+
segundo: second
|
35
|
+
segundos: seconds
|
36
|
+
minuto: minute
|
37
|
+
minutos: minutes
|
38
|
+
hora: hour
|
39
|
+
horas: hours
|
40
|
+
dia: day
|
41
|
+
día: day
|
42
|
+
dias: days
|
43
|
+
semana: week
|
44
|
+
semanas: weeks
|
45
|
+
mes: month
|
46
|
+
meses: months
|
47
|
+
ano: year
|
48
|
+
anos: years
|
49
|
+
año: year
|
50
|
+
años: years
|
51
|
+
una: one
|
52
|
+
dos: two
|
53
|
+
en: in
|
54
|
+
|
55
|
+
# Numbers
|
56
|
+
uno: one
|
57
|
+
dos: two
|
58
|
+
tres: three
|
59
|
+
cuatro: four
|
60
|
+
cinco: five
|
61
|
+
seis: six
|
62
|
+
siete: seven
|
63
|
+
ocho: eight
|
64
|
+
nueve: nine
|
65
|
+
diez: ten
|
66
|
+
once: eleven
|
67
|
+
doce: twelve
|
68
|
+
trece: thirteen
|
69
|
+
catorce: fourteen
|
70
|
+
quice: fifteen
|
71
|
+
dieciseis: sixteen
|
72
|
+
dieciséis: sixteen
|
73
|
+
diecisiete: seventeen
|
74
|
+
dieciocho: eighteen
|
75
|
+
diecinueve: nineteen
|
76
|
+
veinte: twenty
|
77
|
+
treinta: thirty
|
78
|
+
cuarenta: fourty
|
79
|
+
cincuenta: fifty
|
80
|
+
sesenta: sixty
|
81
|
+
setenta: seventy
|
82
|
+
ochenta: eighty
|
83
|
+
noventa: ninety
|
84
|
+
cien: one hundred
|
85
|
+
doscientos: two hundred
|
86
|
+
trecientos: three hundred
|
87
|
+
cuatrocientos: four hundred
|
88
|
+
quinientos: five hundred
|
89
|
+
seicientos: six hundred
|
90
|
+
setecientos: seven hundred
|
91
|
+
ochocientos: eight hundred
|
92
|
+
nuevecientos: nine hundred
|
93
|
+
mil: thousand
|
94
|
+
|
95
|
+
# Wdays
|
96
|
+
domingo: sunday
|
97
|
+
lunes: monday
|
98
|
+
martes: tuesday
|
99
|
+
miercules: wednesday
|
100
|
+
miércules: wednesday
|
101
|
+
jueves: thursday
|
102
|
+
viernes: friday
|
103
|
+
sabado: saturday
|
104
|
+
sábado: saturday
|
105
|
+
|
106
|
+
# Months
|
107
|
+
enero: january
|
108
|
+
febrero: february
|
109
|
+
marcha: march
|
110
|
+
abril: april
|
111
|
+
mayo: may
|
112
|
+
junio: june
|
113
|
+
julio: july
|
114
|
+
agosto: august
|
115
|
+
septiebre: september
|
116
|
+
octubre: october
|
117
|
+
noviebre: november
|
118
|
+
diciembre: december
|
119
|
+
|
120
|
+
# Season
|
121
|
+
verano: summer
|
122
|
+
otono: autumn
|
123
|
+
otoño: autumn
|
124
|
+
invierno: winter
|
125
|
+
primavera: spring
|
126
|
+
|
127
|
+
|
@@ -0,0 +1,109 @@
|
|
1
|
+
:it:
|
2
|
+
# Misc
|
3
|
+
mattina: morning
|
4
|
+
pomeriggio: afternoon
|
5
|
+
note: night
|
6
|
+
questo: this
|
7
|
+
primo: first
|
8
|
+
prima: first
|
9
|
+
terzo: third
|
10
|
+
terza: third
|
11
|
+
quarto: fourth
|
12
|
+
quinto: fifth
|
13
|
+
sesto: sixth
|
14
|
+
settimo: seventh
|
15
|
+
ottavo: eighth
|
16
|
+
nono: nineth
|
17
|
+
|
18
|
+
# Common
|
19
|
+
domani: tomorrow
|
20
|
+
ieri: yesterday
|
21
|
+
prossimo: next
|
22
|
+
prossima: next
|
23
|
+
ultimo: last
|
24
|
+
ultima: last
|
25
|
+
oggi: today
|
26
|
+
secondo: second
|
27
|
+
secondos: seconds
|
28
|
+
minuto: minute
|
29
|
+
minutos: minutes
|
30
|
+
ora: hour
|
31
|
+
oras: hours
|
32
|
+
diorno: day
|
33
|
+
settimana: week
|
34
|
+
settimanas: weeks
|
35
|
+
mese: month
|
36
|
+
meses: months
|
37
|
+
anno: year
|
38
|
+
annos: years
|
39
|
+
una: one
|
40
|
+
|
41
|
+
# Numbers
|
42
|
+
uno: one
|
43
|
+
due: two
|
44
|
+
tre: three
|
45
|
+
quattro: four
|
46
|
+
cinque: five
|
47
|
+
sei: six
|
48
|
+
sette: seven
|
49
|
+
otto: eight
|
50
|
+
nove: nine
|
51
|
+
dieci: ten
|
52
|
+
undici: eleven
|
53
|
+
dodici: twelve
|
54
|
+
tredici: thirteen
|
55
|
+
quattordici: fourteen
|
56
|
+
quindici: fifteen
|
57
|
+
sedici: sixteen
|
58
|
+
diciasette: seventeen
|
59
|
+
diciotto: eighteen
|
60
|
+
dicinnove: nineteen
|
61
|
+
venti: twenty
|
62
|
+
trenta: thirty
|
63
|
+
quaranta: fourty
|
64
|
+
cinquanta: fifty
|
65
|
+
sessanta: sixty
|
66
|
+
settanta: seventy
|
67
|
+
ottanta: eighty
|
68
|
+
novanta: ninety
|
69
|
+
centinaio: one hundred
|
70
|
+
duecento: two hundred
|
71
|
+
trecento: three hundred
|
72
|
+
quattrocento: four hundred
|
73
|
+
cinquecento: five hundred
|
74
|
+
seicento: six hundred
|
75
|
+
settecento: seven hundred
|
76
|
+
ottocento: eight hundred
|
77
|
+
novecento: nine hundred
|
78
|
+
mille: thousand
|
79
|
+
|
80
|
+
# Wdays
|
81
|
+
domenica: sunday
|
82
|
+
lunedi: monday
|
83
|
+
martedi: tuesday
|
84
|
+
mercoledi: wednesday
|
85
|
+
giovedi: thursday
|
86
|
+
venerdi: friday
|
87
|
+
sabato: saturday
|
88
|
+
|
89
|
+
# Months
|
90
|
+
gennaio: january
|
91
|
+
febbraio: february
|
92
|
+
marcia: march
|
93
|
+
aprile: april
|
94
|
+
maggio: may
|
95
|
+
giugno: june
|
96
|
+
luglio: july
|
97
|
+
agosto: august
|
98
|
+
settembre: september
|
99
|
+
ottobre: october
|
100
|
+
novembre: november
|
101
|
+
dicembre: december
|
102
|
+
|
103
|
+
# Season
|
104
|
+
estate: summer
|
105
|
+
autunno: autumn
|
106
|
+
inverno: winter
|
107
|
+
primavera: spring
|
108
|
+
|
109
|
+
|
@@ -0,0 +1,133 @@
|
|
1
|
+
:pt:
|
2
|
+
# Misc
|
3
|
+
manhã: morning
|
4
|
+
manha: morning
|
5
|
+
tarde: afternoon
|
6
|
+
noite: night
|
7
|
+
madrugada: night
|
8
|
+
este: this
|
9
|
+
esta: this
|
10
|
+
primeiro: first
|
11
|
+
primeira: first
|
12
|
+
terceiro: third
|
13
|
+
terceira: third
|
14
|
+
quarto: fourth
|
15
|
+
quinto: fifth
|
16
|
+
sexto: sixth
|
17
|
+
setimo: seventh
|
18
|
+
sétimo: seventh
|
19
|
+
oitavo: eighth
|
20
|
+
nono: nineth
|
21
|
+
|
22
|
+
# Common
|
23
|
+
amanha: tomorrow
|
24
|
+
amanhã: tomorrow
|
25
|
+
ontem: yesterday
|
26
|
+
próximo: next
|
27
|
+
proximo: next
|
28
|
+
próxima: next
|
29
|
+
proxima: next
|
30
|
+
passado: last
|
31
|
+
ultimo: last
|
32
|
+
último: last
|
33
|
+
ultima: last
|
34
|
+
última: last
|
35
|
+
segundo: second
|
36
|
+
segundos: seconds
|
37
|
+
minuto: minute
|
38
|
+
minutos: minutes
|
39
|
+
hora: hour
|
40
|
+
horas: hours
|
41
|
+
dia: day
|
42
|
+
dias: days
|
43
|
+
semana: week
|
44
|
+
semanas: weeks
|
45
|
+
mês: month
|
46
|
+
mes: month
|
47
|
+
meses: months
|
48
|
+
ano: year
|
49
|
+
anos: years
|
50
|
+
uma: one
|
51
|
+
duas: two
|
52
|
+
daqui: in
|
53
|
+
em: in
|
54
|
+
após: in
|
55
|
+
|
56
|
+
# Numbers
|
57
|
+
um: one
|
58
|
+
dois: two
|
59
|
+
tres: three
|
60
|
+
três: three
|
61
|
+
quatro: four
|
62
|
+
cinco: five
|
63
|
+
seis: six
|
64
|
+
sete: seven
|
65
|
+
oito: eight
|
66
|
+
nove: nine
|
67
|
+
dez: ten
|
68
|
+
onze: eleven
|
69
|
+
doze: twelve
|
70
|
+
treze: thirteen
|
71
|
+
quatorze: fourteen
|
72
|
+
quinze: fifteen
|
73
|
+
dezesseis: sixteen
|
74
|
+
dezesete: seventeen
|
75
|
+
dezoito: eighteen
|
76
|
+
dezenove: nineteen
|
77
|
+
vinte: twenty
|
78
|
+
trinta: thirty
|
79
|
+
quarenta: fourty
|
80
|
+
cinquenta: fifty
|
81
|
+
sessenta: sixty
|
82
|
+
setenta: seventy
|
83
|
+
oitenta: eighty
|
84
|
+
noventa: ninety
|
85
|
+
cem: one hundred
|
86
|
+
duzentos: two hundred
|
87
|
+
trezentos: three hundred
|
88
|
+
quatrocentos: four hundred
|
89
|
+
quinhentos: five hundred
|
90
|
+
seicentos: six hundred
|
91
|
+
setecentos: seven hundred
|
92
|
+
oitocentos: eight hundred
|
93
|
+
novecentos: nine hundred
|
94
|
+
mil: thousand
|
95
|
+
|
96
|
+
# Wdays
|
97
|
+
domingo: sunday
|
98
|
+
segunda: monday
|
99
|
+
segunda-feira: monday
|
100
|
+
terça: tuesday
|
101
|
+
terca: tuesday
|
102
|
+
terça-feira: tuesday
|
103
|
+
terca-feira: tuesday
|
104
|
+
quarta: wednesday
|
105
|
+
quarta-feira: wednesday
|
106
|
+
quinta: thursday
|
107
|
+
quinta-feira: thursday
|
108
|
+
sexta: friday
|
109
|
+
sabado: saturday
|
110
|
+
sábado: saturday
|
111
|
+
|
112
|
+
# Months
|
113
|
+
janeiro: january
|
114
|
+
fevereiro: february
|
115
|
+
março: march
|
116
|
+
abril: april
|
117
|
+
maio: may
|
118
|
+
junho: june
|
119
|
+
julho: july
|
120
|
+
agosto: august
|
121
|
+
setembro: september
|
122
|
+
outubro: october
|
123
|
+
novembro: november
|
124
|
+
dezembro: december
|
125
|
+
|
126
|
+
# Season
|
127
|
+
verão: summer
|
128
|
+
verao: summer
|
129
|
+
outono: autumn
|
130
|
+
inverno: winter
|
131
|
+
primavera: spring
|
132
|
+
|
133
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Chronic18n
|
2
|
+
|
3
|
+
|
4
|
+
class Translator
|
5
|
+
|
6
|
+
def initialize(txt, lang)
|
7
|
+
@txt = txt
|
8
|
+
@dic = load_dic(lang)
|
9
|
+
end
|
10
|
+
|
11
|
+
def load_dic(lang)
|
12
|
+
YAML.load(File.read(File.join(File.dirname(__FILE__), "dics", "#{lang}.yml")))[lang]
|
13
|
+
end
|
14
|
+
|
15
|
+
def work
|
16
|
+
@txt.split(/\s/).map { |w| @dic[w] || w }.join(" ")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/lib/chronic18n.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Spanish" do
|
4
|
+
|
5
|
+
it "should parse something" do
|
6
|
+
Chronic18n.parse("lunes", :es).should be_a Time
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should parse hour" do
|
10
|
+
Chronic18n.parse("en 7 horas", :es).hour.should eql((Time.now.hour + 7) % 24)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should parse hour" do
|
14
|
+
Chronic18n.parse("en 7 minutos", :es).min.should eql((Time.now.min + 7) % 60)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should parse sunday" do
|
18
|
+
Chronic18n.parse("domingo", :es).wday.should eql(0)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should parse monday" do
|
22
|
+
Chronic18n.parse("martes", :es).wday.should eql(2)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should parse month" do
|
26
|
+
Chronic18n.parse("mayo 3", :es).month.should eql(5)
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Spanish" do
|
4
|
+
|
5
|
+
it "should parse something" do
|
6
|
+
Chronic18n.parse("sabato", :it).should be_a Time
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should parse hour" do
|
10
|
+
Chronic18n.parse("in 7 oras", :it).hour.should eql((Time.now.hour + 7) % 24)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should parse hour" do
|
14
|
+
Chronic18n.parse("in 7 minutos", :it).min.should eql((Time.now.min + 7) % 60)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should parse sunday" do
|
18
|
+
Chronic18n.parse("domenica", :it).wday.should eql(0)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should parse monday" do
|
22
|
+
Chronic18n.parse("mercoledi", :it).wday.should eql(3)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should parse month" do
|
26
|
+
Chronic18n.parse("maggio", :it).month.should eql(5)
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Portuguese" do
|
4
|
+
|
5
|
+
it "should parse something" do
|
6
|
+
Chronic18n.parse("domingo", :pt).should be_a Time
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should parse hour" do
|
10
|
+
Chronic18n.parse("daqui 7 horas", :pt).hour.should eql(Time.now.hour + 7)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should parse hour" do
|
14
|
+
Chronic18n.parse("em 7 minutos", :pt).min.should eql(Time.now.min + 7)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should parse sunday" do
|
18
|
+
Chronic18n.parse("domingo", :pt).wday.should eql(0)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should parse monday" do
|
22
|
+
Chronic18n.parse("segunda", :pt).wday.should eql(1)
|
23
|
+
Chronic18n.parse("segunda-feira", :pt).wday.should eql(1)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should parse month" do
|
27
|
+
Chronic18n.parse("maio 3", :pt).month.should eql(5)
|
28
|
+
end
|
29
|
+
|
30
|
+
# it "should parse month" do
|
31
|
+
# Chronic18n.parse("daqui 3 dias", :pt).day.should eql(Time.now.day + 3)
|
32
|
+
# end
|
33
|
+
|
34
|
+
# it "should parse month" do
|
35
|
+
# Chronic18n.parse("daqui 3 semanas", :pt).day.should eql(Time.now.day + 3)
|
36
|
+
# end
|
37
|
+
|
38
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chronic18n
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Marcos Piccinini
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-06-14 00:00:00 -03:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: chronic
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 2
|
31
|
+
- 3
|
32
|
+
version: 0.2.3
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 1
|
45
|
+
- 2
|
46
|
+
- 9
|
47
|
+
version: 1.2.9
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
50
|
+
description: One 'way' to i18n chronic
|
51
|
+
email: x@nofxx.com
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files:
|
57
|
+
- LICENSE
|
58
|
+
- README.rdoc
|
59
|
+
files:
|
60
|
+
- .document
|
61
|
+
- .gitignore
|
62
|
+
- LICENSE
|
63
|
+
- README.rdoc
|
64
|
+
- Rakefile
|
65
|
+
- VERSION
|
66
|
+
- chronic18n.gemspec
|
67
|
+
- lib/chronic18n.rb
|
68
|
+
- lib/chronic18n/dics/es.yml
|
69
|
+
- lib/chronic18n/dics/it.yml
|
70
|
+
- lib/chronic18n/dics/pt.yml
|
71
|
+
- lib/chronic18n/translator.rb
|
72
|
+
- spec/chronic18n/en_spec.rb
|
73
|
+
- spec/chronic18n/es_spec.rb
|
74
|
+
- spec/chronic18n/it_spec.rb
|
75
|
+
- spec/chronic18n/pt_spec.rb
|
76
|
+
- spec/chronic18n_spec.rb
|
77
|
+
- spec/spec_helper.rb
|
78
|
+
has_rdoc: true
|
79
|
+
homepage: http://github.com/nofxx/chronic18n
|
80
|
+
licenses: []
|
81
|
+
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options:
|
84
|
+
- --charset=UTF-8
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
version: "0"
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
requirements: []
|
104
|
+
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.3.7
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: i18n chronic
|
110
|
+
test_files:
|
111
|
+
- spec/spec_helper.rb
|
112
|
+
- spec/chronic18n/es_spec.rb
|
113
|
+
- spec/chronic18n/en_spec.rb
|
114
|
+
- spec/chronic18n/pt_spec.rb
|
115
|
+
- spec/chronic18n/it_spec.rb
|
116
|
+
- spec/chronic18n_spec.rb
|