ruboty-wikipedia 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 993e88c917c8bd451031559ee6755f0d8c24fe14
4
+ data.tar.gz: 214f299dc96472d04b414d3f2df1250f0ca5e6da
5
+ SHA512:
6
+ metadata.gz: c31d9906981d0da5770411b31cc1d5b12946fbe62a68454a3838b2f478f74591f4533f6b6e9cf2e933c57ab84f47dca0149611ac6e8a61d135509037b1f057bc
7
+ data.tar.gz: aed37d2c71f30929c5db60da98857edf6671dd6b7485a1de87e8374f0bdcc7996f9a86dadf64934eddfbb1150d0c4cd84e9e3bcb238e4b5a7259ccda228fd23a
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /vendor/bundle/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in ruboty-wikipedia.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 TAGAWA Takao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, 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,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Ruboty::Wikipedia
2
+
3
+ A Ruboty plugin that returns Wikipedia URL.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ruboty-wikipedia'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```
22
+ $ gem install ruboty-wikipedia
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```
28
+ > ruboty wikipedia [keyword]
29
+ > ruboty wiki [keyword]
30
+ ```
31
+
32
+ ## ENV
33
+
34
+ ```
35
+ WIKIPEDIA_DOMAIN - Wikipedia domain (default: en.wikipedia.org)
36
+ WIKIPEDIA_MESSAGE_WHEN_NO_ARTICLE_WAS_FOUND - Message when no article was found (default: No articles found.)
37
+ ```
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dounokouno/ruboty-wikipedia.
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,35 @@
1
+ require 'ruboty'
2
+ require 'wikipedia'
3
+
4
+ module Ruboty
5
+ module Handlers
6
+ class Wikipedia < Base
7
+ DEFAULT_WIKIPEDIA_DOMAIN = 'en.wikipedia.org'
8
+ DEFAULT_WIKIPEDIA_MESSAGE_WHEN_NO_ARTICLE_WAS_FOUND = 'No articles found.'
9
+
10
+ env :WIKIPEDIA_DOMAIN, 'Wikipedia domain (default: en.wikipedia.org)', optional: true
11
+ env :WIKIPEDIA_MESSAGE_WHEN_NO_ARTICLE_WAS_FOUND,
12
+ 'Message when no article was found (default: No articles found.)',
13
+ optional: true
14
+
15
+ on(
16
+ /(wikipedia|wiki) (?<keyword>.*?)\z/i,
17
+ name: 'wikipedia',
18
+ description: 'Returns the Wikipedia url that matches the keyword.'
19
+ )
20
+
21
+ def wikipedia(message)
22
+ ::Wikipedia.configure { domain (ENV['WIKIPEDIA_DOMAIN'] || DEFAULT_WIKIPEDIA_DOMAIN) }
23
+ page = ::Wikipedia.find message[:keyword]
24
+
25
+ if page.summary.nil?
26
+ message.reply(
27
+ ENV['WIKIPEDIA_MESSAGE_WHEN_NO_ARTICLE_WAS_FOUND'] || DEFAULT_WIKIPEDIA_MESSAGE_WHEN_NO_ARTICLE_WAS_FOUND
28
+ )
29
+ else
30
+ message.reply page.fullurl
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,2 @@
1
+ require 'ruboty/wikipedia/version'
2
+ require 'ruboty/handlers/wikipedia'
@@ -0,0 +1,5 @@
1
+ module Ruboty
2
+ module Wikipedia
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruboty/wikipedia/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'ruboty-wikipedia'
8
+ spec.version = Ruboty::Wikipedia::VERSION
9
+ spec.authors = ['TAGAWA Takao']
10
+ spec.email = ['dounokouno@gmail.com']
11
+
12
+ spec.summary = 'A Ruboty plugin that returns Wikipedia URL.'
13
+ spec.homepage = 'https://github.com/dounokouno/ruboty-wikipedia'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = 'exe'
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_dependency 'ruboty'
24
+ spec.add_dependency 'wikipedia-client'
25
+ spec.add_development_dependency 'bundler', '~> 1.15'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruboty-wikipedia
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - TAGAWA Takao
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-11-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruboty
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: wikipedia-client
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.15'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.15'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description:
70
+ email:
71
+ - dounokouno@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - lib/ruboty/handlers/wikipedia.rb
82
+ - lib/ruboty/wikipedia.rb
83
+ - lib/ruboty/wikipedia/version.rb
84
+ - ruboty-wikipedia.gemspec
85
+ homepage: https://github.com/dounokouno/ruboty-wikipedia
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.6.13
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: A Ruboty plugin that returns Wikipedia URL.
109
+ test_files: []