ruboty-train_delay 0.1.1 → 0.2.1
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 +4 -4
- data/README.md +1 -1
- data/lib/ruboty/train_delay/actions/delay.rb +24 -16
- data/lib/ruboty/train_delay/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b3a953ac6c8245342fbddb69208cf83b351b93a
|
4
|
+
data.tar.gz: 774b49dde7c1041cdb4512f137f26a4f247bd4aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 415fa7ac6d28a4e4410530df83a06fc85d5459498f4b2cc2b4daf76c5828073157b8f2f562b42eb6c925f984a11dd032374a5917fc96ac88a51873b43a48ba12
|
7
|
+
data.tar.gz: c2e23f727b15477c7c73bd59a50fd3b11dfb1729641a6f4cdb00bbd010b71f732a354c88d98ae0eadaf95bb6fdb753bae84407388099ff7d0933865bbb0f29a9
|
data/README.md
CHANGED
@@ -16,6 +16,27 @@ module Ruboty
|
|
16
16
|
|
17
17
|
module Actions
|
18
18
|
class Delay < Ruboty::Actions::Base
|
19
|
+
class << self
|
20
|
+
def train_list
|
21
|
+
@train_list ||= []
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_train_list
|
25
|
+
Ruboty::TrainDelay::AREA_SET.values.each do |area|
|
26
|
+
Nokogiri::HTML(open(list_url(area)))
|
27
|
+
.css("#mdAreaMajorLine .elmTblLstLine > table tr a")
|
28
|
+
.map do |a|
|
29
|
+
data = { name: a.content, href: a.attributes["href"].value }
|
30
|
+
train_list.push data
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def list_url(area_code)
|
36
|
+
"http://transit.loco.yahoo.co.jp/traininfo/area/#{area_code}/"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
19
40
|
def call
|
20
41
|
list = delay_list
|
21
42
|
return message.reply(found_route) if list.length == 0
|
@@ -28,28 +49,17 @@ module Ruboty
|
|
28
49
|
|
29
50
|
private
|
30
51
|
|
31
|
-
def area
|
32
|
-
return "関東" unless message.match_data.names.include? "area"
|
33
|
-
message[:area]
|
34
|
-
end
|
35
|
-
|
36
52
|
def route
|
37
53
|
message[:route]
|
38
54
|
end
|
39
55
|
|
40
|
-
def area_code
|
41
|
-
Ruboty::TrainDelay::AREA_SET[area.to_sym]
|
42
|
-
end
|
43
|
-
|
44
56
|
def cause_delay(route)
|
45
57
|
Nokogiri::HTML(open(route[:href]))
|
46
58
|
.css('#mdServiceStatus p').text
|
47
59
|
end
|
48
60
|
|
49
61
|
def delay_list
|
50
|
-
|
51
|
-
.css("#mdAreaMajorLine .elmTblLstLine > table tr a")
|
52
|
-
.map { |a| { name: a.content, href: a.attributes["href"].value } }
|
62
|
+
self.class.train_list
|
53
63
|
.select { |site| site[:name].include? route }
|
54
64
|
end
|
55
65
|
|
@@ -61,10 +71,6 @@ module Ruboty
|
|
61
71
|
EOS
|
62
72
|
end
|
63
73
|
|
64
|
-
def list_url
|
65
|
-
"http://transit.loco.yahoo.co.jp/traininfo/area/#{area_code}/"
|
66
|
-
end
|
67
|
-
|
68
74
|
def many_route(routes)
|
69
75
|
<<-"EOS"
|
70
76
|
絞り込めませんね。下のどれかでしょうか?
|
@@ -75,3 +81,5 @@ module Ruboty
|
|
75
81
|
end
|
76
82
|
end
|
77
83
|
end
|
84
|
+
|
85
|
+
Ruboty::TrainDelay::Actions::Delay.create_train_list
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-train_delay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akira.takahashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruboty
|