lita-zerocater 0.10.0 → 1.0.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 +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +6 -0
- data/.ruby-version +1 -0
- data/.travis.yml +2 -2
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +1 -0
- data/Rakefile +3 -1
- data/lib/lita-zerocater.rb +2 -0
- data/lib/lita/handlers/icons.rb +13 -0
- data/lib/lita/handlers/zerocater.rb +27 -3
- data/lita-zerocater.gemspec +5 -2
- data/locales/en.yml +1 -1
- data/spec/lita/handlers/zerocater_spec.rb +95 -31
- data/spec/spec_helper.rb +2 -0
- data/templates/menu.erb +5 -2
- data/templates/menu.slack.erb +6 -3
- metadata +22 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 648fce0405a5c649d4d3877fc705aa4e3c1f752c
|
4
|
+
data.tar.gz: 304e6cc594679bb97e7ebe877b0a21bf8f6f4ca1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e1dc60d08efc9f19bb38193073b17f9ec87f0d633fe2b732a573de2cd38626628ef7e56c89a1363b820869f7366b36c1ace405897d4da93b6ea81de04b9c91c
|
7
|
+
data.tar.gz: cfec1c75f474e0d25e00af7b61abd1ff3fea4167c9a1d3ae66c4a0db8026ba6769b3282fd1eca165d02834be2a5080a5412414fcc70234e139b9a97d3c070f6c
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.2
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Eric Sigler
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_tasks'
|
2
4
|
require 'rspec/core/rake_task'
|
3
5
|
require 'rubocop/rake_task'
|
@@ -5,4 +7,4 @@ require 'rubocop/rake_task'
|
|
5
7
|
RSpec::Core::RakeTask.new(:spec)
|
6
8
|
RuboCop::RakeTask.new(:rubocop)
|
7
9
|
|
8
|
-
task default: [
|
10
|
+
task default: %i[spec rubocop]
|
data/lib/lita-zerocater.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'icons'
|
4
|
+
|
1
5
|
module Lita
|
2
6
|
module Handlers
|
3
7
|
class Zerocater < Handler
|
@@ -32,14 +36,14 @@ module Lita
|
|
32
36
|
Date.today
|
33
37
|
end
|
34
38
|
|
35
|
-
config.locations.
|
39
|
+
config.locations.each_key do |location|
|
36
40
|
response.reply(fetch_menu(location, search_date))
|
37
41
|
end
|
38
42
|
end
|
39
43
|
# rubocop:enable Metrics/MethodLength
|
40
44
|
|
41
45
|
def alias(response)
|
42
|
-
config.locations.
|
46
|
+
config.locations.each_key do |location|
|
43
47
|
response.reply(fetch_menu(location, Date.today))
|
44
48
|
end
|
45
49
|
end
|
@@ -89,14 +93,34 @@ module Lita
|
|
89
93
|
meals
|
90
94
|
end
|
91
95
|
|
96
|
+
# append emoji icons based on item labels
|
97
|
+
def append_icons(item)
|
98
|
+
labels = get_label_icons(item)
|
99
|
+
# if it's vegan, it's necessarily vegetarian. Remove redundant icon.
|
100
|
+
if labels.include?(ICONS['vegetarian']) &&
|
101
|
+
labels.include?(ICONS['vegan'])
|
102
|
+
labels.delete_at(labels.index(ICONS['vegetarian']))
|
103
|
+
end
|
104
|
+
labels.empty? ? item['name'] : item['name'] << ' | ' << labels.join(' ')
|
105
|
+
end
|
106
|
+
|
107
|
+
def get_label_icons(item)
|
108
|
+
labels = item['labels'].select do |label, value|
|
109
|
+
value['value'] == true && ICONS.key?(label)
|
110
|
+
end
|
111
|
+
labels.map { |label, _| ICONS[label] }
|
112
|
+
end
|
113
|
+
|
92
114
|
def render_menu(location, search_date)
|
93
115
|
menu = find_menu(config.locations[location], search_date)
|
94
116
|
return t('error.empty') if menu.empty?
|
95
117
|
|
118
|
+
items = menu.map { |m| m['items'].map { |item| append_icons(item) } }
|
96
119
|
render_template('menu',
|
97
120
|
menu: menu,
|
121
|
+
items: items,
|
98
122
|
locale: t('menu.locale', location: location))
|
99
|
-
rescue
|
123
|
+
rescue StandardError
|
100
124
|
t('error.retrieve')
|
101
125
|
end
|
102
126
|
end
|
data/lita-zerocater.gemspec
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Gem::Specification.new do |spec|
|
2
4
|
spec.name = 'lita-zerocater'
|
3
|
-
spec.version = '0.
|
5
|
+
spec.version = '1.0.0'
|
4
6
|
spec.authors = ['Eric Sigler']
|
5
7
|
spec.email = ['me@esigler.com']
|
6
8
|
spec.description = 'A ZeroCater menu lookup plugin for Lita'
|
@@ -19,10 +21,11 @@ Gem::Specification.new do |spec|
|
|
19
21
|
spec.add_development_dependency 'bundler'
|
20
22
|
spec.add_development_dependency 'coveralls'
|
21
23
|
spec.add_development_dependency 'pry-byebug'
|
22
|
-
spec.add_development_dependency 'rake'
|
23
24
|
spec.add_development_dependency 'rack-test'
|
25
|
+
spec.add_development_dependency 'rake'
|
24
26
|
spec.add_development_dependency 'rspec'
|
25
27
|
spec.add_development_dependency 'rubocop'
|
28
|
+
spec.add_development_dependency 'rubocop-rspec'
|
26
29
|
spec.add_development_dependency 'simplecov'
|
27
30
|
spec.add_development_dependency 'timecop'
|
28
31
|
spec.add_development_dependency 'vcr'
|
data/locales/en.yml
CHANGED
@@ -11,6 +11,6 @@ en:
|
|
11
11
|
desc: Show appropriate Zerocater menu for all locations
|
12
12
|
error:
|
13
13
|
empty: There are no menu items found for today
|
14
|
-
retrieve: There was an error
|
14
|
+
retrieve: There was an error retrieving the menu
|
15
15
|
menu:
|
16
16
|
locale: "Menu for %{location}"
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Lita::Handlers::Zerocater, lita_handler: true do
|
@@ -5,6 +7,91 @@ describe Lita::Handlers::Zerocater, lita_handler: true do
|
|
5
7
|
registry.config.handlers.zerocater.locations = { 'foo' => 'YVKV' }
|
6
8
|
end
|
7
9
|
|
10
|
+
let(:menu_yesterday) do
|
11
|
+
<<~MENU
|
12
|
+
Menu for foo:
|
13
|
+
|
14
|
+
*Seasonal Salad Bar: Springtime* (Seasonal Salad Bar By 2Forks)
|
15
|
+
- Springtime Salad Bar | 🌱
|
16
|
+
- Grilled Chicken Breast
|
17
|
+
- Grilled Tofu | 🌱
|
18
|
+
- Avocado | 🌱
|
19
|
+
- Citrus Vinaigrette | 🌱
|
20
|
+
- Balsamic Vinaigrette | 🌱
|
21
|
+
- Romano Cheese | 🥕 🧀
|
22
|
+
- Almond Slivers | 🌱 🥜
|
23
|
+
- Citrus Avocado Dressing
|
24
|
+
- Dried Cherries | 🌱
|
25
|
+
*Chicken & Meatballs* (Cafe Sud)
|
26
|
+
- Turkey Meatballs with Fresh Tomato Sauce | 🍞 🥚
|
27
|
+
- Sundried Tomato Grilled Chicken
|
28
|
+
- Pesto Aioli | 🥕 🥚
|
29
|
+
- French Organic Lentils | 🌱
|
30
|
+
- Garlic and Rosemary Roasted Potatoes | 🌱
|
31
|
+
- Grilled Vegetables | 🌱
|
32
|
+
- French Organic Lentils | 🌱
|
33
|
+
MENU
|
34
|
+
end
|
35
|
+
|
36
|
+
let(:menu_today) do
|
37
|
+
<<~MENU
|
38
|
+
Menu for foo:
|
39
|
+
|
40
|
+
*Korean-Thai Fusion* (Crazy Mint)
|
41
|
+
- Sweet Garlic Ginger Grilled Chicken | 🍞
|
42
|
+
- Spicy Korean BBQ Chicken | 🍞
|
43
|
+
- Tofu Green Curry | 🌱
|
44
|
+
- Coconut Rice | 🌱
|
45
|
+
- Soba Noodle Salad | 🍞 🌱
|
46
|
+
- Sake and Miso Glazed Japanese Eggplants | 🌱
|
47
|
+
- Vegetable and Bean Cake | 🌱
|
48
|
+
*Seasonal Salad Bar: Springtime* (Seasonal Salad Bar By 2Forks)
|
49
|
+
- Springtime Salad Bar | 🌱
|
50
|
+
- Grilled Chicken Breast
|
51
|
+
- Grilled Tofu | 🌱
|
52
|
+
- Avocado | 🌱
|
53
|
+
- Citrus Vinaigrette | 🌱
|
54
|
+
- Balsamic Vinaigrette | 🌱
|
55
|
+
- Citrus Avocado Dressing
|
56
|
+
- Almond Slivers | 🌱 🥜
|
57
|
+
- Romano Cheese | 🧀 🥕
|
58
|
+
MENU
|
59
|
+
end
|
60
|
+
|
61
|
+
let(:menu_tomorrow) do
|
62
|
+
<<~MENU
|
63
|
+
Menu for foo:
|
64
|
+
|
65
|
+
*French Breakfast Crepes!* (Crepe Madame)
|
66
|
+
- Savory Buckwheat Crepes | 🧀 🥕 🥚
|
67
|
+
- Sweet Crepes | 🧀 🍞 🥕 🥚 🥜
|
68
|
+
- Organic Egg | 🥕 🥚
|
69
|
+
*Sandwiches!* (Green Bar)
|
70
|
+
- BBQ Chicken with Smoked Gouda Sandwich | 🧀 🍞
|
71
|
+
- Gluten-Free BBQ Chicken with Smoked Gouda Sandwich | 🧀
|
72
|
+
- Beef Tri-Tip Sandwich | 🧀 🍞 🥚
|
73
|
+
- Ham and Brie Sandwich | 🥓 🧀 🍞
|
74
|
+
- Roast Turkey Sandwich with Cranberry Sauce | 🍞 🥚
|
75
|
+
- Gluten-Free Roast Turkey Sandwich with Cranberry Sauce | 🥚
|
76
|
+
- Gluten-Free Grilled Chicken Sandwich | 🥚
|
77
|
+
- Grilled Chicken Sandwich | 🍞 🥚
|
78
|
+
- Hummus, Cucumber, Avocado, and Tomato on Focaccia | 🌱 🍞
|
79
|
+
- Grilled Portobello Mushroom with Provolone Sandwich | 🥕 🧀 🍞
|
80
|
+
- Creamy Brie with Sun Dried Tomato Pesto, Sprouts, and Sliced Apple | 🥕 🥜 🧀 🍞
|
81
|
+
- Grilled Portobello Mushroom with Provolone Sandwich | 🥕 🧀 🍞
|
82
|
+
- Kale Salad | 🌱
|
83
|
+
*Seasonal Salad Bar: Springtime* (Seasonal Salad Bar By 2Forks)
|
84
|
+
- Springtime Salad Bar | 🌱
|
85
|
+
- Grilled Chicken Breast
|
86
|
+
- Grilled Tofu | 🌱
|
87
|
+
- Avocado | 🌱
|
88
|
+
- Citrus Vinaigrette | 🌱
|
89
|
+
- Balsamic Vinaigrette | 🌱
|
90
|
+
- Romano Cheese | 🥕 🧀
|
91
|
+
- Almond Slivers | 🌱 🥜
|
92
|
+
MENU
|
93
|
+
end
|
94
|
+
|
8
95
|
it { is_expected.to route_command('zerocater today').to(:menu) }
|
9
96
|
it { is_expected.to route_command('zerocater tomorrow').to(:menu) }
|
10
97
|
it { is_expected.to route_command('zerocater yesterday').to(:menu) }
|
@@ -19,13 +106,7 @@ describe Lita::Handlers::Zerocater, lita_handler: true do
|
|
19
106
|
Timecop.travel(Time.local(2016, 4, 5, 8, 0, 0))
|
20
107
|
VCR.use_cassette('zerocater') do
|
21
108
|
send_command('zerocater today')
|
22
|
-
expect(replies.last).to eq(
|
23
|
-
Menu for foo:
|
24
|
-
|
25
|
-
Korean-Thai Fusion (Crazy Mint)
|
26
|
-
Seasonal Salad Bar: Springtime (Seasonal Salad Bar By 2Forks)
|
27
|
-
MENU
|
28
|
-
)
|
109
|
+
expect(replies.last).to eq(menu_today)
|
29
110
|
end
|
30
111
|
end
|
31
112
|
|
@@ -37,25 +118,20 @@ MENU
|
|
37
118
|
end
|
38
119
|
end
|
39
120
|
|
40
|
-
|
121
|
+
# rubocop:disable RSpec/AnyInstance
|
122
|
+
it 'shows a warning if there was a problem retrieving the page' do
|
41
123
|
allow_any_instance_of(Faraday::Connection).to receive('get').and_raise
|
42
124
|
send_command('zerocater today')
|
43
|
-
expect(replies.last).to eq('There was an error
|
125
|
+
expect(replies.last).to eq('There was an error retrieving the menu')
|
44
126
|
end
|
127
|
+
# rubocop:enabler RSpec/AnyInstance
|
45
128
|
end
|
46
129
|
|
47
130
|
it 'shows the menu for tomorrow' do
|
48
131
|
Timecop.travel(Time.local(2016, 4, 5, 8, 0, 0))
|
49
132
|
VCR.use_cassette('zerocater') do
|
50
133
|
send_command('zerocater tomorrow')
|
51
|
-
expect(replies.last).to eq(
|
52
|
-
Menu for foo:
|
53
|
-
|
54
|
-
French Breakfast Crepes! (Crepe Madame)
|
55
|
-
Sandwiches! (Green Bar)
|
56
|
-
Seasonal Salad Bar: Springtime (Seasonal Salad Bar By 2Forks)
|
57
|
-
MENU
|
58
|
-
)
|
134
|
+
expect(replies.last).to eq(menu_tomorrow)
|
59
135
|
end
|
60
136
|
end
|
61
137
|
|
@@ -63,13 +139,7 @@ MENU
|
|
63
139
|
Timecop.travel(Time.local(2016, 4, 5, 8, 0, 0))
|
64
140
|
VCR.use_cassette('zerocater') do
|
65
141
|
send_command('zerocater yesterday')
|
66
|
-
expect(replies.last).to eq(
|
67
|
-
Menu for foo:
|
68
|
-
|
69
|
-
Seasonal Salad Bar: Springtime (Seasonal Salad Bar By 2Forks)
|
70
|
-
Chicken & Meatballs (Cafe Sud)
|
71
|
-
MENU
|
72
|
-
)
|
142
|
+
expect(replies.last).to eq(menu_yesterday)
|
73
143
|
end
|
74
144
|
end
|
75
145
|
|
@@ -78,13 +148,7 @@ MENU
|
|
78
148
|
Timecop.travel(Time.local(2016, 4, 5, 8, 0, 0))
|
79
149
|
VCR.use_cassette('zerocater') do
|
80
150
|
send_command('lunch')
|
81
|
-
expect(replies.last).to eq(
|
82
|
-
Menu for foo:
|
83
|
-
|
84
|
-
Korean-Thai Fusion (Crazy Mint)
|
85
|
-
Seasonal Salad Bar: Springtime (Seasonal Salad Bar By 2Forks)
|
86
|
-
MENU
|
87
|
-
)
|
151
|
+
expect(replies.last).to eq(menu_today)
|
88
152
|
end
|
89
153
|
end
|
90
154
|
end
|
data/spec/spec_helper.rb
CHANGED
data/templates/menu.erb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
<%= @locale %>:
|
2
2
|
|
3
|
-
<% @menu.each do |meal| %>
|
4
|
-
|
3
|
+
<% @menu.to_enum.with_index(0).each do |meal, idx| %>
|
4
|
+
*<%= meal['name'] %>* (<%= meal['vendor_name'] %>)
|
5
|
+
<% @items[idx].each do |item| %>
|
6
|
+
- <%= item %>
|
7
|
+
<% end %>
|
5
8
|
<% end %>
|
data/templates/menu.slack.erb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
-
|
1
|
+
<%= @locale %>:
|
2
2
|
|
3
|
-
<% @menu.each do |meal| %>
|
4
|
-
|
3
|
+
<% @menu.to_enum.with_index(0).each do |meal, idx| %>
|
4
|
+
*<%= meal['name'] %>* (<%= meal['vendor_name'] %>)
|
5
|
+
<% @items[idx].each do |item| %>
|
6
|
+
- <%= item %>
|
7
|
+
<% end %>
|
5
8
|
<% end %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-zerocater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Sigler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rack-test
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop-rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: simplecov
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,13 +188,16 @@ files:
|
|
174
188
|
- ".gitignore"
|
175
189
|
- ".rspec"
|
176
190
|
- ".rubocop.yml"
|
191
|
+
- ".ruby-version"
|
177
192
|
- ".travis.yml"
|
178
193
|
- CONTRIBUTING.md
|
179
194
|
- Gemfile
|
195
|
+
- LICENSE
|
180
196
|
- README.md
|
181
197
|
- Rakefile
|
182
198
|
- TODO.md
|
183
199
|
- lib/lita-zerocater.rb
|
200
|
+
- lib/lita/handlers/icons.rb
|
184
201
|
- lib/lita/handlers/zerocater.rb
|
185
202
|
- lita-zerocater.gemspec
|
186
203
|
- locales/en.yml
|
@@ -210,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
227
|
version: '0'
|
211
228
|
requirements: []
|
212
229
|
rubyforge_project:
|
213
|
-
rubygems_version: 2.
|
230
|
+
rubygems_version: 2.6.13
|
214
231
|
signing_key:
|
215
232
|
specification_version: 4
|
216
233
|
summary: A ZeroCater menu lookup plugin for Lita
|