ariejan-warcraft_armory 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +2 -0
- data/LICENSE +20 -0
- data/README.textile +49 -0
- data/Rakefile +22 -0
- data/lib/warcraft_armory.rb +34 -0
- data/test/warcraft_armory_test.rb +38 -0
- metadata +69 -0
data/Changelog
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Ariejan de Vroom
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
h1. Warcraft Armory
|
2
|
+
|
3
|
+
Warcraft Armory allows you to easily query the World of Warcraft Armory site to retrieve information about your character.
|
4
|
+
|
5
|
+
Both US and EU servers are supported.
|
6
|
+
|
7
|
+
Written by "Ariejan de Vroom":mailto:ariejan@ariejan.net
|
8
|
+
|
9
|
+
Copyright 2008 Ariejan de Vroom
|
10
|
+
|
11
|
+
h2. Disclaimer
|
12
|
+
|
13
|
+
This is the usual dislaimer. I'm not liable when you use this gem. Using it may be against the current (or future) terms of service from Blizzard or WoWarmory.com.
|
14
|
+
|
15
|
+
h2. Dependencies
|
16
|
+
|
17
|
+
WarcraftArmory depends on the hpricot gem version >= 0.6.
|
18
|
+
|
19
|
+
<pre>gem install hpricot</pre>
|
20
|
+
|
21
|
+
h2. Download and installation
|
22
|
+
|
23
|
+
Simply install the RubyGem and require it in your project. If you're on rails, require it in your config/environment.rb.
|
24
|
+
|
25
|
+
<pre>gem install ariejan-warcraft-armory --source http://gems.github.com</pre>
|
26
|
+
|
27
|
+
And require it when you need it:
|
28
|
+
|
29
|
+
<pre><code>require 'warcraft-armory'</code></pre>
|
30
|
+
|
31
|
+
Add the following to your environment.rb if you want to use Rails 2.1's dependency manager (which is highly recommended):
|
32
|
+
|
33
|
+
<pre><code>config.gem "ariejan-warcraft-armory",
|
34
|
+
:lib => "warcraft-armory",
|
35
|
+
:source => "http://gems.github.com"</code></pre>
|
36
|
+
|
37
|
+
h2. Usage
|
38
|
+
|
39
|
+
<pre><code>character = WarcraftAmory.find(:eu, 'Aszune', 'Nosius')</code></pre>
|
40
|
+
|
41
|
+
This will either return a WarcraftCharacter object or nil when not character information was found.
|
42
|
+
|
43
|
+
h2. More Information
|
44
|
+
|
45
|
+
"Ariejan.net":http://ariejan.net
|
46
|
+
|
47
|
+
"Blizzard":http://www.blizzard.com
|
48
|
+
"WoW Armory US":http://www.wowarmory.com
|
49
|
+
"WoW Armory EU":http://eu.wowarmory.com
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the acts_as_gold plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.pattern = 'test/**/*_test.rb'
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Generate documentation for the acts_as_gold plugin.'
|
16
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
17
|
+
rdoc.rdoc_dir = 'rdoc'
|
18
|
+
rdoc.title = 'ActsAsGold'
|
19
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
20
|
+
rdoc.rdoc_files.include('README')
|
21
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'hpricot'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
class WarcraftCharacter
|
5
|
+
attr_accessor :name, :level, :guild, :race, :class_name
|
6
|
+
end
|
7
|
+
|
8
|
+
class WarcraftArmory
|
9
|
+
# Find a WoW character
|
10
|
+
#
|
11
|
+
# +location+ defines the server location, valid (tested) options are :eu or :us
|
12
|
+
# +realm+ the realm where your character is. E.g. "Aszune"
|
13
|
+
# +character_name+ the name of your character. E.g. "Adries"
|
14
|
+
def self.find(location, realm, character_name)
|
15
|
+
self.parse_html(Hpricot(open("http://#{location.to_s}.wowarmory.com/character-sheet.xml?r=#{realm}&n=#{character_name}")))
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def self.parse_html(html)
|
21
|
+
char = WarcraftCharacter.new
|
22
|
+
|
23
|
+
details = (html/"div.character-outer").inner_text.strip.split("\n")
|
24
|
+
small_details = details[4].split('?')
|
25
|
+
|
26
|
+
char.name = details[0]
|
27
|
+
char.guild = details[2]
|
28
|
+
char.level = small_details[1]
|
29
|
+
char.race = small_details[2]
|
30
|
+
char.class_name = small_details[3]
|
31
|
+
|
32
|
+
char
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
gem 'activerecord', '>= 1.15.4.7794'
|
5
|
+
require 'active_record'
|
6
|
+
|
7
|
+
require "#{File.dirname(__FILE__)}/../init"
|
8
|
+
|
9
|
+
class WarcraftArmoryTest < Test::Unit::TestCase
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@scraped_content = File.read(File.expand_path(File.dirname(__FILE__)) + '/assets/character.html').to_s
|
13
|
+
@html = Hpricot.parse(@scraped_content)
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
# Nothing
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_asset_loading
|
21
|
+
puts @scraped_content.class
|
22
|
+
assert_equal String, @scraped_content.class
|
23
|
+
assert_equal Hpricot::Doc, @html.class
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_character_loading
|
27
|
+
character = WarcraftArmory.parse_html(@html)
|
28
|
+
|
29
|
+
assert_equal 'Adries', character.name
|
30
|
+
assert_equal '13', character.level
|
31
|
+
assert_equal 'Human', character.race
|
32
|
+
assert_equal 'Warrior', character.class_name
|
33
|
+
|
34
|
+
assert_equal 'The Justice League', character.guild
|
35
|
+
|
36
|
+
assert_equal WarcraftCharacter, character.class
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ariejan-warcraft_armory
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ariejan de Vroom
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-08-14 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hpricot
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0.6"
|
23
|
+
version:
|
24
|
+
description: Retrieve character information from the World of Warcraft Armory
|
25
|
+
email: ariejan@ariejan.net
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README.textile
|
32
|
+
files:
|
33
|
+
- Changelog
|
34
|
+
- LICENSE
|
35
|
+
- Rakefile
|
36
|
+
- README.textile
|
37
|
+
- lib/warcraft_armory.rb
|
38
|
+
- test/warcraft_armory_test.rb
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://ariejan.net
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options:
|
43
|
+
- --line-numbers
|
44
|
+
- --inline-source
|
45
|
+
- --main
|
46
|
+
- README.textile
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
version:
|
61
|
+
requirements: []
|
62
|
+
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.2.0
|
65
|
+
signing_key:
|
66
|
+
specification_version: 2
|
67
|
+
summary: Retrieve character information from the World of Warcraft Armory
|
68
|
+
test_files:
|
69
|
+
- test/warcraft_armory_test.rb
|