Module: BeerList
- Defined in:
- lib/beer_list.rb,
lib/beer_list/cli.rb,
lib/beer_list/list.rb,
lib/beer_list/scraper.rb,
lib/beer_list/listable.rb,
lib/beer_list/settings.rb,
lib/beer_list/exceptions.rb,
lib/beer_list/establishments.rb,
lib/beer_list/leads/beer_advocate.rb,
lib/beer_list/establishments/blue_nile.rb,
lib/beer_list/establishments/muddy_pig.rb,
lib/generators/establishment_generator.rb,
lib/beer_list/establishments/ginger_hop.rb,
lib/beer_list/establishments/mc_coys_mn.rb,
lib/beer_list/establishments/acadia_cafe.rb,
lib/beer_list/establishments/edina_grill.rb,
lib/beer_list/establishments/happy_gnome.rb,
lib/beer_list/establishments/new_bohemia.rb,
lib/beer_list/establishments/lowry_uptown.rb,
lib/beer_list/establishments/muddy_waters.rb,
lib/beer_list/establishments/blue_door_pub.rb,
lib/beer_list/establishments/establishment.rb,
lib/beer_list/establishments/groveland_tap.rb,
lib/beer_list/establishments/mackenzie_pub.rb,
lib/beer_list/establishments/three_squares.rb,
lib/beer_list/establishments/bulldog_uptown.rb,
lib/beer_list/establishments/busters_on28th.rb,
lib/beer_list/establishments/macs_industrial.rb,
lib/beer_list/establishments/longfellow_grill.rb,
lib/beer_list/establishments/bulldog_lowertown.rb,
lib/beer_list/establishments/bulldog_northeast.rb,
lib/beer_list/establishments/stanleys_bar_room.rb,
lib/beer_list/establishments/washington_square.rb
Defined Under Namespace
Modules: Establishments, Leads, Listable
Classes: CLI, EstablishmentGenerator, List, NoEstablishmentsError, NoUrlError, NotAListError, Scraper, Settings
Class Method Summary
collapse
Class Method Details
.add_establishment(*args) ⇒ Object
Also known as:
add_establishments
53
54
55
56
57
|
# File 'lib/beer_list.rb', line 53
def add_establishment(*args)
args.each do |e|
_establishments << e if e.respond_to?(:get_list)
end
end
|
.clear_establishments! ⇒ Object
49
50
51
|
# File 'lib/beer_list.rb', line 49
def clear_establishments!
@establishments.clear if @establishments
end
|
18
19
20
21
|
# File 'lib/beer_list.rb', line 18
def configure
yield settings
true
end
|
.default_url ⇒ Object
27
28
29
|
# File 'lib/beer_list.rb', line 27
def default_url
settings.default_url
end
|
.establishments ⇒ Object
44
45
46
47
|
# File 'lib/beer_list.rb', line 44
def establishments
return [] if @establishments.nil?
@establishments.dup
end
|
.establishments_dir ⇒ Object
31
32
33
|
# File 'lib/beer_list.rb', line 31
def establishments_dir
settings.establishments_dir
end
|
.establishments_dir=(directory) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/beer_list.rb', line 36
def establishments_dir=(directory)
puts <<-dep
BeerList.establishments_dir= is deprecated and will be removed.
Please use BeerList.configure instead
dep
settings.establishments_dir = directory
end
|
.lists ⇒ Object
60
61
62
63
64
65
66
67
|
# File 'lib/beer_list.rb', line 60
def lists
raise NoEstablishmentsError if establishments.empty?
return @lists unless update_necessary?
@lists = establishments.map do |e|
scraper.beer_list e
end
end
|
.lists_as_hash ⇒ Object
69
70
71
72
73
|
# File 'lib/beer_list.rb', line 69
def lists_as_hash
lists.inject({}) do |hsh, list|
hsh.merge! list.to_hash
end
end
|
.lists_as_json ⇒ Object
75
76
77
|
# File 'lib/beer_list.rb', line 75
def lists_as_json
lists_as_hash.to_json
end
|
.scraper ⇒ Object
92
93
94
|
# File 'lib/beer_list.rb', line 92
def scraper
@scraper ||= Scraper.instance
end
|
.send_list(list, url = nil) ⇒ Object
79
80
81
82
83
84
|
# File 'lib/beer_list.rb', line 79
def send_list(list, url=nil)
url ||= default_url
raise NoUrlError unless url
raise NotAListError unless list.is_a? BeerList::List
scraper.send_json url, list.to_json
end
|
.send_lists(url = nil) ⇒ Object
86
87
88
89
90
|
# File 'lib/beer_list.rb', line 86
def send_lists(url=nil)
url ||= default_url
raise NoUrlError unless url
scraper.send_json url, lists_as_json
end
|
.settings ⇒ Object
23
24
25
|
# File 'lib/beer_list.rb', line 23
def settings
@settings ||= Settings.new
end
|