beer_list 0.1.2 → 0.1.3

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/README.md CHANGED
@@ -103,18 +103,17 @@ the following code in an initializer:
103
103
 
104
104
  `BeerList.establishments_dir = File.join(Rails.root, 'path/to/establishments')`
105
105
 
106
- When using Rails, you'll need to register your establishments with BeerList.
107
- Unfortunately, you can't call them directly (I'm working on it):
108
106
 
109
107
  ```
108
+ # Fetch just the list at Applebirds
109
+ BeerList.applebirds
110
+
111
+ # Or, register your establishment
110
112
  BeerList.add_establishment(BeerList::Establishments::Applebirds.new)
111
113
 
112
- # fetch all your lists, including the one at Applebirds
114
+ # fetch all your registered lists, including the one at Applebirds
113
115
  BeerList.lists
114
116
 
115
- # Unsupported in Rails (for now)
116
- BeerList.applebirds
117
-
118
117
  ```
119
118
 
120
119
  See [Getting A List](https://github.com/DanOlson/beer_list#getting-a-list) for more details.
data/beer_list.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'beer_list'
3
- spec.version = '0.1.2'
3
+ spec.version = '0.1.3'
4
4
  spec.authors = ['Dan Olson']
5
5
  spec.email = ['olson_dan@yahoo.com']
6
6
  spec.description = 'A utility for retrieving the beer list from various establishments'
@@ -5,7 +5,7 @@ module BeerList
5
5
 
6
6
  def list
7
7
  raise BeerList::NoScraperError unless @scraper
8
- @list ||= BeerList::List.new get_list, short_class_name
8
+ @list ||= BeerList::List.new establishment: short_class_name, array: get_list
9
9
  end
10
10
 
11
11
  def get_list
@@ -9,7 +9,7 @@ module BeerList
9
9
  end
10
10
 
11
11
  if BeerList.establishments_dir
12
- Dir[File.dirname(BeerList.establishments_dir) + '/*.rb'].each do |f|
12
+ Dir[File.join(BeerList.establishments_dir, '*.rb')].each do |f|
13
13
  require f.split('.rb').first
14
14
  end
15
15
  end
@@ -2,8 +2,9 @@ module BeerList
2
2
  class List < Array
3
3
  attr_reader :establishment
4
4
 
5
- def initialize(ary, establishment)
6
- @establishment = establishment
5
+ def initialize(opts={})
6
+ ary = opts[:array] || []
7
+ @establishment = opts[:establishment]
7
8
  super ary.sort
8
9
  end
9
10
 
data/lib/beer_list.rb CHANGED
@@ -75,14 +75,9 @@ module BeerList
75
75
  end
76
76
 
77
77
  def method_missing(method, *args, &block)
78
- super if defined? Rails
79
78
  class_name = method.to_s.split('_').map(&:capitalize).join
80
- begin
81
- klass = ['BeerList', 'Establishments', class_name].compact.inject(Object){ |o, name| o.const_get(name) }
82
- scraper.beer_list klass.new
83
- rescue NameError
84
- super method, *args, &block
85
- end
79
+ klass = ['BeerList', 'Establishments', class_name].inject(Object){ |o, name| o.const_get(name) }
80
+ scraper.beer_list klass.new
86
81
  end
87
82
  end
88
83
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  module BeerList
4
4
  describe List do
5
5
  let(:est_name){ 'MuddyWaters' }
6
- let(:list){ List.new [], est_name}
6
+ let(:list){ List.new array: [], establishment: est_name }
7
7
 
8
8
  it 'knows its establishent' do
9
9
  list.establishment.should == est_name
@@ -22,5 +22,11 @@ module BeerList
22
22
  list.to_json.should == expected
23
23
  end
24
24
  end
25
+
26
+ context 'when array is nil (the establishment has yet to implement #get_list)' do
27
+ let(:list){ List.new array: nil, establishment: est_name }
28
+
29
+ it { list.should be_empty }
30
+ end
25
31
  end
26
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beer_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
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-04-10 00:00:00.000000000 Z
12
+ date: 2013-04-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mechanize