-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
35 lines (28 loc) · 981 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require 'rubygems'
require 'bundler'
require 'open-uri'
Bundler.require
desc "Scrape sue's special"
task :sues do
url = "http:https://www.suesnydeli.com/?_escaped_fragment_=daily-specials/ccf6"
doc = Nokogiri::HTML(open(url))
food = doc.css('#hxxkv61w').text.split("\n").select { |line| line =~ /\A\w/ }.join("\n")
def match(food, pattern)
food.match(pattern)[1].gsub("\n", " ")
end
client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV["CONSUMER_KEY"]
config.consumer_secret = ENV["CONSUMER_SECRET"]
config.access_token = ENV["ACCESS_TOKEN"]
config.access_token_secret = ENV["ACCESS_SECRET"]
end
salads = match(food, /(Salads.*)Soups/m)
soups = match(food, /(Soups.*)Special/m)
special = match(food, /(Special.*)$/m)
[salads, soups, special].each do |item|
client.update item
RestClient.post ENV['SLACK_URL'], {
text: item
}.to_json, content_type: :json, accept: :json
end
end