lita-whats-brad-eating 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/000_create_gem.session +30 -0
- data/examples/001_routing.rb +12 -0
- data/examples/002_gemfile_include.rb +4 -0
- data/examples/003_route_spec.rb +6 -0
- data/examples/004_faraday_log.rb +19 -0
- data/lib/lita/handlers/whats_brad_eating.rb +10 -5
- data/lita-whats-brad-eating.gemspec +1 -1
- data/spec/lita/handlers/whats_brad_eating_spec.rb +9 -0
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f488b4a6d45fcb416a144c4d7b5f00b74bff3be4
|
4
|
+
data.tar.gz: 4ce5ff22fc40e2855d8c1c90c60ba40907a40c01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e658db15ebbabefc5e905d43f6425c7126930b96f00e8b4697364e1e1056455b82ea86fe434e6abbcd471cc4452c27357bd56a0cced7c27997e734c6c3c10645
|
7
|
+
data.tar.gz: ad388d16ab44345c17753617b30cd2a4aa693e4979fa73075635e6041bb4779ca04d556e3b3d996eff715af10cbbbb2d0a444a2a23df0d2e7ed4c9bf6c6939d4
|
@@ -0,0 +1,30 @@
|
|
1
|
+
$ lita handler whats-brad-eating
|
2
|
+
Do you want to test your plugin on Travis CI?
|
3
|
+
("yes" or "no", default is "no") yes
|
4
|
+
Do you want to generate code coverage information with SimpleCov
|
5
|
+
and Coveralls.io?
|
6
|
+
("yes" or "no", default is "no") yes
|
7
|
+
If your plugin's Git repository will be hosted on GitHub, build status
|
8
|
+
and code coverage badges can be automatically added to your README.
|
9
|
+
Would you like to add these badges? ("yes" or "no", default is "no") yes
|
10
|
+
What is your GitHub username? dpritchett
|
11
|
+
create lita-whats-brad-eating/lib/lita/handlers/whats_brad_eating.rb
|
12
|
+
create lita-whats-brad-eating/lib/lita-whats-brad-eating.rb
|
13
|
+
create lita-whats-brad-eating/spec/lita/handlers/wha..._spec.rb
|
14
|
+
create lita-whats-brad-eating/spec/spec_helper.rb
|
15
|
+
create lita-whats-brad-eating/locales/en.yml
|
16
|
+
create lita-whats-brad-eating/templates/.gitkeep
|
17
|
+
create lita-whats-brad-eating/Gemfile
|
18
|
+
create lita-whats-brad-eating/lita-whats-brad-eating.gemspec
|
19
|
+
create lita-whats-brad-eating/.gitignore
|
20
|
+
create lita-whats-brad-eating/.travis.yml
|
21
|
+
create lita-whats-brad-eating/Rakefile
|
22
|
+
create lita-whats-brad-eating/README.md
|
23
|
+
If you plan to release this plugin as open source software,
|
24
|
+
consider adding a LICENSE file to the root of the repository.
|
25
|
+
Common open source software licenses can be found at
|
26
|
+
http://choosealicense.com/.
|
27
|
+
Remember, for badges to be displayed in your plugin's README,
|
28
|
+
you must host your project on GitHub.
|
29
|
+
Additionally, you will need to configure the project on
|
30
|
+
Travis CI and Coveralls.io.
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# from lita-whats-brad-eating/lib/lita/handlers/whats_brad_eating.rb
|
2
|
+
route /^what's brad eating$/i,
|
3
|
+
:brad_eats,
|
4
|
+
command: true,
|
5
|
+
help: {
|
6
|
+
"what's brad eating" => "latest post from brad's food tumblr"
|
7
|
+
}
|
8
|
+
|
9
|
+
|
10
|
+
def brad_eats(response)
|
11
|
+
response.reply 'Actual results coming soon!'
|
12
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
pry(main)> require 'faraday'
|
2
|
+
true
|
3
|
+
pry(main)> require 'nokogiri'
|
4
|
+
true
|
5
|
+
pry(main)> raw_response = Faraday
|
6
|
+
.get('https://whatsbradeating.tumblr.com').body;
|
7
|
+
|
8
|
+
pry(main)> parsed_response = Nokogiri.parse(raw_response)
|
9
|
+
... response snipped
|
10
|
+
|
11
|
+
pry(main)> parsed_response.class
|
12
|
+
Nokogiri::HTML::Document < Nokogiri::XML::Document
|
13
|
+
pry(main)> parsed_response.css('.post').first
|
14
|
+
# <Nokogiri::XML::Element:0x3fe00cd4a48c name="section"
|
15
|
+
# attributes=[#<Nokogiri::XML::Attr:0x3fe00 name="class" value="post">]
|
16
|
+
# children=[#<Nokogiri::XML::Text:0x3fe00a301a90 "\r\n
|
17
|
+
# \r\n\r\n \r\n
|
18
|
+
# ">, #<Nokogiri::XML::Element:0x3fe00a3019dc name="
|
19
|
+
... remaining response snipped
|
@@ -3,16 +3,18 @@ require 'nokogiri'
|
|
3
3
|
module Lita
|
4
4
|
module Handlers
|
5
5
|
class WhatsBradEating < Handler
|
6
|
-
route
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
route /^what('|’)s brad eating$/i,
|
7
|
+
:brad_eats,
|
8
|
+
command: true,
|
9
|
+
help: { "what's brad eating" => "latest post from brad's food tumblr" }
|
10
10
|
|
11
|
+
# START:blog_url
|
11
12
|
BLOG_URL = 'https://whatsbradeating.tumblr.com'.freeze
|
12
13
|
|
13
14
|
def response
|
14
15
|
@_response ||= http.get(BLOG_URL)
|
15
16
|
end
|
17
|
+
# END:blog_url
|
16
18
|
|
17
19
|
def parsed_response
|
18
20
|
Nokogiri.parse(response.body)
|
@@ -30,14 +32,17 @@ module Lita
|
|
30
32
|
image.attributes.fetch('alt')
|
31
33
|
end
|
32
34
|
|
35
|
+
# START:brad_eats
|
33
36
|
def brad_eats(response)
|
34
|
-
|
37
|
+
# caption text had some stray newlines we don't need
|
38
|
+
caption_text = caption.text.strip
|
35
39
|
img_url = image.get_attribute('src')
|
36
40
|
|
37
41
|
msg = "#{caption_text} >> #{img_url}"
|
38
42
|
|
39
43
|
response.reply msg
|
40
44
|
end
|
45
|
+
# END:brad_eats
|
41
46
|
|
42
47
|
Lita.register_handler(self)
|
43
48
|
end
|
@@ -10,8 +10,10 @@ describe Lita::Handlers::WhatsBradEating, lita_handler: true, vcr: true do
|
|
10
10
|
describe 'routes' do
|
11
11
|
it { is_expected.to route("Lita what's brad eating") }
|
12
12
|
it { is_expected.to route("Lita what's BRAD eating") }
|
13
|
+
it { is_expected.to route("Lita what’s BRAD eating") }
|
13
14
|
end
|
14
15
|
|
16
|
+
# START:response
|
15
17
|
describe ':response' do
|
16
18
|
let(:body) { subject.response.body }
|
17
19
|
|
@@ -27,7 +29,9 @@ describe Lita::Handlers::WhatsBradEating, lita_handler: true, vcr: true do
|
|
27
29
|
expect(body.include?('caption')).to be_truthy
|
28
30
|
end
|
29
31
|
end
|
32
|
+
# END:response
|
30
33
|
|
34
|
+
# START:parsed_response
|
31
35
|
describe ':parsed_response' do
|
32
36
|
it 'should return a nokogiri object with a :css method we can search on' do
|
33
37
|
expect(subject.parsed_response).to respond_to(:css)
|
@@ -36,6 +40,7 @@ describe Lita::Handlers::WhatsBradEating, lita_handler: true, vcr: true do
|
|
36
40
|
expect(images.any?).to be_truthy
|
37
41
|
end
|
38
42
|
end
|
43
|
+
# END:parsed_response
|
39
44
|
|
40
45
|
describe ':first_post' do
|
41
46
|
it 'finds exactly one node' do
|
@@ -47,6 +52,7 @@ describe Lita::Handlers::WhatsBradEating, lita_handler: true, vcr: true do
|
|
47
52
|
end
|
48
53
|
end
|
49
54
|
|
55
|
+
# START:image
|
50
56
|
describe ':image' do
|
51
57
|
it 'finds at least one node' do
|
52
58
|
attributes = subject.image.attributes
|
@@ -56,11 +62,14 @@ describe Lita::Handlers::WhatsBradEating, lita_handler: true, vcr: true do
|
|
56
62
|
expect(attributes.key?('alt')).to be_truthy
|
57
63
|
end
|
58
64
|
end
|
65
|
+
# END:image
|
59
66
|
|
67
|
+
# START:brad_eats
|
60
68
|
describe ':brad_eats' do
|
61
69
|
it 'responds with a caption and an image URL' do
|
62
70
|
send_message "Lita what's brad eating"
|
63
71
|
expect(replies.last).to match(/\w+ >> http/i)
|
64
72
|
end
|
65
73
|
end
|
74
|
+
# END:brad_eats
|
66
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-whats-brad-eating
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Pritchett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -175,13 +175,23 @@ files:
|
|
175
175
|
- ".tool-versions"
|
176
176
|
- ".travis.yml"
|
177
177
|
- Gemfile
|
178
|
+
- Gemfile.lock
|
178
179
|
- LICENSE
|
179
180
|
- README.md
|
180
181
|
- Rakefile
|
182
|
+
- coverage/.last_run.json
|
183
|
+
- coverage/.resultset.json.lock
|
184
|
+
- examples/000_create_gem.session
|
185
|
+
- examples/001_routing.rb
|
186
|
+
- examples/002_gemfile_include.rb
|
187
|
+
- examples/003_route_spec.rb
|
188
|
+
- examples/004_faraday_log.rb
|
181
189
|
- lib/lita-whats-brad-eating.rb
|
182
190
|
- lib/lita/handlers/whats_brad_eating.rb
|
191
|
+
- lita-whats-brad-eating-0.1.0.gem
|
183
192
|
- lita-whats-brad-eating.gemspec
|
184
193
|
- locales/en.yml
|
194
|
+
- pkg/lita-whats-brad-eating-1.0.0.gem
|
185
195
|
- spec/cassettes/Lita_Handlers_WhatsBradEating.yml
|
186
196
|
- spec/cassettes/Lita_Handlers_WhatsBradEating/The_class.yml
|
187
197
|
- spec/cassettes/Lita_Handlers_WhatsBradEating/_brad_eats.yml
|