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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa14f72af870cf04cf4c10673cfdb8f414703ce0
4
- data.tar.gz: 8e7e19cc83f02e9924da81bd9b0523aad50e3931
3
+ metadata.gz: fda15fa0cd044b83edd1f407159916549680bf88
4
+ data.tar.gz: 718f1e7e46b989436275044e297b1dc71902cd9b
5
5
  SHA512:
6
- metadata.gz: 0300734c25bcdef6446942b1943ea6f1c2412d53181ec7e4a45f285de7cf19e2d6a032802318beb73188420f0c29d76c6f33ee707bd4c4b200fde0165034ef83
7
- data.tar.gz: 45bc19769f14d620a092fa5caa724e8f0310da02750eae60cbef29ae903bf5a80aadf3ee9876bd240533a557629c0f2e03bc1bf48a92502960afe8a75783864c
6
+ metadata.gz: afa13e3cb0bdfe390bca7695905241ca17f6604ad608e97d3ed5914bd09e852d8238a1960b05c57c71c40b1e560eec05ff697bad713f7c534cea3052a14d99e0
7
+ data.tar.gz: e2b309bf8bf345578af76fc1dc90f803ae0ad02eec90dab9fd05d10d3605277348604fb17eebdec353816714b8b53180da45a9da0348c5a53996e03d058ef3f3
@@ -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
@@ -3,6 +3,5 @@ before_install:
3
3
  - gem update --system 2.1.11
4
4
  - gem --version
5
5
  rvm:
6
- - 1.9.3
7
6
  - 2.0.0
8
7
  - 2.1
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
- $ qiitam a tbpgr
61
+ $ qiita_scouter a tbpgr
58
62
  ユーザー名: tbpgr 戦闘力: 101717 攻撃力: 10780 知力: 87010 すばやさ: 3927
59
63
  ~~~
60
64
 
61
65
  または
62
66
 
63
67
  ~~~bash
64
- $ qiitam analyze tbpgr
68
+ $ qiita_scouter analyze tbpgr
65
69
  ユーザー名: tbpgr 戦闘力: 101717 攻撃力: 10780 知力: 87010 すばやさ: 3927
66
70
  ~~~
67
71
 
@@ -1,8 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
3
 
4
- require 'qiita_scouter_core'
5
- require 'qiita_scouter/version'
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
@@ -1,11 +1,11 @@
1
1
  module QiitaScouter
2
2
  # QiitaScouter::Article
3
3
  class Article
4
- attr_accessor :tags, :stock_count
4
+ attr_accessor :tags, :likes_count
5
5
 
6
6
  def initialize(options = {})
7
7
  @tags = options['tags'].map { |e|e['name'] }
8
- @stock_count = options['stock_count']
8
+ @likes_count = options['likes_count']
9
9
  end
10
10
  end
11
11
  end
@@ -5,8 +5,8 @@ module QiitaScouter
5
5
 
6
6
  def initialize(options = {})
7
7
  @url_name = options['url_name']
8
- @followers = options['followers']
9
- @items = options['items']
8
+ @followers = options['followers_count']
9
+ @items = options['items_count']
10
10
  end
11
11
  end
12
12
  end
@@ -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/v1/users/%s/items?page=%s&per_page=%s'
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
 
@@ -1,4 +1,4 @@
1
1
  # QiitaScouter
2
2
  module QiitaScouter
3
- VERSION = '0.0.1'
3
+ VERSION = '0.1.0'
4
4
  end
@@ -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
- stock_count = articles.map(&:stock_count).reduce(&:+)
15
- @stock_rate = stock_count / 10
14
+ likes_count = articles.map(&:likes_count).reduce(&:+)
15
+ @likes_rate = likes_count / 10
16
16
  end
17
17
 
18
18
  # 攻撃力を計算
19
- # フォロワー数 × 10 × (ストック数/10)
19
+ # フォロワー数 × 10 × (いいね数/10)
20
20
  def calc_strength
21
- @followers * 10 * @stock_rate
21
+ @followers * 10 * @likes_rate
22
22
  end
23
23
 
24
24
  # 知力を計算
25
- # 記事数 × 5 × (ストック数/10)
25
+ # 記事数 × 5 × (いいね数/10)
26
26
  def calc_intelligence
27
- @items * 5 * @stock_rate
27
+ @items * 5 * @likes_rate
28
28
  end
29
29
 
30
30
  # すばやさを計算
31
- # Tag数 × (ストック数/10)
31
+ # Tag数 × (いいね数/10)
32
32
  def calc_quickness
33
- @tags * @stock_rate
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/v1/users/%s'
10
+ QIITA_URL = 'https://qiita.com/api/v2/users/%s'
11
11
 
12
12
  def load(target_user)
13
13
  @target_user = target_user
@@ -17,10 +17,10 @@ describe QiitaScouter::Article do
17
17
  'versions' => []
18
18
  }
19
19
  ],
20
- 'stock_count' => 2
20
+ 'likes_count' => 2
21
21
  },
22
22
  expected_tags: ['Ruby'],
23
- expected_stock_count: 2
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
- actual_stock_count = article.stock_count
37
+ actual_likes_count = article.likes_count
38
38
 
39
39
  # -- then --
40
40
  expect(actual_tags).to eq(c[:expected_tags])
41
- expect(actual_stock_count).to eq(c[:expected_stock_count])
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
- 'stock_count' => 25
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
- 'stock_count' => 25
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
- 'stock_count' => 25
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
- 'stock_count' => 25
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
- 'stock_count' => 32
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
- 'stock_count' => 25
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
- 'stock_count' => 25
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
- 'stock_count' => 25
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
- 'stock_count' => 32
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
- 'stock_count' => 25
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
- 'stock_count' => 25
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
- 'stock_count' => 1
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
- 'stock_count' => 2
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.stock_count }
262
+ qiita_scouter_articles.each { |e|total += e.likes_count }
263
263
 
264
264
  # -- then --
265
265
  expect(total).to eq(c[:expected])
@@ -11,8 +11,8 @@ describe QiitaScouter::User do
11
11
  case_title: 'valid case',
12
12
  init: {
13
13
  'url_name' => 'tbpgr',
14
- 'followers' => 10,
15
- 'items' => 20
14
+ 'followers_count' => 10,
15
+ 'items_count' => 20
16
16
  },
17
17
  expected_url_name: 'tbpgr',
18
18
  expected_followers: 10,
@@ -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
- 'followers' => 10,
13
- 'items' => 20
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
- 'stock_count' => 25
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
- 'stock_count' => 32
28
+ 'likes_count' => 32
29
29
  )
30
30
  ])
31
31
 
@@ -25,8 +25,8 @@ describe QiitaScouter::QiitaUserJsonLoader do
25
25
  <<-EOS
26
26
  {"id":43480,
27
27
  "url_name":"tbpgr",
28
- "followers":14,
29
- "items":226
28
+ "followers_count":14,
29
+ "items_count":226
30
30
  }
31
31
  EOS
32
32
  end
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.1
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: 2014-09-16 00:00:00.000000000 Z
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: