warcraft-armory 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ j~k�5t -2�KG�g��I����#� �C����+I���
2
+ iB$�p�Ԑ��I�C]uʤ#g��6[�&��^���eՂ�)3k%�e<x��D�H��_\�*�5ne�
3
+ ���t 7�/�����.#M�V��s��Ѫ� ��+�N�X0��R~U:ڎ�M��7f]�Α�G��LWg�Z_���*���<������B�*O�Œ��E��\�7{$#���X�4�� wgd��V�%�����%k����%i��
@@ -0,0 +1,4 @@
1
+ == 0.1.0 2009-02-06
2
+
3
+ * Intial release of warcraft-armory:
4
+ * Retrieval of character information from EU and US armories.
@@ -0,0 +1,20 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.rdoc
4
+ Rakefile
5
+ config/config.yml
6
+ lib/warcraft-armory.rb
7
+ lib/warcraft_armory.rb
8
+ lib/warcraft_armory/base.rb
9
+ lib/warcraft_armory/character.rb
10
+ lib/warcraft_armory/utils/parser.rb
11
+ script/console
12
+ script/destroy
13
+ script/generate
14
+ spec/fixtures/character-sheet.xml
15
+ spec/spec.opts
16
+ spec/spec_helper.rb
17
+ spec/warcraft_armory/base_spec.rb
18
+ spec/warcraft_armory/character_spec.rb
19
+ spec/warcraft_armory/utils/parser_spec.rb
20
+ tasks/rspec.rake
@@ -0,0 +1,50 @@
1
+ = Warcraft Armory
2
+
3
+ * http://ariejan.net/tags/warcraft-armory
4
+
5
+ == DESCRIPTION:
6
+
7
+ The warcraft-armory gem allows your application to easily access information
8
+ from the World of Warcraft Armory site.
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ * Retrieve basic character information from the EU and US armory.
13
+
14
+ == SYNOPSIS:
15
+
16
+ require 'warcraft-armory'
17
+ WarcraftArmory::Character.find(:eu, :aszune, :adries)
18
+
19
+ == REQUIREMENTS:
20
+
21
+ * You'll need the <tt>hpricot</tt> gem installed. It's a dependency, so it should already be installed for you with this gem.
22
+
23
+ == INSTALL:
24
+
25
+ * sudo gem install warcraft-armory
26
+
27
+ == LICENSE:
28
+
29
+ (The MIT License)
30
+
31
+ Copyright (c) 2009 Ariejan de Vroom
32
+
33
+ Permission is hereby granted, free of charge, to any person obtaining
34
+ a copy of this software and associated documentation files (the
35
+ 'Software'), to deal in the Software without restriction, including
36
+ without limitation the rights to use, copy, modify, merge, publish,
37
+ distribute, sublicense, and/or sell copies of the Software, and to
38
+ permit persons to whom the Software is furnished to do so, subject to
39
+ the following conditions:
40
+
41
+ The above copyright notice and this permission notice shall be
42
+ included in all copies or substantial portions of the Software.
43
+
44
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
45
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
46
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
47
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
48
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
49
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
50
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
+ require File.dirname(__FILE__) + '/lib/warcraft-armory'
3
+
4
+ # Generate all the Rake tasks
5
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
6
+ $hoe = Hoe.new('warcraft-armory', WarcraftArmory::VERSION) do |p|
7
+ p.developer('Ariejan de Vroom', 'ariejan@ariejan.net')
8
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
9
+ p.rubyforge_name = p.name
10
+ p.extra_deps = [
11
+ ['hpricot','>= 0.6.164'],
12
+ ]
13
+ p.extra_dev_deps = [
14
+ ['newgem', ">= #{::Newgem::VERSION}"]
15
+ ]
16
+ # p.description = "The warcraft-armory gem allows your application to easily access information from the World of Warcraft Armory site."
17
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
18
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
19
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
20
+ p.rsync_args = '-av --delete --ignore-errors'
21
+ end
22
+
23
+ require 'newgem/tasks' # load /tasks/*.rake
24
+ Dir['tasks/**/*.rake'].each { |t| load t }
25
+
26
+ # TODO - want other tests/tasks run by default? Add them to the list
27
+ # task :default => [:spec, :features]
28
+ task :default => [:spec]
@@ -0,0 +1,24 @@
1
+ # Describes how to parse XML and name attributes
2
+ character:
3
+ file: "character-sheet.xml"
4
+ attributes:
5
+ name: '(doc/:character).first["name"]'
6
+ prefix: '(doc/:character).first["prefix"]'
7
+ suffix: '(doc/:character).first["suffix"]'
8
+
9
+ level: '(doc/:character).first["level"].to_i'
10
+ points: '(doc/:character).first["points"].to_i'
11
+
12
+ gender: '(doc/:character).first["gender"]'
13
+ gender_id: '(doc/:character).first["genderId"].to_i'
14
+
15
+ race: '(doc/:character).first["race"]'
16
+ race_id: '(doc/:character).first["raceId"].to_i'
17
+
18
+ class_name: '(doc/:character).first["class"]'
19
+ class_id: '(doc/:character).first["classId"].to_i'
20
+
21
+ faction: '(doc/:character).first["faction"]'
22
+ faction_id: '(doc/:character).first["factionId"].to_i'
23
+
24
+ last_modified_at: 'DateTime.parse((doc/:character).first["lastModified"])'
@@ -0,0 +1 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/warcraft_armory')
@@ -0,0 +1,17 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ GEM_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(GEM_ROOT)
5
+
6
+ require 'rubygems'
7
+ require 'hpricot'
8
+ require 'open-uri'
9
+
10
+ require 'warcraft_armory/base'
11
+ require 'warcraft_armory/character'
12
+
13
+ require 'warcraft_armory/utils/parser'
14
+
15
+ module WarcraftArmory
16
+ VERSION = '0.1.0'
17
+ end
@@ -0,0 +1,25 @@
1
+ module WarcraftArmory
2
+
3
+ # The Base class provides general purpose methods to access the Armory
4
+ class Base
5
+
6
+ # Generates a URL to the Armory.
7
+ #
8
+ # ==== Usage
9
+ # * <tt>location</tt> - A symbol specifying your realm's location. E.g. <tt>:eu</tt> or <tt>:us</tt>
10
+ # * <tt>realm</tt> - A symbol specifying your realm. E.g. <tt>:aszune</tt> or <tt>:bloodhoof</tt>
11
+ # * <tt>character</tt> - A symbol specifying the character. E.g. <tt>:adries</tt> or <tt>:dwaria</tt>
12
+ # * <tt>file</tt> - Optionally specifies the XML file to retrieve. Defauls to <tt>character-sheet.xml</tt>
13
+ #
14
+ # ==== Examples
15
+ # WarcraftArmory::Base.generate_url(:eu, :aszune, :adries)
16
+ # # => http://eu.wowarmory.com/character-sheet.xml?r=Aszune&n=Adries
17
+ #
18
+ # WarcraftArmory::Base.generate_url(:us, :nazgrel, :gorgious, 'character-talents.xml')
19
+ # # => http://us.wowarmory.com/character-talents.xml?r=Nazgrel&n=Gorgious
20
+ def self.generate_url(location, realm, character, file = 'character-sheet.xml')
21
+ "http://#{location.to_s}.wowarmory.com/#{file.to_s}?r=#{realm.to_s}&n=#{character.to_s}"
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,90 @@
1
+ module WarcraftArmory
2
+
3
+ # Gives you access to Character information
4
+ #
5
+ # ==== Usage
6
+ # * <tt>location</tt> - A symbol specifying your realm's location. E.g. <tt>:eu</tt> or <tt>:us</tt>
7
+ # * <tt>realm</tt> - A symbol specifying your realm. E.g. <tt>:aszune</tt> or <tt>:bloodhoof</tt>
8
+ # * <tt>character</tt> - A symbol specifying the character. E.g. <tt>:adries</tt> or <tt>:dwaria</tt>
9
+ #
10
+ # ==== Available Attributes
11
+ # * <tt>name</tt> - The name of the character
12
+ # * <tt>prefix</tt> - An optional prefix to the name. E.g. "Private ". Default: ""
13
+ # * <tt>suffix</tt> - An optional suffix to the name. E.g. " the Explorer". Default: ""
14
+ # * <tt>level</tt> - The character's current level. E.g. 48. Note that characters below level 10 are not available on the armory.
15
+ # * <tt>faction</tt> - The name of the character's faction. E.g. "Alliance" or "Horde"
16
+ # * <tt>faction_id</tt> - The internal (World of Warcraft) id for the faction.
17
+ # * <tt>race</tt> - The name of the character's race. E.g. "Human" or "Night Elf"
18
+ # * <tt>race_id</tt> - The internal (World of Warcraft) id for the race.
19
+ # * <tt>class_name</tt> - The name of the character's class. E.g. "Mage" or "Warlock"
20
+ # * <tt>class_id</tt> - The internal (World of Warcraft) id for the class.
21
+ # * <tt>gender</tt> - The character's gender. E.g. "Male"
22
+ # * <tt>gender_id</tt> - The internal (World of Warcraft) id for gender.
23
+ # * <tt>points</tt> - Total number of the character's achievement points.
24
+ # * <tt>last_modifiedat</tt> - A <tt>DateTime</tt> object with the date the armory data was last updated.
25
+ #
26
+ # ==== Available helper methods
27
+ # * <tt>full_name</tt> - Returns the full name of the character, including the <tt>prefix</tt> and <tt>suffix</tt>
28
+ # * <tt>description</tt> - Gives the usual World of Warcraft description of the character. E.g. "Level 80 Night Elf Hunter"
29
+ #
30
+ # ==== Examples
31
+ # character = WarcraftArmory::Character.find(:eu, :aszune, :adries)
32
+ # # => <WarcraftArmory::Character>
33
+ #
34
+ # character.name
35
+ # # => "Adries"
36
+ #
37
+ # character.level
38
+ # # => 48
39
+ #
40
+ # character.full_name
41
+ # # => "Adries the Explorer"
42
+ #
43
+ # characer.description
44
+ # # => "Level 48 Human Warrior"
45
+ #
46
+ class Character
47
+ # Load the XML Mappings from the supplied config.yml file.
48
+ CONFIG = YAML.load_file("#{GEM_ROOT}/config/config.yml")["character"]
49
+
50
+ CONFIG["attributes"].each_pair do |key, value|
51
+ attr_accessor "#{key}".to_sym
52
+ end
53
+
54
+ # Returns the full name of the character, including the prefix and suffix.
55
+ #
56
+ # character.full_name
57
+ # # => "Adries the Explorer"
58
+ def full_name
59
+ [prefix, name, suffix].join("")
60
+ end
61
+
62
+ # Returns a classic character description.
63
+ #
64
+ # characer.description
65
+ # # => "Level 48 Human Warrior"
66
+ def description
67
+ "Level #{level} #{race} #{class_name}"
68
+ end
69
+
70
+ # Finds a World of Warcraft character.
71
+ # * <tt>location</tt> - A symbol specifying your realm's location. E.g. <tt>:eu</tt> or <tt>:us</tt>
72
+ # * <tt>realm</tt> - A symbol specifying your realm. E.g. <tt>:aszune</tt> or <tt>:bloodhoof</tt>
73
+ # * <tt>character</tt> - A symbol specifying the character. E.g. <tt>:adries</tt> or <tt>:dwaria</tt>
74
+ #
75
+ # character = WarcraftArmory::Character.find(:eu, :aszune, :adries)
76
+ # # => <WarcraftArmory::Character>
77
+ def self.find(location, realm, character)
78
+ result = WarcraftArmory::Character.new
79
+
80
+ url = WarcraftArmory::Base.generate_url(location, realm, character, CONFIG["file"])
81
+ doc = WarcraftArmory::Utils::Parser.parse_url(url)
82
+
83
+ CONFIG["attributes"].each_pair do |key, code|
84
+ result.send("#{key}=".to_sym, eval(code))
85
+ end
86
+
87
+ return result
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,16 @@
1
+ module WarcraftArmory
2
+ module Utils
3
+ class Parser # :nodoc:
4
+
5
+ # We need to call with a FireFox user-agent, which makes the armory
6
+ # spit out XML instead of HTML.
7
+ USER_AGENT = 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4'
8
+
9
+ # Open the +url+ and return the data retrieved as a String
10
+ def self.parse_url(url)
11
+ Hpricot.XML(open(url, "User-Agent" => USER_AGENT))
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/warcraft-armory.rb'}"
9
+ puts "Loading warcraft-armory gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,108 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="/layout/character-sheet.xsl"?><page globalSearch="1" lang="en_us" requestUrl="/character-sheet.xml">
2
+ <characterInfo>
3
+ <character battleGroup="Blackout" charUrl="r=Aszune&amp;n=Adries" class="Warrior" classId="1" faction="Alliance" factionId="0" gender="Male" genderId="0" guildName="Impact" guildUrl="r=Aszune&amp;n=Impact&amp;p=1" lastModified="February 2, 2009" level="48" name="Adries" points="420" prefix="" race="Human" raceId="1" realm="Aszune" suffix=" the Explorer"/>
4
+ <characterTab>
5
+ <talentSpec treeOne="8" treeThree="0" treeTwo="31"/>
6
+ <buffs/>
7
+ <debuffs/>
8
+ <pvp>
9
+ <lifetimehonorablekills value="91"/>
10
+ <arenacurrency value="0"/>
11
+ </pvp>
12
+ <professions>
13
+ <skill key="blacksmithing" max="300" name="Blacksmithing" value="207"/>
14
+ <skill key="mining" max="300" name="Mining" value="224"/>
15
+ </professions>
16
+ <title value=""/>
17
+ <knownTitles/>
18
+ <characterBars>
19
+ <health effective="2611"/>
20
+ <secondBar casting="-1" effective="100" notCasting="-1" perFive="-1" type="r"/>
21
+ </characterBars>
22
+ <baseStats>
23
+ <strength attack="398" base="94" block="10" effective="209"/>
24
+ <agility armor="168" attack="-1" base="64" critHitPercent="8.43" effective="84"/>
25
+ <stamina base="91" effective="171" health="1530" petBonus="-1"/>
26
+ <intellect base="27" critHitPercent="-1.00" effective="31" mana="-1" petBonus="-1"/>
27
+ <spirit base="39" effective="54" healthRegen="33" manaRegen="-1"/>
28
+ <armor base="2761" effective="2761" percent="38.13" petBonus="-1"/>
29
+ </baseStats>
30
+ <resistances>
31
+ <arcane petBonus="-1" value="0"/>
32
+ <fire petBonus="-1" value="0"/>
33
+ <frost petBonus="-1" value="10"/>
34
+ <holy petBonus="-1" value="0"/>
35
+ <nature petBonus="-1" value="0"/>
36
+ <shadow petBonus="-1" value="0"/>
37
+ </resistances>
38
+ <melee>
39
+ <mainHandDamage dps="44.0" max="134" min="131" percent="0" speed="3.00"/>
40
+ <offHandDamage dps="27.2" max="55" min="54" percent="0" speed="2.00"/>
41
+ <mainHandSpeed hastePercent="0.00" hasteRating="0" value="3.00"/>
42
+ <offHandSpeed hastePercent="0.00" hasteRating="0" value="2.00"/>
43
+ <power base="542" effective="602" increasedDps="43.0"/>
44
+ <hitRating increasedHitPercent="0.00" penetration="0" reducedArmorPercent="0.00" value="0"/>
45
+ <critChance percent="0.00" plusPercent="0.74" rating="8"/>
46
+ <expertise additional="0" percent="0.00" rating="0" value="0"/>
47
+ </melee>
48
+ <ranged>
49
+ <weaponSkill rating="0" value="0"/>
50
+ <damage dps="48.0" max="149" min="111" percent="0" speed="2.70"/>
51
+ <speed hastePercent="0.00" hasteRating="0" value="2.70"/>
52
+ <power base="122" effective="182" increasedDps="13.0" petAttack="-1.00" petSpell="-1.00"/>
53
+ <hitRating increasedHitPercent="0.00" penetration="0" reducedArmorPercent="0.00" value="0"/>
54
+ <critChance percent="8.29" plusPercent="0.74" rating="8"/>
55
+ </ranged>
56
+ <spell>
57
+ <bonusDamage>
58
+ <arcane value="0"/>
59
+ <fire value="0"/>
60
+ <frost value="0"/>
61
+ <holy value="0"/>
62
+ <nature value="0"/>
63
+ <shadow value="0"/>
64
+ <petBonus attack="-1" damage="-1" fromType=""/>
65
+ </bonusDamage>
66
+ <bonusHealing value="0"/>
67
+ <hitRating increasedHitPercent="0.00" penetration="0" reducedResist="0" value="0"/>
68
+ <critChance rating="8">
69
+ <arcane percent="0.74"/>
70
+ <fire percent="0.74"/>
71
+ <frost percent="0.74"/>
72
+ <holy percent="0.74"/>
73
+ <nature percent="0.74"/>
74
+ <shadow percent="0.74"/>
75
+ </critChance>
76
+ <penetration value="0"/>
77
+ <manaRegen casting="0.00" notCasting="0.00"/>
78
+ <hasteRating hastePercent="0.00" hasteRating="0"/>
79
+ </spell>
80
+ <defenses>
81
+ <armor base="2761" effective="2761" percent="38.13" petBonus="-1"/>
82
+ <defense decreasePercent="0.00" increasePercent="0.00" plusDefense="0" rating="0" value="238.00"/>
83
+ <dodge increasePercent="0.00" percent="7.87" rating="0"/>
84
+ <parry increasePercent="0.00" percent="9.92" rating="0"/>
85
+ <block increasePercent="0.00" percent="4.92" rating="0"/>
86
+ <resilience damagePercent="0.00" hitPercent="0.00" value="0.00"/>
87
+ </defenses>
88
+ <items>
89
+ <item durability="80" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_helmet_13" id="10763" maxDurability="80" permanentenchant="0" randomPropertiesId="0" seed="0" slot="0"/>
90
+ <item durability="0" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_jewelry_necklace_02" id="33265" maxDurability="0" permanentenchant="0" randomPropertiesId="0" seed="2040783260" slot="1"/>
91
+ <item durability="76" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_shoulder_01" id="9476" maxDurability="80" permanentenchant="0" randomPropertiesId="0" seed="799330898" slot="2"/>
92
+ <item durability="108" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_chest_leather_07" id="10086" maxDurability="115" permanentenchant="1892" randomPropertiesId="313" seed="1595075004" slot="4"/>
93
+ <item durability="40" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_belt_19" id="8277" maxDurability="40" permanentenchant="0" randomPropertiesId="0" seed="1570783238" slot="5"/>
94
+ <item durability="81" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_pants_03" id="9291" maxDurability="85" permanentenchant="0" randomPropertiesId="1127" seed="0" slot="6"/>
95
+ <item durability="64" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_boots_plate_06" id="9387" maxDurability="65" permanentenchant="0" randomPropertiesId="1200" seed="836190896" slot="7"/>
96
+ <item durability="38" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_bracer_13" id="14910" maxDurability="40" permanentenchant="0" randomPropertiesId="1195" seed="904127922" slot="8"/>
97
+ <item durability="45" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_gauntlets_26" id="9640" maxDurability="45" permanentenchant="0" randomPropertiesId="1209" seed="0" slot="9"/>
98
+ <item durability="0" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_jewelry_ring_05" id="2933" maxDurability="0" permanentenchant="0" randomPropertiesId="0" seed="140716838" slot="10"/>
99
+ <item durability="0" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_jewelry_ring_05" id="6757" maxDurability="0" permanentenchant="0" randomPropertiesId="0" seed="1799814769" slot="11"/>
100
+ <item durability="0" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_misc_cape_16" id="33261" maxDurability="0" permanentenchant="0" randomPropertiesId="0" seed="122449525" slot="14"/>
101
+ <item durability="16" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_fishingpole_02" id="6256" maxDurability="16" permanentenchant="0" randomPropertiesId="0" seed="0" slot="15"/>
102
+ <item durability="65" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_weapon_bow_02" id="33273" maxDurability="65" permanentenchant="0" randomPropertiesId="0" seed="290621992" slot="17"/>
103
+ <item durability="0" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_shirt_guildtabard_01" id="5976" maxDurability="0" permanentenchant="0" randomPropertiesId="0" seed="0" slot="18"/>
104
+ <item durability="0" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_weapon_shortblade_25" id="11285" maxDurability="0" permanentenchant="0" randomPropertiesId="0" seed="0" slot="-1"/>
105
+ </items>
106
+ </characterTab>
107
+ </characterInfo>
108
+ </page>
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'warcraft-armory'
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+
4
+ describe WarcraftArmory::Base do
5
+
6
+ it "should generate a proper URL" do
7
+ WarcraftArmory::Base.generate_url(:eu, :aszune, :nosius, 'character-sheet.xml').should
8
+ eql("http://eu}.wowarmory.com/character-sheet.xml?r=Aszune&n=Nosius")
9
+ end
10
+
11
+ end
@@ -0,0 +1,60 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+
4
+ describe WarcraftArmory::Character do
5
+
6
+ before(:each) do
7
+ @adries = {
8
+ :name => "Adries",
9
+ :level => 48,
10
+ :race => "Human",
11
+ :race_id => 1,
12
+ :points => 420,
13
+ :faction => "Alliance",
14
+ :faction_id => 0,
15
+ :gender => "Male",
16
+ :gender_id => 0,
17
+ :class_name => "Warrior",
18
+ :class_id => 1,
19
+ :prefix => "",
20
+ :suffix => " the Explorer",
21
+ :last_modified_at => DateTime.parse("February 2, 2009")
22
+ }
23
+ end
24
+
25
+ it "should load yaml" do
26
+ yaml = YAML.load_file("#{GEM_ROOT}/config/config.yml")["character"]
27
+
28
+ WarcraftArmory::Character::CONFIG.should eql(yaml)
29
+ end
30
+
31
+ it "should be able to find a character" do
32
+ WarcraftArmory::Utils::Parser.should_receive(:parse_url).once.and_return(xml_data('character-sheet.xml'))
33
+ result = WarcraftArmory::Character.find(:eu, :aszune, :adries)
34
+
35
+ result.should_not be_nil
36
+ result.should be_an_instance_of(WarcraftArmory::Character)
37
+
38
+ @adries.each_pair do |key, value|
39
+ result.send(key.to_sym).should eql(value)
40
+ end
41
+ end
42
+
43
+ it "should return a full name" do
44
+ WarcraftArmory::Utils::Parser.should_receive(:parse_url).once.and_return(xml_data('character-sheet.xml'))
45
+ result = WarcraftArmory::Character.find(:eu, :aszune, :adries)
46
+
47
+ result.full_name.should eql([result.prefix, result.name, result.suffix].join(""))
48
+ end
49
+
50
+ it "should return a description" do
51
+ WarcraftArmory::Utils::Parser.should_receive(:parse_url).once.and_return(xml_data('character-sheet.xml'))
52
+ result = WarcraftArmory::Character.find(:eu, :aszune, :adries)
53
+
54
+ result.description.should eql("Level #{result.level} #{result.race} #{result.class_name}")
55
+ end
56
+
57
+ def xml_data(filename)
58
+ Hpricot.XML(open(File.dirname(__FILE__) + "/../fixtures/#{filename}"))
59
+ end
60
+ end
@@ -0,0 +1,21 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
+
3
+
4
+ describe WarcraftArmory::Utils::Parser do
5
+
6
+ before(:each) do
7
+ @user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4'
8
+ end
9
+
10
+ it "should have the correct user agent" do
11
+ WarcraftArmory::Utils::Parser::USER_AGENT.should eql(@user_agent)
12
+ end
13
+
14
+ it "should use the user agent string when fetching remote data" do
15
+ url = "Some URL"
16
+
17
+ WarcraftArmory::Utils::Parser.should_receive(:open).with(url, "User-Agent" => @user_agent).once.and_return("done!")
18
+ WarcraftArmory::Utils::Parser.parse_url(url)
19
+ end
20
+
21
+ end
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: warcraft-armory
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ariejan de Vroom
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDNDCCAhygAwIBAgIBADANBgkqhkiG9w0BAQUFADBAMRAwDgYDVQQDDAdhcmll
14
+ amFuMRcwFQYKCZImiZPyLGQBGRYHYXJpZWphbjETMBEGCgmSJomT8ixkARkWA25l
15
+ dDAeFw0wOTAyMDMxODI5NDdaFw0xMDAyMDMxODI5NDdaMEAxEDAOBgNVBAMMB2Fy
16
+ aWVqYW4xFzAVBgoJkiaJk/IsZAEZFgdhcmllamFuMRMwEQYKCZImiZPyLGQBGRYD
17
+ bmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArMSCEjhB9DNdsXd2
18
+ 7Z1bpHXsmJw7e4WCqjDzxU47QkA3t4loGE4m9Ek3TfSfaRziWvgN/MEoVeGsYkkm
19
+ Bt1cSU66cAHXqn+xh/wULdQcluKmQtlf4LCK+NRGSOZcSCi5EXgfSrUnVMbVSEae
20
+ Mce6aQ3HV4Ccx05wMEdfA2KXF05QFAKk4lRgp1a/IEshSGrZvzODd5w24wKvz1bg
21
+ Bp4c8HvWsyJjCSA+Em1RtIvP2tIkfHZX5XiN/jRurIE8OMIAS2F/Brg3JXZOTgl8
22
+ Lbk4Qq2wdnyPpflvPedOpMseAx1GnaohBmyrOOG7JnJYOCcTSDR2VLfR3WOHcXdu
23
+ vtGs5wIDAQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU
24
+ F21nkoOPZLWzDA1vTJHfvmEK8MUwDQYJKoZIhvcNAQEFBQADggEBAIHvz+XRTpre
25
+ lxFnJS+Mij+ukb4e0lxK68Jc7Yq5Ek5fDZ6S2UBM6xDVHvZtTFVUfJ0e43BDzaV8
26
+ tiD2jOv3o8TP+zbl378bbfg/4CaVBlgJe5zqit2h690/EIBKYDsRluHbWiEr1pBf
27
+ rK/lyZStUdC6hIlM5wjgcoomPBZnza/a/HRMWvYBr84+i1RiDL8A3TexzoR2v6gH
28
+ dU86LPZemsmEvUib5vs0hl6gu27u7qB/wtcM1/h1847D8lxEqHgG1hwge00epw3A
29
+ k/Hoj5meQGdzZpZn1Ka6dBUZbu9wZO5j+XRjloML9cgT2Bc6d8VU8IRhtbDi1PSz
30
+ 1hW2G0g9ib0=
31
+ -----END CERTIFICATE-----
32
+
33
+ date: 2009-02-06 00:00:00 +01:00
34
+ default_executable:
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: hpricot
38
+ type: :runtime
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 0.6.164
45
+ version:
46
+ - !ruby/object:Gem::Dependency
47
+ name: newgem
48
+ type: :development
49
+ version_requirement:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.3
55
+ version:
56
+ - !ruby/object:Gem::Dependency
57
+ name: hoe
58
+ type: :development
59
+ version_requirement:
60
+ version_requirements: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 1.8.0
65
+ version:
66
+ description: The warcraft-armory gem allows your application to easily access information from the World of Warcraft Armory site.
67
+ email:
68
+ - ariejan@ariejan.net
69
+ executables: []
70
+
71
+ extensions: []
72
+
73
+ extra_rdoc_files:
74
+ - History.txt
75
+ - Manifest.txt
76
+ - README.rdoc
77
+ files:
78
+ - History.txt
79
+ - Manifest.txt
80
+ - README.rdoc
81
+ - Rakefile
82
+ - config/config.yml
83
+ - lib/warcraft-armory.rb
84
+ - lib/warcraft_armory.rb
85
+ - lib/warcraft_armory/base.rb
86
+ - lib/warcraft_armory/character.rb
87
+ - lib/warcraft_armory/utils/parser.rb
88
+ - script/console
89
+ - script/destroy
90
+ - script/generate
91
+ - spec/fixtures/character-sheet.xml
92
+ - spec/spec.opts
93
+ - spec/spec_helper.rb
94
+ - spec/warcraft_armory/base_spec.rb
95
+ - spec/warcraft_armory/character_spec.rb
96
+ - spec/warcraft_armory/utils/parser_spec.rb
97
+ - tasks/rspec.rake
98
+ has_rdoc: true
99
+ homepage: http://ariejan.net/tags/warcraft-armory
100
+ post_install_message:
101
+ rdoc_options:
102
+ - --main
103
+ - README.rdoc
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: "0"
111
+ version:
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: "0"
117
+ version:
118
+ requirements: []
119
+
120
+ rubyforge_project: warcraft-armory
121
+ rubygems_version: 1.3.1
122
+ signing_key:
123
+ specification_version: 2
124
+ summary: The warcraft-armory gem allows your application to easily access information from the World of Warcraft Armory site.
125
+ test_files: []
126
+
Binary file