lita-vrt-mess 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4576410fd68cdb2930767614d444f947c50560ab25cbb181ba4f7b0416a661dc
4
+ data.tar.gz: e1db775722c184eb09c76ed3eb7017542d812ca5081e5ab3648eeeedb1312247
5
+ SHA512:
6
+ metadata.gz: cba1dd1a8803823517ee2ce658a4dcc7d6dd8da85a592e3f087cce99cc31b7385bd245ad0d60537a7e40181c07dcfe85b252ff5ba506c0a4c74df4149ccb4493
7
+ data.tar.gz: 12ede921b10498af576d5b4609325404cd821ed226be333a4e0e598bb9480c9e4ee2dee4a9db01e1518ca67bc66d54b8af20d55b9944ef49496ff11e766ca210
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor/
19
+
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # lita-vrt-mess
2
+
3
+ TODO: Add a description of the plugin.
4
+
5
+ ## Installation
6
+
7
+ Add lita-vrt-mess to your Lita instance's Gemfile:
8
+
9
+ ``` ruby
10
+ gem "lita-vrt-mess"
11
+ ```
12
+
13
+ ## Configuration
14
+
15
+ TODO: Describe any configuration attributes the plugin exposes.
16
+
17
+ ## Usage
18
+
19
+ TODO: Describe the plugin's features and how to use them.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,60 @@
1
+ require 'HTTParty'
2
+ require 'nokogiri'
3
+
4
+ module Lita
5
+ module Handlers
6
+ # Handle the VRT Mess requests for the Lita.io bot
7
+ class VrtMess < Handler
8
+ help = { 'mess' => 'Show menu from ishetlekkerindemess.be.' }
9
+ route(/mess(.|$)+?(?<w>week)?/, :handle_mess, command: true, help: help)
10
+
11
+ def handle_mess(response)
12
+ week = response.match_data[:w]
13
+ if week == 'week'
14
+ response.reply(weekmenu)
15
+ else
16
+ response.reply(daymenu)
17
+ end
18
+ end
19
+
20
+ def weekmenu
21
+ header = []
22
+ result = []
23
+ menu = parse_menu 'week'
24
+ table = menu.at('table')
25
+ table.search('tr').each do |tr|
26
+ cells = tr.search('th')
27
+ cells.each do |d|
28
+ header << d.text
29
+ end
30
+ end
31
+ table.search('tr').each do |tr|
32
+ cells = tr.search('td')
33
+ cells.each_with_index do |d, i|
34
+ result << "#{header[i]} : #{d.text}"
35
+ end
36
+ result << '--------------------------'
37
+ end
38
+ result.join("\n")
39
+ end
40
+
41
+ def daymenu
42
+ result = []
43
+ menu = parse_menu
44
+ items = menu.css('div.item')
45
+ items.each do |item|
46
+ name = item.css('h3 img')[0]['alt']
47
+ result << "#{name} : #{item.text.strip}"
48
+ end
49
+ result.join("\n")
50
+ end
51
+
52
+ def parse_menu(page = '')
53
+ menu = HTTParty.get("http://ishetlekkerindemess.be/#{page}")
54
+ Nokogiri::HTML(menu)
55
+ end
56
+
57
+ Lita.register_handler(self)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,12 @@
1
+ require "lita"
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join("..", "..", "locales", "*.yml"), __FILE__
5
+ )]
6
+
7
+ require "lita/handlers/vrt_mess"
8
+
9
+ Lita::Handlers::VrtMess.template_root File.expand_path(
10
+ File.join("..", "..", "templates"),
11
+ __FILE__
12
+ )
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'lita-vrt-mess'
3
+ spec.version = '0.1.0'
4
+ spec.authors = ['Stefan Goethals']
5
+ spec.email = ['stefan.goethals@vrt.be']
6
+ spec.description = 'Lita.io handler for getting the Menu of the VRT mess'
7
+ spec.summary = 'Lita.io handler for getting the Menu of the VRT mess'
8
+ spec.homepage = 'http://vrt.be'
9
+ spec.license = 'Apache '
10
+ spec.metadata = { 'lita_plugin_type' => 'handler' }
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ['lib']
16
+
17
+ spec.add_runtime_dependency 'httparty'
18
+ spec.add_runtime_dependency 'lita', '>= 4.7'
19
+ spec.add_runtime_dependency 'nokogiri'
20
+ # spec.add_runtime_dependency 'pry'
21
+
22
+ spec.add_development_dependency 'bundler'
23
+ spec.add_development_dependency 'pry-byebug'
24
+ spec.add_development_dependency 'rack-test'
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'rspec'
27
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,4 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ vrt_mess:
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ require 'pry'
3
+
4
+ describe Lita::Handlers::VrtMess, lita_handler: true do
5
+ it { is_expected.to route_command('mess').to(:handle_mess) }
6
+
7
+ it 'returns the VRT Mess menu' do
8
+ send_command('mess')
9
+ expect(replies.first).to include('Soep : ')
10
+ end
11
+
12
+ it 'returns the VRT Mess weekmenu' do
13
+ send_command('mess week')
14
+ expect(replies.first).to include('Datum : ')
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ require 'lita-vrt-mess'
2
+ require 'lita/rspec'
3
+
4
+ # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
5
+ # was generated with Lita 4, the compatibility mode should be left disabled.
6
+ Lita.version_3_compatibility_mode = false
File without changes
metadata ADDED
@@ -0,0 +1,170 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-vrt-mess
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stefan Goethals
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-10-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
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: lita
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '4.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '4.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
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: pry-byebug
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: rack-test
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: rake
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: rspec
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: Lita.io handler for getting the Menu of the VRT mess
126
+ email:
127
+ - stefan.goethals@vrt.be
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - Gemfile
134
+ - README.md
135
+ - Rakefile
136
+ - lib/lita-vrt-mess.rb
137
+ - lib/lita/handlers/vrt_mess.rb
138
+ - lita-vrt-mess.gemspec
139
+ - locales/en.yml
140
+ - spec/lita/handlers/vrt_mess_spec.rb
141
+ - spec/spec_helper.rb
142
+ - templates/.gitkeep
143
+ homepage: http://vrt.be
144
+ licenses:
145
+ - 'Apache '
146
+ metadata:
147
+ lita_plugin_type: handler
148
+ post_install_message:
149
+ rdoc_options: []
150
+ require_paths:
151
+ - lib
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements: []
163
+ rubyforge_project:
164
+ rubygems_version: 2.7.6.2
165
+ signing_key:
166
+ specification_version: 4
167
+ summary: Lita.io handler for getting the Menu of the VRT mess
168
+ test_files:
169
+ - spec/lita/handlers/vrt_mess_spec.rb
170
+ - spec/spec_helper.rb