smogon 0.1 → 0.2

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWZlODFlOWI1OTRhZGJjOWZmZjc1YzllZWVhODU2OTQ2ZDNiNDY1Mw==
4
+ NGZjMTQ0NjJmMzc5YjBkOGVhODA3YmY0OTA0ZWNhMzZkZjU1Yjg1Zg==
5
5
  data.tar.gz: !binary |-
6
- MmI4NjIwOWY5YTU5NmZiNWJjNDA3NjY1YmUxOThmM2FiN2ZiMTNkMg==
6
+ NThkYWUwZjQzMGQyYjI5ZGY4ZGQ2MjdlYTU3NTMwNGU1YTA2NGZkYg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- OTNmMTUwYmMwMTBkNGQzNGU2MDA1MjZlNGVjMjQ4MjY4OTk3OWI2NTRkYTJk
10
- YTNhMjRmNDkxZmJkMDBhNDlmN2VkNDA5ZjIwYTM5MTM5MTBmMzJlMjY4M2E3
11
- MTMwZTRmZjJmZTYyMTRjNDQ0YmFlOTczNGFkYWZkOTA3ZWZkNWY=
9
+ ZDVlY2NhYTUyYmYzM2M3NzZjYjlmNTQxOGIzNWUzZTM2ZTE2YzY4MzA2NWI0
10
+ YzMxMjIyYzI3MTdhZGRjNDI1NjkxYjg4NzhlYjAyODExOWZkMzEzZjU3ODg5
11
+ MTYxZTA5ZGFlZTZhMWE4NTk5MTY2NjJkMThmNzk5Mjg5NWU5OTA=
12
12
  data.tar.gz: !binary |-
13
- MTM0ZDNiZDBmMjNlMjM2NWVjNTZlODM5ZGI0M2Y3MWI0OGIxZDljOGQ2MjFm
14
- ZTQ1NWRhZWJjMzE5YjVmNmY5MzEzN2EyZDhlZTdhMjk3NzYzYjM3OTkwNTUz
15
- M2Q5OTI5MWVjYzY3Y2U5MzA0MzBjYzdhN2MzNjEzMjc3MmFmYzY=
13
+ NGQ2ZDI2MDUzYTJlZmQ5YzU2NDk5Y2I4ZTM1YmU0OTMwNmViYTIyNGY4NjA4
14
+ OTU2OTkzMDIzZGExMzdiMTU3ZWE1NDNkNjYzMDI1YTcwZDk2MGY2NDM4MDI3
15
+ NDMzMzIxNGIxMDMxYzUzNWVhNWUyOWIxODc4ZjQ2YzA2NDNmMTI=
@@ -20,10 +20,12 @@
20
20
  require 'open-uri'
21
21
  require 'nokogiri'
22
22
 
23
- require 'smogon/pokemon'
24
- require 'smogon/pokedex'
23
+ require 'smogon/types/pokemon'
24
+ require 'smogon/types/moveset'
25
+ require 'smogon/types/ability'
25
26
 
26
- require 'smogon/moveset'
27
+ require 'smogon/pokedex'
27
28
  require 'smogon/movedex'
29
+ require 'smogon/abilitydex'
28
30
 
29
31
  require 'smogon/version'
@@ -0,0 +1,52 @@
1
+ #--
2
+ # Copyright(C) 2013 Giovanni Capuano <webmaster@giovannicapuano.net>
3
+ #
4
+ # This file is part of Smogon-API.
5
+ #
6
+ # Smogon-API is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Smogon-API is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Smogon-API. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ module Smogon
21
+ class Abilitydex
22
+ def self.get(name)
23
+ begin
24
+ name.downcase.gsub!(/\s/, ?_)
25
+ url = URI::encode "http://www.smogon.com/bw/abilities/#{name}"
26
+
27
+ smogon = Nokogiri::HTML(open(url))
28
+ rescue
29
+ return nil
30
+ end
31
+
32
+ ability = Ability.new
33
+
34
+ s = smogon.xpath('//div[@id="content_wrapper"]')[0]
35
+ ability.name = s.xpath('.//h1').first.text
36
+ ability._name = name
37
+
38
+ ability.description = ''.tap { |d|
39
+ h2 = 0
40
+ s.children.each { |c|
41
+ if c.name == 'h2'
42
+ h2 += 1
43
+ next
44
+ end
45
+ d << c.text if h2 == 1 && !c.text.strip.empty?
46
+ }
47
+ }
48
+
49
+ return ability
50
+ end
51
+ end
52
+ end
@@ -19,9 +19,7 @@
19
19
 
20
20
  module Smogon
21
21
  class Movedex
22
-
23
22
  def self.get(name, tier)
24
-
25
23
  begin
26
24
  url = URI::encode "http://www.smogon.com/bw/pokemon/#{name}/#{tier}"
27
25
 
@@ -19,7 +19,6 @@
19
19
 
20
20
  module Smogon
21
21
  class Pokedex
22
-
23
22
  def self.get(name)
24
23
  begin
25
24
  url = URI::encode "http://www.smogon.com/bw/pokemon/#{name}"
@@ -0,0 +1,32 @@
1
+ #--
2
+ # Copyright(C) 2013 Giovanni Capuano <webmaster@giovannicapuano.net>
3
+ #
4
+ # This file is part of Smogon-API.
5
+ #
6
+ # Smogon-API is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Smogon-API is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Smogon-API. If not, see <http://www.gnu.org/licenses/>.
18
+ #++
19
+
20
+ module Smogon
21
+ class Ability
22
+ attr_accessor :name, :_name, :description
23
+
24
+ def to_s
25
+ "Name: #{name}\nDescription: #{description}"
26
+ end
27
+
28
+ def url
29
+ "http://www.smogon.com/bw/abilities/#{_name}"
30
+ end
31
+ end
32
+ end
@@ -24,5 +24,9 @@ module Smogon
24
24
  def to_s
25
25
  "Name: #{name}\nAbility: #{abilities.join(', ')}\nType: #{types.join(?/)}\nTier: #{tier}\nBase stats: #{base_stats.join(?/)}"
26
26
  end
27
+
28
+ def url
29
+ "http://www.smogon.com/bw/pokemon/#{_name}"
30
+ end
27
31
  end
28
32
  end
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Smogon
21
21
  def self.version
22
- '0.1'
22
+ '0.2'
23
23
  end
24
24
  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.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Capuano
@@ -30,10 +30,12 @@ executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
+ - lib/smogon/abilitydex.rb
33
34
  - lib/smogon/movedex.rb
34
- - lib/smogon/moveset.rb
35
35
  - lib/smogon/pokedex.rb
36
- - lib/smogon/pokemon.rb
36
+ - lib/smogon/types/ability.rb
37
+ - lib/smogon/types/moveset.rb
38
+ - lib/smogon/types/pokemon.rb
37
39
  - lib/smogon/version.rb
38
40
  - lib/smogon.rb
39
41
  homepage: http://www.giovannicapuano.net