smogon 0.7.5 → 0.7.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59884f9bb4970cac11cfd60a0668278731461e74
4
- data.tar.gz: d4c58760010bc6394e5c0b90f16d0db0c98482b4
3
+ metadata.gz: 73bff19724e1c8b47fe1fa3d145f7d04ed3a085f
4
+ data.tar.gz: 900832d172da1e972d04ec539c31d6c9a47363ab
5
5
  SHA512:
6
- metadata.gz: bc424452ea115f2bf17740f2b9bdbd82149ab9637ea8b0794a0d0f6190dcfa14e190285e64bec16675fd7adb5c5d41aa8b544b447c0f2fa3a0f5101b82568cd8
7
- data.tar.gz: 3f4b6377c3230d8daf9ed85847ab472665a98fce4c9d494dbfa8b71417eb3161a1b06fa48e37ebfc79581b3acff13346f4171578abd19846486dd261ebd4b733
6
+ metadata.gz: 62ddbfbda00e4d3815e72abe623ec17a9d06e4eeb61c0784c758f818badcd6e95c3a749defc43a54872160451a09aff10495aad3a997aa4b04fad97b1e345450
7
+ data.tar.gz: 11e09f0f953a2177a7ebb3a374be7dca905309ea795293306e9ee654dc84bdbd122176263205e8504cd34fdb5ffc105a2bf83a09e0d46d66d79625aaa408ee04
@@ -18,6 +18,7 @@
18
18
  #++
19
19
 
20
20
  require 'net/http'
21
+ require 'open-uri'
21
22
  require 'json'
22
23
 
23
24
  require 'smogon/api'
@@ -51,11 +51,8 @@ module Smogon
51
51
  end
52
52
 
53
53
  def self.id2name(id)
54
- begin
55
- Nokogiri::HTML(open("http://www.marriland.com/pokedex/#{id}")).xpath('//div[@class="overview"]/h2')[0].text
56
- rescue
57
- nil
58
- end
54
+ response = open("http://pokeapi.co/api/v2/pokemon/#{id}")
55
+ JSON.parse(response.read)['name']
59
56
  end
60
57
  end
61
58
  end
@@ -18,5 +18,5 @@
18
18
  #++
19
19
 
20
20
  module Smogon
21
- VERSION = '0.7.5'
21
+ VERSION = '0.7.6'
22
22
  end
@@ -0,0 +1,9 @@
1
+ #! /usr/bin/env ruby
2
+ require 'smogon'
3
+
4
+ describe 'Pokemon' do
5
+ it 'returns the name of the pokémon, given its ID' do
6
+ name = Smogon::Type::Pokemon.id2name(1)
7
+ expect(name).to eq 'bulbasaur'
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smogon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Capuano
@@ -78,6 +78,7 @@ files:
78
78
  - spec/movedex.rb
79
79
  - spec/movesetdex.rb
80
80
  - spec/pokedex.rb
81
+ - spec/pokemon.rb
81
82
  homepage: http://www.giovannicapuano.net
82
83
  licenses:
83
84
  - GPL-3.0
@@ -108,3 +109,4 @@ test_files:
108
109
  - spec/movedex.rb
109
110
  - spec/movesetdex.rb
110
111
  - spec/pokedex.rb
112
+ - spec/pokemon.rb