beer_bash 0.0.1 → 0.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c9dc72c8d34c4b58a55e0afecc9018f921ce972
4
- data.tar.gz: 30cd95b8c46c02852548f79eb7a867386731ed63
3
+ metadata.gz: 2f1bd29b0ac97815e15f064587d92d33cc2bfa6a
4
+ data.tar.gz: cdb3f148dfca0310304ff9cb8d0ff7fe88f396ed
5
5
  SHA512:
6
- metadata.gz: da188f55ba7826f4ea78fef716294b17bfe671c4cdf3cd96126acfee56009ef3439b4d1f5a72f1ec35eb58275437353090789df97e5c32535507c0efc1833b97
7
- data.tar.gz: 454d3df368ea3d55472e5b7898167491b9dec60fe382d76c3da5b50e40f7ac604e636ac4f07141e9edcf7f0e69bfc685d2b8fcabcdb084464576dccb823a534f
6
+ metadata.gz: 347c7fd4067ea8689156ee9c74cd83a93eead2b1e3c040593b8e5168be79bfbc33c62dc43a52f74906f3ff2df9b0351ec0202b56e69a4c482256a9f12451c92a
7
+ data.tar.gz: 114696c4f03b3ff4c23448b8f08b5203ee2c1f409433bc596a76262249b38a03da094a11d1a99c1a02e73c4b2d42eb99d651faad0b7d7d7ac11c1e337abeceef
data/README.md CHANGED
@@ -15,7 +15,7 @@ This only pulls from BeerMenus currently, but perhaps that will change.
15
15
  $ ontap at the owl farm
16
16
 
17
17
  +----------------------------------------------------+------+-------------+--------+
18
- | The Owl Farm * Updated on 03/31/2014 |
18
+ | The Owl Farm * Updated Today! |
19
19
  +----------------------------------------------------+------+-------------+--------+
20
20
  | Beer | ABV | Format | Price |
21
21
  +----------------------------------------------------+------+-------------+--------+
data/lib/beer_bash.rb CHANGED
@@ -26,7 +26,7 @@ module BeerBash
26
26
  tap_list = place.on_tap
27
27
 
28
28
  table = Terminal::Table.new do |t|
29
- t.title = "#{place} * Updated on #{tap_list.updated_at}"
29
+ t.title = "#{place} * Updated #{format_date(tap_list.updated_at)}"
30
30
  t.headings = %w(Beer ABV Format Price)
31
31
  t.rows = tap_list.taps.collect {|beer| [beer.name, beer.abv, beer.format, beer.price]}
32
32
  (1..3).each {|idx| t.align_column(idx, :right)}
@@ -34,5 +34,18 @@ module BeerBash
34
34
 
35
35
  puts table
36
36
  end
37
+
38
+ def format_date(date)
39
+ days_ago = (Date.today - date).to_i
40
+ case days_ago
41
+ when 0 then 'Today!'
42
+ when 1 then 'Yesterday'
43
+ when 2 then 'a Couple Days Ago'
44
+ when 3 then 'a Few Days Ago'
45
+ when 4..6 then "#{days_ago} Days Ago"
46
+ when 7 then 'a Week Ago'
47
+ else "Waaay Back on #{date.strftime('%m/%d/%Y')}"
48
+ end
49
+ end
37
50
  end
38
51
  end
@@ -63,8 +63,9 @@ module BeerBash
63
63
  end
64
64
 
65
65
  def find_updated(page)
66
- page.search('//div[contains(@class,"content")]/p[contains(text(),"Updated: ")]')
67
- .first.text.strip.match(/Updated: (.*)/)[1] rescue '???'
66
+ date = page.search('//div[contains(@class,"content")]/p[contains(text(),"Updated: ")]')
67
+ .first.text.strip.match(/Updated: (.*)/)[1]
68
+ Date.strptime(date, '%m/%d/%Y')
68
69
  end
69
70
 
70
71
  def find_taps(page)
@@ -1,4 +1,4 @@
1
1
 
2
2
  module BeerBash
3
- VERSION = '0.0.1'
3
+ VERSION = '0.1.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beer_bash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Evanoff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-10 00:00:00.000000000 Z
11
+ date: 2014-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake