robut-wikipedia 0.0.3

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1e21ec274672b9e59b5ed40c30c9592a8322d3a6
4
+ data.tar.gz: 777c42eaed12561b6c65cbf3805ac13bfcf66637
5
+ SHA512:
6
+ metadata.gz: b19577302f9d009b1c610d9991777024cea8cdf8bd3adafbf66fc68691e0c22b9149755fd33af7eb81d954d2968865b8266ec40bae5ffd8cf61930f542d13c1d
7
+ data.tar.gz: 86232da295e8fba115a40b348c5972a5b5bab0da0da76dd13c772e78f02873b562ddeab72eadb6cf284392b807c57606a064430dc7c1265c0d7a5cec2b6cf6f1
data/Gemfile ADDED
File without changes
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) [year] [fullname]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ # robut-wikipedia
@@ -0,0 +1,45 @@
1
+ require 'robut'
2
+ require 'wikipedia'
3
+ require 'nokogiri'
4
+
5
+ class Robut::Plugin::Wikipedia
6
+ include Robut::Plugin
7
+ WIKI_REGEX = /^wiki (.*)$/
8
+
9
+ def usage
10
+ [
11
+ "#{at_nick} wiki [page-slug]"
12
+ ]
13
+ end
14
+
15
+ def handle(time, sender_nick, message)
16
+ return unless sent_to_me?(message)
17
+
18
+ request = words(message).join(" ")
19
+ if match = request.match(WIKI_REGEX)
20
+ process_response_for(match[1])
21
+ end
22
+
23
+ end
24
+
25
+ def process_response_for(query)
26
+ page_slug = query.strip.gsub(/\s/, "_")
27
+ page = ::Wikipedia.find(page_slug)
28
+
29
+ content = page.content
30
+ if content.nil?
31
+ reply("Couldn't find a page for: '#{page_slug}'")
32
+ return
33
+ end
34
+
35
+ doc = Nokogiri::HTML(page.sanitized_content)
36
+ reply("Wikipedia result for '#{page.title}'")
37
+ reply(doc.search('p:first-child').text)
38
+
39
+ if image = page.image_urls.first
40
+ reply(image)
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,19 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'robut-wikipedia'
3
+ s.version = '0.0.3'
4
+ s.authors = ["Jeff Ching"]
5
+ s.description = %{ Robut plugin that provides Wikipedia querying functionality. }
6
+ s.summary = "Wikipedia Robut plugin"
7
+ s.email = "ching.jeff@gmail.com"
8
+ s.homepage = "http://github.com/chingor13/robut-wikipedia"
9
+
10
+ s.platform = Gem::Platform::RUBY
11
+ s.add_dependency 'robut', '>= 0.3.0'
12
+ s.add_dependency 'wikipedia-client', '~> 1.3.0'
13
+ s.add_dependency 'nokogiri'
14
+
15
+ s.license = 'MIT'
16
+ s.files = `git ls-files`.split("\n")
17
+ s.extra_rdoc_files = ["README.md"]
18
+ s.require_path = "lib"
19
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: robut-wikipedia
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Ching
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: robut
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.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.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: wikipedia-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.3.0
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
+ description: ' Robut plugin that provides Wikipedia querying functionality. '
56
+ email: ching.jeff@gmail.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files:
60
+ - README.md
61
+ files:
62
+ - Gemfile
63
+ - LICENSE
64
+ - README.md
65
+ - lib/robut-wikipedia.rb
66
+ - robut-wikipedia.gemspec
67
+ homepage: http://github.com/chingor13/robut-wikipedia
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.0.3
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Wikipedia Robut plugin
91
+ test_files: []