qiita_scouter 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -5
- data/.travis.yml +0 -1
- data/README.md +7 -3
- data/bin/qiita_scouter +8 -2
- data/lib/models/article.rb +2 -2
- data/lib/models/user.rb +2 -2
- data/lib/qiita_items_json_loader.rb +1 -1
- data/lib/qiita_scouter/version.rb +1 -1
- data/lib/qiita_scouter_calculator.rb +8 -8
- data/lib/qiita_user_json_loader.rb +1 -1
- data/spec/models/article_spec.rb +4 -4
- data/spec/models/articles_spec.rb +14 -14
- data/spec/models/user_spec.rb +2 -2
- data/spec/qiita_scouter_calculator_spec.rb +4 -4
- data/spec/qiita_user_json_loader_spec.rb +2 -2
- 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: fda15fa0cd044b83edd1f407159916549680bf88
|
4
|
+
data.tar.gz: 718f1e7e46b989436275044e297b1dc71902cd9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afa13e3cb0bdfe390bca7695905241ca17f6604ad608e97d3ed5914bd09e852d8238a1960b05c57c71c40b1e560eec05ff697bad713f7c534cea3052a14d99e0
|
7
|
+
data.tar.gz: e2b309bf8bf345578af76fc1dc90f803ae0ad02eec90dab9fd05d10d3605277348604fb17eebdec353816714b8b53180da45a9da0348c5a53996e03d058ef3f3
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
AsciiComments:
|
2
|
-
Enabled: false
|
3
|
-
|
4
|
-
Semicolon:
|
5
|
-
Enabled: false
|
1
|
+
AsciiComments:
|
2
|
+
Enabled: false
|
3
|
+
|
4
|
+
Semicolon:
|
5
|
+
Enabled: false
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
# QiitaScouter
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/qiita_scouter.svg)](http://badge.fury.io/rb/qiita_scouter)
|
4
|
+
[![Build Status](https://travis-ci.org/tbpgr/qiita_scouter.png?branch=master)](https://travis-ci.org/tbpgr/qiita_scouter)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/tbpgr/qiita_scouter/badge.png)](https://coveralls.io/r/tbpgr/qiita_scouter)
|
6
|
+
|
3
7
|
Qiita Scouter
|
4
8
|
|
5
9
|
## 概要
|
6
10
|
|
7
|
-
Qiita
|
11
|
+
Qiitaの記事投稿、フォロワー、タグ、いいね数を戦闘力化します
|
8
12
|
|
9
13
|
## 動作確認済み環境
|
10
14
|
* ruby 2.0.0 環境にて動作確認済み
|
@@ -54,14 +58,14 @@ Options:
|
|
54
58
|
または
|
55
59
|
|
56
60
|
~~~bash
|
57
|
-
$
|
61
|
+
$ qiita_scouter a tbpgr
|
58
62
|
ユーザー名: tbpgr 戦闘力: 101717 攻撃力: 10780 知力: 87010 すばやさ: 3927
|
59
63
|
~~~
|
60
64
|
|
61
65
|
または
|
62
66
|
|
63
67
|
~~~bash
|
64
|
-
$
|
68
|
+
$ qiita_scouter analyze tbpgr
|
65
69
|
ユーザー名: tbpgr 戦闘力: 101717 攻撃力: 10780 知力: 87010 すばやさ: 3927
|
66
70
|
~~~
|
67
71
|
|
data/bin/qiita_scouter
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: utf-8
|
3
3
|
|
4
|
-
|
5
|
-
require '
|
4
|
+
begin
|
5
|
+
require 'qiita_scouter_core'
|
6
|
+
require 'qiita_scouter/version'
|
7
|
+
rescue LoadError
|
8
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
9
|
+
require 'qiita_scouter_core'
|
10
|
+
require 'qiita_scouter/version'
|
11
|
+
end
|
6
12
|
require 'thor'
|
7
13
|
|
8
14
|
# rubocop:disable LineLength
|
data/lib/models/article.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module QiitaScouter
|
2
2
|
# QiitaScouter::Article
|
3
3
|
class Article
|
4
|
-
attr_accessor :tags, :
|
4
|
+
attr_accessor :tags, :likes_count
|
5
5
|
|
6
6
|
def initialize(options = {})
|
7
7
|
@tags = options['tags'].map { |e|e['name'] }
|
8
|
-
@
|
8
|
+
@likes_count = options['likes_count']
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
data/lib/models/user.rb
CHANGED
@@ -8,7 +8,7 @@ module QiitaScouter
|
|
8
8
|
# QiitaScouter::QiitaItemsJsonLoader
|
9
9
|
class QiitaItemsJsonLoader
|
10
10
|
attr_reader :user, :articles
|
11
|
-
QIITA_URL = 'https://qiita.com/api/
|
11
|
+
QIITA_URL = 'https://qiita.com/api/v2/users/%s/items?page=%s&per_page=%s'
|
12
12
|
PER_PAGE = 100
|
13
13
|
PAGE_LIMIT = 50
|
14
14
|
|
@@ -11,26 +11,26 @@ module QiitaScouter
|
|
11
11
|
@followers = user.followers
|
12
12
|
@items = user.items
|
13
13
|
@tags = articles.reduce([]) { |a, e|a += e.tags; a }.uniq.size
|
14
|
-
|
15
|
-
@
|
14
|
+
likes_count = articles.map(&:likes_count).reduce(&:+)
|
15
|
+
@likes_rate = likes_count / 10
|
16
16
|
end
|
17
17
|
|
18
18
|
# 攻撃力を計算
|
19
|
-
# フォロワー数 × 10 × (
|
19
|
+
# フォロワー数 × 10 × (いいね数/10)
|
20
20
|
def calc_strength
|
21
|
-
@followers * 10 * @
|
21
|
+
@followers * 10 * @likes_rate
|
22
22
|
end
|
23
23
|
|
24
24
|
# 知力を計算
|
25
|
-
# 記事数 × 5 × (
|
25
|
+
# 記事数 × 5 × (いいね数/10)
|
26
26
|
def calc_intelligence
|
27
|
-
@items * 5 * @
|
27
|
+
@items * 5 * @likes_rate
|
28
28
|
end
|
29
29
|
|
30
30
|
# すばやさを計算
|
31
|
-
# Tag数 × (
|
31
|
+
# Tag数 × (いいね数/10)
|
32
32
|
def calc_quickness
|
33
|
-
@tags * @
|
33
|
+
@tags * @likes_rate
|
34
34
|
end
|
35
35
|
|
36
36
|
# 戦闘力を計算
|
@@ -7,7 +7,7 @@ module QiitaScouter
|
|
7
7
|
# QiitaScouter::QiitaUserJsonLoader
|
8
8
|
class QiitaUserJsonLoader
|
9
9
|
attr_reader :target_user, :user
|
10
|
-
QIITA_URL = 'https://qiita.com/api/
|
10
|
+
QIITA_URL = 'https://qiita.com/api/v2/users/%s'
|
11
11
|
|
12
12
|
def load(target_user)
|
13
13
|
@target_user = target_user
|
data/spec/models/article_spec.rb
CHANGED
@@ -17,10 +17,10 @@ describe QiitaScouter::Article do
|
|
17
17
|
'versions' => []
|
18
18
|
}
|
19
19
|
],
|
20
|
-
'
|
20
|
+
'likes_count' => 2
|
21
21
|
},
|
22
22
|
expected_tags: ['Ruby'],
|
23
|
-
|
23
|
+
expected_likes_count: 2
|
24
24
|
}
|
25
25
|
]
|
26
26
|
|
@@ -34,11 +34,11 @@ describe QiitaScouter::Article do
|
|
34
34
|
|
35
35
|
# -- when --
|
36
36
|
actual_tags = article.tags
|
37
|
-
|
37
|
+
actual_likes_count = article.likes_count
|
38
38
|
|
39
39
|
# -- then --
|
40
40
|
expect(actual_tags).to eq(c[:expected_tags])
|
41
|
-
expect(
|
41
|
+
expect(actual_likes_count).to eq(c[:expected_likes_count])
|
42
42
|
ensure
|
43
43
|
case_after c
|
44
44
|
end
|
@@ -16,14 +16,14 @@ describe QiitaScouter::Articles do
|
|
16
16
|
{ 'name' => 'Ruby' },
|
17
17
|
{ 'name' => 'Graphviz' }
|
18
18
|
],
|
19
|
-
'
|
19
|
+
'likes_count' => 25
|
20
20
|
),
|
21
21
|
QiitaScouter::Article.new(
|
22
22
|
'tags' => [
|
23
23
|
{ 'name' => 'Ruby' },
|
24
24
|
{ 'name' => 'Graphviz' }
|
25
25
|
],
|
26
|
-
'
|
26
|
+
'likes_count' => 25
|
27
27
|
)
|
28
28
|
],
|
29
29
|
expected: 2
|
@@ -37,7 +37,7 @@ describe QiitaScouter::Articles do
|
|
37
37
|
{ 'name' => 'Ruby' },
|
38
38
|
{ 'name' => 'Graphviz' }
|
39
39
|
],
|
40
|
-
'
|
40
|
+
'likes_count' => 25
|
41
41
|
)
|
42
42
|
],
|
43
43
|
expected: 1
|
@@ -85,14 +85,14 @@ describe QiitaScouter::Articles do
|
|
85
85
|
{ 'name' => 'Ruby' },
|
86
86
|
{ 'name' => 'Graphviz' }
|
87
87
|
],
|
88
|
-
'
|
88
|
+
'likes_count' => 25
|
89
89
|
),
|
90
90
|
QiitaScouter::Article.new(
|
91
91
|
'tags' => [
|
92
92
|
{ 'name' => 'PHP' },
|
93
93
|
{ 'name' => 'Graphviz' }
|
94
94
|
],
|
95
|
-
'
|
95
|
+
'likes_count' => 32
|
96
96
|
)
|
97
97
|
]),
|
98
98
|
expected: 2
|
@@ -106,14 +106,14 @@ describe QiitaScouter::Articles do
|
|
106
106
|
{ 'name' => 'Ruby' },
|
107
107
|
{ 'name' => 'Graphviz' }
|
108
108
|
],
|
109
|
-
'
|
109
|
+
'likes_count' => 25
|
110
110
|
),
|
111
111
|
QiitaScouter::Article.new(
|
112
112
|
'tags' => [
|
113
113
|
{ 'name' => 'Ruby' },
|
114
114
|
{ 'name' => 'Graphviz' }
|
115
115
|
],
|
116
|
-
'
|
116
|
+
'likes_count' => 25
|
117
117
|
)
|
118
118
|
],
|
119
119
|
appends: QiitaScouter::Articles.new([
|
@@ -122,14 +122,14 @@ describe QiitaScouter::Articles do
|
|
122
122
|
{ 'name' => 'Ruby' },
|
123
123
|
{ 'name' => 'Graphviz' }
|
124
124
|
],
|
125
|
-
'
|
125
|
+
'likes_count' => 25
|
126
126
|
),
|
127
127
|
QiitaScouter::Article.new(
|
128
128
|
'tags' => [
|
129
129
|
{ 'name' => 'PHP' },
|
130
130
|
{ 'name' => 'Graphviz' }
|
131
131
|
],
|
132
|
-
'
|
132
|
+
'likes_count' => 32
|
133
133
|
)
|
134
134
|
]),
|
135
135
|
expected: 4
|
@@ -176,14 +176,14 @@ describe QiitaScouter::Articles do
|
|
176
176
|
{ 'name' => 'Ruby' },
|
177
177
|
{ 'name' => 'Graphviz' }
|
178
178
|
],
|
179
|
-
'
|
179
|
+
'likes_count' => 25
|
180
180
|
),
|
181
181
|
QiitaScouter::Article.new(
|
182
182
|
'tags' => [
|
183
183
|
{ 'name' => 'Ruby' },
|
184
184
|
{ 'name' => 'Graphviz' }
|
185
185
|
],
|
186
|
-
'
|
186
|
+
'likes_count' => 25
|
187
187
|
)
|
188
188
|
],
|
189
189
|
expected: 2
|
@@ -235,14 +235,14 @@ describe QiitaScouter::Articles do
|
|
235
235
|
{ 'name' => 'Ruby' },
|
236
236
|
{ 'name' => 'Graphviz' }
|
237
237
|
],
|
238
|
-
'
|
238
|
+
'likes_count' => 1
|
239
239
|
),
|
240
240
|
QiitaScouter::Article.new(
|
241
241
|
'tags' => [
|
242
242
|
{ 'name' => 'Ruby' },
|
243
243
|
{ 'name' => 'Graphviz' }
|
244
244
|
],
|
245
|
-
'
|
245
|
+
'likes_count' => 2
|
246
246
|
)
|
247
247
|
],
|
248
248
|
expected: 3
|
@@ -259,7 +259,7 @@ describe QiitaScouter::Articles do
|
|
259
259
|
|
260
260
|
# -- when --
|
261
261
|
total = 0
|
262
|
-
qiita_scouter_articles.each { |e|total += e.
|
262
|
+
qiita_scouter_articles.each { |e|total += e.likes_count }
|
263
263
|
|
264
264
|
# -- then --
|
265
265
|
expect(total).to eq(c[:expected])
|
data/spec/models/user_spec.rb
CHANGED
@@ -9,8 +9,8 @@ require 'models/articles'
|
|
9
9
|
describe QiitaScouter::Calculator do
|
10
10
|
user = QiitaScouter::User.new(
|
11
11
|
'url_name' => 'tbpgr',
|
12
|
-
'
|
13
|
-
'
|
12
|
+
'followers_count' => 10,
|
13
|
+
'items_count' => 20
|
14
14
|
)
|
15
15
|
articles = QiitaScouter::Articles.new([
|
16
16
|
QiitaScouter::Article.new(
|
@@ -18,14 +18,14 @@ describe QiitaScouter::Calculator do
|
|
18
18
|
{ 'name' => 'Ruby' },
|
19
19
|
{ 'name' => 'Graphviz' }
|
20
20
|
],
|
21
|
-
'
|
21
|
+
'likes_count' => 25
|
22
22
|
),
|
23
23
|
QiitaScouter::Article.new(
|
24
24
|
'tags' => [
|
25
25
|
{ 'name' => 'PHP' },
|
26
26
|
{ 'name' => 'Graphviz' }
|
27
27
|
],
|
28
|
-
'
|
28
|
+
'likes_count' => 32
|
29
29
|
)
|
30
30
|
])
|
31
31
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qiita_scouter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tbpgr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -158,3 +158,4 @@ test_files:
|
|
158
158
|
- spec/qiita_scouter_calculator_spec.rb
|
159
159
|
- spec/qiita_user_json_loader_spec.rb
|
160
160
|
- spec/spec_helper.rb
|
161
|
+
has_rdoc:
|