Skip to content

Commit e2c3cda

Browse files
committed
DBLista -> DList
1 parent 7af2594 commit e2c3cda

32 files changed

+211
-211
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ Automatyczne statystyki:
3535

3636
```ruby
3737
bot = Discordrb::Bot.new token: 'TOKEN'
38-
dbl = DBLista::Stats.new 'DBLISTA_TOKEN', bot
38+
dbl = DList::Stats.new 'DLIST_TOKEN', bot
3939
```
4040

4141
Pobieranie topki botów:
4242

4343
```ruby
44-
top = DBLista::List::Bot.top
44+
top = DList::List::Bot.top
4545
puts top
4646
```
4747

bin/console

100644100755
File mode changed.

dblista.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require "dblista/version"
55

66
Gem::Specification.new do |spec|
77
spec.name = "dblista"
8-
spec.version = DBLista::VERSION
8+
spec.version = DList::VERSION
99
spec.authors = ["deepivin"]
1010
spec.email = ["marek12306@gmail.com"]
1111

examples/auto_stats.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require 'discordrb'
33

44
bot = Discordrb::Bot.new token: 'TOKEN'
5-
dbl = DBLista::Stats.new 'DBLISTA_TOKEN', bot
5+
dbl = DList::Stats.new 'DList_TOKEN', bot
66

77
bot.message(content: 'Ping!') do |event|
88
event.respond 'Pong!'

examples/bot_add.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
require 'dblista'
22

3-
client = DBLista::User::Client.new('TOKEN')
3+
client = DList::User::Client.new('TOKEN')
44

55
client.add({
66
id: 'id',
77
info: {
88
library: 'NiceBot',
99
tags: [
10-
DBLista::Tags::Bot::FUN,
11-
DBLista::Tags::Bot::TOOLS
10+
DList::Tags::Bot::FUN,
11+
DList::Tags::Bot::TOOLS
1212
],
1313
prefix: '!',
1414
fullDescription: 'long description',

examples/full_bot_name_list.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require 'dblista'
22

3-
DBLista::List::Bot.all.each do |server|
3+
DList::List::Bot.all.each do |server|
44
puts server['name']
55
end

examples/notifications.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'dblista'
22

3-
client = DBLista::User::Client.new('TOKEN')
3+
client = DList::User::Client.new('TOKEN')
44

55
puts client.notifications
66
client.clear_notifications

examples/tag_search.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require 'dblista'
22

3-
results = DBLista::List::Bot.search(DBLista::Tags::Bot::MUSIC)
3+
results = DList::List::Bot.search(DList::Tags::Bot::MUSIC)
44

55
puts results

examples/user_avatar.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require 'dblista'
22

3-
user = DBLista::Information.user('ID')
3+
user = DList::Information.user('ID')
44

5-
puts DBLista::Helpers.get_avatar(user['id'], user['avatar'], 1024)
5+
puts DList::Helpers.get_avatar(user['id'], user['avatar'], 1024)

lib/dblista.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
require_relative 'dblista/constants'
1818

1919
# Main module
20-
module DBLista
21-
# DBLista error class
20+
module DList
21+
# DList error class
2222
class Error < StandardError; end
2323
# API path prefix
2424
API_PATH = 'https://api.dlist.top/v1'
@@ -43,55 +43,55 @@ def self._handle_request(req, uri, token, data)
4343
req['Authorization'] = token if token
4444
response = _https(uri).request(req)
4545
result = JSON.parse response.body
46-
raise DBLista::Error, result['error'].capitalize unless result['status'] == 'success'
46+
raise DList::Error, result['error'].capitalize unless result['status'] == 'success'
4747

4848
result['data']
4949
end
5050

5151
# @!visibility private
5252
def self._get(path, token = nil)
53-
uri = URI("#{DBLista::API_PATH}#{path}")
53+
uri = URI("#{DList::API_PATH}#{path}")
5454
req = Net::HTTP::Get.new(uri)
5555
_handle_request(req, uri, token, nil)
5656
end
5757

5858
# @!visibility private
5959
def self._post(path, data = nil, token = nil)
60-
uri = URI("#{DBLista::API_PATH}#{path}")
60+
uri = URI("#{DList::API_PATH}#{path}")
6161
req = Net::HTTP::Post.new(uri)
6262
_handle_request(req, uri, token, data)
6363
end
6464

6565
# @!visibility private
6666
def self._delete(path, data = nil, token = nil)
67-
uri = URI("#{DBLista::API_PATH}#{path}")
67+
uri = URI("#{DList::API_PATH}#{path}")
6868
req = Net::HTTP::Delete.new(uri)
6969
_handle_request(req, uri, token, data)
7070
end
7171

7272
# @!visibility private
7373
def self._put(path, data = nil, token = nil)
74-
uri = URI("#{DBLista::API_PATH}#{path}")
74+
uri = URI("#{DList::API_PATH}#{path}")
7575
req = Net::HTTP::Put.new(uri)
7676
_handle_request(req, uri, token, data)
7777
end
7878

7979
# @!visibility private
8080
def self._validate_id(id)
81-
raise DBLista::Error, DBLista::Errors::ID_NEEDED unless DBLista::IS_NUMBER.match?(id.to_s)
81+
raise DList::Error, DList::Errors::ID_NEEDED unless DList::IS_NUMBER.match?(id.to_s)
8282
end
8383

8484
# @!visibility private
8585
def self._page_integer(input)
86-
raise DBLista::Error, DBLista::Errors::PAGE_INTEGER unless input.is_a?(Integer)
86+
raise DList::Error, DList::Errors::PAGE_INTEGER unless input.is_a?(Integer)
8787
end
8888

8989
# @!visibility private
9090
def self._limit_integer(input)
91-
raise DBLista::Error, DBLista::Errors::LIMIT_INTEGER unless input.is_a?(Integer)
91+
raise DList::Error, DList::Errors::LIMIT_INTEGER unless input.is_a?(Integer)
9292
end
9393

9494
def self._cache(name)
95-
DBLista::Cache.get(name.to_sym, lifetime: DBLista::CACHE_LIFETIME) { yield }
95+
DList::Cache.get(name.to_sym, lifetime: DList::CACHE_LIFETIME) { yield }
9696
end
9797
end

lib/dblista/constants.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
module DBLista
3+
module DList
44
# Tags
55
module Tags
66
# Bot tags

lib/dblista/errors.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22

33
# Error messages
4-
module DBLista::Errors
4+
module DList::Errors
55
# Raised when ID is not provided
66
ID_NEEDED = 'You need to enter ID'
77
# Raised when provided page is not an integer

lib/dblista/helpers.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# frozen_string_literal: true
22

33
# Helper methods
4-
module DBLista::Helpers
4+
module DList::Helpers
55
# Crafts avatar url from user ID and avatar hash
66
#
77
# @param id [Integer] user ID
88
# @param hash [String] avatar hash
99
# @param size [Integer] avatar width (defaults to 2048)
10-
# @return [Hash] raw data from DBLista
10+
# @return [Hash] raw data from DList
1111
def self.get_avatar(id, hash, size = 2048)
1212
"https://cdn.discordapp.com/avatars/#{id}/#{hash}?size=#{size}"
1313
end

lib/dblista/info.rb

+18-18
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,43 @@
33
require 'open-uri'
44
require 'json'
55

6-
module DBLista
6+
module DList
77
# Bot/server/user detailed information
88
#
9-
# @example Checking DBLista user information
10-
# info = DBLista::Information.user 123456789012345678
9+
# @example Checking DList user information
10+
# info = DList::Information.user 123456789012345678
1111
# puts info
1212
module Information
13-
# Fetches DBLista bot information
13+
# Fetches DList bot information
1414
#
1515
# @param id [Integer] bot ID
16-
# @return [Hash] raw data from DBLista
16+
# @return [Hash] raw data from DList
1717
def self.bot(id)
18-
DBLista._validate_id id
19-
DBLista._cache(id.to_s.to_sym) do
20-
DBLista._get("/bots/#{id}")
18+
DList._validate_id id
19+
DList._cache(id.to_s.to_sym) do
20+
DList._get("/bots/#{id}")
2121
end
2222
end
2323

24-
# Fetches DBLista server information
24+
# Fetches DList server information
2525
#
2626
# @param id [Integer] server ID
27-
# @return [Hash] raw data from DBLista
27+
# @return [Hash] raw data from DList
2828
def self.server(id)
29-
DBLista._validate_id id
30-
DBLista._cache(id.to_s.to_sym) do
31-
DBLista._get("/servers/#{id}")
29+
DList._validate_id id
30+
DList._cache(id.to_s.to_sym) do
31+
DList._get("/servers/#{id}")
3232
end
3333
end
3434

35-
# Fetches DBLista user information
35+
# Fetches DList user information
3636
#
3737
# @param id [Integer] user ID
38-
# @return [Hash] raw data from DBLista
38+
# @return [Hash] raw data from DList
3939
def self.user(id)
40-
DBLista._validate_id id
41-
DBLista._cache(id.to_s.to_sym) do
42-
DBLista._get("/users/#{id}")
40+
DList._validate_id id
41+
DList._cache(id.to_s.to_sym) do
42+
DList._get("/users/#{id}")
4343
end
4444
end
4545
end

lib/dblista/list/bot.rb

+25-25
Original file line numberDiff line numberDiff line change
@@ -7,73 +7,73 @@
77
# Lists
88
#
99
# @example Fetch top 25 bots
10-
# top = DBLista::List::Bot.top
10+
# top = DList::List::Bot.top
1111
# puts top
12-
module DBLista::List
12+
module DList::List
1313
# Bot lists
1414
module Bot
1515
# Fetches top bots
1616
#
1717
# @param page [Integer] page
1818
# @param limit [Integer] limit of bots per page
19-
# @return [Hash] raw data from DBLista
19+
# @return [Hash] raw data from DList
2020
def self.top(page = 0, limit = 10)
21-
DBLista._page_integer page
22-
DBLista._limit_integer limit
23-
DBLista._cache("botstop#{page}-#{limit}") do
24-
DBLista._get("/bots/list/top/#{page}?limit=#{limit}")
21+
DList._page_integer page
22+
DList._limit_integer limit
23+
DList._cache("botstop#{page}-#{limit}") do
24+
DList._get("/bots/list/top/#{page}?limit=#{limit}")
2525
end
2626
end
2727

2828
# Fetches premium bots
2929
#
3030
# @param page [Integer] page
3131
# @param limit [Integer] limit of bots per page
32-
# @return [Hash] raw data from DBLista
32+
# @return [Hash] raw data from DList
3333
def self.premium(page = 0, limit = 10)
34-
DBLista._page_integer page
35-
DBLista._limit_integer limit
36-
DBLista._cache("botspremium#{page}-#{limit}") do
37-
DBLista._get("/bots/list/premium/#{page}?limit=#{limit}")
34+
DList._page_integer page
35+
DList._limit_integer limit
36+
DList._cache("botspremium#{page}-#{limit}") do
37+
DList._get("/bots/list/premium/#{page}?limit=#{limit}")
3838
end
3939
end
4040

4141
# Fetches unverified bots
4242
#
43-
# @return [Hash] raw data from DBLista
43+
# @return [Hash] raw data from DList
4444
def self.unverified
45-
DBLista._cache(:botsunverified) do
46-
DBLista._get('/bots/list/unverified')
45+
DList._cache(:botsunverified) do
46+
DList._get('/bots/list/unverified')
4747
end
4848
end
4949

5050
# Fetches rejected bots
5151
#
52-
# @return [Hash] raw data from DBLista
52+
# @return [Hash] raw data from DList
5353
def self.rejected
54-
DBLista._cache(:botsrejected) do
55-
DBLista._get('/bots/list/rejected')
54+
DList._cache(:botsrejected) do
55+
DList._get('/bots/list/rejected')
5656
end
5757
end
5858

5959
# Fetches all bots
6060
#
61-
# @return [Array] array of raw bot data from DBLista
61+
# @return [Array] array of raw bot data from DList
6262
def self.all
63-
DBLista._cache(:botsall) do
64-
DBLista._get('/bots/list/top/0?limit=1000000')
63+
DList._cache(:botsall) do
64+
DList._get('/bots/list/top/0?limit=1000000')
6565
end
6666
end
6767

6868
# Bot search
6969
#
7070
# @param query [String] query search
71-
# @return [Hash] raw data from DBLista
71+
# @return [Hash] raw data from DList
7272
def self.search(query)
73-
raise DBLista::Error, DBLista::Errors::QUERY_NOT_PROVIDED unless query
73+
raise DList::Error, DList::Errors::QUERY_NOT_PROVIDED unless query
7474

75-
DBLista._cache("botsearch#{query}") do
76-
DBLista._get("/bots/search/#{CGI.escape query.to_s}")
75+
DList._cache("botsearch#{query}") do
76+
DList._get("/bots/search/#{CGI.escape query.to_s}")
7777
end
7878
end
7979
end

0 commit comments

Comments
 (0)