holiday_tools 0.0.8 → 0.0.9
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.
- data/lib/holiday_tools/locator.rb +125 -124
- data/lib/holiday_tools/version.rb +1 -1
- data/lib/holiday_tools.rb +8 -0
- data/spec/holiday_tools/locator_spec.rb +2 -3
- metadata +2 -2
@@ -1,12 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
# monkey path to see available regions
|
4
|
-
module Holidays
|
5
|
-
def self.regions
|
6
|
-
@@regions
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
3
|
module HolidayTools
|
11
4
|
class Locator
|
12
5
|
|
@@ -45,135 +38,143 @@ module HolidayTools
|
|
45
38
|
# require "holidays/vz"
|
46
39
|
require "holidays/za"
|
47
40
|
|
48
|
-
|
49
|
-
|
41
|
+
# names of the regions/subregions used in the holidays gem
|
42
|
+
@@reg_names = {
|
43
|
+
at: 'Austria',
|
44
|
+
au: 'Australia',
|
45
|
+
au_act: 'Australia/Australian Capital Terretory',
|
46
|
+
au_nsw: 'Australia/New South Wales',
|
47
|
+
au_nt: 'Australia/Nothern Terretory',
|
48
|
+
au_qld: 'Australia/Queensland',
|
49
|
+
au_qld_brisbane: 'Australia/Queensland and Brisbane',
|
50
|
+
au_sa: 'Australia/South Australia',
|
51
|
+
au_tas: 'Australia/Tasmania',
|
52
|
+
au_vic: 'Australia/Victoria',
|
53
|
+
au_wa: 'Australia/Western Australia',
|
54
|
+
br: 'Brasilia',
|
55
|
+
ca: 'Canada',
|
56
|
+
ca_ab: 'Canada/Alberta',
|
57
|
+
ca_bc: 'Canada/British Columbia',
|
58
|
+
ca_mb: 'Canada/Manitoba',
|
59
|
+
# ca_nb: 'Canada/New Brunswick',
|
60
|
+
ca_nf: 'Canada/Newfoundland',
|
61
|
+
ca_ns: 'Canada/Nova Scotia',
|
62
|
+
ca_nt: 'Canada/Northwest Territories',
|
63
|
+
ca_nu: 'Canada/Nunavut',
|
64
|
+
ca_on: 'Canada/Ontario',
|
65
|
+
# ca_pe: 'Canada/Prince Edward Island',
|
66
|
+
ca_qc: 'Canada/Quebeck',
|
67
|
+
ca_sk: 'Canada/Saskatchewan',
|
68
|
+
ca_yk: 'Canada/Yukon',
|
69
|
+
cz: 'Czech Republic',
|
70
|
+
de: 'Germany',
|
71
|
+
de_bb: 'Germany/Brandenburg',
|
72
|
+
# de_be: 'Germany/Berlin',
|
73
|
+
de_bw: 'Germany/Baden-Württemberg',
|
74
|
+
de_by: 'Germany/Bayern',
|
75
|
+
# de_hb: 'Germany/Freie Hansestadt Bremen',
|
76
|
+
de_he: 'Germany/Hessen',
|
77
|
+
# de_hh: 'Germany/Hamburg',
|
78
|
+
de_mv: 'Germany/Mecklenburg-Vorpommern',
|
79
|
+
# de_ni: 'Germany/Niedersachsen',
|
80
|
+
de_nw: 'Germany/Nordrhein-Westfalen',
|
81
|
+
de_rp: 'Germany/Rheinland-Pfalz',
|
82
|
+
# de_sh: 'Germany/Schleswig-Holstein',
|
83
|
+
de_sl: 'Germany/Saarland',
|
84
|
+
de_sn: 'Germany/Sachsen',
|
85
|
+
de_st: 'Germany/Sachsen-Anhalt',
|
86
|
+
de_th: 'Germany/Thüringen',
|
87
|
+
dk: 'Denmark',
|
88
|
+
el: 'Greece',
|
89
|
+
es: 'Spain',
|
90
|
+
es_an: 'Spain/Andalusia',
|
91
|
+
es_ar: 'Spain/Aragon',
|
92
|
+
es_ce: 'Spain/Ceuta',
|
93
|
+
es_cl: 'Spain/Castile and Leon',
|
94
|
+
es_cm: 'Spain/Castile-La Mancha',
|
95
|
+
es_cn: 'Spain/Canary Island',
|
96
|
+
es_ct: 'Spain/Catalonia',
|
97
|
+
es_ex: 'Spain/Extremadura',
|
98
|
+
es_ga: 'Spain/Galicia',
|
99
|
+
es_ib: 'Spain/Islas Baleares',
|
100
|
+
es_lo: 'Spain/La Rioja',
|
101
|
+
es_m: 'Spain/Madrid',
|
102
|
+
es_mu: 'Spain/Murcia',
|
103
|
+
es_na: 'Spain/Navarre',
|
104
|
+
es_o: 'Spain/Asturias',
|
105
|
+
es_pv: 'Spain/Euskadi (Pais Vasco - Basque Country)',
|
106
|
+
es_v: 'Spain/Valencia',
|
107
|
+
es_vc: 'Spain/Valencia',
|
108
|
+
fi: 'Finland',
|
109
|
+
fr: 'France',
|
110
|
+
gb: 'Great Britain',
|
111
|
+
gb_con: 'Great Britain/Cornwall',
|
112
|
+
gb_eaw: 'Great Britain/England and Wales',
|
113
|
+
gb_eng: 'Great Britain/England',
|
114
|
+
gb_gsy: 'Great Britain/Guernsey',
|
115
|
+
gb_iom: 'Great Britain/Isle of Man',
|
116
|
+
gb_jsy: 'Great Britain/Jersey',
|
117
|
+
gb_nir: 'Great Britain/Norther Ireland',
|
118
|
+
gb_sct: 'Great Britain/Scotland',
|
119
|
+
gb_wls: 'Great Britain/Wales',
|
120
|
+
# gg: 'Guernsey',
|
121
|
+
ie: 'ireland',
|
122
|
+
im: 'Isle of Man',
|
123
|
+
it: 'Italy',
|
124
|
+
is: 'Iceland',
|
125
|
+
je: 'Jersey',
|
126
|
+
jp: 'Japan',
|
127
|
+
li: 'Liechtenstein',
|
128
|
+
mx: 'Mexico',
|
129
|
+
mx_pue: 'Mexico/Puebla',
|
130
|
+
nz: 'New Zealand',
|
131
|
+
nz_ak: 'New Zealand/Auckland',
|
132
|
+
nz_ca: 'New Zealand/Canterbury',
|
133
|
+
nz_ch: 'New Zealand/Chatham',
|
134
|
+
nz_hb: "New Zealand/Hawke's Bay",
|
135
|
+
nz_mb: 'New Zealand/Marlboro',
|
136
|
+
nz_nl: 'New Zealand/Northland',
|
137
|
+
nz_ot: 'New Zealand/Otago',
|
138
|
+
nz_sc: 'New Zealand/South Canterbury',
|
139
|
+
nz_sl: 'New Zealand/Southland',
|
140
|
+
nz_we: 'New Zealand/Wellington',
|
141
|
+
nz_wl: 'New Zealand/Westland',
|
142
|
+
nl: 'Netherlands',
|
143
|
+
no: 'Norway',
|
144
|
+
pl: 'Poland',
|
145
|
+
pt: 'Portugal',
|
146
|
+
se: 'Sweden',
|
147
|
+
us: 'United States of America',
|
148
|
+
us_dc: 'United States of America/Washington DC',
|
149
|
+
za: 'South Africa'
|
150
|
+
}
|
151
|
+
|
152
|
+
# class methods
|
153
|
+
###############
|
50
154
|
|
51
|
-
# names of the regions/subregions used in the holidays gem
|
52
|
-
@reg_names = {
|
53
|
-
at: 'Austria',
|
54
|
-
au: 'Australia',
|
55
|
-
au_act: 'Australia/Australian Capital Terretory',
|
56
|
-
au_nsw: 'Australia/New South Wales',
|
57
|
-
au_nt: 'Australia/Nothern Terretory',
|
58
|
-
au_qld: 'Australia/Queensland',
|
59
|
-
au_qld_brisbane: 'Australia/Queensland and Brisbane',
|
60
|
-
au_sa: 'Australia/South Australia',
|
61
|
-
au_tas: 'Australia/Tasmania',
|
62
|
-
au_vic: 'Australia/Victoria',
|
63
|
-
au_wa: 'Australia/Western Australia',
|
64
|
-
br: 'Brasilia',
|
65
|
-
ca: 'Canada',
|
66
|
-
ca_ab: 'Canada/Alberta',
|
67
|
-
ca_bc: 'Canada/British Columbia',
|
68
|
-
ca_mb: 'Canada/Manitoba',
|
69
|
-
# ca_nb: 'Canada/New Brunswick',
|
70
|
-
ca_nf: 'Canada/Newfoundland',
|
71
|
-
ca_ns: 'Canada/Nova Scotia',
|
72
|
-
ca_nt: 'Canada/Northwest Territories',
|
73
|
-
ca_nu: 'Canada/Nunavut',
|
74
|
-
ca_on: 'Canada/Ontario',
|
75
|
-
# ca_pe: 'Canada/Prince Edward Island',
|
76
|
-
ca_qc: 'Canada/Quebeck',
|
77
|
-
ca_sk: 'Canada/Saskatchewan',
|
78
|
-
ca_yk: 'Canada/Yukon',
|
79
|
-
cz: 'Czech Republic',
|
80
|
-
de: 'Germany',
|
81
|
-
de_bb: 'Germany/Brandenburg',
|
82
|
-
# de_be: 'Germany/Berlin',
|
83
|
-
de_bw: 'Germany/Baden-Württemberg',
|
84
|
-
de_by: 'Germany/Bayern',
|
85
|
-
# de_hb: 'Germany/Freie Hansestadt Bremen',
|
86
|
-
de_he: 'Germany/Hessen',
|
87
|
-
# de_hh: 'Germany/Hamburg',
|
88
|
-
de_mv: 'Germany/Mecklenburg-Vorpommern',
|
89
|
-
# de_ni: 'Germany/Niedersachsen',
|
90
|
-
de_nw: 'Germany/Nordrhein-Westfalen',
|
91
|
-
de_rp: 'Germany/Rheinland-Pfalz',
|
92
|
-
# de_sh: 'Germany/Schleswig-Holstein',
|
93
|
-
de_sl: 'Germany/Saarland',
|
94
|
-
de_sn: 'Germany/Sachsen',
|
95
|
-
de_st: 'Germany/Sachsen-Anhalt',
|
96
|
-
de_th: 'Germany/Thüringen',
|
97
|
-
dk: 'Denmark',
|
98
|
-
el: 'Greece',
|
99
|
-
es: 'Spain',
|
100
|
-
es_an: 'Spain/Andalusia',
|
101
|
-
es_ar: 'Spain/Aragon',
|
102
|
-
es_ce: 'Spain/Ceuta',
|
103
|
-
es_cl: 'Spain/Castile and Leon',
|
104
|
-
es_cm: 'Spain/Castile-La Mancha',
|
105
|
-
es_cn: 'Spain/Canary Island',
|
106
|
-
es_ct: 'Spain/Catalonia',
|
107
|
-
es_ex: 'Spain/Extremadura',
|
108
|
-
es_ga: 'Spain/Galicia',
|
109
|
-
es_ib: 'Spain/Islas Baleares',
|
110
|
-
es_lo: 'Spain/La Rioja',
|
111
|
-
es_m: 'Spain/Madrid',
|
112
|
-
es_mu: 'Spain/Murcia',
|
113
|
-
es_na: 'Spain/Navarre',
|
114
|
-
es_o: 'Spain/Asturias',
|
115
|
-
es_pv: 'Spain/Euskadi (Pais Vasco - Basque Country)',
|
116
|
-
es_v: 'Spain/Valencia',
|
117
|
-
es_vc: 'Spain/Valencia',
|
118
|
-
fi: 'Finland',
|
119
|
-
fr: 'France',
|
120
|
-
gb: 'Great Britain',
|
121
|
-
gb_con: 'Great Britain/Cornwall',
|
122
|
-
gb_eaw: 'Great Britain/England and Wales',
|
123
|
-
gb_eng: 'Great Britain/England',
|
124
|
-
gb_gsy: 'Great Britain/Guernsey',
|
125
|
-
gb_iom: 'Great Britain/Isle of Man',
|
126
|
-
gb_jsy: 'Great Britain/Jersey',
|
127
|
-
gb_nir: 'Great Britain/Norther Ireland',
|
128
|
-
gb_sct: 'Great Britain/Scotland',
|
129
|
-
gb_wls: 'Great Britain/Wales',
|
130
|
-
gg: 'Guernsey',
|
131
|
-
ie: 'ireland',
|
132
|
-
im: 'Isle of Man',
|
133
|
-
it: 'Italy',
|
134
|
-
is: 'Iceland',
|
135
|
-
je: 'Jersey',
|
136
|
-
jp: 'Japan',
|
137
|
-
li: 'Liechtenstein',
|
138
|
-
mx: 'Mexico',
|
139
|
-
mx_pue: 'Mexico/Puebla',
|
140
|
-
nz: 'New Zealand',
|
141
|
-
nz_ak: 'New Zealand/Auckland',
|
142
|
-
nz_ca: 'New Zealand/Canterbury',
|
143
|
-
nz_ch: 'New Zealand/Chatham',
|
144
|
-
nz_hb: "New Zealand/Hawke's Bay",
|
145
|
-
nz_mb: 'New Zealand/Marlboro',
|
146
|
-
nz_nl: 'New Zealand/Northland',
|
147
|
-
nz_ot: 'New Zealand/Otago',
|
148
|
-
nz_sc: 'New Zealand/South Canterbury',
|
149
|
-
nz_sl: 'New Zealand/Southland',
|
150
|
-
nz_we: 'New Zealand/Wellington',
|
151
|
-
nz_wl: 'New Zealand/Westland',
|
152
|
-
nl: 'Netherlands',
|
153
|
-
no: 'Norway',
|
154
|
-
pl: 'Poland',
|
155
|
-
pt: 'Portugal',
|
156
|
-
se: 'Sweden',
|
157
|
-
us: 'United States of America',
|
158
|
-
us_dc: 'United States of America/Washington DC',
|
159
|
-
za: 'South Africa'
|
160
|
-
}
|
161
|
-
end
|
162
|
-
|
163
155
|
# loop over region names
|
164
|
-
def show_regions
|
156
|
+
def self.show_regions
|
165
157
|
regs = Holidays.regions.sort
|
166
158
|
txt = []
|
167
159
|
txt << "Region \tName"
|
168
160
|
regs.each do |key|
|
169
|
-
name =
|
161
|
+
name = @@reg_names[key]
|
170
162
|
if name
|
171
163
|
txt << "%s \t%s" % [key, name]
|
164
|
+
else
|
165
|
+
txt << "%s: unexpected region id" % [key]
|
172
166
|
end
|
173
167
|
end
|
174
168
|
txt
|
175
169
|
end
|
176
170
|
|
171
|
+
# instance methods
|
172
|
+
##################
|
173
|
+
|
174
|
+
def initialize( filter=[] )
|
175
|
+
@filter = filter
|
176
|
+
end
|
177
|
+
|
177
178
|
# get the name of a holiday and the regions, where it is observed
|
178
179
|
def show_holiday(date)
|
179
180
|
ans = Holidays.on(date, :any, :observed)
|
@@ -228,7 +229,7 @@ module HolidayTools
|
|
228
229
|
|
229
230
|
# show the expanded name of a region
|
230
231
|
def show_reg(reg)
|
231
|
-
rn =
|
232
|
+
rn = @@reg_names[reg]
|
232
233
|
if rn
|
233
234
|
"\t \t %s" % [ rn ]
|
234
235
|
else
|
data/lib/holiday_tools.rb
CHANGED
@@ -21,9 +21,8 @@ describe HolidayTools do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'should list all available regions' do
|
24
|
-
|
25
|
-
regions
|
26
|
-
# p regions
|
24
|
+
regions = HolidayTools::Locator.show_regions
|
25
|
+
p regions
|
27
26
|
regions.size.should == 101
|
28
27
|
|
29
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: holiday_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: holidays
|