daily_menu 0.0.1
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 +7 -0
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/.rubocop.yml +7 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +10 -0
- data/bin/daily_menu +5 -0
- data/configs/Budapest/Central.yml +42 -0
- data/daily_menu.gemspec +32 -0
- data/fixtures/feed_entries/hu/menu_entries.yml +8 -0
- data/fixtures/feed_entries/hu/other_entries.yml +3 -0
- data/lib/daily_menu/cli.rb +48 -0
- data/lib/daily_menu/entry.rb +3 -0
- data/lib/daily_menu/fetcher.rb +9 -0
- data/lib/daily_menu/filters/hungarian.rb +10 -0
- data/lib/daily_menu/filters/regexp.rb +11 -0
- data/lib/daily_menu/filters.rb +5 -0
- data/lib/daily_menu/restaurant.rb +31 -0
- data/lib/daily_menu/scrapers/facebook.rb +30 -0
- data/lib/daily_menu/scrapers.rb +4 -0
- data/lib/daily_menu/version.rb +3 -0
- data/lib/daily_menu.rb +12 -0
- data/spec/daily_menu/cli_spec.rb +39 -0
- data/spec/daily_menu/filters/hungarian_spec.rb +29 -0
- data/spec/daily_menu/restaurant_spec.rb +51 -0
- data/spec/daily_menu/scrapers/facebook_spec.rb +53 -0
- data/spec/daily_menu_spec.rb +16 -0
- data/spec/integration/koala_spec.rb +55 -0
- data/spec/spec_helper.rb +18 -0
- metadata +195 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ee0f01493bab7b55c78e5bc956056db33ac63d8a
|
4
|
+
data.tar.gz: e6a12d8abf89d9696bfbc4dce4ffbfbdcb6ee0f4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5c4b45314212d43d9e028a60955d58e9de1f39229c928523afd79f4c4d91ce2603cbd29b56c675c479383b8ce07979f31fd01b8902a6bfd0067b803c5bfef041
|
7
|
+
data.tar.gz: 674f17eed0ae2865ecc010cfbe894122cb9627dbb0a7f59970d9bcd09808c6bee952dfe25de2b9e30e3f2f4757d47d6dc876d7652269de2bd08e73bb56788dbb
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 István Karaszi
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# DailyMenu
|
2
|
+
|
3
|
+
Fetches the daily menu for you.
|
4
|
+
|
5
|
+
[](https://travis-ci.org/raszi/daily_menu)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'daily_menu'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install daily_menu
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
You need to set the `FACEBOOK_OAUTH_TOKEN` environment variable to the Facebook provided token to make it work.
|
24
|
+
|
25
|
+
$ echo 'Budapest/Central' > '.daily_menurc'
|
26
|
+
$ daily_menu
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/daily_menu
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
- :name: 'Kőleves Étterem'
|
2
|
+
:scraper:
|
3
|
+
:class: Facebook
|
4
|
+
:params:
|
5
|
+
- 'Koleves'
|
6
|
+
:filter:
|
7
|
+
:class: Hungarian
|
8
|
+
- :name: '400'
|
9
|
+
:scraper:
|
10
|
+
:class: Facebook
|
11
|
+
:params:
|
12
|
+
- '400bar.hu'
|
13
|
+
:filter:
|
14
|
+
:class: Hungarian
|
15
|
+
- :name: 'Keksz'
|
16
|
+
:scraper:
|
17
|
+
:class: Facebook
|
18
|
+
:params:
|
19
|
+
- '268952226502652'
|
20
|
+
:filter:
|
21
|
+
:class: Hungarian
|
22
|
+
- :name: 'Rézangyal Bistro'
|
23
|
+
:scraper:
|
24
|
+
:class: Facebook
|
25
|
+
:params:
|
26
|
+
- 'rezangyalmadach'
|
27
|
+
:filter:
|
28
|
+
:class: Hungarian
|
29
|
+
- :name: 'Castro Bistro'
|
30
|
+
:scraper:
|
31
|
+
:class: Facebook
|
32
|
+
:params:
|
33
|
+
- 'castrobistro'
|
34
|
+
:filter:
|
35
|
+
:class: Hungarian
|
36
|
+
- :name: 'Csináltam neked egy éttermet, és ez sem elég'
|
37
|
+
:scraper:
|
38
|
+
:class: Facebook
|
39
|
+
:params:
|
40
|
+
- 'CsinaltamNeked'
|
41
|
+
:filter:
|
42
|
+
:class: Hungarian
|
data/daily_menu.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'daily_menu/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'daily_menu'
|
8
|
+
spec.version = DailyMenu::VERSION
|
9
|
+
spec.authors = ['KARASZI István']
|
10
|
+
spec.email = ['github@spam.raszi.hu']
|
11
|
+
spec.description = %q{DailyMenu fetcher}
|
12
|
+
spec.summary = %q{Fetches the daily menus of the local restaurants}
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.required_ruby_version = '>= 2.0.0'
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_dependency 'koala'
|
24
|
+
spec.add_dependency 'awesome_print'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
27
|
+
spec.add_development_dependency 'rake'
|
28
|
+
spec.add_development_dependency 'vcr'
|
29
|
+
spec.add_development_dependency 'simplecov'
|
30
|
+
spec.add_development_dependency 'rspec'
|
31
|
+
spec.add_development_dependency 'rubocop'
|
32
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
- "Ajánljuk figyelmetekbe a mai menüt:\nMinestrone leves\nSpenótos csirkés
|
2
|
+
lasagne\nvagy\nFüstölt sajttal sült rakott zöldségek, jázmin rizzsel (gluténmentes)"
|
3
|
+
- "Sziasztok!\nHeti menü 08.05.-08.09.\n\nHÉTFŐ :\nZöldségleves\n\nA: Virslis lecsó\nB:
|
4
|
+
Tojásos lecsó\n\nKEDD:\nKapros cukkini krémleves\n\nA: Csirkés-zöldséges rizs\nB:
|
5
|
+
Sült kecskefeta salátával\n\nSZERDA:\nPadlizsánkrém lepénnyel\n\nA: Túrós csusza\nB:
|
6
|
+
Vegetáriánus csusza\n\nCSÜTÖRTÖK:\nMagyaros gombaleves\n\nA: Tárkonyos-tejszínes
|
7
|
+
pulykamell burgonyapürével\nB: Töltött cukkini paradicsomszósszal \n\nPÉNTEK:\nFokhagyma
|
8
|
+
krémleves\n\nA: Szerb burger pljeskavica\nB: Gomolya burger\n"
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'awesome_print'
|
3
|
+
|
4
|
+
module DailyMenu
|
5
|
+
class CLI
|
6
|
+
RC_FILE = File.expand_path('.daily_menurc', ENV['HOME']).freeze
|
7
|
+
|
8
|
+
def self.start(arguments)
|
9
|
+
location = arguments.empty? ? read_rc : arguments.first
|
10
|
+
ap fetch(location)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.fetch(location)
|
14
|
+
menus = restaurants_for_location(location).map do |restaurant|
|
15
|
+
[restaurant.name, restaurant.menu]
|
16
|
+
end
|
17
|
+
|
18
|
+
Hash[menus]
|
19
|
+
end
|
20
|
+
private_class_method :fetch
|
21
|
+
|
22
|
+
def self.read_rc
|
23
|
+
raise 'Unable to read the config file' unless file_accessible?(RC_FILE)
|
24
|
+
|
25
|
+
File.new(RC_FILE).read.chomp
|
26
|
+
end
|
27
|
+
private_class_method :read_rc
|
28
|
+
|
29
|
+
def self.restaurants_for_location(location)
|
30
|
+
configs_for_location(location).map { |config| Restaurant.from_hash(config) }
|
31
|
+
end
|
32
|
+
private_class_method :restaurants_for_location
|
33
|
+
|
34
|
+
def self.configs_for_location(location)
|
35
|
+
config_file = ROOT.join('configs', "#{location}.yml")
|
36
|
+
raise %(No configuration found for: "#{location}") unless file_accessible?(config_file)
|
37
|
+
|
38
|
+
YAML.load_file(config_file)
|
39
|
+
end
|
40
|
+
private_class_method :configs_for_location
|
41
|
+
|
42
|
+
def self.file_accessible?(file)
|
43
|
+
File.exists?(file) && File.readable?(file)
|
44
|
+
end
|
45
|
+
private_class_method :file_accessible?
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module DailyMenu
|
2
|
+
class Restaurant
|
3
|
+
attr_reader :name
|
4
|
+
|
5
|
+
def initialize(name, scraper, filter)
|
6
|
+
@name, @scraper, @filter = name, scraper, filter
|
7
|
+
end
|
8
|
+
|
9
|
+
def menu
|
10
|
+
@scraper.entries.select { |entry| @filter.matches?(entry) }.sort_by(&:time).last
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.from_hash(hash)
|
14
|
+
scraper = create_instance_from('Scrapers', hash[:scraper])
|
15
|
+
filter = create_instance_from('Filters', hash[:filter])
|
16
|
+
|
17
|
+
new(hash[:name], scraper, filter)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.create_instance_from(namespace, config)
|
21
|
+
class_to_instantiate = Object.const_get("DailyMenu::#{namespace}::#{config[:class].capitalize}")
|
22
|
+
if config[:params]
|
23
|
+
class_to_instantiate.new(*config[:params])
|
24
|
+
else
|
25
|
+
class_to_instantiate.new
|
26
|
+
end
|
27
|
+
end
|
28
|
+
private_class_method :create_instance_from
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'koala'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
module DailyMenu
|
5
|
+
class Scrapers::Facebook
|
6
|
+
|
7
|
+
def initialize(user)
|
8
|
+
@user = user
|
9
|
+
@api = Koala::Facebook::API.new(DailyMenu::OAUTH_TOKEN)
|
10
|
+
end
|
11
|
+
|
12
|
+
def entries
|
13
|
+
@api
|
14
|
+
.get_connections(user_id, 'feed')
|
15
|
+
.select { |feed_item| feed_item['from']['id'] == user_id && feed_item['message'] }
|
16
|
+
.map { |entry| Entry.new(entry['message'], parse_time(entry['created_time'])) }
|
17
|
+
end
|
18
|
+
|
19
|
+
def user_id
|
20
|
+
@user_id ||= @api.get_object(@user)['id']
|
21
|
+
end
|
22
|
+
private :user_id
|
23
|
+
|
24
|
+
def parse_time(time)
|
25
|
+
DateTime.parse(time).new_offset(0)
|
26
|
+
end
|
27
|
+
private :parse_time
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
data/lib/daily_menu.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'daily_menu/version'
|
2
|
+
|
3
|
+
module DailyMenu
|
4
|
+
OAUTH_TOKEN = ENV['FACEBOOK_OAUTH_TOKEN'].freeze
|
5
|
+
ROOT = Pathname.new(File.expand_path('../..', __FILE__)).freeze
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'daily_menu/entry'
|
9
|
+
require 'daily_menu/filters'
|
10
|
+
require 'daily_menu/scrapers'
|
11
|
+
require 'daily_menu/restaurant'
|
12
|
+
require 'daily_menu/cli'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module DailyMenu
|
4
|
+
describe CLI do
|
5
|
+
describe '.start' do
|
6
|
+
|
7
|
+
context 'when passing no location' do
|
8
|
+
it 'should raise an error when no config file found' do
|
9
|
+
File.stub(:exists?) { true }
|
10
|
+
File.stub(:readable?) { true }
|
11
|
+
|
12
|
+
expect { described_class.start([]) }.to raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should read the rc file' do
|
16
|
+
rc_file = double('RC file', read: 'Foo/Bar')
|
17
|
+
|
18
|
+
described_class.stub(:file_accessible?) { true }
|
19
|
+
File.stub(:new).with(described_class::RC_FILE) { rc_file }
|
20
|
+
described_class.stub(:configs_for_location) { [] }
|
21
|
+
described_class.stub(:ap)
|
22
|
+
|
23
|
+
described_class.start([])
|
24
|
+
|
25
|
+
expect(rc_file).to have_received(:read)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when passing the location' do
|
30
|
+
it 'should raise an error when no config file found' do
|
31
|
+
File.stub(:exists?) { false }
|
32
|
+
|
33
|
+
expect { described_class.start(['Budapest/Central']) }.to raise_error RuntimeError
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module DailyMenu
|
4
|
+
describe Filters::Hungarian do
|
5
|
+
def load_fixture(name)
|
6
|
+
fixture_path = DailyMenu::ROOT.join('fixtures', 'feed_entries', 'hu', name)
|
7
|
+
YAML.load_file(fixture_path).map { |text| Entry.new(text, Time.now) }
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:menu_entries) { load_fixture('menu_entries.yml') }
|
11
|
+
let(:other_entries) { load_fixture('other_entries.yml') }
|
12
|
+
|
13
|
+
let(:filter) { described_class.new }
|
14
|
+
|
15
|
+
describe '#matches?' do
|
16
|
+
it 'should return true on valid menus' do
|
17
|
+
menu_entries.each do |menu|
|
18
|
+
expect(filter.matches?(menu)).to be_true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should return false on non-menu entries' do
|
23
|
+
other_entries.each do |other|
|
24
|
+
expect(filter.matches?(other)).to be_false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module DailyMenu
|
4
|
+
describe Restaurant do
|
5
|
+
|
6
|
+
describe '.from_hash' do
|
7
|
+
let(:config) { { scraper: { class: 'Facebook', params: '1' }, filter: { class: 'Hungarian' } } }
|
8
|
+
|
9
|
+
it 'should create an instance' do
|
10
|
+
expect(described_class.from_hash(config)).to be_a(described_class)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#menu' do
|
15
|
+
let(:filter) { double('Filter') }
|
16
|
+
let(:scraper) { double('Scraper') }
|
17
|
+
let(:restaurant) { described_class.new('Restaurant', scraper, filter) }
|
18
|
+
|
19
|
+
it 'should fetch the menus from scraper' do
|
20
|
+
scraper.stub(:entries) { [] }
|
21
|
+
|
22
|
+
restaurant.menu
|
23
|
+
|
24
|
+
expect(scraper).to have_received(:entries)
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when there are fetched entries' do
|
28
|
+
let(:entries) { [Entry.new('This is a menu entry', 2), Entry.new('This is not', 1), Entry.new('This is also a menu entry', 0)] }
|
29
|
+
before do
|
30
|
+
scraper.stub(:entries) { entries }
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should call filter for filtering out menus' do
|
34
|
+
filter.stub(:matches?) { true }
|
35
|
+
|
36
|
+
restaurant.menu
|
37
|
+
|
38
|
+
expect(filter).to have_received(:matches?).exactly(entries.count).times
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should leave in only the filtered items' do
|
42
|
+
filter.stub(:matches?) do |entry|
|
43
|
+
entry.content.include?('menu')
|
44
|
+
end
|
45
|
+
|
46
|
+
expect(restaurant.menu).to eq(Entry.new('This is a menu entry', 2))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module DailyMenu
|
4
|
+
describe Scrapers::Facebook do
|
5
|
+
From = Struct.new(:id)
|
6
|
+
FeedItem = Struct.new(:from, :message, :created_time)
|
7
|
+
|
8
|
+
def random_time
|
9
|
+
Time.at(rand(Time.now.to_i)).utc.to_datetime
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:user) { 'Koleves' }
|
13
|
+
let(:user_id) { '185479434829378' }
|
14
|
+
let(:scraper) { described_class.new(user) }
|
15
|
+
|
16
|
+
let(:greeting_text) { 'This is just a greeting' }
|
17
|
+
let(:greeting_time) { random_time }
|
18
|
+
|
19
|
+
let(:daily_menu_text) { 'Our daily menu is' }
|
20
|
+
let(:daily_menu_time) { random_time }
|
21
|
+
|
22
|
+
let(:other_user_time) { random_time }
|
23
|
+
let(:other_user) { From.new(0) }
|
24
|
+
|
25
|
+
let(:feed_items) do
|
26
|
+
[
|
27
|
+
FeedItem.new(From.new(user_id), greeting_text, greeting_time.rfc3339),
|
28
|
+
FeedItem.new(From.new(user_id), daily_menu_text, daily_menu_time.rfc3339),
|
29
|
+
FeedItem.new(other_user, daily_menu_text, other_user_time.rfc3339)
|
30
|
+
]
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#entries' do
|
34
|
+
before do
|
35
|
+
::Koala::Facebook::API.any_instance.stub(:get_connections) { feed_items }
|
36
|
+
::Koala::Facebook::API.any_instance.stub(:get_object) { { 'id' => user_id } }
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should create Entry items' do
|
40
|
+
entries = scraper.entries
|
41
|
+
|
42
|
+
expect(entries.all? { |entry| entry.is_a?(Entry) }).to be_true
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should fetch the entries of the specified user from Facebook' do
|
46
|
+
entries = scraper.entries
|
47
|
+
|
48
|
+
expect(entries).to have(2).entries
|
49
|
+
expect(entries).to include(Entry.new(greeting_text, greeting_time), Entry.new(daily_menu_text, daily_menu_time))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DailyMenu do
|
4
|
+
describe 'ROOT' do
|
5
|
+
it 'should return the root path of the gem' do
|
6
|
+
expected_path = File.expand_path('..', File.dirname(__FILE__))
|
7
|
+
expect(described_class::ROOT.to_s).to eq(expected_path)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'VERSION' do
|
12
|
+
it 'should not be nil' do
|
13
|
+
expect(described_class::VERSION).to_not be_nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'koala'
|
3
|
+
|
4
|
+
module Koala::Facebook
|
5
|
+
describe API do
|
6
|
+
let(:user) { 'Koleves' }
|
7
|
+
let(:token) { DailyMenu::OAUTH_TOKEN }
|
8
|
+
let(:api) { described_class.new(token) }
|
9
|
+
|
10
|
+
it 'should get the feed as an Array' do
|
11
|
+
pending('OAuth token is not provided') if token.nil?
|
12
|
+
|
13
|
+
VCR.use_cassette('feed') do
|
14
|
+
expect(api.get_connections(user, 'feed')).to be_an(Array)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.get_object' do
|
19
|
+
it 'should contain the id' do
|
20
|
+
pending('OAuth token is not provided') if token.nil?
|
21
|
+
|
22
|
+
VCR.use_cassette('object') do
|
23
|
+
expect(api.get_object('Koleves').keys).to include('id')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context('an item from the feed') do
|
29
|
+
let(:item) do
|
30
|
+
VCR.use_cassette('feed') do
|
31
|
+
api.get_connections(user, 'feed').first
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should be a Hash' do
|
36
|
+
pending('OAuth token is not provided') if token.nil?
|
37
|
+
|
38
|
+
expect(item).to be_a(Hash)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should have the correct keys' do
|
42
|
+
pending('OAuth token is not provided') if token.nil?
|
43
|
+
|
44
|
+
expect(item.keys).to include(*%w(id from type created_time))
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'the from field should contain the id' do
|
48
|
+
pending('OAuth token is not provided') if token.nil?
|
49
|
+
|
50
|
+
expect(item['from'].keys).to include('id')
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
require 'daily_menu'
|
5
|
+
require 'vcr'
|
6
|
+
|
7
|
+
VCR.configure do |conf|
|
8
|
+
conf.cassette_library_dir = 'fixtures/vcr_cassettes'
|
9
|
+
conf.hook_into :faraday
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
14
|
+
config.run_all_when_everything_filtered = true
|
15
|
+
config.filter_run :focus
|
16
|
+
|
17
|
+
config.order = 'random'
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: daily_menu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- KARASZI István
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: koala
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: awesome_print
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: vcr
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: DailyMenu fetcher
|
126
|
+
email:
|
127
|
+
- github@spam.raszi.hu
|
128
|
+
executables:
|
129
|
+
- daily_menu
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .gitignore
|
134
|
+
- .rspec
|
135
|
+
- .rubocop.yml
|
136
|
+
- .travis.yml
|
137
|
+
- Gemfile
|
138
|
+
- LICENSE.txt
|
139
|
+
- README.md
|
140
|
+
- Rakefile
|
141
|
+
- bin/daily_menu
|
142
|
+
- configs/Budapest/Central.yml
|
143
|
+
- daily_menu.gemspec
|
144
|
+
- fixtures/feed_entries/hu/menu_entries.yml
|
145
|
+
- fixtures/feed_entries/hu/other_entries.yml
|
146
|
+
- lib/daily_menu.rb
|
147
|
+
- lib/daily_menu/cli.rb
|
148
|
+
- lib/daily_menu/entry.rb
|
149
|
+
- lib/daily_menu/fetcher.rb
|
150
|
+
- lib/daily_menu/filters.rb
|
151
|
+
- lib/daily_menu/filters/hungarian.rb
|
152
|
+
- lib/daily_menu/filters/regexp.rb
|
153
|
+
- lib/daily_menu/restaurant.rb
|
154
|
+
- lib/daily_menu/scrapers.rb
|
155
|
+
- lib/daily_menu/scrapers/facebook.rb
|
156
|
+
- lib/daily_menu/version.rb
|
157
|
+
- spec/daily_menu/cli_spec.rb
|
158
|
+
- spec/daily_menu/filters/hungarian_spec.rb
|
159
|
+
- spec/daily_menu/restaurant_spec.rb
|
160
|
+
- spec/daily_menu/scrapers/facebook_spec.rb
|
161
|
+
- spec/daily_menu_spec.rb
|
162
|
+
- spec/integration/koala_spec.rb
|
163
|
+
- spec/spec_helper.rb
|
164
|
+
homepage: ''
|
165
|
+
licenses:
|
166
|
+
- MIT
|
167
|
+
metadata: {}
|
168
|
+
post_install_message:
|
169
|
+
rdoc_options: []
|
170
|
+
require_paths:
|
171
|
+
- lib
|
172
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - '>='
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: 2.0.0
|
177
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - '>='
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
requirements: []
|
183
|
+
rubyforge_project:
|
184
|
+
rubygems_version: 2.0.6
|
185
|
+
signing_key:
|
186
|
+
specification_version: 4
|
187
|
+
summary: Fetches the daily menus of the local restaurants
|
188
|
+
test_files:
|
189
|
+
- spec/daily_menu/cli_spec.rb
|
190
|
+
- spec/daily_menu/filters/hungarian_spec.rb
|
191
|
+
- spec/daily_menu/restaurant_spec.rb
|
192
|
+
- spec/daily_menu/scrapers/facebook_spec.rb
|
193
|
+
- spec/daily_menu_spec.rb
|
194
|
+
- spec/integration/koala_spec.rb
|
195
|
+
- spec/spec_helper.rb
|