wow_community_api 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  module WowCommunityApi
2
2
  class Character < BattleNet
3
3
  def self.find_by_realm_and_name(realm, name)
4
- OpenStruct.new get("/character/#{realm}/#{name}")
4
+ get("/character/#{realm}/#{name}").to_ostruct
5
5
  end
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  module WowCommunityApi
2
2
  class Guild < BattleNet
3
3
  def self.find_by_realm_and_name(realm, name)
4
- OpenStruct.new get("/guild/#{realm}/#{name}")
4
+ get("/guild/#{realm}/#{name}").to_ostruct
5
5
  end
6
6
  end
7
7
  end
@@ -1,9 +1,10 @@
1
1
  module WowCommunityApi
2
2
  class Realm < BattleNet
3
- def self.find_by_name(name)
4
- results = get("/realm/status", :query => { :realms => name })
5
- realm = results['realms'].first
6
- OpenStruct.new realm
3
+ def self.find_by_name(*name)
4
+ names = { :realms => name.join(",") }
5
+ results = get("/realm/status", :query => names).to_ostruct
6
+ realms = results.realms
7
+ (name.size == 1) ? realms.first : realms
7
8
  end
8
9
  end
9
10
  end
@@ -1,3 +1,3 @@
1
1
  module WowCommunityApi
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,5 +1,5 @@
1
1
  require 'httparty'
2
- require 'ostruct'
2
+ require 'hash-to-ostruct'
3
3
  require 'uri'
4
4
 
5
5
  require "wow_community_api/version"
@@ -4,6 +4,7 @@ describe Character do
4
4
  describe "#find_by_realm_and_name" do
5
5
  it "gets character by realm and name" do
6
6
  stub_json "http://us.battle.net/api/wow/character/uther/malkyth", 'character.json'
7
+
7
8
  character = Character.find_by_realm_and_name("uther", "malkyth")
8
9
  character.name.should == "Malkyth"
9
10
  end
@@ -7,6 +7,14 @@
7
7
  "population":"medium",
8
8
  "name":"Medivh",
9
9
  "slug":"medivh"
10
+ },
11
+ {
12
+ "type":"pve",
13
+ "queue":false,
14
+ "status":true,
15
+ "population":"high",
16
+ "name":"Lightbringer",
17
+ "slug":"lightbringer"
10
18
  }
11
19
  ]
12
20
  }
data/spec/guild_spec.rb CHANGED
@@ -4,6 +4,7 @@ describe Guild do
4
4
  describe "#find_by_realm_and_name" do
5
5
  it "gets guild by realm and name" do
6
6
  stub_json 'http://us.battle.net/api/wow/guild/uther/nova', 'guild.json'
7
+
7
8
  guild = Guild.find_by_realm_and_name("uther", "nova")
8
9
  guild.name.should == "Nova"
9
10
  end
data/spec/realm_spec.rb CHANGED
@@ -4,6 +4,7 @@ describe Realm do
4
4
  describe "#find_by_name" do
5
5
  it "gets the status of a realm by name" do
6
6
  stub_json 'http://us.battle.net/api/wow/realm/status?realms=medivh', 'realms.json'
7
+
7
8
  realm = Realm.find_by_name("medivh")
8
9
  realm.status.should be_true
9
10
  end
@@ -14,5 +15,14 @@ describe Realm do
14
15
  realm = Realm.find_by_name("altar of storms")
15
16
  realm.status.should be_true
16
17
  end
18
+
19
+ it "gets multiple realms by name" do
20
+ stub_json 'http://us.battle.net/api/wow/realm/status?realms=medivh,lightbringer', 'realms.json'
21
+
22
+ realms = Realm.find_by_name("medivh", "lightbringer")
23
+ realms.size.should == 2
24
+ realms[0].name.should == "Medivh"
25
+ realms[1].name.should == "Lightbringer"
26
+ end
17
27
  end
18
28
  end
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_dependency "httparty"
22
+ s.add_dependency "hash-to-ostruct"
22
23
 
23
24
  s.add_development_dependency "rspec"
24
25
  s.add_development_dependency "webmock"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: wow_community_api
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - eddie cianci
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-18 00:00:00 Z
13
+ date: 2011-07-19 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -24,7 +24,7 @@ dependencies:
24
24
  type: :runtime
25
25
  version_requirements: *id001
26
26
  - !ruby/object:Gem::Dependency
27
- name: rspec
27
+ name: hash-to-ostruct
28
28
  prerelease: false
29
29
  requirement: &id002 !ruby/object:Gem::Requirement
30
30
  none: false
@@ -32,10 +32,10 @@ dependencies:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: "0"
35
- type: :development
35
+ type: :runtime
36
36
  version_requirements: *id002
37
37
  - !ruby/object:Gem::Dependency
38
- name: webmock
38
+ name: rspec
39
39
  prerelease: false
40
40
  requirement: &id003 !ruby/object:Gem::Requirement
41
41
  none: false
@@ -45,6 +45,17 @@ dependencies:
45
45
  version: "0"
46
46
  type: :development
47
47
  version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: webmock
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
48
59
  description: a Ruby library for Blizzard's World of Warcraft Community Platform API
49
60
  email:
50
61
  - defeated2k4@gmail.com