Fall back to Pre-Pack items for meals without an entree
Assisted-by: Claude Opus 5 via Claude Code
diff --git a/lib/menu_feed.rb b/lib/menu_feed.rb
index 3d4efa2..34638fa 100644
--- a/lib/menu_feed.rb
+++ b/lib/menu_feed.rb
@@ -9,6 +9,8 @@ class MenuFeed
# Item types that name the meal, in the order they should appear in a title.
PRIMARY_TYPES = ["Entree", "Grab & Go", "Breakfast"]
+ # Stands in for the entree on days without one, e.g. a soup-and-stew day.
+ ENTREE_FALLBACK = "Pre-Pack"
SKIPPED_TYPES = ["Condiment"]
Item = Data.define(:type, :name)
@@ -27,9 +29,11 @@ class MenuFeed
end
def summary
+ types = PRIMARY_TYPES
+ types = types.map { it == "Entree" ? ENTREE_FALLBACK : it } if items.none? { it.type == "Entree" }
primary = items
- .select { PRIMARY_TYPES.include?(it.type) }
- .sort_by.with_index { |item, i| [PRIMARY_TYPES.index(item.type), i] }
+ .select { types.include?(it.type) }
+ .sort_by.with_index { |item, i| [types.index(item.type), i] }
return block_name if primary.empty?
primary.map(&:name).join(" / ")
diff --git a/test/menu_feed_test.rb b/test/menu_feed_test.rb
index 5e353be..69dbefa 100644
--- a/test/menu_feed_test.rb
+++ b/test/menu_feed_test.rb
@@ -16,6 +16,19 @@ class MenuFeedTest < Minitest::Test
assert_equal "Chicken Teriyaki w/ Steamed Rice / Turkey and Cheese Wrap", lunch.summary
end
+ def test_summary_falls_back_to_pre_pack_without_an_entree
+ lunch = meal(Date.new(2026, 9, 4), "Lunch")
+
+ assert_equal "Honey BBQ Wings w/ Mac and Cheese / Wowbutter Lunchbox", lunch.summary
+ end
+
+ def test_summary_ignores_pre_pack_with_an_entree
+ items = [MenuFeed::Item.new(type: "Pre-Pack", name: "Soup, Tomato"), MenuFeed::Item.new(type: "Entree", name: "Ciabatta Cheese Melt")]
+ meal = MenuFeed::Meal.new(date: Date.new(2026, 9, 17), block_id: 1, block_name: "Lunch", items:)
+
+ assert_equal "Ciabatta Cheese Melt", meal.summary
+ end
+
def test_description_omits_condiments
lunch = meal(Date.new(2026, 9, 2), "Lunch")