dblista 0.3.0 → 0.3.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
  SHA256:
3
- metadata.gz: a75838be15e70b98ad6b8f37c880a53539b82f8e0f11ff433ec7665efb9cb4f7
4
- data.tar.gz: cf00504ac704fff20bb6eea3d4c585f7feb1337529aff5bf488e23e15496df18
3
+ metadata.gz: af5c06a56c095575ded742823dfeb531103e6746113c81a0c9a2e14081dd6d78
4
+ data.tar.gz: 2ed0b2d32d232b0e5d51bc5f78488762ace9fda84de2d551aead67033fb25d54
5
5
  SHA512:
6
- metadata.gz: e8c280dae3019394510864fb8f8d8ac9f8b7fc59d0ab0278620fd159f64629768088f0654d4d060804a187ff7230cf07ef88819e313dcebd15e8ef70bf587146
7
- data.tar.gz: 4de0995b3040d0ef57a8a6f8d3eb07b7e58d931f1a58ae5995944b1f121961bb52d0dbfbabc188b40d4baf076c12e25546dd09930e0c97dd33036dbf1a53ac98
6
+ metadata.gz: 1ec8859f47192634b82352e48fb3198e32e5b1ee275c952844a8a1e2162393b098cfbf2e3f4ed5417b6a0442b8e1de88e73f367ae27cf023d5e6f57a9665dfa0
7
+ data.tar.gz: 59e82924a1a5ebf293e62af219773ab5ddce35d72eb7f06258b1c0e8b01cc09ed9f25771a642f13dcbf9d07d991005a92b8ced9e72cd4bc5c3fd9fe938bcf94b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dblista (0.3.0)
4
+ dblista (0.3.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -33,7 +33,7 @@ Pobieranie topki botów:
33
33
 
34
34
  ```ruby
35
35
  top = DBLista::List::Bot.top
36
- puts top['data'].inspect
36
+ puts top.inspect
37
37
  ```
38
38
 
39
39
  ## Licencja
@@ -78,4 +78,11 @@ module DBLista
78
78
  def self._page_integer(input)
79
79
  raise DBLista::Error, DBLista::Errors::PAGE_INTEGER unless input.is_a?(Integer)
80
80
  end
81
+
82
+ # @!visibility private
83
+ def self._limit_integer(input)
84
+ puts input
85
+ puts input.is_a?(Integer)
86
+ raise DBLista::Error, DBLista::Errors::LIMIT_INTEGER unless input.is_a?(Integer)
87
+ end
81
88
  end
@@ -8,6 +8,8 @@ module DBLista::Errors
8
8
  PAGE_INTEGER = 'Page must be an integer'
9
9
  # Raised when rank is not an integer
10
10
  RANK_INTEGER = 'Rank must be an integer'
11
+ # Raised when provided limit is not an integer
12
+ LIMIT_INTEGER = 'Limit must be an integer'
11
13
  # Raised when token is not provided
12
14
  TOKEN_NOT_PROVIDED = 'Token is not provided'
13
15
  # Raised when type symbol is invalid
@@ -15,19 +15,23 @@ module DBLista::List
15
15
  # Fetches top bots
16
16
  #
17
17
  # @param page [Integer] page
18
+ # @param limit [Integer] limit of bots per page
18
19
  # @return [Hash] raw data from DBLista
19
- def self.top(page = 0)
20
+ def self.top(page = 0, limit = 10)
20
21
  DBLista._page_integer page
21
- DBLista._get("/bots/list/top/#{page}")
22
+ DBLista._limit_integer limit
23
+ DBLista._get("/bots/list/top/#{page}?limit=#{limit}")
22
24
  end
23
25
 
24
26
  # Fetches premium bots
25
27
  #
26
28
  # @param page [Integer] page
29
+ # @param limit [Integer] limit of bots per page
27
30
  # @return [Hash] raw data from DBLista
28
- def self.premium(page = 0)
31
+ def self.premium(page = 0, limit = 10)
29
32
  DBLista._page_integer page
30
- DBLista._get("/bots/list/premium/#{page}")
33
+ DBLista._limit_integer limit
34
+ DBLista._get("/bots/list/premium/#{page}?limit=#{limit}")
31
35
  end
32
36
 
33
37
  # Fetches unverified bots
@@ -48,16 +52,7 @@ module DBLista::List
48
52
  #
49
53
  # @return [Array] array of raw bot data from DBLista
50
54
  def self.all
51
- bots = []
52
- i = 0
53
- loop do
54
- page = DBLista::List::Bot.top(i)
55
- break if page.length.zero?
56
-
57
- bots += page
58
- i += 1
59
- end
60
- bots
55
+ DBLista::List::Bot.top(0, 100_000_000)
61
56
  end
62
57
 
63
58
  # Bot search
@@ -8,35 +8,30 @@ module DBLista::List
8
8
  # Fetches top servers
9
9
  #
10
10
  # @param page [Integer] page
11
+ # @param limit [Integer] limit of servers per page
11
12
  # @return [Hash] raw data from DBLista
12
- def self.top(page = 0)
13
+ def self.top(page = 0, limit = 10)
13
14
  DBLista._page_integer page
14
- DBLista._get("/servers/list/top/#{page}")
15
+ DBLista._limit_integer limit
16
+ DBLista._get("/servers/list/top/#{page}?limit=#{limit}")
15
17
  end
16
18
 
17
19
  # Fetches premium servers
18
20
  #
19
21
  # @param page [Integer] page
22
+ # @param limit [Integer] limit of servers per page
20
23
  # @return [Hash] raw data from DBLista
21
- def self.premium(page = 0)
24
+ def self.premium(page = 0, limit = 10)
22
25
  DBLista._page_integer page
23
- DBLista._get("/servers/list/premium/#{page}")
26
+ DBLista._limit_integer limit
27
+ DBLista._get("/servers/list/premium/#{page}?limit=#{limit}")
24
28
  end
25
29
 
26
30
  # Fetches all servers
27
31
  #
28
32
  # @return [Array] array of raw server data from DBLista
29
33
  def self.all
30
- servers = []
31
- i = 0
32
- loop do
33
- page = DBLista::List::Server.top(i)
34
- break if page.length.zero?
35
-
36
- servers += page
37
- i += 1
38
- end
39
- servers
34
+ DBLista::List::Server.top(0, 100_000_000)
40
35
  end
41
36
 
42
37
  # Server search
@@ -2,5 +2,5 @@
2
2
 
3
3
  module DBLista
4
4
  # Wrapper version
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.1'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dblista
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - deepivin