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 +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +1 -0
- data/lib/ruboty-sonar/version.rb +1 -1
- data/lib/ruboty-sonar.rb +30 -3
- data/spec/ruboty-sonar_spec.rb +3 -3
- 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: d3741cfddd2004d9d8adfa3cf418a58621f68b59
|
4
|
+
data.tar.gz: 36665bffed686a1deddf1c8196931fc9ec9cc43a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfcd7475cb13c9021ebc9e2b55e942becd00fe1d04d0ec7240fe2b5deb04848b0a72e90d9a7327ceb6aa13f109cd6bf35970bf6db6edefafe66359fceb4654df
|
7
|
+
data.tar.gz: ee2c99ad8ce8206e806db0665c168eea59c5641f71ed77c57dcd28e5fdad7936512daf899c5b8eaa834f230706c8ddb38e2472556d8daa505005594442fa87cb
|
data/CHANGELOG.md
ADDED
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
|
|
data/lib/ruboty-sonar/version.rb
CHANGED
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 =
|
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
|
-
|
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
|
-
|
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|
|
data/spec/ruboty-sonar_spec.rb
CHANGED
@@ -125,7 +125,7 @@ describe RubotySonar do
|
|
125
125
|
case_before c
|
126
126
|
|
127
127
|
# -- given --
|
128
|
-
allow(
|
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(
|
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(
|
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.
|
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:
|
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
|