ruboty-dmm 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/Gemfile.lock +7 -7
- data/README.md +3 -3
- data/doc/ja/README.md +3 -3
- data/lib/ruboty/dmm/actions/messenger.rb +18 -2
- data/lib/ruboty/dmm/agent.rb +0 -2
- data/lib/ruboty/dmm/ranking.rb +3 -3
- data/lib/ruboty/dmm/version.rb +1 -1
- data/spec/ruboty/dmm/ranking_spec.rb +6 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8eb0d93dcba3e0825cf3ce4392da8190b24b9d6
|
4
|
+
data.tar.gz: 8c7ee10f8d1a0ce550f3a985492dd988c9315598
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9fcc39e3f8296f07d9f3c46b01a732d6a2b810ade055a43238536fa767e6d5c5c842711855545cab2fbcb51b2a0b9f4c3aec9619c2255160ba31815a53043c9
|
7
|
+
data.tar.gz: d767603ed172abe30be1bed464dd922027122f80437022463e8c698350dd4e735139c1f89d65d1b82de03b4a27452622286e15d60c7e37db8b4a445d41420efb
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# v0.0.3 (Unreleased)
|
2
|
+
- Correct READMEs
|
3
|
+
- Add an example needed for each rank.
|
4
|
+
|
5
|
+
## Breaking changes
|
6
|
+
- Show thumbnail for each ranks.
|
7
|
+
- From this changes, dropped support except for Slack.
|
8
|
+
|
9
|
+
# v0.0.2
|
10
|
+
- Remove an unused method.
|
11
|
+
- Support all rankings (all, weekly, cg, game, voice).
|
12
|
+
- Update document according to now specification.
|
13
|
+
|
14
|
+
# v0.0.1
|
15
|
+
- Implement fetch the ranking for the DMM.R18's doujin cg.
|
16
|
+
- Modify the task for managing the gem.
|
17
|
+
- Create an environment for test.
|
data/Gemfile.lock
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ruboty-dmm (0.0.
|
4
|
+
ruboty-dmm (0.0.3)
|
5
5
|
mechanize
|
6
6
|
ruboty
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (5.0.
|
11
|
+
activesupport (5.0.2)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
13
|
i18n (~> 0.7)
|
14
14
|
minitest (~> 5.1)
|
15
15
|
tzinfo (~> 1.1)
|
16
16
|
ast (2.3.0)
|
17
17
|
coderay (1.1.1)
|
18
|
-
concurrent-ruby (1.0.
|
18
|
+
concurrent-ruby (1.0.5)
|
19
19
|
diff-lcs (1.3)
|
20
|
-
domain_name (0.5.
|
20
|
+
domain_name (0.5.20170223)
|
21
21
|
unf (>= 0.0.5, < 1.0.0)
|
22
22
|
dotenv (2.2.0)
|
23
23
|
http-cookie (1.0.3)
|
24
24
|
domain_name (~> 0.5)
|
25
|
-
i18n (0.8.
|
25
|
+
i18n (0.8.1)
|
26
26
|
mechanize (2.7.5)
|
27
27
|
domain_name (~> 0.5, >= 0.5.1)
|
28
28
|
http-cookie (~> 1.0)
|
@@ -80,7 +80,7 @@ GEM
|
|
80
80
|
slop
|
81
81
|
ruby-progressbar (1.8.1)
|
82
82
|
slop (3.6.0)
|
83
|
-
thread_safe (0.3.
|
83
|
+
thread_safe (0.3.6)
|
84
84
|
tzinfo (1.2.2)
|
85
85
|
thread_safe (~> 0.1)
|
86
86
|
unf (0.1.4)
|
@@ -101,4 +101,4 @@ DEPENDENCIES
|
|
101
101
|
ruboty-dmm!
|
102
102
|
|
103
103
|
BUNDLED WITH
|
104
|
-
1.14.
|
104
|
+
1.14.6
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Ruboty DMM
|
4
4
|
|
5
5
|
## What is Ruboty DMM
|
6
|
-
Ruboty DMM is a notifying rankings for DMM.R18's Japanese doujin CG.
|
6
|
+
Ruboty DMM is a notifying rankings for DMM.R18's Japanese doujin CG on Slack.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
On your gemfile:
|
@@ -39,10 +39,10 @@ gem 'ruboty-cron'
|
|
39
39
|
Deployed after, register a task.
|
40
40
|
|
41
41
|
```
|
42
|
-
@ruboty add job "
|
42
|
+
@ruboty add job "0 21 * * *" @ruboty dmm cg 24
|
43
43
|
```
|
44
44
|
|
45
|
-
Notify the 24-hour ranking at every 9 pm.
|
45
|
+
Notify the 24-hour ranking for CG genre at every 9 pm.
|
46
46
|
|
47
47
|
|
48
48
|
## Thanks
|
data/doc/ja/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Ruboty DMM
|
4
4
|
|
5
5
|
## Ruboty DMMとは
|
6
|
-
Ruboty DMMはDMM.R18
|
6
|
+
Ruboty DMMはDMM.R18のランキングをSlackに通知するためのボットです。
|
7
7
|
現在は同人誌のみになっています。
|
8
8
|
|
9
9
|
## インストール
|
@@ -41,10 +41,10 @@ gem 'ruboty-cron'
|
|
41
41
|
deploy後タスクを登録します。
|
42
42
|
|
43
43
|
```
|
44
|
-
@ruboty add job "
|
44
|
+
@ruboty add job "0 21 * * *" @ruboty dmm cg 24
|
45
45
|
```
|
46
46
|
|
47
|
-
ruboty-cron
|
47
|
+
ruboty-cronを使ってCGジャンルのランキングを毎日9時に通知することが出来ます。
|
48
48
|
|
49
49
|
## 謝辞
|
50
50
|
ruboty, ruboty-cronを作ってくれた[r7kamura氏](https://github.com/r7kamura)に感謝
|
@@ -3,11 +3,27 @@ module Ruboty
|
|
3
3
|
module Actions
|
4
4
|
class Messenger < Ruboty::Actions::Base
|
5
5
|
def call
|
6
|
-
|
7
|
-
message.
|
6
|
+
attachments = Ruboty::DMM::Ranking.new(submedia: message.match_data[:submedia], term: message.match_data[:term]).call
|
7
|
+
term = term_converter(message.match_data[:term])
|
8
|
+
message.reply("#{term}の本日のランキングです。", attachments: attachments)
|
8
9
|
rescue => exception
|
9
10
|
message.reply("Failed by #{exception.class}")
|
10
11
|
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def term_converter(term)
|
16
|
+
case term
|
17
|
+
when '24'
|
18
|
+
'24時間'
|
19
|
+
when 'weekly'
|
20
|
+
'週間'
|
21
|
+
when 'monthly'
|
22
|
+
'月間'
|
23
|
+
when 'total'
|
24
|
+
'全体'
|
25
|
+
end
|
26
|
+
end
|
11
27
|
end
|
12
28
|
end
|
13
29
|
end
|
data/lib/ruboty/dmm/agent.rb
CHANGED
data/lib/ruboty/dmm/ranking.rb
CHANGED
@@ -2,7 +2,7 @@ module Ruboty
|
|
2
2
|
module DMM
|
3
3
|
class Ranking
|
4
4
|
BASE_URL = 'http://www.dmm.co.jp'.freeze
|
5
|
-
|
5
|
+
COLORS = %w(7acc28 9dcc28 cc2828 cc6e28 28a9cc 3428cc cc28b4 c0cc28 2886cc 28cca9).map { |hex| "##{hex}" }.freeze
|
6
6
|
|
7
7
|
def initialize(arguments)
|
8
8
|
@term = discriminate_term(arguments[:term])
|
@@ -15,11 +15,11 @@ module Ruboty
|
|
15
15
|
books = page.search('.rank-rankListItem.fn-setPurchaseChange').map do |element|
|
16
16
|
[
|
17
17
|
element.search('.rank-name').first.text.strip,
|
18
|
+
element.search('img').last.attributes['src'].value,
|
18
19
|
"#{BASE_URL}#{element.search('.rank-name').first.search('a').first.attributes.first[1].value}"
|
19
20
|
]
|
20
21
|
end
|
21
|
-
|
22
|
-
ranking.join("\n\n")
|
22
|
+
books.take(10).zip(COLORS).map.with_index(1) { |((title, image, url), color), rank| { title: "#{rank}位: #{title}", title_link: url, image_url: image, color: color } }
|
23
23
|
end
|
24
24
|
|
25
25
|
private
|
data/lib/ruboty/dmm/version.rb
CHANGED
@@ -1,18 +1,21 @@
|
|
1
1
|
describe Ruboty::DMM::Ranking do
|
2
|
-
let(:
|
2
|
+
let(:attachments) { described_class.new(arguments).call }
|
3
|
+
|
3
4
|
let(:submedia) { 'cg' }
|
4
5
|
let(:arguments) { { submedia: submedia, term: term } }
|
5
6
|
|
6
7
|
describe '#call' do
|
7
8
|
context 'with 24 argument' do
|
8
|
-
subject {
|
9
|
+
subject { attachments }
|
10
|
+
|
9
11
|
let(:term) { '24' }
|
10
12
|
|
11
13
|
it { is_expected.not_to be_empty }
|
14
|
+
it { is_expected.to all(include(:title, :title_link, :image_url, :color)) }
|
12
15
|
end
|
13
16
|
|
14
17
|
context 'with not registered argument' do
|
15
|
-
subject { -> {
|
18
|
+
subject { -> { attachments } }
|
16
19
|
|
17
20
|
let(:term) { 'hoge' }
|
18
21
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-dmm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Satoshi Ohmori
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruboty
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- ".rspec"
|
120
120
|
- ".rubocop.yml"
|
121
121
|
- ".travis.yml"
|
122
|
+
- CHANGELOG.md
|
122
123
|
- Gemfile
|
123
124
|
- Gemfile.lock
|
124
125
|
- LICENSE.txt
|