ruboty-dmm 0.0.1 → 0.0.2
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/Gemfile.lock +1 -1
- data/README.md +8 -3
- data/doc/ja/README.md +8 -7
- data/lib/ruboty/dmm/actions/messenger.rb +1 -1
- data/lib/ruboty/dmm/ranking.rb +14 -20
- data/lib/ruboty/dmm/version.rb +1 -1
- data/lib/ruboty/handlers/dmm.rb +1 -1
- data/spec/ruboty/dmm/ranking_spec.rb +5 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf81d446a430d2fb6627ee953265dacbabea461e
|
4
|
+
data.tar.gz: f689bc29fa750b263446e3b6d93d7b6acb40e206
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 190a1bf87326e8e1fa288e229c129238a1afcb254fbe7c9d2e1c826b7282da1dbf1e9b91b11276ee1f165e0ed9a327fad1be0221a1bbd481ff9706a69cdb75b5
|
7
|
+
data.tar.gz: fa2ca0351daf563b0863874d25a9b34af583834412af9ef1acb7b599721176f60daeb221c283e2c907f1ed6e04f8908787862ed04f2388f32792f54aa3c2a54b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
:us: [:jp:](./doc/ja/README.md)
|
1
|
+
:us: [:jp:](./doc/ja/README.md) [](https://travis-ci.org/sachin21/ruboty-dmm)  [](https://travis-ci.org/sachin21/ruboty-dmm) [](https://codeclimate.com/github/sachin21/ruboty-dmm) [](https://rubygems.org/gems/ruboty-dmm)
|
2
2
|
|
3
3
|
# Ruboty DMM
|
4
4
|
|
@@ -18,11 +18,16 @@ From the bot in invited Slack's room:
|
|
18
18
|
### 1. Show the 24's ranking
|
19
19
|
|
20
20
|
```
|
21
|
-
@ruboty dmm
|
21
|
+
@ruboty dmm cg 24
|
22
22
|
--- output ---
|
23
23
|
```
|
24
24
|
|
25
|
-
|
25
|
+
For example, Above command will notify the doujin cg 24's ranking.
|
26
|
+
|
27
|
+
### Available arguments
|
28
|
+
- The first argument is only available for dmm.
|
29
|
+
- The second argument is available for all, comic, cg, game, voice.
|
30
|
+
- The third argument is available for 24, weekly, monthly, total.
|
26
31
|
|
27
32
|
### 2. Register a job by ruboty-cron
|
28
33
|
Add ruboty-cron to your bot's Gemfile.
|
data/doc/ja/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
:jp: [](https://travis-ci.org/sachin21/ruboty-dmm)
|
1
|
+
[:us:](../../README.md) :jp: [](https://travis-ci.org/sachin21/ruboty-dmm)  [](https://travis-ci.org/sachin21/ruboty-dmm) [](https://codeclimate.com/github/sachin21/ruboty-dmm) [](https://rubygems.org/gems/ruboty-dmm)
|
2
2
|
|
3
3
|
# Ruboty DMM
|
4
4
|
|
@@ -19,16 +19,17 @@ gem 'ruboty-dmm'
|
|
19
19
|
### 1. 24時間ランキングの表示の仕方
|
20
20
|
|
21
21
|
```
|
22
|
-
@ruboty dmm
|
22
|
+
@ruboty dmm cg 24
|
23
23
|
--- output ---
|
24
24
|
```
|
25
25
|
|
26
|
-
|
26
|
+
例えば、上記のコマンドはdoujin cgの24ランキングを通知します。
|
27
|
+
|
28
|
+
### 仕様可能な引数
|
29
|
+
- 最初の引数はdmmのみ利用可能です。
|
30
|
+
- 二個目の引数はall, comic, cg, game, voiceのみ利用可能です。
|
31
|
+
- 三個目の引数は24, weekly, monthly, totalのみ利用可能です。
|
27
32
|
|
28
|
-
- 24
|
29
|
-
- weekly
|
30
|
-
- monthly
|
31
|
-
- total
|
32
33
|
|
33
34
|
### 2. ruboty-cronを使い、特定の時間に通知する
|
34
35
|
ruboty-cronを追加します。
|
@@ -3,7 +3,7 @@ module Ruboty
|
|
3
3
|
module Actions
|
4
4
|
class Messenger < Ruboty::Actions::Base
|
5
5
|
def call
|
6
|
-
ranking = Ruboty::DMM::Ranking.new(message.
|
6
|
+
ranking = Ruboty::DMM::Ranking.new(submedia: message.match_data[:submedia], term: message.match_data[:term]).call
|
7
7
|
message.reply(ranking)
|
8
8
|
rescue => exception
|
9
9
|
message.reply("Failed by #{exception.class}")
|
data/lib/ruboty/dmm/ranking.rb
CHANGED
@@ -2,10 +2,12 @@ module Ruboty
|
|
2
2
|
module DMM
|
3
3
|
class Ranking
|
4
4
|
BASE_URL = 'http://www.dmm.co.jp'.freeze
|
5
|
-
RANKING_URL =
|
5
|
+
RANKING_URL =
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
7
|
+
def initialize(arguments)
|
8
|
+
@term = discriminate_term(arguments[:term])
|
9
|
+
@submedia = discriminate_submedia(arguments[:submedia])
|
10
|
+
@url = "#{BASE_URL}/dc/doujin/-/ranking-all/=/sort=popular/submedia=#{@submedia}/term=#{@term}"
|
9
11
|
@agent = Agent.new.agent
|
10
12
|
end
|
11
13
|
|
@@ -22,10 +24,6 @@ module Ruboty
|
|
22
24
|
|
23
25
|
private
|
24
26
|
|
25
|
-
def client
|
26
|
-
@client ||= Rdmm::Client.new(credentials)
|
27
|
-
end
|
28
|
-
|
29
27
|
def credentials
|
30
28
|
{
|
31
29
|
api_id: ENV['API_ID'],
|
@@ -34,21 +32,17 @@ module Ruboty
|
|
34
32
|
end
|
35
33
|
|
36
34
|
def page
|
37
|
-
@agent.get(
|
35
|
+
@agent.get(@url)
|
38
36
|
end
|
39
37
|
|
40
|
-
def
|
41
|
-
if
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
'total'
|
49
|
-
else
|
50
|
-
raise TypeError
|
51
|
-
end
|
38
|
+
def discriminate_term(term)
|
39
|
+
return term if %w(24 weekly monthly total).include?(term)
|
40
|
+
raise TypeError
|
41
|
+
end
|
42
|
+
|
43
|
+
def discriminate_submedia(submedia)
|
44
|
+
return submedia if %w(all weekly cg game voice).include?(submedia)
|
45
|
+
raise TypeError
|
52
46
|
end
|
53
47
|
end
|
54
48
|
end
|
data/lib/ruboty/dmm/version.rb
CHANGED
data/lib/ruboty/handlers/dmm.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
describe Ruboty::DMM::Ranking do
|
2
|
-
let(:instance) { described_class.new(
|
2
|
+
let(:instance) { described_class.new(arguments).call }
|
3
|
+
let(:submedia) { 'cg' }
|
4
|
+
let(:arguments) { { submedia: submedia, term: term } }
|
3
5
|
|
4
6
|
describe '#call' do
|
5
7
|
context 'with 24 argument' do
|
6
8
|
subject { instance }
|
7
|
-
|
8
|
-
let(:command) { '@ruboty dmm ranking 24' }
|
9
|
+
let(:term) { '24' }
|
9
10
|
|
10
11
|
it { is_expected.not_to be_empty }
|
11
12
|
end
|
@@ -13,7 +14,7 @@ describe Ruboty::DMM::Ranking do
|
|
13
14
|
context 'with not registered argument' do
|
14
15
|
subject { -> { instance.size } }
|
15
16
|
|
16
|
-
let(:
|
17
|
+
let(:term) { 'hoge' }
|
17
18
|
|
18
19
|
it { is_expected.to raise_error(TypeError) }
|
19
20
|
end
|