smogon 0.3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/smogon.rb CHANGED
File without changes
@@ -22,7 +22,7 @@ module Smogon
22
22
  def self.get(name)
23
23
  begin
24
24
  name = name.downcase.gsub /\s/, ?_
25
- url = URI::encode "http://www.smogon.com/bw/abilities/#{name}"
25
+ url = URI::encode "http://www.smogon.com/bw/abilities/#{name}"
26
26
 
27
27
  smogon = Nokogiri::HTML(open(url))
28
28
  rescue
@@ -32,16 +32,22 @@ module Smogon
32
32
  ability = Ability.new
33
33
 
34
34
  s = smogon.xpath('//div[@id="content_wrapper"]')[0]
35
- ability.name = s.xpath('.//h1').first.text
36
- ability._name = name
35
+ ability.name = s.xpath('.//h1').first.text
36
+ ability._name = name
37
37
 
38
38
  ability.description = ''.tap { |d|
39
39
  h2 = 0
40
+ ul = 0
40
41
  s.children.each { |c|
41
- if c.name == 'h2'
42
+ if c.name == 'h2'
42
43
  h2 += 1
43
44
  next
44
45
  end
46
+ if c.name == 'ul'
47
+ ul += 1
48
+ next
49
+ end
50
+ break if ul >= 2
45
51
  d << c.text if h2 == 1 && !c.text.strip.empty?
46
52
  }
47
53
  }
@@ -22,7 +22,7 @@ module Smogon
22
22
  def self.get(name)
23
23
  begin
24
24
  name = name.downcase.gsub /\s/, ?_
25
- url = URI::encode "http://www.smogon.com/bw/moves/#{name}"
25
+ url = URI::encode "http://www.smogon.com/bw/moves/#{name}"
26
26
 
27
27
  smogon = Nokogiri::HTML(open(url))
28
28
  rescue
@@ -31,8 +31,8 @@ module Smogon
31
31
 
32
32
  move = Move.new
33
33
 
34
- move.name = smogon.xpath('//div[@id="content_wrapper"]/h1').first.text
35
- move._name = name
34
+ move.name = smogon.xpath('//div[@id="content_wrapper"]/h1').first.text
35
+ move._name = name
36
36
 
37
37
  move.description = ''.tap { |d|
38
38
  h2 = 0
File without changes
@@ -24,7 +24,7 @@ module Smogon
24
24
  url = URI::encode "http://www.smogon.com/bw/pokemon/#{name}"
25
25
 
26
26
  pokemon = Pokemon.new
27
- smogon = Nokogiri::HTML(open(url))
27
+ smogon = Nokogiri::HTML(open(url))
28
28
  rescue
29
29
  return nil
30
30
  end
@@ -55,4 +55,4 @@ module Smogon
55
55
  return pokemon
56
56
  end
57
57
  end
58
- end
58
+ end
File without changes
File without changes
File without changes
File without changes
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Smogon
21
21
  def self.version
22
- '0.3'
22
+ '0.3.1'
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,68 +1,87 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: smogon
3
- version: !ruby/object:Gem::Version
4
- version: '0.3'
3
+ version: !ruby/object:Gem::Version
4
+ hash: 17
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 1
10
+ version: 0.3.1
5
11
  platform: ruby
6
- authors:
12
+ authors:
7
13
  - Giovanni Capuano
8
14
  autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
- date: 2013-07-12 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-07-15 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
14
21
  name: nokogiri
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ! '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
22
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ! '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- description: API written in Ruby to get (poké|ability|move|moveset)dex from Smogon.
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: "API written in Ruby to get (Pok\xC3\xA9|Ability|Move|Moveset)dex from Smogon."
28
35
  email: webmaster@giovannicapuano.net
29
36
  executables: []
37
+
30
38
  extensions: []
39
+
31
40
  extra_rdoc_files: []
32
- files:
33
- - lib/smogon/abilitydex.rb
34
- - lib/smogon/movedex.rb
41
+
42
+ files:
43
+ - lib/smogon.rb
35
44
  - lib/smogon/movesetdex.rb
36
45
  - lib/smogon/pokedex.rb
37
- - lib/smogon/pokemon.rb
38
- - lib/smogon/types/ability.rb
39
- - lib/smogon/types/move.rb
40
- - lib/smogon/types/moveset.rb
46
+ - lib/smogon/abilitydex.rb
41
47
  - lib/smogon/types/pokemon.rb
48
+ - lib/smogon/types/moveset.rb
49
+ - lib/smogon/types/move.rb
50
+ - lib/smogon/types/ability.rb
51
+ - lib/smogon/movedex.rb
42
52
  - lib/smogon/version.rb
43
- - lib/smogon.rb
44
53
  homepage: http://www.giovannicapuano.net
45
- licenses:
54
+ licenses:
46
55
  - GPL-3
47
- metadata: {}
48
56
  post_install_message:
49
57
  rdoc_options: []
50
- require_paths:
58
+
59
+ require_paths:
51
60
  - lib
52
- required_ruby_version: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - ! '>='
55
- - !ruby/object:Gem::Version
56
- version: '0'
57
- required_rubygems_version: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 3
76
+ segments:
77
+ - 0
78
+ version: "0"
62
79
  requirements: []
80
+
63
81
  rubyforge_project:
64
- rubygems_version: 2.0.4
82
+ rubygems_version: 1.8.25
65
83
  signing_key:
66
- specification_version: 4
84
+ specification_version: 3
67
85
  summary: Smogon API in Ruby.
68
86
  test_files: []
87
+
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MWFhYzlhYmU0YTU4OGM3OTAxMWNlODg3MTFjZDk2ZTZmNTJjNDA1NQ==
5
- data.tar.gz: !binary |-
6
- MmRlMzZmOTA3YjY4MTJkNzdjNmEwOTAxNTBjMjBjZjE1NjJlNzIwNQ==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YWU0MDJiMjY1ZTFjOTJhN2FiNGE1MzA5OTQ2ZjI3NmVmMzFhMWY4YzI4ZmMx
10
- MzNjZTlhYTlmZTkwZGNmZDM0ZGUxZDAzMmI5MjAwYmNhNmExZDlhZTU2ZGRj
11
- NTIyYTBlOWVlYWQ0NTAyZGQ0NWU2MzNmNmFjZjNiOTU5NjcxYWM=
12
- data.tar.gz: !binary |-
13
- MzllMjg4MGEzNmE5Mjg5NzA3ZDYwZWIxNWUxMjMyNjMzYjJhYzM0NGQwNTA4
14
- ZTgyMjg4NzkwNGVkMjJiZTk5YzU0Y2QzMzgxMjNmMzBmZDE3NGEyMDk4OThi
15
- NDU0ZTNiNmI2YzFhMGVjZTFkYjVjNDY5NGE0NjFkY2E2ZmFhMDI=
@@ -1,28 +0,0 @@
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 Pokemon
22
- attr_accessor :name, :_name, :types, :tier, :abilities, :base_stats
23
-
24
- def to_s
25
- "Name: #{name}\nAbility: #{abilities.join(', ')}\nType: #{types.join(?/)}\nTier: #{tier}\nBase stats: #{base_stats.join(?/)}"
26
- end
27
- end
28
- end