beer_in_the_evening 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +24 -0
- data/Rakefile +71 -0
- data/beer_in_the_evening.gemspec +22 -0
- data/lib/beer_in_the_evening.rb +13 -0
- data/lib/beer_in_the_evening/location/dlr.rb +40 -0
- data/lib/beer_in_the_evening/location/tube.rb +297 -0
- data/lib/beer_in_the_evening/pub.rb +33 -0
- data/lib/beer_in_the_evening/search.rb +65 -0
- data/lib/beer_in_the_evening/version.rb +3 -0
- metadata +67 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# BeerInTheEvening
|
2
|
+
|
3
|
+
It can be hard to decide which pub to go to, right?
|
4
|
+
|
5
|
+
Wrong.
|
6
|
+
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
require 'beer_in_the_evening'
|
11
|
+
search = BeerInTheEvening::Search.new
|
12
|
+
search.tube_station = BeerInTheEvening::Location::Tube::HOLBORN
|
13
|
+
search.minimum_rating = 6
|
14
|
+
search.real_ale = true
|
15
|
+
search.wifi = true
|
16
|
+
search.food = true
|
17
|
+
random_pub = search.sort_by{rand}.first
|
18
|
+
random_pub.to_s
|
19
|
+
# => "Lord Clyde, 2.2 miles, 6.7 / 10, http://beerintheevening.com/pubs/s/65/6501/Lord_Clyde/Canonbury"
|
20
|
+
|
21
|
+
|
22
|
+
## Authors
|
23
|
+
|
24
|
+
Craig R Webster <http://barkingiguana.com/>
|
data/Rakefile
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
task :generate_tube_locations do
|
4
|
+
require 'open-uri'
|
5
|
+
require 'nokogiri'
|
6
|
+
options = open("http://www.beerintheevening.com/pubs/search.shtml").read
|
7
|
+
doc = Nokogiri::HTML options
|
8
|
+
nodes = doc.css "select[@name='tu'] option"
|
9
|
+
station_options = nodes.to_a.select { |s| s.parent.parent.previous.xpath("./form")[0]['name'] == 'tube_select' }
|
10
|
+
stations = station_options.to_a.map do |station|
|
11
|
+
id = station['value'].to_i
|
12
|
+
name = station.inner_text.to_s.strip
|
13
|
+
next if id == 0 || name == "" # Skip blank options
|
14
|
+
[ id, name ]
|
15
|
+
end.compact
|
16
|
+
tube_stations = File.dirname(__FILE__) + '/lib/beer_in_the_evening/location/tube.rb'
|
17
|
+
File.open tube_stations, 'w+' do |f|
|
18
|
+
f.puts "module BeerInTheEvening"
|
19
|
+
f.puts " module Location"
|
20
|
+
f.puts " module Tube"
|
21
|
+
stations.each do |id, name|
|
22
|
+
constant_name = name.dup
|
23
|
+
constant_name.upcase!
|
24
|
+
constant_name.gsub! /s+/, '_'
|
25
|
+
constant_name.gsub! /\'/, ''
|
26
|
+
constant_name.gsub! /[^A-Z0-9]/, '_'
|
27
|
+
constant_name.gsub! /_+/, '_'
|
28
|
+
constant_name.gsub! /^_+|_+$/, ''
|
29
|
+
f.puts " #{constant_name} = #{id}"
|
30
|
+
end
|
31
|
+
f.puts " end"
|
32
|
+
f.puts " end"
|
33
|
+
f.puts "end"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
task :generate_dlr_locations do
|
38
|
+
require 'open-uri'
|
39
|
+
require 'nokogiri'
|
40
|
+
options = open("http://www.beerintheevening.com/pubs/search.shtml").read
|
41
|
+
doc = Nokogiri::HTML options
|
42
|
+
nodes = doc.css "select[@name='tu'] option"
|
43
|
+
station_options = nodes.to_a.select { |s| s.parent.parent.previous.xpath("./form")[0]['name'] == 'dlr_select' }
|
44
|
+
stations = station_options.to_a.map do |station|
|
45
|
+
id = station['value'].to_i
|
46
|
+
name = station.inner_text.to_s.strip
|
47
|
+
next if id == 0 || name == "" # Skip blank options
|
48
|
+
[ id, name ]
|
49
|
+
end.compact
|
50
|
+
tube_stations = File.dirname(__FILE__) + '/lib/beer_in_the_evening/location/dlr.rb'
|
51
|
+
File.open tube_stations, 'w+' do |f|
|
52
|
+
f.puts "module BeerInTheEvening"
|
53
|
+
f.puts " module Location"
|
54
|
+
f.puts " module Dlr"
|
55
|
+
stations.each do |id, name|
|
56
|
+
constant_name = name.dup
|
57
|
+
constant_name.upcase!
|
58
|
+
constant_name.gsub! /s+/, '_'
|
59
|
+
constant_name.gsub! /\'/, ''
|
60
|
+
constant_name.gsub! /[^A-Z0-9]/, '_'
|
61
|
+
constant_name.gsub! /_+/, '_'
|
62
|
+
constant_name.gsub! /^_+|_+$/, ''
|
63
|
+
f.puts " #{constant_name} = #{id}"
|
64
|
+
end
|
65
|
+
f.puts " end"
|
66
|
+
f.puts " end"
|
67
|
+
f.puts "end"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
task :generate => [ :generate_dlr_locations, :generate_tube_locations ]
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "beer_in_the_evening/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "beer_in_the_evening"
|
7
|
+
s.version = BeerInTheEvening::VERSION
|
8
|
+
s.authors = ["Craig R Webster"]
|
9
|
+
s.email = ["craig@barkingiguana.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Is it pub time?}
|
12
|
+
s.description = %q{Search over the Beer In The Evening site looking for suitable pubs}
|
13
|
+
|
14
|
+
s.rubyforge_project = "beer_in_the_evening"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_runtime_dependency "nokogiri"
|
22
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
require "open-uri"
|
3
|
+
require "digest/sha1"
|
4
|
+
require "tmpdir"
|
5
|
+
|
6
|
+
require "beer_in_the_evening/version"
|
7
|
+
require "beer_in_the_evening/pub"
|
8
|
+
require "beer_in_the_evening/search"
|
9
|
+
require "beer_in_the_evening/location/tube"
|
10
|
+
require "beer_in_the_evening/location/dlr"
|
11
|
+
|
12
|
+
module BeerInTheEvening
|
13
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module BeerInTheEvening
|
2
|
+
module Location
|
3
|
+
module Dlr
|
4
|
+
ALL_SAINTS = 6
|
5
|
+
BANK = 325
|
6
|
+
BECKTON = 21
|
7
|
+
BECKTON_PARK = 22
|
8
|
+
BLACKWALL = 30
|
9
|
+
BOW_CHURCH = 35
|
10
|
+
CANARY_WHARF = 328
|
11
|
+
CANNING_TOWN = 329
|
12
|
+
CROSSHARBOUR_AND_LONDON_ARENA = 69
|
13
|
+
CUSTOM_HOUSE = 71
|
14
|
+
CUTTY_SARK = 72
|
15
|
+
CYPRUS = 73
|
16
|
+
DEPTFORD_BRIDGE = 78
|
17
|
+
DEVONS_ROAD = 79
|
18
|
+
EAST_INDIA = 87
|
19
|
+
ELVERSON_ROAD = 94
|
20
|
+
GALLIONS_REACH = 107
|
21
|
+
GREENWICH = 118
|
22
|
+
HERON_QUAYS = 134
|
23
|
+
ISLAND_GARDENS = 150
|
24
|
+
LEWISHAM = 169
|
25
|
+
LIMEHOUSE = 172
|
26
|
+
MUDCHUTE = 188
|
27
|
+
POPLAR = 219
|
28
|
+
PRINCE_REGENT = 221
|
29
|
+
PUDDING_MILL_LANE = 222
|
30
|
+
ROYAL_ALBERT = 236
|
31
|
+
ROYAL_VICTORIA = 238
|
32
|
+
SHADWELL = 326
|
33
|
+
SOUTH_QUAY = 256
|
34
|
+
STRATFORD = 327
|
35
|
+
TOWER_GATEWAY = 283
|
36
|
+
WEST_INDIA_QUAY = 310
|
37
|
+
WESTFERRY = 314
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,297 @@
|
|
1
|
+
module BeerInTheEvening
|
2
|
+
module Location
|
3
|
+
module Tube
|
4
|
+
ACTON = 1
|
5
|
+
ACTON_CENTRAL = 2
|
6
|
+
ACTON_TOWN = 3
|
7
|
+
ALDGATE = 4
|
8
|
+
ALDGATE_EAST = 5
|
9
|
+
ALPERTON = 7
|
10
|
+
AMERSHAM = 8
|
11
|
+
ANGEL = 9
|
12
|
+
ARCHWAY = 10
|
13
|
+
ARNOS_GROVE = 11
|
14
|
+
ARSENAL = 12
|
15
|
+
BAKER_STREET = 13
|
16
|
+
BALHAM = 14
|
17
|
+
BANK = 15
|
18
|
+
BARBICAN = 16
|
19
|
+
BARKING = 17
|
20
|
+
BARKINGSIDE = 18
|
21
|
+
BARONS_COURT = 19
|
22
|
+
BAYSWATER = 20
|
23
|
+
BECONTREE = 23
|
24
|
+
BELSIZE_PARK = 24
|
25
|
+
BERMONDSEY = 25
|
26
|
+
BETHNAL_GREEN = 26
|
27
|
+
BLACK_HORSE_ROAD = 27
|
28
|
+
BLACKFRIARS = 28
|
29
|
+
BLACKHORSE_ROAD = 29
|
30
|
+
BOND_STREET = 31
|
31
|
+
BOROUGH = 32
|
32
|
+
BOSTON_MANOR = 33
|
33
|
+
BOUNDS_GREEN = 34
|
34
|
+
BOW_ROAD = 36
|
35
|
+
BRENT_CROSS = 37
|
36
|
+
BRIXTON = 38
|
37
|
+
BROMLEY_BY_BOW = 39
|
38
|
+
BRONDESBURY = 40
|
39
|
+
BRONDESBURY_PARK = 41
|
40
|
+
BUCKHURST_HILL = 42
|
41
|
+
BURNT_OAK = 43
|
42
|
+
CALEDONIAN_ROAD = 44
|
43
|
+
CALEDONIAN_ROAD_AND_BARNSBURY = 45
|
44
|
+
CAMDEN_TOWN = 47
|
45
|
+
CANADA_WATER = 48
|
46
|
+
CANARY_WHARF = 49
|
47
|
+
CANNING_TOWN = 50
|
48
|
+
CANNON_STREET = 51
|
49
|
+
CANONBURY = 52
|
50
|
+
CANONS_PARK = 53
|
51
|
+
CHALFONT_AND_LATIMER = 54
|
52
|
+
CHALK_FARM = 55
|
53
|
+
CHANCERY_LANE = 56
|
54
|
+
CHARING_CROSS = 57
|
55
|
+
CHESHAM = 58
|
56
|
+
CHIGWELL = 59
|
57
|
+
CHISWICK_PARK = 60
|
58
|
+
CHORLEYWOOD = 61
|
59
|
+
CLAPHAM_COMMON = 62
|
60
|
+
CLAPHAM_NORTH = 63
|
61
|
+
CLAPHAM_SOUTH = 64
|
62
|
+
COCKFOSTERS = 65
|
63
|
+
COLINDALE = 66
|
64
|
+
COLLIERS_WOOD = 67
|
65
|
+
COVENT_GARDEN = 68
|
66
|
+
CROXLEY = 70
|
67
|
+
DAGENHAM_EAST = 74
|
68
|
+
DAGENHAM_HEATH = 75
|
69
|
+
DALSTON_KINGSLAND = 76
|
70
|
+
DEBDEN = 77
|
71
|
+
DOLLIS_HILL = 80
|
72
|
+
EALING_BROADWAY = 81
|
73
|
+
EALING_COMMON = 82
|
74
|
+
EARLS_COURT = 83
|
75
|
+
EAST_ACTON = 84
|
76
|
+
EAST_FINCHLEY = 85
|
77
|
+
EAST_HAM = 86
|
78
|
+
EAST_PUTNEY = 88
|
79
|
+
EASTCOTE = 89
|
80
|
+
EDGEWARE = 90
|
81
|
+
EDGEWARE_ROAD = 91
|
82
|
+
ELEPHANT_AND_CASTLE = 92
|
83
|
+
ELM_PARK = 93
|
84
|
+
EMBANKMENT = 96
|
85
|
+
EPPING = 97
|
86
|
+
EUSTON = 98
|
87
|
+
EUSTON_SQUARE = 99
|
88
|
+
FAIRLOP = 100
|
89
|
+
FARRINGDON = 101
|
90
|
+
FINCHLEY_CENTRAL = 102
|
91
|
+
FINCHLEY_ROAD = 103
|
92
|
+
FINCHLEY_ROAD_AND_FROGNAL = 104
|
93
|
+
FINSBURY_PARK = 105
|
94
|
+
FULHAM_BROADWAY = 106
|
95
|
+
GANTS_HILL = 108
|
96
|
+
GLOUCESTER_ROAD = 109
|
97
|
+
GOLDERS_GREEN = 110
|
98
|
+
GOLDHAWK_ROAD = 111
|
99
|
+
GOODGE_STREET = 112
|
100
|
+
GOSPEL_OAK = 113
|
101
|
+
GRANGE_HILL = 114
|
102
|
+
GREAT_PORTLAND_STREET = 115
|
103
|
+
GREEN_PARK = 116
|
104
|
+
GREENFORD = 117
|
105
|
+
GUNNERSBURY = 119
|
106
|
+
HACKNEY_CENTRAL = 120
|
107
|
+
HACKNEY_WICK = 121
|
108
|
+
HAINAULT = 122
|
109
|
+
HAMMERSMITH = 123
|
110
|
+
HAMPSTEAD_HEATH = 124
|
111
|
+
HAMSPTEAD = 125
|
112
|
+
HANGER_LANE = 126
|
113
|
+
HARLESDEN = 127
|
114
|
+
HARROW_AND_WEALDSTONE = 128
|
115
|
+
HARROW_ON_THE_HILL = 129
|
116
|
+
HATTON_CROSS = 130
|
117
|
+
HEATHROW_TERMINAL_4 = 131
|
118
|
+
HEATHROW_TERMINALS_1_2_3 = 132
|
119
|
+
HENDON_CENTRAL = 133
|
120
|
+
HIGH_BARNET = 135
|
121
|
+
HIGH_STREET_KENSINGTON = 136
|
122
|
+
HIGHBURY_AND_ISLINGTON = 137
|
123
|
+
HIGHGATE = 138
|
124
|
+
HILLINGDON = 139
|
125
|
+
HOLBORN = 140
|
126
|
+
HOLLAND_PARK = 141
|
127
|
+
HOLLOWAY_ROAD = 142
|
128
|
+
HOMERTON = 143
|
129
|
+
HORNCHURCH = 144
|
130
|
+
HOUNSLOW_CENTRAL = 145
|
131
|
+
HOUNSLOW_EAST = 146
|
132
|
+
HOUNSLOW_WEST = 147
|
133
|
+
HYDE_PARK_CORNER = 148
|
134
|
+
ICKENHAM = 149
|
135
|
+
KENNINGTON = 151
|
136
|
+
KENSAL_GREEN = 152
|
137
|
+
KENSAL_RISE = 153
|
138
|
+
KENSINGTON_OLYMPIA = 154
|
139
|
+
KENTISH_TOWN = 155
|
140
|
+
KENTISH_TOWN_WEST = 156
|
141
|
+
KENTON = 157
|
142
|
+
KEW_GARDENS = 158
|
143
|
+
KILBURN = 159
|
144
|
+
KILBURN_PARK = 160
|
145
|
+
KINGS_CROSS_ST_PANCRAS = 161
|
146
|
+
KINGSBURY = 162
|
147
|
+
KNIGHTSBRIDGE = 163
|
148
|
+
LADBROKE_GROVE = 164
|
149
|
+
LAMBETH_NORTH = 165
|
150
|
+
LANCASTER_GATE = 166
|
151
|
+
LATIMER_ROAD = 167
|
152
|
+
LEICESTER_SQUARE = 168
|
153
|
+
LEYTON = 170
|
154
|
+
LEYTONSTONE = 171
|
155
|
+
LIVERPOOL_STREET = 173
|
156
|
+
LONDON_BRIDGE = 174
|
157
|
+
LOUGHTON = 175
|
158
|
+
MAIDA_VALE = 176
|
159
|
+
MANOR_HOUSE = 177
|
160
|
+
MANSION_HOUSE = 178
|
161
|
+
MARBLE_ARCH = 179
|
162
|
+
MARYLEBONE = 180
|
163
|
+
MILE_END = 181
|
164
|
+
MILL_HILL_EAST = 182
|
165
|
+
MONUMENT = 183
|
166
|
+
MOORGATE = 184
|
167
|
+
MOORPARK = 185
|
168
|
+
MORDEN = 186
|
169
|
+
MORNINGTON_CRESCENT = 187
|
170
|
+
NEASDEN = 189
|
171
|
+
NEW_CROSS = 190
|
172
|
+
NEW_CROSS_GATE = 191
|
173
|
+
NEWBURY_PARK = 192
|
174
|
+
NORTH_ACTON = 193
|
175
|
+
NORTH_EALING = 194
|
176
|
+
NORTH_GREENWICH = 195
|
177
|
+
NORTH_HARROW = 196
|
178
|
+
NORTH_WEMBLEY = 197
|
179
|
+
NORTH_WOOLWICH = 198
|
180
|
+
NORTHFIELDS = 199
|
181
|
+
NORTHOLT = 200
|
182
|
+
NORTHWICK_PARK = 201
|
183
|
+
NORTHWOOD = 202
|
184
|
+
NORTHWOOD_HILLS = 203
|
185
|
+
NOTTING_HILL_GATE = 204
|
186
|
+
OAKWOOD = 206
|
187
|
+
OLD_STREET = 207
|
188
|
+
OSTERLEY = 208
|
189
|
+
OVAL = 209
|
190
|
+
OXFORD_CIRCUS = 210
|
191
|
+
PADDINGTON = 211
|
192
|
+
PARK_ROYAL = 212
|
193
|
+
PARSONS_GREEN = 213
|
194
|
+
PERIVALE = 214
|
195
|
+
PICCADILLY_CIRCUS = 215
|
196
|
+
PIMLICO = 216
|
197
|
+
PINNER = 217
|
198
|
+
PLAISTOW = 218
|
199
|
+
PRESTON_ROAD = 220
|
200
|
+
PUTNEY_BRIDGE = 223
|
201
|
+
QUEENS_PARK = 224
|
202
|
+
QUEENSBURY = 225
|
203
|
+
QUEENSWAY = 226
|
204
|
+
RAVENSCOURT_PARK = 227
|
205
|
+
RAYNERS_LANE = 228
|
206
|
+
REDBRIDGE = 229
|
207
|
+
REGENTS_PARK = 230
|
208
|
+
RICHMOND = 231
|
209
|
+
RICKMANSWORTH = 232
|
210
|
+
RODING_VALLEY = 233
|
211
|
+
ROTHERHITHE = 234
|
212
|
+
ROTHERITHE = 235
|
213
|
+
ROYAL_OAK = 237
|
214
|
+
RUISLIP = 239
|
215
|
+
RUISLIP_GARDENS = 240
|
216
|
+
RUISLIP_MANOR = 241
|
217
|
+
RUSSELL_SQUARE = 243
|
218
|
+
SEVEN_SISTERS = 244
|
219
|
+
SHADWELL = 245
|
220
|
+
SHEPHERDS_BUSH = 246
|
221
|
+
SHOREDITCH = 247
|
222
|
+
SILVERTOWN = 248
|
223
|
+
SLOANE_SQUARE = 249
|
224
|
+
SNARESBROOK = 250
|
225
|
+
SOUTH_ACTON = 251
|
226
|
+
SOUTH_EALING = 252
|
227
|
+
SOUTH_HARROW = 253
|
228
|
+
SOUTH_KENSINGTON = 254
|
229
|
+
SOUTH_KENTON = 255
|
230
|
+
SOUTH_RUISLIP = 257
|
231
|
+
SOUTH_WIMBLEDON = 258
|
232
|
+
SOUTH_WOODFORD = 259
|
233
|
+
SOUTHFIELDS = 260
|
234
|
+
SOUTHGATE = 261
|
235
|
+
SOUTHWARK = 262
|
236
|
+
ST_JAMESS_PARK = 263
|
237
|
+
ST_JOHNS_WOOD = 264
|
238
|
+
ST_PAULS = 265
|
239
|
+
STAMFORD_BROOK = 266
|
240
|
+
STANMORE = 267
|
241
|
+
STEPNEY_GREEN = 268
|
242
|
+
STOCKWELL = 269
|
243
|
+
STONEBRIDGE_PARK = 270
|
244
|
+
STRATFORD = 271
|
245
|
+
SUDBURY_HILL = 272
|
246
|
+
SUDBURY_TOWN = 273
|
247
|
+
SURREY_QUAYS = 274
|
248
|
+
SWISS_COTTAGE = 275
|
249
|
+
TEMPLE = 276
|
250
|
+
THEYDON_BOIS = 277
|
251
|
+
TOOTING_BEC = 278
|
252
|
+
TOOTING_BROADWAY = 279
|
253
|
+
TOTTENHAM_COURT_ROAD = 280
|
254
|
+
TOTTENHAM_HALE = 281
|
255
|
+
TOTTERIDGE_AND_WHETSTONE = 282
|
256
|
+
TOWER_HILL = 284
|
257
|
+
TUFFNELL_PARK = 285
|
258
|
+
TURNHAM_GREEN = 286
|
259
|
+
TURNPIKE_LANE = 287
|
260
|
+
UPMINSTER = 288
|
261
|
+
UPMINSTER_BRIDGE = 289
|
262
|
+
UPNEY = 290
|
263
|
+
UPTON_PARK = 291
|
264
|
+
UXBRIDGE = 292
|
265
|
+
VAUXHALL = 293
|
266
|
+
VICTORIA = 294
|
267
|
+
WALTHAMSTOW_CENTRAL = 295
|
268
|
+
WANSTEAD = 296
|
269
|
+
WAPPING = 297
|
270
|
+
WARREN_STREET = 298
|
271
|
+
WARWICK_AVENUE = 299
|
272
|
+
WATERLOO = 300
|
273
|
+
WATFORD = 301
|
274
|
+
WEMBLEY_CENTRAL = 302
|
275
|
+
WEMBLEY_PARK = 303
|
276
|
+
WEST_ACTON = 304
|
277
|
+
WEST_BROMPTON = 305
|
278
|
+
WEST_FINCHLEY = 306
|
279
|
+
WEST_HAM = 307
|
280
|
+
WEST_HAMPSTEAD = 308
|
281
|
+
WEST_HARROW = 309
|
282
|
+
WEST_KENSINGTON = 311
|
283
|
+
WEST_RUISLIP = 312
|
284
|
+
WESTBOURNE_PARK = 313
|
285
|
+
WESTMINSTER = 315
|
286
|
+
WHITE_CITY = 316
|
287
|
+
WHITECHAPEL = 317
|
288
|
+
WILLESDEN_GREEN = 318
|
289
|
+
WILLESDEN_JUNCTION = 319
|
290
|
+
WIMBLEDON = 320
|
291
|
+
WIMBLEDON_PARK = 321
|
292
|
+
WOOD_GREEN = 322
|
293
|
+
WOODFORD = 323
|
294
|
+
WOODSIDE_PARK = 324
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module BeerInTheEvening
|
2
|
+
class Pub
|
3
|
+
def initialize data
|
4
|
+
@data = data
|
5
|
+
end
|
6
|
+
|
7
|
+
def name
|
8
|
+
@data.css("td b a:first-child")[0].inner_text.to_s
|
9
|
+
end
|
10
|
+
|
11
|
+
def url
|
12
|
+
"http://beerintheevening.com" + @data.css("td b a:first-child")[0]['href'].to_s
|
13
|
+
end
|
14
|
+
|
15
|
+
def rating
|
16
|
+
results = @data.css("td:nth-child(3)")[0].inner_text.scan /Rating:(.*)\/10/
|
17
|
+
results[0][0].to_f if results[0]
|
18
|
+
end
|
19
|
+
|
20
|
+
def visited?
|
21
|
+
Meetup.exists? self
|
22
|
+
end
|
23
|
+
|
24
|
+
def distance
|
25
|
+
results = @data.css("td:nth-child(2)")[0].inner_text.scan /Distance:(.*)miles/
|
26
|
+
results[0][0].to_f if results[0]
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_s
|
30
|
+
[ name, "#{distance} miles", "#{rating} / 10", url ].join ', '
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module BeerInTheEvening
|
2
|
+
class Search
|
3
|
+
attr_accessor :tube_station
|
4
|
+
attr_accessor :real_ale
|
5
|
+
attr_accessor :food
|
6
|
+
attr_accessor :wifi
|
7
|
+
attr_accessor :minimum_rating
|
8
|
+
|
9
|
+
def number_of_results
|
10
|
+
matches = page(0).to_s.scan /showing \d+ to \d+ of (\d+)/
|
11
|
+
matches[0][0].to_i
|
12
|
+
end
|
13
|
+
|
14
|
+
def each &block
|
15
|
+
current_page = 0
|
16
|
+
loop do
|
17
|
+
results = results_on_page current_page
|
18
|
+
break if results.empty?
|
19
|
+
results.each &block
|
20
|
+
current_page += 1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
include Enumerable
|
24
|
+
|
25
|
+
def query_string
|
26
|
+
params = []
|
27
|
+
params << "tu=#{tube_station}" if tube_station
|
28
|
+
params << "ra=on" if real_ale
|
29
|
+
params << "f=on" if food
|
30
|
+
params << "wireless=on" if wifi
|
31
|
+
params << "rating=#{minimum_rating}" if minimum_rating
|
32
|
+
params.join '&'
|
33
|
+
end
|
34
|
+
private :query_string
|
35
|
+
|
36
|
+
def page n
|
37
|
+
uri = "http://www.beerintheevening.com/pubs/results.shtml?#{query_string}&page=#{n}"
|
38
|
+
content = read_cache uri do
|
39
|
+
open(uri).read
|
40
|
+
end
|
41
|
+
doc = Nokogiri::HTML content
|
42
|
+
end
|
43
|
+
private :page
|
44
|
+
|
45
|
+
def read_cache uri
|
46
|
+
cache_dir = Dir.tmpdir + "/beer_in_the_evening-#{BeerInTheEvening::VERSION}"
|
47
|
+
Dir.mkdir cache_dir unless File.exists? cache_dir
|
48
|
+
cache_file_name = "#{cache_dir}/#{Digest::SHA1.hexdigest(uri)}.html"
|
49
|
+
return File.read(cache_file_name) if File.exists? cache_file_name
|
50
|
+
data = yield
|
51
|
+
File.open cache_file_name, 'w+' do |f|
|
52
|
+
f.puts data
|
53
|
+
end
|
54
|
+
data
|
55
|
+
end
|
56
|
+
private :read_cache
|
57
|
+
|
58
|
+
def results_on_page n
|
59
|
+
page(n).css('table.pubtable tr.pubtable').to_a.map { |row|
|
60
|
+
Pub.new row
|
61
|
+
}
|
62
|
+
end
|
63
|
+
private :results_on_page
|
64
|
+
end
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: beer_in_the_evening
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Craig R Webster
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-01 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: &70318119693620 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70318119693620
|
25
|
+
description: Search over the Beer In The Evening site looking for suitable pubs
|
26
|
+
email:
|
27
|
+
- craig@barkingiguana.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- README.md
|
35
|
+
- Rakefile
|
36
|
+
- beer_in_the_evening.gemspec
|
37
|
+
- lib/beer_in_the_evening.rb
|
38
|
+
- lib/beer_in_the_evening/location/dlr.rb
|
39
|
+
- lib/beer_in_the_evening/location/tube.rb
|
40
|
+
- lib/beer_in_the_evening/pub.rb
|
41
|
+
- lib/beer_in_the_evening/search.rb
|
42
|
+
- lib/beer_in_the_evening/version.rb
|
43
|
+
homepage: ''
|
44
|
+
licenses: []
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project: beer_in_the_evening
|
63
|
+
rubygems_version: 1.8.10
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: Is it pub time?
|
67
|
+
test_files: []
|