ygoprodeck 1.2.1 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/examples/archetype.rb +23 -23
- data/examples/banlist.rb +3 -3
- data/examples/search.rb +26 -25
- data/lib/ygoprodeck/search/banlist.rb +60 -2
- data/lib/ygoprodeck/version.rb +1 -1
- data/spec/fuzzy_name_spec.rb +3 -3
- metadata +1 -4
- data/examples/id.rb +0 -25
- data/examples/list.rb +0 -3
- data/examples/search_fuzzy.rb +0 -25
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d8f58d072a6210f4dec5f82b1add541ed8423a54bf2b0f6bad38ce2393d0dd78
|
|
4
|
+
data.tar.gz: 7667c4fba4f29d1edb23757ca053a9e2078546a051c12cf3cc97f705e3e17fcc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f86d612102dfe91f809f1112e54b2f884d88bc0a207512ac624afb86625e965dba19223d94f6143ff0e2841248d1f9ebda5350e1ee5d0b343e59acbe03f0204a
|
|
7
|
+
data.tar.gz: 54a057d0ab4104da90a76ff0e5e6e1f4bfb41b12d9e0811d52790119d807670e0c70c638318360d75559c3114cbb526535c7bc8517977dd0a97ca6e77104ff36
|
data/.rubocop.yml
CHANGED
data/examples/archetype.rb
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
require "ygoprodeck"
|
|
2
|
-
|
|
3
|
-
# kaiba is example, you free to change card name
|
|
4
|
-
kaiba = Ygoprodeck::Archetype.is("blue-eyes") # example I wanna search 'blue-eyes' archetype
|
|
5
|
-
|
|
6
|
-
# make for looping for listing archetype
|
|
7
|
-
kaiba_listing = [] # save listing here
|
|
8
|
-
count = 50 # count max listing . example 50
|
|
9
|
-
num_default = 0 # number default
|
|
10
|
-
|
|
11
|
-
# looping logic
|
|
12
|
-
for logic_search in 1..50
|
|
13
|
-
if kaiba[num_default]
|
|
14
|
-
else
|
|
15
|
-
kaiba_listing << kaiba[num_default]["name"]
|
|
16
|
-
num_default += 1
|
|
17
|
-
count -= 1
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
puts "#{kaiba_listing.length} card matches for blue-eyes archetype" #length blue-eyes archetype
|
|
22
|
-
puts "#" * 30
|
|
23
|
-
puts "#{kaiba_listing.join(" \n")}" # each listing
|
|
1
|
+
require "ygoprodeck"
|
|
2
|
+
|
|
3
|
+
# kaiba is example, you free to change card name
|
|
4
|
+
kaiba = Ygoprodeck::Archetype.is("blue-eyes") # example I wanna search 'blue-eyes' archetype
|
|
5
|
+
|
|
6
|
+
# make for looping for listing archetype
|
|
7
|
+
kaiba_listing = [] # save listing here
|
|
8
|
+
count = 50 # count max listing . example 50
|
|
9
|
+
num_default = 0 # number default
|
|
10
|
+
|
|
11
|
+
# looping logic
|
|
12
|
+
for logic_search in 1..50
|
|
13
|
+
if kaiba[num_default].nil?
|
|
14
|
+
else
|
|
15
|
+
kaiba_listing << kaiba[num_default]["name"]
|
|
16
|
+
num_default += 1
|
|
17
|
+
count -= 1
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
puts "#{kaiba_listing.length} card matches for blue-eyes archetype" # length blue-eyes archetype
|
|
22
|
+
puts "#" * 30
|
|
23
|
+
puts "#{kaiba_listing.join(" \n")}" # each listing
|
data/examples/banlist.rb
CHANGED
data/examples/search.rb
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
require "ygoprodeck"
|
|
2
|
-
|
|
3
|
-
#
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
puts yugi["
|
|
16
|
-
puts yugi["
|
|
17
|
-
puts yugi["
|
|
18
|
-
puts yugi["
|
|
19
|
-
puts yugi["
|
|
20
|
-
puts yugi["
|
|
21
|
-
puts yugi["
|
|
22
|
-
puts yugi["
|
|
23
|
-
puts
|
|
24
|
-
puts Ygoprodeck::
|
|
25
|
-
|
|
1
|
+
require "ygoprodeck"
|
|
2
|
+
|
|
3
|
+
# match name card exactly
|
|
4
|
+
matching = Ygoprodeck::Match.is('dark magician')
|
|
5
|
+
yugi = Ygoprodeck::Fname.is(matching)
|
|
6
|
+
|
|
7
|
+
if yugi.nil?
|
|
8
|
+
puts "Card not found"
|
|
9
|
+
else
|
|
10
|
+
puts yugi # => get all information of dark magician (name,id,level,attr,atk,def,etc)
|
|
11
|
+
|
|
12
|
+
puts "#" * 10
|
|
13
|
+
|
|
14
|
+
# => get specific information of dark magician
|
|
15
|
+
puts yugi["id"]
|
|
16
|
+
puts yugi["name"]
|
|
17
|
+
puts yugi["attribute"]
|
|
18
|
+
puts yugi["type"]
|
|
19
|
+
puts yugi["race"]
|
|
20
|
+
puts yugi["level"]
|
|
21
|
+
puts yugi["desc"]
|
|
22
|
+
puts yugi["atk"]
|
|
23
|
+
puts yugi["def"]
|
|
24
|
+
puts Ygoprodeck::Image.is(yugi["id"]) # => use id from yugi['id'] to get dark magician image
|
|
25
|
+
puts Ygoprodeck::Image_small.is(yugi["id"]) # => small version
|
|
26
|
+
end
|
|
@@ -29,11 +29,69 @@ module Ygoprodeck
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def self.tcg
|
|
32
|
-
|
|
32
|
+
dates_uri = URI("#{API_BASE}/getBanListDates.php")
|
|
33
|
+
dates_res = Net::HTTP.get(dates_uri)
|
|
34
|
+
dates = JSON.parse(dates_res)
|
|
35
|
+
|
|
36
|
+
tcg_dates = dates.select { |d| d['type'] == 'TCG' }
|
|
37
|
+
return { 'error' => 'No TCG dates found' } if tcg_dates.empty?
|
|
38
|
+
|
|
39
|
+
latest_date = tcg_dates.map { |d| d['date'] }.max
|
|
40
|
+
|
|
41
|
+
list_uri = URI("#{API_BASE}/getBanList.php?list=TCG&date=#{latest_date}")
|
|
42
|
+
req = Net::HTTP::Get.new(list_uri)
|
|
43
|
+
req['User-Agent'] = 'Mozilla/5.0'
|
|
44
|
+
|
|
45
|
+
res = Net::HTTP.start(list_uri.host, list_uri.port, use_ssl: true) do |http|
|
|
46
|
+
http.request(req)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
load = JSON.parse(res.body)
|
|
50
|
+
|
|
51
|
+
if load.is_a?(Hash) && load.key?('error')
|
|
52
|
+
{ 'error' => load['error'] }
|
|
53
|
+
else
|
|
54
|
+
load
|
|
55
|
+
end
|
|
56
|
+
rescue JSON::ParserError
|
|
57
|
+
{ 'error' => 'Failed to parse JSON response' }
|
|
58
|
+
rescue SocketError
|
|
59
|
+
{ 'error' => 'Network connection error' }
|
|
60
|
+
rescue StandardError => e
|
|
61
|
+
{ 'error' => "An unexpected error occurred: #{e.message}" }
|
|
33
62
|
end
|
|
34
63
|
|
|
35
64
|
def self.ocg
|
|
36
|
-
|
|
65
|
+
dates_uri = URI("#{API_BASE}/getBanListDates.php")
|
|
66
|
+
dates_res = Net::HTTP.get(dates_uri)
|
|
67
|
+
dates = JSON.parse(dates_res)
|
|
68
|
+
|
|
69
|
+
ocg_dates = dates.select { |d| d['type'] == 'OCG' }
|
|
70
|
+
return { 'error' => 'No OCG dates found' } if ocg_dates.empty?
|
|
71
|
+
|
|
72
|
+
latest_date = ocg_dates.map { |d| d['date'] }.max
|
|
73
|
+
|
|
74
|
+
list_uri = URI("#{API_BASE}/getBanList.php?list=OCG&date=#{latest_date}")
|
|
75
|
+
req = Net::HTTP::Get.new(list_uri)
|
|
76
|
+
req['User-Agent'] = 'Mozilla/5.0'
|
|
77
|
+
|
|
78
|
+
res = Net::HTTP.start(list_uri.host, list_uri.port, use_ssl: true) do |http|
|
|
79
|
+
http.request(req)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
load = JSON.parse(res.body)
|
|
83
|
+
|
|
84
|
+
if load.is_a?(Hash) && load.key?('error')
|
|
85
|
+
{ 'error' => load['error'] }
|
|
86
|
+
else
|
|
87
|
+
load
|
|
88
|
+
end
|
|
89
|
+
rescue JSON::ParserError
|
|
90
|
+
{ 'error' => 'Failed to parse JSON response' }
|
|
91
|
+
rescue SocketError
|
|
92
|
+
{ 'error' => 'Network connection error' }
|
|
93
|
+
rescue StandardError => e
|
|
94
|
+
{ 'error' => "An unexpected error occurred: #{e.message}" }
|
|
37
95
|
end
|
|
38
96
|
|
|
39
97
|
def self.goat
|
data/lib/ygoprodeck/version.rb
CHANGED
data/spec/fuzzy_name_spec.rb
CHANGED
|
@@ -4,7 +4,7 @@ RSpec.describe Ygoprodeck do
|
|
|
4
4
|
end
|
|
5
5
|
|
|
6
6
|
it "check search by fuzzy name spesific" do
|
|
7
|
-
|
|
8
|
-
expect(spec_name['id']).to eq(
|
|
9
|
-
|
|
7
|
+
spec_name = Ygoprodeck::Fname.is('dark magician')
|
|
8
|
+
expect(spec_name['id']).to eq(46986421)
|
|
9
|
+
end
|
|
10
10
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ygoprodeck
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rokhimin Wahid
|
|
@@ -114,12 +114,9 @@ files:
|
|
|
114
114
|
- examples/archetype.rb
|
|
115
115
|
- examples/banlist.rb
|
|
116
116
|
- examples/check_db.rb
|
|
117
|
-
- examples/id.rb
|
|
118
|
-
- examples/list.rb
|
|
119
117
|
- examples/match.rb
|
|
120
118
|
- examples/random.rb
|
|
121
119
|
- examples/search.rb
|
|
122
|
-
- examples/search_fuzzy.rb
|
|
123
120
|
- examples/set.rb
|
|
124
121
|
- lib/ygoprodeck.rb
|
|
125
122
|
- lib/ygoprodeck/errors.rb
|
data/examples/id.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
require "ygoprodeck"
|
|
2
|
-
|
|
3
|
-
yugi = Ygoprodeck::ID.is("46986414")
|
|
4
|
-
|
|
5
|
-
case
|
|
6
|
-
when yugi == nil
|
|
7
|
-
puts "Card not found"
|
|
8
|
-
else
|
|
9
|
-
puts yugi # => get all information of dark magician (name,id,level,attr,atk,def,etc)
|
|
10
|
-
|
|
11
|
-
puts "#" * 10
|
|
12
|
-
|
|
13
|
-
# => get specific information of dark magician
|
|
14
|
-
puts yugi["id"]
|
|
15
|
-
puts yugi["name"]
|
|
16
|
-
puts yugi["attribute"]
|
|
17
|
-
puts yugi["type"]
|
|
18
|
-
puts yugi["race"]
|
|
19
|
-
puts yugi["level"]
|
|
20
|
-
puts yugi["desc"]
|
|
21
|
-
puts yugi["atk"]
|
|
22
|
-
puts yugi["def"]
|
|
23
|
-
puts Ygoprodeck::Image.is(yugi["id"]) # => use id from yugi['id'] to get dark magician image
|
|
24
|
-
puts Ygoprodeck::Image_small.is(yugi["id"]) # => small version
|
|
25
|
-
end
|
data/examples/list.rb
DELETED
data/examples/search_fuzzy.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
require "ygoprodeck"
|
|
2
|
-
|
|
3
|
-
# yugi is example, you free to change name card
|
|
4
|
-
yugi = Ygoprodeck::Fname.is("dark magician") # example I wanna search 'dark magician' using fuzzy search
|
|
5
|
-
|
|
6
|
-
if yugi.nil?
|
|
7
|
-
puts "Card not found"
|
|
8
|
-
else
|
|
9
|
-
puts yugi # => get all information of dark magician (name,id,level,attr,atk,def,etc)
|
|
10
|
-
|
|
11
|
-
puts "#" * 10
|
|
12
|
-
|
|
13
|
-
# => get specific information of dark magician
|
|
14
|
-
puts yugi["id"]
|
|
15
|
-
puts yugi["name"]
|
|
16
|
-
puts yugi["attribute"]
|
|
17
|
-
puts yugi["type"]
|
|
18
|
-
puts yugi["race"]
|
|
19
|
-
puts yugi["level"]
|
|
20
|
-
puts yugi["desc"]
|
|
21
|
-
puts yugi["atk"]
|
|
22
|
-
puts yugi["def"]
|
|
23
|
-
puts Ygoprodeck::Image.is(yugi["id"]) # => use id from yugi['id'] to get dark magician image
|
|
24
|
-
puts Ygoprodeck::Image_small.is(yugi["id"]) # => small version
|
|
25
|
-
end
|