meimei 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +67 -6
  4. data/VERSION +1 -1
  5. data/meimei.gemspec +16 -4
  6. data/plugins/eta.rb +20 -21
  7. metadata +69 -24
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4e63297c5cc55dfe6073e09f54b2d8b4af4fe3b5
4
+ data.tar.gz: c45e79b4a396565a6d0fb3c7a5d109dfc9ce5cd0
5
+ SHA512:
6
+ metadata.gz: 6c735386c36beb044fc25331e209bcfa548b69655372ed126829ce65acc90da9c9d3558bba1193809304486cf8b2b8605615634013929bcee82a7ec029a8a7e5
7
+ data.tar.gz: fbf33e4484b121033755ac7fa1144eb80e772e04550b5205050eb8dadc7b398a4274397cfda7961e2fb1d503340ba5d4f2f86d6aee440dab51fdcc2d7e48f75c
data/Gemfile CHANGED
@@ -3,3 +3,7 @@ source 'https://rubygems.org'
3
3
  gem 'jeweler'
4
4
  gem 'rake'
5
5
  gem 'rdoc'
6
+ gem 'nokogiri'
7
+ gem 'json'
8
+ gem 'damerau-levenshtein'
9
+ gem 'time_difference'
data/Gemfile.lock CHANGED
@@ -1,21 +1,82 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- git (1.2.5)
5
- jeweler (1.8.4)
6
- bundler (~> 1.0)
4
+ activesupport (4.2.1)
5
+ i18n (~> 0.7)
6
+ json (~> 1.7, >= 1.7.7)
7
+ minitest (~> 5.1)
8
+ thread_safe (~> 0.3, >= 0.3.4)
9
+ tzinfo (~> 1.1)
10
+ addressable (2.3.8)
11
+ builder (3.2.2)
12
+ damerau-levenshtein (1.1.0)
13
+ bundler (~> 1.7)
14
+ json (~> 1.8)
15
+ rake (~> 10.4)
16
+ rake-compiler (~> 0.9)
17
+ descendants_tracker (0.0.4)
18
+ thread_safe (~> 0.3, >= 0.3.1)
19
+ faraday (0.9.1)
20
+ multipart-post (>= 1.2, < 3)
21
+ git (1.2.9.1)
22
+ github_api (0.12.3)
23
+ addressable (~> 2.3)
24
+ descendants_tracker (~> 0.0.4)
25
+ faraday (~> 0.8, < 0.10)
26
+ hashie (>= 3.3)
27
+ multi_json (>= 1.7.5, < 2.0)
28
+ nokogiri (~> 1.6.3)
29
+ oauth2
30
+ hashie (3.4.1)
31
+ highline (1.7.2)
32
+ i18n (0.7.0)
33
+ jeweler (2.0.1)
34
+ builder
35
+ bundler (>= 1.0)
7
36
  git (>= 1.2.5)
37
+ github_api
38
+ highline (>= 1.6.15)
39
+ nokogiri (>= 1.5.10)
8
40
  rake
9
41
  rdoc
10
- json (1.8.0)
11
- rake (10.0.4)
12
- rdoc (3.12.2)
42
+ json (1.8.2)
43
+ jwt (1.5.0)
44
+ mini_portile (0.6.2)
45
+ minitest (5.7.0)
46
+ multi_json (1.11.0)
47
+ multi_xml (0.5.5)
48
+ multipart-post (2.0.0)
49
+ nokogiri (1.6.6.2)
50
+ mini_portile (~> 0.6.0)
51
+ oauth2 (1.0.0)
52
+ faraday (>= 0.8, < 0.10)
53
+ jwt (~> 1.0)
54
+ multi_json (~> 1.3)
55
+ multi_xml (~> 0.5)
56
+ rack (~> 1.2)
57
+ rack (1.6.1)
58
+ rake (10.4.2)
59
+ rake-compiler (0.9.5)
60
+ rake
61
+ rdoc (4.2.0)
13
62
  json (~> 1.4)
63
+ thread_safe (0.3.5)
64
+ time_difference (0.4.2)
65
+ activesupport
66
+ tzinfo (1.2.2)
67
+ thread_safe (~> 0.1)
14
68
 
15
69
  PLATFORMS
16
70
  ruby
17
71
 
18
72
  DEPENDENCIES
73
+ damerau-levenshtein
19
74
  jeweler
75
+ json
76
+ nokogiri
20
77
  rake
21
78
  rdoc
79
+ time_difference
80
+
81
+ BUNDLED WITH
82
+ 1.10.2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.4.0
data/meimei.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "meimei"
8
- s.version = "0.3.1"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["r888888888"]
12
- s.date = "2014-03-10"
12
+ s.date = "2015-06-02"
13
13
  s.description = "If all you need is a simple infobot and don't need a full RFC1459 implementation."
14
14
  s.email = "r888888888@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -73,25 +73,37 @@ Gem::Specification.new do |s|
73
73
  s.homepage = "http://github.com/r888888888/meimei"
74
74
  s.licenses = ["MIT"]
75
75
  s.require_paths = ["lib"]
76
- s.rubygems_version = "1.8.23"
76
+ s.rubygems_version = "2.0.14"
77
77
  s.summary = "Minimalistic IRC bot framework"
78
78
 
79
79
  if s.respond_to? :specification_version then
80
- s.specification_version = 3
80
+ s.specification_version = 4
81
81
 
82
82
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
83
83
  s.add_runtime_dependency(%q<jeweler>, [">= 0"])
84
84
  s.add_runtime_dependency(%q<rake>, [">= 0"])
85
85
  s.add_runtime_dependency(%q<rdoc>, [">= 0"])
86
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
87
+ s.add_runtime_dependency(%q<json>, [">= 0"])
88
+ s.add_runtime_dependency(%q<damerau-levenshtein>, [">= 0"])
89
+ s.add_runtime_dependency(%q<time_difference>, [">= 0"])
86
90
  else
87
91
  s.add_dependency(%q<jeweler>, [">= 0"])
88
92
  s.add_dependency(%q<rake>, [">= 0"])
89
93
  s.add_dependency(%q<rdoc>, [">= 0"])
94
+ s.add_dependency(%q<nokogiri>, [">= 0"])
95
+ s.add_dependency(%q<json>, [">= 0"])
96
+ s.add_dependency(%q<damerau-levenshtein>, [">= 0"])
97
+ s.add_dependency(%q<time_difference>, [">= 0"])
90
98
  end
91
99
  else
92
100
  s.add_dependency(%q<jeweler>, [">= 0"])
93
101
  s.add_dependency(%q<rake>, [">= 0"])
94
102
  s.add_dependency(%q<rdoc>, [">= 0"])
103
+ s.add_dependency(%q<nokogiri>, [">= 0"])
104
+ s.add_dependency(%q<json>, [">= 0"])
105
+ s.add_dependency(%q<damerau-levenshtein>, [">= 0"])
106
+ s.add_dependency(%q<time_difference>, [">= 0"])
95
107
  end
96
108
  end
97
109
 
data/plugins/eta.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'net/http'
3
- require 'nokogiri'
3
+ require 'json'
4
+ require 'damerau-levenshtein'
5
+ require 'time_difference'
4
6
 
5
7
  define_plugin("!eta") do |msg|
6
8
  query = msg
@@ -8,36 +10,33 @@ define_plugin("!eta") do |msg|
8
10
  if query.strip == ""
9
11
  reply "http://www.mahou.org/Showtime"
10
12
  else
11
- Net::HTTP.start("www.mahou.org", 80) do |http|
12
- resp = http.get("/Showtime")
13
+ Net::HTTP.start("anime.yshi.org", 80) do |http|
14
+ resp = http.get("/api/calendar/upcoming/all")
13
15
  if resp.code !~ /200/
14
16
  reply "Could not fetch web page, try again later"
15
17
  break
16
18
  end
17
19
 
18
20
  answer = "Show not found"
19
- doc = Nokogiri::HTML(resp.body)
20
- doc.xpath('//table[@summary="Currently Airing"]/tr/td/table/tr').each do |element|
21
- name = element.children[2].text
22
- eta = element.children[12].text
23
- if name =~ /#{query}/i
24
- answer = "ETA for #{name}: #{eta}"
25
- break
21
+ json = JSON.parse(resp.body)
22
+ best, score = nil, 1_000
23
+ json.each do |show|
24
+ d = DamerauLevenshtein.distance(show["title_name"].downcase, query)
25
+ if d < score
26
+ best = show
27
+ score = d
26
28
  end
27
29
  end
28
30
 
29
- if answer == "Show not found"
30
- doc.xpath('//table[@summary="Starting Soon"]/tr/td/table/tr').each do |element|
31
- name = element.children[2].text
32
- eta = element.children[16].text
33
- if name =~ /#{query}/i
34
- answer = "ETA for #{name}: #{eta}"
35
- break
36
- end
37
- end
38
- end
31
+ if best
32
+ anime = best["title_name"]
33
+ episode = best["count"]
34
+ start_time = Time.at(best["start_time"].to_i)
35
+ distance = TimeDifference.between(start_time, Time.now).in_general
36
+ distance_s = "#{distance[:days]}d #{distance[:hours]}h #{distance[:minutes]}m"
39
37
 
40
- reply answer
38
+ reply "ETA for #{anime} (ep #{episode}): #{distance_s}"
39
+ end
41
40
  end
42
41
  end
43
42
  end
metadata CHANGED
@@ -1,62 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meimei
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
5
- prerelease:
4
+ version: 0.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - r888888888
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-03-10 00:00:00.000000000 Z
11
+ date: 2015-06-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: jeweler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rdoc
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: damerau-levenshtein
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: time_difference
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
60
109
  - !ruby/object:Gem::Version
61
110
  version: '0'
62
111
  description: If all you need is a simple infobot and don't need a full RFC1459 implementation.
@@ -122,29 +171,25 @@ files:
122
171
  homepage: http://github.com/r888888888/meimei
123
172
  licenses:
124
173
  - MIT
174
+ metadata: {}
125
175
  post_install_message:
126
176
  rdoc_options: []
127
177
  require_paths:
128
178
  - lib
129
179
  required_ruby_version: !ruby/object:Gem::Requirement
130
- none: false
131
180
  requirements:
132
- - - ! '>='
181
+ - - '>='
133
182
  - !ruby/object:Gem::Version
134
183
  version: '0'
135
- segments:
136
- - 0
137
- hash: 2634099626359637905
138
184
  required_rubygems_version: !ruby/object:Gem::Requirement
139
- none: false
140
185
  requirements:
141
- - - ! '>='
186
+ - - '>='
142
187
  - !ruby/object:Gem::Version
143
188
  version: '0'
144
189
  requirements: []
145
190
  rubyforge_project:
146
- rubygems_version: 1.8.23
191
+ rubygems_version: 2.0.14
147
192
  signing_key:
148
- specification_version: 3
193
+ specification_version: 4
149
194
  summary: Minimalistic IRC bot framework
150
195
  test_files: []