ygoprodeck 1.0.5 → 1.0.7
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/README.md +10 -5
- data/Rakefile +4 -2
- data/examples/{try_archetype.rb → archetype.rb} +1 -1
- data/examples/banlist.rb +5 -0
- data/examples/check_db.rb +3 -0
- data/examples/list.rb +3 -0
- data/examples/random.rb +18 -0
- data/examples/search.rb +27 -0
- data/examples/search_fuzzy.rb +27 -0
- data/examples/set.rb +3 -0
- data/lib/ygoprodeck/search/archetype.rb +27 -20
- data/lib/ygoprodeck/search/assets/names_card.json +13719 -0
- data/lib/ygoprodeck/search/banlist.rb +36 -24
- data/lib/ygoprodeck/search/card_sets.rb +26 -10
- data/lib/ygoprodeck/search/check_db_version.rb +31 -9
- data/lib/ygoprodeck/search/fuzzy_name.rb +18 -19
- data/lib/ygoprodeck/search/list.rb +46 -20
- data/lib/ygoprodeck/search/match.rb +35 -0
- data/lib/ygoprodeck/search/name.rb +20 -19
- data/lib/ygoprodeck/search/random.rb +18 -10
- data/lib/ygoprodeck/version.rb +1 -1
- data/lib/ygoprodeck.rb +3 -0
- data/spec/spec_helper.rb +1 -1
- data/ygoprodeck.gemspec +3 -2
- metadata +29 -10
- data/examples/try.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e53f20b5354b1ac1a2532f84eae83110c4a65ef26dac5c4b9e3412b4c1aeb228
|
4
|
+
data.tar.gz: 4e03b5f1ef075c30492bcd6d52459a70b0575230707b1706a593ea1b0544d119
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aecc0495d0a3ec55e908d394197031a5ce3d3621f36fceb2467cfa77b8b6f18b5baf1a765c586e3b25944e4f1c5dd37dceb97028f5f79cbd9ab77203559d9ca8
|
7
|
+
data.tar.gz: 3f01529f717c70201c6ba67139f3ad4cd7583537ce4c2f22f12633d992fa2c193cab057bd9d75c4618bee7bea4bac45e378cf62f6b232e5deddda76a763cd5a5
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# Ygoprodeck
|
2
2
|
|
3
3
|

|
4
|
-
[](https://rubygems.org/gems/ygoprodeck)
|
5
|
-
[](https://rubygems.org/gems/ygoprodeck)
|
6
|
-
[](https://rubygems.org/gems/ygoprodeck)
|
5
|
+
[](https://rubygems.org/gems/ygoprodeck)
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
7
7
|
|
8
8
|
API wrapper for search yugioh card
|
9
9
|
|
@@ -66,6 +66,11 @@ Ygoprodeck::Banlist.ocg
|
|
66
66
|
Ygoprodeck::Banlist.goat
|
67
67
|
```
|
68
68
|
|
69
|
+
Check Database Version :
|
70
|
+
```ruby
|
71
|
+
Ygoprodeck::CheckDbVer.info
|
72
|
+
```
|
73
|
+
|
69
74
|
or look [examples](https://github.com/rokhimin/ygoprodeck/blob/master/examples)
|
70
75
|
|
71
76
|
#### Noted
|
@@ -103,9 +108,9 @@ Rate Limiting on the API is enabled. The rate limit is 20 requests per 1 second
|
|
103
108
|
|
104
109
|
## Development
|
105
110
|
|
106
|
-
#### Test
|
111
|
+
#### Unit Test
|
107
112
|
```
|
108
|
-
|
113
|
+
rspec
|
109
114
|
```
|
110
115
|
|
111
116
|
## Contributing
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'ygoprodeck'
|
2
2
|
|
3
|
-
# kaiba is example, you free to change
|
3
|
+
# kaiba is example, you free to change card name
|
4
4
|
kaiba = Ygoprodeck::Archetype.is('blue-eyes') # example I wanna search 'blue-eyes' archetype
|
5
5
|
|
6
6
|
# make for looping for listing archetype
|
data/examples/banlist.rb
ADDED
data/examples/list.rb
ADDED
data/examples/random.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'ygoprodeck'
|
2
|
+
|
3
|
+
yugi = Ygoprodeck::Card.random
|
4
|
+
puts yugi
|
5
|
+
|
6
|
+
puts '#' *10
|
7
|
+
|
8
|
+
puts yugi['id']
|
9
|
+
puts yugi['name']
|
10
|
+
puts yugi['attribute']
|
11
|
+
puts yugi['type']
|
12
|
+
puts yugi['race']
|
13
|
+
puts yugi['level']
|
14
|
+
puts yugi['desc']
|
15
|
+
puts yugi['atk']
|
16
|
+
puts yugi['def']
|
17
|
+
puts Ygoprodeck::Image.is(yugi['id'])
|
18
|
+
puts Ygoprodeck::Image_small.is(yugi['id'])
|
data/examples/search.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'ygoprodeck'
|
2
|
+
|
3
|
+
# yugi is example, you free to change name card
|
4
|
+
yugi = Ygoprodeck::Name.is('dark magician') # example I wanna search 'dark magician' using fuzzy search
|
5
|
+
|
6
|
+
case
|
7
|
+
when 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
|
+
|
15
|
+
# => get specific information of dark magician
|
16
|
+
puts yugi['id']
|
17
|
+
puts yugi['name']
|
18
|
+
puts yugi['attribute']
|
19
|
+
puts yugi['type']
|
20
|
+
puts yugi['race']
|
21
|
+
puts yugi['level']
|
22
|
+
puts yugi['desc']
|
23
|
+
puts yugi['atk']
|
24
|
+
puts yugi['def']
|
25
|
+
puts Ygoprodeck::Image.is(yugi['id']) # => use id from yugi['id'] to get dark magician image
|
26
|
+
puts Ygoprodeck::Image_small.is(yugi['id']) # => small version
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
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
|
+
case
|
7
|
+
when 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
|
+
|
15
|
+
# => get specific information of dark magician
|
16
|
+
puts yugi['id']
|
17
|
+
puts yugi['name']
|
18
|
+
puts yugi['attribute']
|
19
|
+
puts yugi['type']
|
20
|
+
puts yugi['race']
|
21
|
+
puts yugi['level']
|
22
|
+
puts yugi['desc']
|
23
|
+
puts yugi['atk']
|
24
|
+
puts yugi['def']
|
25
|
+
puts Ygoprodeck::Image.is(yugi['id']) # => use id from yugi['id'] to get dark magician image
|
26
|
+
puts Ygoprodeck::Image_small.is(yugi['id']) # => small version
|
27
|
+
end
|
data/examples/set.rb
ADDED
@@ -1,21 +1,28 @@
|
|
1
|
-
|
2
1
|
module Ygoprodeck
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
2
|
+
class Archetype
|
3
|
+
attr_reader :archetype
|
4
|
+
|
5
|
+
def self.is(archetype)
|
6
|
+
url = "#{Ygoprodeck::Endpoint.is}cardinfo.php?archetype=#{URI.encode_www_form_component(archetype)}"
|
7
|
+
uri = URI(url)
|
8
|
+
|
9
|
+
begin
|
10
|
+
response = Net::HTTP.get(uri)
|
11
|
+
load = JSON.parse(response)
|
12
|
+
|
13
|
+
if load['data'].nil? || load['data'].empty?
|
14
|
+
{ 'error' => 'No card matching your query was found in the database.' }
|
15
|
+
else
|
16
|
+
load['data']
|
17
|
+
end
|
18
|
+
|
19
|
+
rescue JSON::ParserError => e
|
20
|
+
{ 'error' => 'Failed to parse JSON response' }
|
21
|
+
rescue SocketError => e
|
22
|
+
{ 'error' => 'Network connection error' }
|
23
|
+
rescue StandardError => e
|
24
|
+
{ 'error' => "An unexpected error occurred: #{e.message}" }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|