ruboty-ueno_park_event 1.0.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
+ SHA1:
3
+ metadata.gz: fa43c4495ffd574dbb4fe3fbce02dea05f85c702
4
+ data.tar.gz: 8d06bbb37df95542fa75e6dcc2c2e479850b74f4
5
+ SHA512:
6
+ metadata.gz: 228f30c75959363f39aca7b0ccd5b01d5449489a5da12233b3a902323a9c431932391d5fc6989991224d20c77259bec810f1e1f1076120683d2ec5c502c0b39e
7
+ data.tar.gz: 1fa9e27f592d158f562fd94536aac5b5bab920c4ce5b0503e0afe827e31a888a3606129af0a5cc62c38a5332621fab3e508236905900c7c2b243c3996b244fd3
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ruboty-ueno_park_event.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 block_given?
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,38 @@
1
+ # Ruboty::UenoParkEvent
2
+
3
+ ruboty plugin for Ueno park event.
4
+
5
+ ![screenshot](screenshot.png)
6
+
7
+ ## Support
8
+
9
+ - [x] [ueno park museum event](http://museum.guidenet.jp/)
10
+ - [ ] [ueno park event](http://www.kensetsu.metro.tokyo.jp/toubuk/ueno/index_top.html)
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'ruboty-ueno_park_event'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install ruboty-ueno_park_event
27
+
28
+ ## Usage
29
+
30
+ @ruboty 上野のイベント教えて
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it ( https://github.com/blockgiven/ruboty-ueno_park_event/fork )
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,11 @@
1
+ module Ruboty
2
+ module Handlers
3
+ class UenoParkEvent < Base
4
+ on /上野(公園)?(の?イベント)?.*/, name: 'ueno_park_event', description: '上野公園のイベント'
5
+
6
+ def ueno_park_event(message)
7
+ Ruboty::UenoParkEvent::Actions::UenoParkEvent.new(message).call
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,52 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+
4
+ module Ruboty
5
+ module UenoParkEvent
6
+ module Actions
7
+ class UenoParkEvent < Ruboty::Actions::Base
8
+ def call
9
+ message.reply(ueno_park_event_text)
10
+ rescue => e
11
+ message.reply(e.message)
12
+ end
13
+
14
+ private
15
+
16
+ def ueno_park_event_text
17
+ title_and_link = ueno_park_events.map {|e|
18
+ "#{e[:text]}#{$/}#{e[:url]}"
19
+ }.join($/)
20
+
21
+ image_urls = ueno_park_events.map {|e|
22
+ e[:image_url]
23
+ }.join($/)
24
+
25
+ "#{title_and_link}#{$/*3}#{image_urls}"
26
+ end
27
+
28
+ def ueno_park_events
29
+ ueno_park_event_doc.search('.exblock .exbox').map {|ev|
30
+ {
31
+ text: ev.at_css('.extext h3').text.chomp,
32
+ url: ev.at_css('.extext h3 a')['href'],
33
+ image_url: ev.at_css('.exleaf img')['src']
34
+ }
35
+ }
36
+ end
37
+
38
+ def ueno_park_event_doc
39
+ @ueno_park_event_doc ||= Nokogiri::HTML(ueno_park_event_html)
40
+ end
41
+
42
+ def ueno_park_event_html
43
+ @ueno_park_event_html ||= OpenURI.open_uri(ueno_park_event_url)
44
+ end
45
+
46
+ def ueno_park_event_url
47
+ 'http://museum.guidenet.jp/'
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,5 @@
1
+ module Ruboty
2
+ module UenoParkEvent
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ require "ruboty/ueno_park_event/version"
2
+ require "ruboty/handlers/ueno_park_event"
3
+ require "ruboty/ueno_park_event/actions/ueno_park_event"
4
+
5
+ module Ruboty
6
+ module UenoParkEvent
7
+ # Your code goes here...
8
+ end
9
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ruboty/ueno_park_event/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruboty-ueno_park_event"
8
+ spec.version = Ruboty::UenoParkEvent::VERSION
9
+ spec.authors = ["block_given?"]
10
+ spec.email = ["block_given@outlook.com"]
11
+ spec.summary = %q{ruboty plugin for Ueno park event.}
12
+ spec.homepage = "https://github.com/blockgiven/ueno_park_event"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency "nokogiri"
21
+ spec.add_runtime_dependency "ruboty"
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ end
data/screenshot.png ADDED
Binary file
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruboty-ueno_park_event
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - block_given?
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
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: ruboty
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.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
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
+ - block_given@outlook.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/ueno_park_event.rb
82
+ - lib/ruboty/ueno_park_event.rb
83
+ - lib/ruboty/ueno_park_event/actions/ueno_park_event.rb
84
+ - lib/ruboty/ueno_park_event/version.rb
85
+ - ruboty-ueno_park_event.gemspec
86
+ - screenshot.png
87
+ homepage: https://github.com/blockgiven/ueno_park_event
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.2.2
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: ruboty plugin for Ueno park event.
111
+ test_files: []
112
+ has_rdoc: