wow_armory 0.0.2 → 0.0.5pre

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.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Guardfile ADDED
@@ -0,0 +1,12 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2, :cli => "--format documentation --color" do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^lib/wow_armory/(.+)\.rb$}) { |m| "spec/wow_armory/#{m[1]}_spec.rb"}
12
+ end
@@ -0,0 +1,22 @@
1
+ module WowArmory
2
+ class ArmoryError < StandardError
3
+ end
4
+
5
+ class InvalidRegionError < StandardError
6
+ end
7
+
8
+ class CharacterNotFoundError < StandardError
9
+ end
10
+
11
+ class GuildNotFoundError < StandardError
12
+ end
13
+
14
+ class ItemNotFoundError < StandardError
15
+ end
16
+
17
+ class InvalidItemIdError < StandardError
18
+ end
19
+
20
+ class RealmNotFoundError < StandardError
21
+ end
22
+ end
@@ -0,0 +1,128 @@
1
+ require "wow_armory/data_object"
2
+
3
+ module WowArmory
4
+
5
+ class CharacterClass < DataObject
6
+ def class_id
7
+ return @data['id']
8
+ end
9
+
10
+ def mask
11
+ return @data['mask']
12
+ end
13
+
14
+ def power_type
15
+ return @data['powerType']
16
+ end
17
+
18
+ def name
19
+ return @data['name']
20
+ end
21
+
22
+ end
23
+
24
+ class CharacterRace < DataObject
25
+ def race_id
26
+ return @data['id']
27
+ end
28
+
29
+ def name
30
+ return @data['name']
31
+ end
32
+
33
+ def side
34
+ return @data['side']
35
+ end
36
+
37
+ def mask
38
+ return @data['mask']
39
+ end
40
+ end
41
+
42
+ class Character < DataObject
43
+
44
+ IMAGE_BASE_URL = "static-render/us"
45
+ IMAGE_TYPES = ["profilemain", "inset", "card", "avatar"];
46
+ CHARACTER_FIELDS = ['guild', 'stats', 'talents', 'items', 'reputation', 'titles', 'professions', 'appearence', 'companions', 'mounts', 'pets', 'achievements', 'progression', 'pvp', 'quests']
47
+
48
+ attr_reader :guild, :stats, :talents, :items, :reputation, :titles, :professions, :appearance, :companions, :mounts, :pets, :achievements, :progression, :pvp, :quests, :character_classes, :character_races
49
+
50
+ def initialize(raw_data)
51
+ super
52
+
53
+ @guild = Guild.new(@data['guild']) || nil
54
+
55
+ @stats = @data['stats'] || nil
56
+
57
+ @talents = @data['talents'] || nil
58
+
59
+ @items = @data['items'] || nil
60
+
61
+ @reputation = @data['reputation'] || nil
62
+
63
+ @titles = @data['titles'] || nil
64
+
65
+ @professions = @data['professions'] || nil
66
+
67
+ @appearance = @data['appearance'] || nil
68
+
69
+ @companions = @data['companions'] || nil
70
+
71
+ @mounts = @data['mounts'] || nil
72
+
73
+ @pets = @data['pets'] || nil
74
+
75
+ @achievements = @data['achievements'] || nil
76
+
77
+ @progression = @data['progression'] || nil
78
+
79
+ @pvp = @data['pvp'] || nil
80
+
81
+ @quests = @data['quests'] || nil
82
+ end
83
+
84
+ def avatar_image_url
85
+ return "http://us.battle.net/#{IMAGE_BASE_URL}/#{@data['thumbnail']}"
86
+ end
87
+
88
+ def profile_image_url
89
+ "http://us.battle.net/#{IMAGE_BASE_URL}/#{@data['thumbnail'].gsub(/avatar/, 'profilemain')}"
90
+ end
91
+
92
+ def card_image_url
93
+ "http://us.battle.net/#{IMAGE_BASE_URL}/#{@data['thumbnail']}".gsub(/avatar/, 'card')
94
+ end
95
+
96
+ def inset_image_url
97
+ "http://us.battle.net/#{IMAGE_BASE_URL}/#{@data['thumbnail']}".gsub(/avatar/, 'inset')
98
+ end
99
+
100
+ def name
101
+ return @data['name']
102
+ end
103
+
104
+ def level
105
+ return @data['level']
106
+ end
107
+
108
+ def primary_talents
109
+ Spec.new(@talents.first) if @talents
110
+ end
111
+
112
+ def secondary_talents
113
+ if @talents.is_a?(Array) && @talents.length > 1
114
+ Spec.new(@talents.last)
115
+ else
116
+ nil
117
+ end
118
+ end
119
+
120
+ def character_class
121
+ RACE[@data['class']]
122
+ end
123
+
124
+ def race
125
+ CLASS[@data['race']]
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,62 @@
1
+ UNITED_STATES = 'us'
2
+ EUROPE = 'eu'
3
+ KOREA = 'kr'
4
+ TAIWAN = 'tw'
5
+
6
+ REGIONS = ['us', 'eu', 'kr', 'tw']
7
+
8
+ RACE = {
9
+ 1 => 'Human',
10
+ 2 => 'Orc',
11
+ 3 => 'Dwarf',
12
+ 4 => 'Night Elf',
13
+ 5 => 'Undead',
14
+ 6 => 'Tauren',
15
+ 7 => 'Gnome',
16
+ 8 => 'Troll',
17
+ 9 => 'Goblin',
18
+ 10 => 'Blood Elf',
19
+ 11 => 'Draenei',
20
+ 22 => 'Worgen'
21
+ }
22
+
23
+ CLASS = {
24
+ 1 => 'Warrior',
25
+ 2 => 'Paladin',
26
+ 3 => 'Hunter',
27
+ 4 => 'Rogue',
28
+ 5 => 'Priest',
29
+ 6 => 'Death Knight',
30
+ 7 => 'Shaman',
31
+ 8 => 'Mage',
32
+ 9 => 'Warlock',
33
+ 11 => 'Druid'
34
+ }
35
+
36
+ QUALITY = {
37
+ 1 => 'Common',
38
+ 2 => 'Uncommon',
39
+ 3 => 'Rare',
40
+ 4 => 'Epic',
41
+ 5 => 'Legendary'
42
+ }
43
+
44
+ FACTION = {
45
+ 0 => "Alliance",
46
+ 1 => "Horde"
47
+ }
48
+
49
+ RACE_TO_FACTION = {
50
+ 1 => 'Alliance',
51
+ 2 => 'Horde',
52
+ 3 => 'Alliance',
53
+ 4 => 'Alliance',
54
+ 5 => 'Horde',
55
+ 6 => 'Horde',
56
+ 7 => 'Alliance',
57
+ 8 => 'Horde',
58
+ 9 => 'Horde',
59
+ 10 => 'Horde',
60
+ 11 => 'Alliance',
61
+ 22 => 'Alliance'
62
+ }
@@ -1,26 +1,23 @@
1
+ require 'wow_armory/constants'
2
+
1
3
  module WowArmory
2
- module Data
3
- class DataObject
4
- attr_reader :data
5
- def initialize(raw_data)
6
- @data = raw_data
7
- end
8
-
9
- def method_missing(method)
10
- return @data[method.to_s]
11
- end
4
+ class DataObject
5
+ attr_reader :data
6
+
7
+ def initialize(raw_data)
8
+ @data = raw_data
12
9
  end
13
-
14
- class Character < DataObject
15
-
10
+
11
+ def dump
12
+ return @data
16
13
  end
17
14
 
18
- class Guild < DataObject
19
-
15
+ def inspect
16
+ return @data.inspect
20
17
  end
21
-
22
- class Item < DataObject
23
-
18
+
19
+ def method_missing(method)
20
+ return @data[method.to_s]
24
21
  end
25
22
  end
26
23
  end
@@ -0,0 +1,28 @@
1
+ require "wow_armory/data_object"
2
+
3
+ module WowArmory
4
+ class Guild < DataObject
5
+ include HTTParty
6
+ base_uri 'http://us.battle.net'
7
+
8
+ def name
9
+ return @data['name']
10
+ end
11
+
12
+ def side
13
+ return @data['side']
14
+ end
15
+
16
+ def level
17
+ return @data['level']
18
+ end
19
+
20
+ def realm
21
+ return Realm.new(self.class.get('/api/wow/realm/status', :query => {:realm => @data['realm']}).parsed_response)
22
+ end
23
+
24
+ def achievement_points
25
+ return @data['achievementPoints']
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,7 @@
1
+ require "wow_armory/data_object"
2
+
3
+ module WowArmory
4
+ class Item < DataObject
5
+
6
+ end
7
+ end
@@ -0,0 +1,36 @@
1
+ require "wow_armory/data_object"
2
+ module WowArmory
3
+ class Realm < DataObject
4
+ def available?
5
+ return @data["status"]
6
+ end
7
+
8
+ def name
9
+ return @data['name']
10
+ end
11
+
12
+ def type
13
+ return @data['type']
14
+ end
15
+
16
+ def slug
17
+ return @data['slug']
18
+ end
19
+
20
+ def population
21
+ return @data['population']
22
+ end
23
+
24
+ def queue
25
+ return @data['queue']
26
+ end
27
+
28
+ def status
29
+ return @data['status']
30
+ end
31
+
32
+ def battlegroup
33
+ return @data['battlegroup']
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,7 @@
1
+ require "wow_armory/data_object"
2
+
3
+ module WowArmory
4
+ class Spec < DataObject
5
+
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ class String
2
+ def is_i?
3
+ !!(self =~ /^[-+]?[0-9]+$/)
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module WowArmory
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.5pre"
3
3
  end
data/lib/wow_armory.rb CHANGED
@@ -1,27 +1,88 @@
1
+ require "wow_armory/armory_errors"
1
2
  require "wow_armory/version"
2
- require "wow_armory/data_object.rb"
3
+ require "wow_armory/data_object"
4
+ require "wow_armory/character"
5
+ require "wow_armory/guild"
6
+ require "wow_armory/realm"
7
+ require "wow_armory/item"
8
+ require "wow_armory/spec"
9
+ require 'wow_armory/utility'
3
10
 
4
11
  module WowArmory
5
- class API
12
+ class ArmoryApi
6
13
  include HTTParty
7
- base_uri "http://us.battle.net"
14
+ attr_reader :region
8
15
 
9
- def initialize(options)
10
- return self
16
+ def initialize(region = UNITED_STATES)
17
+ @region = region
18
+ unless REGIONS.include?(region)
19
+ raise InvalidRegionError, "Invalid region selected #{region}"
20
+ end
21
+ self.class.base_uri "http://#{region}.battle.net"
11
22
  end
12
23
 
13
- def getCharacter(realm_name, character_name)
14
- Character.new(self.class.get("/api/wow/character/#{URI.escape realm_name}/#{URI.escape character_name}").parsed_response)
24
+ def get_realm(realm_name)
25
+ raise StandardError, "Realm name cannot be nil" unless realm_name.present?
26
+ uri = "/api/wow/realm/status"
27
+ query = {:realm => URI.escape(realm_name)}
28
+ begin
29
+ realm = get_data(uri, query)
30
+ rescue ArmoryError => e
31
+ raise RealmNotFoundError, "Could not find the realm #{realm_name} in http://#{@region}.battle.net"
32
+ end
33
+ Realm.new(realm.parsed_response["realms"].first)
15
34
  end
16
35
 
17
- def getGuild(realm_name, guild_name)
18
- Guild.new(self.class.get("/api/wow/guild/#{URI.escape realm_name}/#{URI.escape guild_name}").parsed_response)
36
+ def get_character(realm_name, character_name, fields = [])
37
+ raise StandardError, "Realm name cannot be nil" unless realm_name.present?
38
+ raise StandardError, "Character name cannot be nil" unless character_name.present?
39
+ uri = "/api/wow/character/#{URI.escape realm_name}/#{URI.escape character_name}"
40
+ query = {:fields => fields.join(',')}
41
+ begin
42
+ character = get_data(uri, query)
43
+ rescue ArmoryError => e
44
+ raise CharacterNotFoundError, "Character #{character_name} not found in #{realm_name}"
45
+ end
46
+ Character.new(character.parsed_response)
19
47
  end
20
48
 
21
- def getItem(item_id)
22
- Item.new(self.class.get("/api/wow/item/#{item_id}").parsed_response)
49
+ def get_guild(realm_name, guild_name, fields = [])
50
+ raise StandardError, "Realm name cannot be nil" unless realm_name.present?
51
+ raise StandardError, "Guild name cannot be nil" unless guild_name.present?
52
+
53
+ uri = "/api/wow/guild/#{URI.escape realm_name}/#{URI.escape guild_name}"
54
+ query = {:fields => fields.join(",")}
55
+ begin
56
+ guild = get_data(uri, query)
57
+ rescue ArmoryError => e
58
+ raise GuildNotFoundError, "Could not find the guild #{guild_name} on #{realm_name}"
59
+ end
60
+ Guild.new(guild.parsed_response)
23
61
  end
24
62
 
63
+ def get_item(item_id)
64
+ raise StandardError, "Item ID cannot be nil" unless item_id.present?
65
+ raise InvalidItemIdError, "The Item ID #{item_id} is invalid. Item ID must be a number" unless item_id.is_i?
66
+ uri = "/api/wow/item/#{URI.escape item_id}"
67
+ begin
68
+ item = get_data(uri, nil)
69
+ rescue ArmoryError => e
70
+ raise ItemNotFoundError, "Could not find item with id #{item_id}"
71
+ end
72
+ Item.new(item.parsed_response)
73
+
74
+ end
75
+
76
+ private
77
+ def get_data(uri, query)
78
+ data = self.class.get(uri, :query => query)
79
+ if(data.parsed_response['status'] == 'nok')
80
+ raise ArmoryError, data.parsed_response['reason']
81
+ else
82
+ return data
83
+ end
84
+ end
25
85
  end
86
+
87
+
26
88
  end
27
-
@@ -0,0 +1,37 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper.rb"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+
8
+ $LOAD_PATH << "." unless $LOAD_PATH.include?(".")
9
+ require 'logger'
10
+
11
+ begin
12
+ require "rubygems"
13
+ require "httparty"
14
+ require "rails"
15
+ require "bundler"
16
+
17
+ if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.5")
18
+ raise RuntimeError, "Your bundler version is too old." +
19
+ "Run `gem install bundler` to upgrade."
20
+ end
21
+
22
+ # Set up load paths for all bundled gems
23
+ Bundler.setup
24
+ rescue Bundler::GemNotFound
25
+ raise RuntimeError, "Bundler couldn't find some gems." +
26
+ "Did you run \`bundlee install\`?"
27
+ end
28
+
29
+ Bundler.require
30
+ require File.expand_path('../../lib/wow_armory', __FILE__)
31
+
32
+
33
+ RSpec.configure do |config|
34
+ config.treat_symbols_as_metadata_keys_with_true_values = true
35
+ config.run_all_when_everything_filtered = true
36
+ config.filter_run :focus
37
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe WowArmory::CharacterClass do
4
+ before :all do
5
+ @class = WowArmory::ArmoryApi.new.get_character('mannoroth', 'hreindyri').character_class
6
+ end
7
+ it "should be a CharacterRace Object" do
8
+ # pending @class.should be_instance_of(WowArmory::CharacterClass)
9
+ end
10
+
11
+ it "should have an ID" do
12
+ # pending @class.class_id.should == 6
13
+ end
14
+
15
+ it "should have a name" do
16
+ # pending @class.name.should == "Death Knight"
17
+ end
18
+
19
+ it "should be Alliance" do
20
+ # pending @class.power_type.should == "runic-power"
21
+ end
22
+
23
+ it "should have a mask value" do
24
+ # pending @class.mask.should == 32
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe WowArmory::CharacterRace do
4
+ before :all do
5
+ @race = WowArmory::ArmoryApi.new.get_character('mannoroth', 'hreindyri').race
6
+ end
7
+ it "should be a CharacterRace Object" do
8
+ # @race.should be_instance_of(WowArmory::CharacterRace)
9
+ end
10
+
11
+ it "should have an ID" do
12
+ # @race.race_id.should == 11
13
+ end
14
+
15
+ it "should have a name" do
16
+ # @race.name.should == "Draenei"
17
+ end
18
+
19
+ it "should be Alliance" do
20
+ # @race.side.should == "alliance"
21
+ end
22
+
23
+ it "should have a mask value" do
24
+ # @race.mask.should == 1024
25
+ end
26
+
27
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe WowArmory::Character do
4
+ context "with valid user name & realm" do
5
+ before :all do
6
+ @character = WowArmory::ArmoryApi.new.get_character('kul-tiras', 'Vervain', ['guild', 'talents', 'stats', 'progression', ])
7
+ end
8
+ it "should have a name" do
9
+ @character.name.should == "Vervain"
10
+ end
11
+
12
+ it "should have a level" do
13
+ @character.level.should == 85
14
+ end
15
+
16
+ it "should have an avatar" do
17
+ @character.avatar_image_url.should == "http://us.battle.net/static-render/us/kul-tiras/193/37832897-avatar.jpg"
18
+ end
19
+
20
+ it "should have an profile image" do
21
+ @character.profile_image_url.should == "http://us.battle.net/static-render/us/kul-tiras/193/37832897-profilemain.jpg"
22
+ end
23
+
24
+ it "should have an card image" do
25
+ @character.card_image_url.should == "http://us.battle.net/static-render/us/kul-tiras/193/37832897-card.jpg"
26
+ end
27
+
28
+ it "should have an inset image" do
29
+ @character.inset_image_url.should == "http://us.battle.net/static-render/us/kul-tiras/193/37832897-inset.jpg"
30
+ end
31
+ end
32
+
33
+ context "with invalid user information" do
34
+ it "should raise a CharacterNotFoundError" do
35
+ expect { WowArmory::ArmoryApi.new.get_character('kul-tiras', 'Elleria', [])}.should raise_error(WowArmory::CharacterNotFoundError)
36
+ end
37
+ end
38
+
39
+ context "with character name - nil" do
40
+ it "should raise StandardError - Character name cannot be nil" do
41
+ expect { WowArmory::ArmoryApi.new.get_character('kul-tiras', nil) }.should raise_error(StandardError, 'Character name cannot be nil')
42
+ end
43
+ end
44
+
45
+ context "with realm name - nil" do
46
+ it "should raise a StandardError - Realm name cannot be nil" do
47
+ expect { WowArmory::ArmoryApi.new.get_character(nil, "Elleria") }.should raise_error(StandardError, 'Realm name cannot be nil')
48
+ end
49
+ end
50
+
51
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ describe WowArmory::Guild do
4
+ context "with correct guild information" do
5
+ before :all do
6
+ @guild = WowArmory::ArmoryApi.new.get_guild('kul-tiras', "Death Defiancy")
7
+ end
8
+ it "should have a name" do
9
+ @guild.name.should == "Death Defiancy"
10
+ end
11
+
12
+ it "should have a level" do
13
+ @guild.level.should == 6
14
+ end
15
+
16
+ it "should have a side" do
17
+ @guild.side.should == 0
18
+ end
19
+
20
+ it "should return a realm object" do
21
+ @guild.realm.is_a?(WowArmory::Realm).should == true
22
+ end
23
+
24
+ it "should have achievement points" do
25
+ @guild.achievement_points.should == 260
26
+ end
27
+ end
28
+
29
+ context "with incorrect guild information" do
30
+ it "should return a GuildNotFoundError" do
31
+ expect {WowArmory::ArmoryApi.new.get_guild('kul-tiras', "Lexingtin")}.should raise_error(WowArmory::GuildNotFoundError)
32
+ end
33
+ end
34
+
35
+ context "with guild name - nil" do
36
+ it "should raise StandardError - Guild name cannot be nil" do
37
+ expect { WowArmory::ArmoryApi.new.get_guild('kul-tiras', nil)}.should raise_error(StandardError, "Guild name cannot be nil")
38
+ end
39
+ end
40
+
41
+ context "with realm name - nil" do
42
+ it "should raise a StandardError - Realm name cannot be nil" do
43
+ expect { WowArmory::ArmoryApi.new.get_guild(nil, "Death Defiancy")}.should raise_error(StandardError, "Realm name cannot be nil")
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe WowArmory::Item do
4
+ context "with valid item id - 78699" do
5
+ before :all do
6
+ @item = WowArmory::ArmoryApi.new.get_item('78699')
7
+ end
8
+
9
+ it "should have a name" do
10
+ @item.name.should == 'Blackfang Battleweave Helmet'
11
+ end
12
+
13
+ it "should have an id" do
14
+ @item.id.should == 78699
15
+ end
16
+
17
+ it "should have an item level" do
18
+ @item.itemLevel.should == 410
19
+ end
20
+
21
+ it "should have a base armor" do
22
+ @item.baseArmor.should == 1700
23
+ end
24
+ it "should have a armor" do
25
+ @item.armor.should == 1700
26
+ end
27
+ end
28
+
29
+ context "with invalid item id" do
30
+ it "should raise an ItemNotFoundError" do
31
+ expect { WowArmory::ArmoryApi.new.get_item('000000') }.should raise_error(WowArmory::ItemNotFoundError)
32
+ end
33
+
34
+ it "should raise an InvalidItemIdError" do
35
+ expect { WowArmory::ArmoryApi.new.get_item('asdf') }.should raise_error(WowArmory::InvalidItemIdError)
36
+ end
37
+ end
38
+
39
+ context "with missing item id" do
40
+ it "should raise a StandardError - Item id cannot be nil" do
41
+ expect { WowArmory::ArmoryApi.new.get_item(nil) }.should raise_error(StandardError, "Item ID cannot be nil")
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe WowArmory::Realm do
4
+ context "with realm name kul-tiras" do
5
+ before :all do
6
+ @realm = WowArmory::ArmoryApi.new.get_realm('kul-tiras')
7
+ end
8
+
9
+ it "should have name" do
10
+ @realm.name.should == "Kul Tiras"
11
+ end
12
+
13
+ it "should have a type" do
14
+ @realm.type.should == "pve"
15
+ end
16
+
17
+ it "should have a slug" do
18
+ @realm.slug.should == "kul-tiras"
19
+ end
20
+
21
+ it "should have a population" do
22
+ @realm.population.should == "medium"
23
+ end
24
+
25
+ it "should be available" do
26
+ @realm.should be_available
27
+ end
28
+
29
+ it "has a queue" do
30
+ @realm.queue.should == false
31
+ end
32
+
33
+ it "should have a battlegroup" do
34
+ @realm.battlegroup.should == "Vengeance"
35
+ end
36
+ end
37
+
38
+ context "with realm name - nil" do
39
+ it "should raise a StandardError - Realm name cannot be nil" do
40
+ expect { WowArmory::ArmoryApi.new.get_realm(nil) }.should raise_error(StandardError, 'Realm name cannot be nil')
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,29 @@
1
+ require "spec_helper.rb"
2
+
3
+ describe WowArmory do
4
+ context "with valid Region code - 'us'" do
5
+ before :all do
6
+ @api = WowArmory::ArmoryApi.new('us')
7
+ end
8
+ it "should return a guild object" do
9
+ @api.get_guild('kul-tiras', 'Death Defiancy').is_a?(WowArmory::Guild).should == true
10
+ end
11
+
12
+ it "should return a character object" do
13
+ @api.get_character('earthen-ring', 'Sophyliora').is_a?(WowArmory::Character).should == true
14
+ end
15
+
16
+ it "should return an item object" do
17
+ @api.get_item('78699').is_a?(WowArmory::Item).should == true
18
+ end
19
+
20
+ it "should return a realm" do
21
+ @api.get_realm('kul-tiras').is_a?(WowArmory::Realm).should == true
22
+ end
23
+ end
24
+ context "with invalid region code - 'ca'" do
25
+ it "should raise an InvalidRegionError" do
26
+ expect { WowArmory::ArmoryApi.new('ca') }.should raise_error(WowArmory::InvalidRegionError)
27
+ end
28
+ end
29
+ end
data/wow_armory.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Mende Najdov"]
9
9
  s.email = ["mende.najdov@gmail.com"]
10
10
  s.homepage = ""
11
- s.summary = %q{Blizzard Community Platform API Wrapper}
11
+ s.summary = %q{Write a gem summary}
12
12
  s.description = %q{Write a gem description}
13
13
 
14
14
  s.rubyforge_project = "wow_armory"
@@ -19,7 +19,11 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  # specify any dependencies here; for example:
22
- # s.add_development_dependency "rspec"
23
- # s.add_runtime_dependency "rest-client"
22
+ s.add_development_dependency "rspec"
23
+ s.add_development_dependency "guard"
24
+ s.add_development_dependency "guard-rspec"
25
+ s.add_development_dependency "ruby_gntp"
24
26
  s.add_dependency "httparty"
27
+ s.add_dependency "rails"
28
+ # s.add_runtime_dependency "rest-client"
25
29
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wow_armory
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.2
4
+ prerelease: 5
5
+ version: 0.0.5pre
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mende Najdov
@@ -10,10 +10,10 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-02-03 00:00:00 Z
13
+ date: 2012-02-26 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: httparty
16
+ name: rspec
17
17
  prerelease: false
18
18
  requirement: &id001 !ruby/object:Gem::Requirement
19
19
  none: false
@@ -21,8 +21,63 @@ dependencies:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
- type: :runtime
24
+ type: :development
25
25
  version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: guard
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :development
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: guard-rspec
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ type: :development
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: ruby_gntp
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :development
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: httparty
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :runtime
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: rails
72
+ prerelease: false
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ type: :runtime
80
+ version_requirements: *id006
26
81
  description: Write a gem description
27
82
  email:
28
83
  - mende.najdov@gmail.com
@@ -34,12 +89,29 @@ extra_rdoc_files: []
34
89
 
35
90
  files:
36
91
  - .gitignore
92
+ - .rspec
37
93
  - Gemfile
38
- - README
94
+ - Guardfile
39
95
  - Rakefile
40
96
  - lib/wow_armory.rb
97
+ - lib/wow_armory/armory_errors.rb
98
+ - lib/wow_armory/character.rb
99
+ - lib/wow_armory/constants.rb
41
100
  - lib/wow_armory/data_object.rb
101
+ - lib/wow_armory/guild.rb
102
+ - lib/wow_armory/item.rb
103
+ - lib/wow_armory/realm.rb
104
+ - lib/wow_armory/spec.rb
105
+ - lib/wow_armory/utility.rb
42
106
  - lib/wow_armory/version.rb
107
+ - spec/spec_helper.rb
108
+ - spec/wow_armory/character_class_spec.rb
109
+ - spec/wow_armory/character_race_spec.rb
110
+ - spec/wow_armory/character_spec.rb
111
+ - spec/wow_armory/guild_spec.rb
112
+ - spec/wow_armory/item_spec.rb
113
+ - spec/wow_armory/realm_spec.rb
114
+ - spec/wow_armory_spec.rb
43
115
  - wow_armory.gemspec
44
116
  homepage: ""
45
117
  licenses: []
@@ -58,15 +130,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
130
  required_rubygems_version: !ruby/object:Gem::Requirement
59
131
  none: false
60
132
  requirements:
61
- - - ">="
133
+ - - ">"
62
134
  - !ruby/object:Gem::Version
63
- version: "0"
135
+ version: 1.3.1
64
136
  requirements: []
65
137
 
66
138
  rubyforge_project: wow_armory
67
139
  rubygems_version: 1.8.15
68
140
  signing_key:
69
141
  specification_version: 3
70
- summary: Blizzard Community Platform API Wrapper
71
- test_files: []
72
-
142
+ summary: Write a gem summary
143
+ test_files:
144
+ - spec/spec_helper.rb
145
+ - spec/wow_armory/character_class_spec.rb
146
+ - spec/wow_armory/character_race_spec.rb
147
+ - spec/wow_armory/character_spec.rb
148
+ - spec/wow_armory/guild_spec.rb
149
+ - spec/wow_armory/item_spec.rb
150
+ - spec/wow_armory/realm_spec.rb
151
+ - spec/wow_armory_spec.rb
data/README DELETED
@@ -1,3 +0,0 @@
1
- # Blizzard Community Platform API Wrapper
2
-
3
- This gem is a simple Ruby API wrapper gem. Work in progress