ruboty-sonar 1.0.0 → 1.0.1

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: fb26a94550171751a97ee20bfde93a8ccd0304d4
4
- data.tar.gz: a420cc9b6b9daec5454f94eb3951253ea1cf94f2
3
+ metadata.gz: d3741cfddd2004d9d8adfa3cf418a58621f68b59
4
+ data.tar.gz: 36665bffed686a1deddf1c8196931fc9ec9cc43a
5
5
  SHA512:
6
- metadata.gz: dc2e06c3c9286e3771d76d441b0c68b96626712c537a1fcde3f9cf0a060e0006c424106b6ac6cde420dbe5cd56220f108c8b9dcea87c2c8ea0fe324e6ae5f168
7
- data.tar.gz: 12f2f354aea7ebb48abc264643bf79a16f980936b22c83333d795149009389b7b4c9092ffc67835b101b552e69c16df246c213b28cf347467e2127530c0138b6
6
+ metadata.gz: cfcd7475cb13c9021ebc9e2b55e942becd00fe1d04d0ec7240fe2b5deb04848b0a72e90d9a7327ceb6aa13f109cd6bf35970bf6db6edefafe66359fceb4654df
7
+ data.tar.gz: ee2c99ad8ce8206e806db0665c168eea59c5641f71ed77c57dcd28e5fdad7936512daf899c5b8eaa834f230706c8ddb38e2472556d8daa505005594442fa87cb
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ ## v.1.0.1
2
+ 2015/01/05
3
+
4
+ ### Update Feature
5
+ * Fix search (Enable Paging)
6
+
7
+ ## v.1.0.0
8
+ 2014/12/02
9
+
10
+ * first release
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  RubotySonar search ruboty plugin gems.
4
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/ruboty-sonar.svg)](http://badge.fury.io/rb/ruboty-sonar)
5
6
  [![Build Status](https://travis-ci.org/tbpgr/ruboty-sonar.png?branch=master)](https://travis-ci.org/tbpgr/ruboty-sonar)
6
7
  [![Coverage Status](https://coveralls.io/repos/tbpgr/ruboty-sonar/badge.png)](https://coveralls.io/r/tbpgr/ruboty-sonar)
7
8
 
@@ -1,4 +1,4 @@
1
1
  # RubotySonar
2
2
  module RubotySonar
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.1'
4
4
  end
data/lib/ruboty-sonar.rb CHANGED
@@ -1,11 +1,38 @@
1
1
  # encoding: utf-8
2
2
  require 'gems'
3
+ require 'date'
4
+ require 'gems/configuration'
5
+ require 'gems/request'
6
+ require 'json'
7
+
8
+ # open class for paging
9
+ module Gems
10
+ class Client
11
+ include Gems::Request
12
+ def search_with_page(query, page)
13
+ response = get('/api/v1/search.json', query: query, page: page.to_s)
14
+ JSON.parse(response)
15
+ end
16
+ end
17
+ end
3
18
 
4
19
  module RubotySonar
5
20
  module_function
6
21
 
7
22
  RUBOTY_SEARCH_CONDITION = 'ruboty-'
8
23
 
24
+ def self.search(query)
25
+ results = []
26
+ page = 1
27
+ loop do
28
+ ret = Gems.search_with_page(query, page)
29
+ break if ret.empty?
30
+ results += ret
31
+ page += 1
32
+ end
33
+ results
34
+ end
35
+
9
36
  def self.info(gem_name)
10
37
  gem_info = Gems.info(gem_name)
11
38
  {
@@ -18,7 +45,7 @@ module RubotySonar
18
45
  end
19
46
 
20
47
  def self.random
21
- gem_info = Gems.search(RUBOTY_SEARCH_CONDITION).sample
48
+ gem_info = search(RUBOTY_SEARCH_CONDITION).sample
22
49
  {
23
50
  name: gem_info['name'],
24
51
  desc: gem_info['info'],
@@ -29,7 +56,7 @@ module RubotySonar
29
56
  end
30
57
 
31
58
  def self.ranking(limit = 5)
32
- Gems.search(RUBOTY_SEARCH_CONDITION)
59
+ search(RUBOTY_SEARCH_CONDITION)
33
60
  .map do |e|
34
61
  {
35
62
  name: e['name'],
@@ -41,7 +68,7 @@ module RubotySonar
41
68
  end
42
69
 
43
70
  def self.author_ranking(limit = 5)
44
- Gems.search(RUBOTY_SEARCH_CONDITION)
71
+ search(RUBOTY_SEARCH_CONDITION)
45
72
  .map { |e|{ authors: e['authors'], downloads: e['downloads'] } }
46
73
  .group_by { |e| e[:authors] }
47
74
  .map do |key, values|
@@ -125,7 +125,7 @@ describe RubotySonar do
125
125
  case_before c
126
126
 
127
127
  # -- given --
128
- allow(Gems).to receive(:search).and_return(gems_mock)
128
+ allow(RubotySonar).to receive(:search).and_return(gems_mock)
129
129
 
130
130
  # -- when --
131
131
  actual = RubotySonar.random
@@ -208,7 +208,7 @@ describe RubotySonar do
208
208
  case_before c
209
209
 
210
210
  # -- given --
211
- allow(Gems).to receive(:search).and_return(gems_mock)
211
+ allow(RubotySonar).to receive(:search).and_return(gems_mock)
212
212
 
213
213
  # -- when --
214
214
  if c[:limit]
@@ -305,7 +305,7 @@ describe RubotySonar do
305
305
  case_before c
306
306
 
307
307
  # -- given --
308
- allow(Gems).to receive(:search).and_return(gems_mock)
308
+ allow(RubotySonar).to receive(:search).and_return(gems_mock)
309
309
 
310
310
  # -- when --
311
311
  if c[:limit]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-sonar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - tbpgr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-02 00:00:00.000000000 Z
11
+ date: 2015-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -80,6 +80,7 @@ files:
80
80
  - .rubocop.yml
81
81
  - .rubocop_todo.yml
82
82
  - .travis.yml
83
+ - CHANGELOG.md
83
84
  - Gemfile
84
85
  - LICENSE.txt
85
86
  - README.md