dmm-crawler 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: 5df41735d4f8eedf776285760e2cc02e4bcc7c39
4
- data.tar.gz: 85f963c4432c166a3d5b9896099babaffc9cd407
3
+ metadata.gz: b2a971f680dc60f0a06721a2a0c6b29f1f06aced
4
+ data.tar.gz: c36967cc3cc6cc8c7a72283c28905e6db4b18d20
5
5
  SHA512:
6
- metadata.gz: 79819ff75becdf9790590491d15afc27f641c2c61b68c9a8f5049fc971121eebc6b4894d114ecec719d62497f8eb5cd6e45d7260d1b31736d19b63f7cdb3f1d8
7
- data.tar.gz: bfe581c5bff9f8a69910fac9821ff86e9822df122a409cdae86199229db302ccc4885d337479ac559dd9db2d53dc97f0d9c84b57cd08ea0e8500033c2845da70
6
+ metadata.gz: 853c15408188b05ee7be37d1bc57e6f478c893253f3c0979c09f7c9adfd589a611253d280cdce49883ba0d3625204db6292906fe4fc7b111fe372e15e5811feb
7
+ data.tar.gz: 2eed407e8d1de2ec579f59ebe9ef8e93dc99a5b846e5ca60f904e845eaf7751b9ac48068ffef2cc6d1bb2f8591afd172511ccc679c1da35bc7227503d5928df5
@@ -0,0 +1,8 @@
1
+ # Change logs
2
+
3
+ ## v0.0.2
4
+ - Write docs for dmm-crawler.
5
+ - Add a function to fetch tags for the title.
6
+
7
+ ## v0.0.1
8
+ - Implement fetch the ranking for the DMM.R18's rankings.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dmm-crawler (0.0.1)
4
+ dmm-crawler (0.0.2)
5
5
  mechanize
6
6
 
7
7
  GEM
@@ -0,0 +1,50 @@
1
+ :us: [:jp:](./doc/ja/README.md) [![Build Status](https://travis-ci.org/sachin21/dmm-crawler.svg?branch=master)](https://travis-ci.org/sachin21/dmm-crawler) ![Gem Version](https://badge.fury.io/rb/dmm-crawler.svg) [![Build Status](https://travis-ci.org/sachin21/dmm-crawler.svg?branch=master)](https://travis-ci.org/sachin21/dmm-crawler) [![Code Climate](https://codeclimate.com/github/sachin21/dmm-crawler/badges/gpa.svg)](https://codeclimate.com/github/sachin21/dmm-crawler) [![Gem](https://img.shields.io/gem/dt/dmm-crawler.svg)](https://rubygems.org/gems/dmm-crawler)
2
+
3
+ # DMM Crawler
4
+
5
+ ## What is DMM Crawler
6
+
7
+ Show DMM and DMM.R18's crawled data. Now, All rankings for doujin is crawlable.
8
+
9
+ ## Installation
10
+
11
+ On your gemfile.
12
+
13
+ ```
14
+ gem 'dmm-crawler'
15
+ ```
16
+
17
+ ## Usage
18
+ From the bot in invited Slack's room.
19
+
20
+ ```ruby
21
+ require 'dmm-crawler'
22
+
23
+ include DMMCrawler
24
+
25
+ args = {
26
+ term: '24',
27
+ submedia: 'cg'
28
+ }
29
+
30
+ Ranking.new(args).books
31
+
32
+ # =>
33
+ # {
34
+ # title: "title",
35
+ # url: 'URL for title',
36
+ # image_url: 'Link to title's main image',
37
+ # tags: ['tag1', 'tag2']
38
+ # }
39
+ ```
40
+
41
+ For example, Above command will show the doujin cg 24's ranking.
42
+
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create new Pull Request
@@ -0,0 +1,48 @@
1
+ [:us:](../../README.md) :jp: [![Build Status](https://travis-ci.org/sachin21/dmm-crawler.svg?branch=master)](https://travis-ci.org/sachin21/dmm-crawler) ![Gem Version](https://badge.fury.io/rb/dmm-crawler.svg) [![Build Status](https://travis-ci.org/sachin21/dmm-crawler.svg?branch=master)](https://travis-ci.org/sachin21/dmm-crawler) [![Code Climate](https://codeclimate.com/github/sachin21/dmm-crawler/badges/gpa.svg)](https://codeclimate.com/github/sachin21/dmm-crawler) [![Gem](https://img.shields.io/gem/dt/dmm-crawler.svg)](https://rubygems.org/gems/dmm-crawler)
2
+
3
+ # DMM Crawler
4
+
5
+ ## DMM Crawlerとは
6
+ DMM.R18のクロールしたデータを取得するgemです。現在、**同人**のランキングにのみ対応しております。
7
+
8
+ ## インストール
9
+
10
+ Gemfileに以下を追記してください。
11
+
12
+ ```
13
+ gem 'dmm-crawler'
14
+ ```
15
+
16
+ ## 使い方
17
+ データを使いたい`.rb`ファイルで以下を実行したらクロールしたデータが取得出来ます。
18
+
19
+ ```ruby
20
+ require 'dmm-crawler'
21
+
22
+ include DMMCrawler
23
+
24
+ args = {
25
+ term: '24',
26
+ submedia: 'cg'
27
+ }
28
+
29
+ Ranking.new(args).books
30
+
31
+ # =>
32
+ # {
33
+ # title: "タイトル",
34
+ # url: '作品のURL',
35
+ # image_url: '作品のメイン画像へのURL',
36
+ # tags: ['タグ1', 'タグ2']
37
+ # }
38
+ ```
39
+
40
+ この例ではCG作品の24時間ランキングのデータを取得しています。
41
+
42
+ ## コントリビューション
43
+
44
+ 1. フォークする
45
+ 2. 新しくブランチを切る (`git checkout -b my-new-feature`)
46
+ 3. 変更をコミットする (`git commit -am 'Add some feature'`)
47
+ 4. 変更をプッシュする (`git push origin my-new-feature`)
48
+ 5. プルリクエストを投げる :+1:
@@ -1,7 +1,6 @@
1
1
  module DMMCrawler
2
2
  class Ranking
3
3
  BASE_URL = 'http://www.dmm.co.jp'.freeze
4
- COLORS = %w(7acc28 9dcc28 cc2828 cc6e28 28a9cc 3428cc cc28b4 c0cc28 2886cc 28cca9).map { |hex| "##{hex}" }.freeze
5
4
 
6
5
  def initialize(arguments)
7
6
  @term = discriminate_term(arguments[:term])
@@ -15,10 +14,12 @@ module DMMCrawler
15
14
  [
16
15
  element.search('.rank-name').first.text.strip,
17
16
  element.search('img').last.attributes['src'].value,
18
- "#{BASE_URL}#{element.search('.rank-name').first.search('a').first.attributes.first[1].value}"
17
+ "#{BASE_URL}#{element.search('.rank-name').first.search('a').first.attributes.first[1].value}",
18
+ element.search('.rank-labelListItem').map { |e| e.search('a').text.strip }
19
19
  ]
20
20
  end
21
- 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 } }
21
+
22
+ books.map.with_index(1) { |(title, image, url, tags), rank| { title: "#{rank}位: #{title}", url: url, image_url: image, tags: tags } }
22
23
  end
23
24
 
24
25
  private
@@ -1,3 +1,3 @@
1
1
  module DMMCrawler
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
@@ -5,13 +5,23 @@ describe DMMCrawler::Ranking do
5
5
  let(:arguments) { { submedia: submedia, term: term } }
6
6
 
7
7
  describe '#books' do
8
+ after { sleep 2 }
9
+
10
+ context 'with length' do
11
+ subject { attachments.length }
12
+
13
+ let(:term) { '24' }
14
+
15
+ it { is_expected.to be 20 }
16
+ end
17
+
8
18
  context 'with 24 argument' do
9
19
  subject { attachments }
10
20
 
11
21
  let(:term) { '24' }
12
22
 
13
23
  it { is_expected.not_to be_empty }
14
- it { is_expected.to all(include(:title, :title_link, :image_url, :color)) }
24
+ it { is_expected.to all(include(:title, :url, :image_url, :tags)) }
15
25
  end
16
26
 
17
27
  context 'with not registered argument' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dmm-crawler
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
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-29 00:00:00.000000000 Z
11
+ date: 2017-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
@@ -105,11 +105,14 @@ files:
105
105
  - ".rspec"
106
106
  - ".rubocop.yml"
107
107
  - ".travis.yml"
108
+ - CHANGELOG.md
108
109
  - Gemfile
109
110
  - Gemfile.lock
110
111
  - LICENSE.txt
112
+ - README.md
111
113
  - Rakefile
112
114
  - dmm-crawler.gemspec
115
+ - doc/ja/README.md
113
116
  - lib/dmm-crawler.rb
114
117
  - lib/dmm-crawler/agent.rb
115
118
  - lib/dmm-crawler/ranking.rb