cmm-lunch 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +8 -0
- data/lib/cmm-lunch.rb +22 -0
- data/test/test_cmm_lunch.rb +23 -0
- metadata +48 -0
data/Rakefile
ADDED
data/lib/cmm-lunch.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'Date'
|
2
|
+
|
3
|
+
class CmmLunch
|
4
|
+
DOUBLE_BREAK = "\n\n"
|
5
|
+
SINGLE_BREAK = "\n"
|
6
|
+
|
7
|
+
def self.menu(rawmenu)
|
8
|
+
menu = {}
|
9
|
+
rawmenu.split(DOUBLE_BREAK).each do |line|
|
10
|
+
if lunch_line?(line)
|
11
|
+
item = line.split(SINGLE_BREAK)
|
12
|
+
menu[item[0].strip.to_sym] = [item[1],item[2]]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
return menu
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def self.lunch_line?(entry_line)
|
20
|
+
return Date::DAYNAMES.any?{|day| entry_line.split(SINGLE_BREAK)[0].include? day}
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'cmm-lunch'
|
3
|
+
|
4
|
+
class CmmLunchTest < Test::Unit::TestCase
|
5
|
+
def test_for_single_monday
|
6
|
+
result = {:Monday => ["burger", "fries"]}
|
7
|
+
input = "Good afternoon!\n\nHere is the menu for this week.\n\nMonday\nburger\nfries"
|
8
|
+
assert_equal result, CmmLunch.menu(input)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_for_multiple_days
|
12
|
+
result = {}
|
13
|
+
result[:Monday] = ["Broccoli cheddar soup with rolls","Butter lettuce, blueberries, hearts of palm, strawberries, spiced pecans"]
|
14
|
+
result[:Tuesday] = ["Roasted chicken with spinach, tomatoes and pesto cream served with orzo","Mesclun, cucumber, artichokes, olives, pine nuts"]
|
15
|
+
result[:Wednesday] = ["Ham and Brie on croissant with apples and whole grain mustard, served with pretzels","Arugula, black berries, walnuts, cucumber, asparagus"]
|
16
|
+
result[:Thursday] = ["Barbacoa beef with rice, black beans, corn salsa, tortilla chips","Romaine, avocado, tomato, pepitas, feta"]
|
17
|
+
result[:Friday] = ["Cornmeal crusted tilapia with Old bay cream sauce served with roasted red skin potatoes","Mixed greens, bell pepper, onion, celery, hard boiled egg"]
|
18
|
+
input = "Good afternoon!\n\nHere is the menu for this week. Please let me know if you will have any guests.\n\nMonday\nBroccoli cheddar soup with rolls\nButter lettuce, blueberries, hearts of palm, strawberries, spiced pecans\n\nTuesday\nRoasted chicken with spinach, tomatoes and pesto cream served with orzo\nMesclun, cucumber, artichokes, olives, pine nuts\n\nWednesday \nHam and Brie on croissant with apples and whole grain mustard, served with pretzels\nArugula, black berries, walnuts, cucumber, asparagus\n\nThursday\nBarbacoa beef with rice, black beans, corn salsa, tortilla chips\nRomaine, avocado, tomato, pepitas, feta\n\nFriday\nCornmeal crusted tilapia with Old bay cream sauce served with roasted red skin potatoes\nMixed greens, bell pepper, onion, celery, hard boiled egg\n\nThanks!\nBecky\n\n\nSent from my iPad\n"
|
19
|
+
menu = CmmLunch.menu(input)
|
20
|
+
|
21
|
+
assert_equal result, menu
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cmm-lunch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Justin Rolston
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-03 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: This parses my work's lunch menu
|
15
|
+
email: justinrolston@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- Rakefile
|
21
|
+
- lib/cmm-lunch.rb
|
22
|
+
- test/test_cmm_lunch.rb
|
23
|
+
homepage: http://rubygems.org/gems/cmm-lunch
|
24
|
+
licenses: []
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 1.8.25
|
44
|
+
signing_key:
|
45
|
+
specification_version: 3
|
46
|
+
summary: CMM Lunch!
|
47
|
+
test_files:
|
48
|
+
- test/test_cmm_lunch.rb
|