ruboty-dmm 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c68febe22711f064807924d51f16f24d97cad87d
4
- data.tar.gz: 7232934e8e2acd9d22610c4d7c92e9763ca1f81d
3
+ metadata.gz: cf81d446a430d2fb6627ee953265dacbabea461e
4
+ data.tar.gz: f689bc29fa750b263446e3b6d93d7b6acb40e206
5
5
  SHA512:
6
- metadata.gz: 7df0bc5b27bad579e016c9fbc44439b21ddf2a5008337e65d81172b561df6c82552010de6998a2c45d22a4f5c294fe18df9ee146d96de68db7bd07aa96770a7f
7
- data.tar.gz: ac28f52a803bd2c39dff72436ed56f20c6fa5ce2d00ffc473dc825072059cd91b8b757157251588b7f65c5d45cf3777013af8eadf8569aed8454634786a44868
6
+ metadata.gz: 190a1bf87326e8e1fa288e229c129238a1afcb254fbe7c9d2e1c826b7282da1dbf1e9b91b11276ee1f165e0ed9a327fad1be0221a1bbd481ff9706a69cdb75b5
7
+ data.tar.gz: fa2ca0351daf563b0863874d25a9b34af583834412af9ef1acb7b599721176f60daeb221c283e2c907f1ed6e04f8908787862ed04f2388f32792f54aa3c2a54b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruboty-dmm (0.0.1)
4
+ ruboty-dmm (0.0.2)
5
5
  mechanize
6
6
  ruboty
7
7
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- :us: [:jp:](./doc/ja/README.md) [![Build Status](https://travis-ci.org/sachin21/ruboty-dmm.svg?branch=master)](https://travis-ci.org/sachin21/ruboty-dmm)
1
+ :us: [:jp:](./doc/ja/README.md) [![Build Status](https://travis-ci.org/sachin21/ruboty-dmm.svg?branch=master)](https://travis-ci.org/sachin21/ruboty-dmm) ![Gem Version](https://badge.fury.io/rb/ruboty-dmm.svg) [![Build Status](https://travis-ci.org/sachin21/ruboty-dmm.svg?branch=master)](https://travis-ci.org/sachin21/ruboty-dmm) [![Code Climate](https://codeclimate.com/github/sachin21/ruboty-dmm/badges/gpa.svg)](https://codeclimate.com/github/sachin21/ruboty-dmm) [![Gem](https://img.shields.io/gem/dt/ruboty-dmm.svg)](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 ranking 24
21
+ @ruboty dmm cg 24
22
22
  --- output ---
23
23
  ```
24
24
 
25
- The command can be putting the argument for 24, weekly, monthly, total.
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.
@@ -1,4 +1,4 @@
1
- :jp: [![Build Status](https://travis-ci.org/sachin21/ruboty-dmm.svg?branch=master)](https://travis-ci.org/sachin21/ruboty-dmm)
1
+ [:us:](../../README.md) :jp: [![Build Status](https://travis-ci.org/sachin21/ruboty-dmm.svg?branch=master)](https://travis-ci.org/sachin21/ruboty-dmm) ![Gem Version](https://badge.fury.io/rb/ruboty-dmm.svg) [![Build Status](https://travis-ci.org/sachin21/ruboty-dmm.svg?branch=master)](https://travis-ci.org/sachin21/ruboty-dmm) [![Code Climate](https://codeclimate.com/github/sachin21/ruboty-dmm/badges/gpa.svg)](https://codeclimate.com/github/sachin21/ruboty-dmm) [![Gem](https://img.shields.io/gem/dt/ruboty-dmm.svg)](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 ranking 24
22
+ @ruboty dmm cg 24
23
23
  --- output ---
24
24
  ```
25
25
 
26
- このコマンドは以下の4種類の引数を投げることが可能です。
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.body).call
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}")
@@ -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 = '/dc/doujin/-/ranking-all/=/sort=popular/submedia=cg/term='.freeze
5
+ RANKING_URL =
6
6
 
7
- def initialize(body)
8
- @type = discriminate_argument(body)
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("#{BASE_URL}#{RANKING_URL}#{@type.upcase}")
35
+ @agent.get(@url)
38
36
  end
39
37
 
40
- def discriminate_argument(body)
41
- if body =~ /24/
42
- '24'
43
- elsif body =~ /weekly/
44
- 'weekly'
45
- elsif body =~ /monthly/
46
- 'monthly'
47
- elsif body =~ /total/
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
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module DMM
3
- VERSION = '0.0.1'.freeze
3
+ VERSION = '0.0.2'.freeze
4
4
  end
5
5
  end
@@ -4,7 +4,7 @@ module Ruboty
4
4
  DESCRIPTION = 'Fetch rankings for DMM R18 only searchable for 24, weekly, monthly, total'.freeze
5
5
 
6
6
  on(
7
- /dmm ranking (?<type>.*?)\z/,
7
+ /dmm (?<submedia>.*?) (?<term>.*?)\z/,
8
8
  name: 'messenger',
9
9
  description: DESCRIPTION
10
10
  )
@@ -1,11 +1,12 @@
1
1
  describe Ruboty::DMM::Ranking do
2
- let(:instance) { described_class.new(command).call }
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(:command) { '@ruboty dmm ranking hoge' }
17
+ let(:term) { 'hoge' }
17
18
 
18
19
  it { is_expected.to raise_error(TypeError) }
19
20
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-dmm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi Ohmori