ruboty-dmm 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf81d446a430d2fb6627ee953265dacbabea461e
4
- data.tar.gz: f689bc29fa750b263446e3b6d93d7b6acb40e206
3
+ metadata.gz: a8eb0d93dcba3e0825cf3ce4392da8190b24b9d6
4
+ data.tar.gz: 8c7ee10f8d1a0ce550f3a985492dd988c9315598
5
5
  SHA512:
6
- metadata.gz: 190a1bf87326e8e1fa288e229c129238a1afcb254fbe7c9d2e1c826b7282da1dbf1e9b91b11276ee1f165e0ed9a327fad1be0221a1bbd481ff9706a69cdb75b5
7
- data.tar.gz: fa2ca0351daf563b0863874d25a9b34af583834412af9ef1acb7b599721176f60daeb221c283e2c907f1ed6e04f8908787862ed04f2388f32792f54aa3c2a54b
6
+ metadata.gz: c9fcc39e3f8296f07d9f3c46b01a732d6a2b810ade055a43238536fa767e6d5c5c842711855545cab2fbcb51b2a0b9f4c3aec9619c2255160ba31815a53043c9
7
+ data.tar.gz: d767603ed172abe30be1bed464dd922027122f80437022463e8c698350dd4e735139c1f89d65d1b82de03b4a27452622286e15d60c7e37db8b4a445d41420efb
@@ -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.
@@ -1,28 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruboty-dmm (0.0.2)
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.1)
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.4)
18
+ concurrent-ruby (1.0.5)
19
19
  diff-lcs (1.3)
20
- domain_name (0.5.20161129)
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.0)
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.5)
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.4
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 "* 21 * * *" @ruboty dmm ranking 24
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
@@ -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 "* 21 * * *" @ruboty dmm ranking 24
44
+ @ruboty add job "0 21 * * *" @ruboty dmm cg 24
45
45
  ```
46
46
 
47
- ruboty-cronを使って毎日9時に通知することが出来ます。
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
- ranking = Ruboty::DMM::Ranking.new(submedia: message.match_data[:submedia], term: message.match_data[:term]).call
7
- message.reply(ranking)
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
@@ -5,8 +5,6 @@ module Ruboty
5
5
 
6
6
  def initialize
7
7
  @agent = ::Mechanize.new
8
- @agent.user_agent_alias = 'Mac Safari'
9
- @agent.ignore_bad_chunking = true
10
8
  @agent.request_headers = { 'Accept-Encoding' => '' }
11
9
  @agent.ignore_bad_chunking = true
12
10
  end
@@ -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
- RANKING_URL =
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
- ranking = books.take(10).map.with_index(1) { |book, index| "#{index}位\nタイトル: #{book.first}\nURL: #{book.last}" }
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
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module DMM
3
- VERSION = '0.0.2'.freeze
3
+ VERSION = '0.0.3'.freeze
4
4
  end
5
5
  end
@@ -1,18 +1,21 @@
1
1
  describe Ruboty::DMM::Ranking do
2
- let(:instance) { described_class.new(arguments).call }
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 { instance }
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 { -> { instance.size } }
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.2
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-02-24 00:00:00.000000000 Z
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