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 +8 -8
- data/lib/smogon.rb +5 -3
- data/lib/smogon/abilitydex.rb +52 -0
- data/lib/smogon/movedex.rb +0 -2
- data/lib/smogon/pokedex.rb +0 -1
- data/lib/smogon/types/ability.rb +32 -0
- data/lib/smogon/{moveset.rb → types/moveset.rb} +0 -0
- data/lib/smogon/{pokemon.rb → types/pokemon.rb} +4 -0
- data/lib/smogon/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGZjMTQ0NjJmMzc5YjBkOGVhODA3YmY0OTA0ZWNhMzZkZjU1Yjg1Zg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NThkYWUwZjQzMGQyYjI5ZGY4ZGQ2MjdlYTU3NTMwNGU1YTA2NGZkYg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDVlY2NhYTUyYmYzM2M3NzZjYjlmNTQxOGIzNWUzZTM2ZTE2YzY4MzA2NWI0
|
10
|
+
YzMxMjIyYzI3MTdhZGRjNDI1NjkxYjg4NzhlYjAyODExOWZkMzEzZjU3ODg5
|
11
|
+
MTYxZTA5ZGFlZTZhMWE4NTk5MTY2NjJkMThmNzk5Mjg5NWU5OTA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGQ2ZDI2MDUzYTJlZmQ5YzU2NDk5Y2I4ZTM1YmU0OTMwNmViYTIyNGY4NjA4
|
14
|
+
OTU2OTkzMDIzZGExMzdiMTU3ZWE1NDNkNjYzMDI1YTcwZDk2MGY2NDM4MDI3
|
15
|
+
NDMzMzIxNGIxMDMxYzUzNWVhNWUyOWIxODc4ZjQ2YzA2NDNmMTI=
|
data/lib/smogon.rb
CHANGED
@@ -20,10 +20,12 @@
|
|
20
20
|
require 'open-uri'
|
21
21
|
require 'nokogiri'
|
22
22
|
|
23
|
-
require 'smogon/pokemon'
|
24
|
-
require 'smogon/
|
23
|
+
require 'smogon/types/pokemon'
|
24
|
+
require 'smogon/types/moveset'
|
25
|
+
require 'smogon/types/ability'
|
25
26
|
|
26
|
-
require 'smogon/
|
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
|
data/lib/smogon/movedex.rb
CHANGED
data/lib/smogon/pokedex.rb
CHANGED
@@ -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
|
File without changes
|
data/lib/smogon/version.rb
CHANGED
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.
|
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/
|
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
|