wow_community_api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.autotest ADDED
@@ -0,0 +1 @@
1
+ require "autotest/bundler"
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/.rspec ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in wow_community_api.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2011 eddie cianci
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.mdown ADDED
@@ -0,0 +1,17 @@
1
+ # WoW Community Platform API Ruby library
2
+
3
+ A Ruby library for Blizzard's World of Warcraft Community Platform API. <http://blizzard.github.com/api-wow-docs>
4
+
5
+ ## Contributing to the WoW Community Platform API Ruby library
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ ## Copyright
16
+
17
+ Copyright (c) 2011 eddie cianci. Released under the MIT license. See LICENSE for further details.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,11 @@
1
+ module WowCommunityApi
2
+ class BattleNet
3
+ include HTTParty
4
+
5
+ def self.region(name)
6
+ self.base_uri "#{name}.battle.net/api/wow"
7
+ end
8
+ base_uri region(Regions::US)
9
+
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module WowCommunityApi
2
+ class Character < BattleNet
3
+ def self.find_by_realm_and_name(realm, name)
4
+ OpenStruct.new get("/character/#{realm}/#{name}")
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module WowCommunityApi
2
+ class Guild < BattleNet
3
+ def self.find_by_realm_and_name(realm, name)
4
+ OpenStruct.new get("/guild/#{realm}/#{name}")
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module WowCommunityApi
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
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ module WowCommunityApi
2
+ class Regions
3
+ US = "us"
4
+ EU = "eu"
5
+ KR = "kr"
6
+ TW = "tw"
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module WowCommunityApi
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,10 @@
1
+ require 'httparty'
2
+ require 'ostruct'
3
+ require 'webmock/rspec'
4
+
5
+ require "wow_community_api/version"
6
+ require "wow_community_api/regions"
7
+ require "wow_community_api/battle_net"
8
+ require "wow_community_api/realm"
9
+ require "wow_community_api/character"
10
+ require "wow_community_api/guild"
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe BattleNet do
4
+ describe "#region" do
5
+ it "sets the base uri to a region" do
6
+ BattleNet.region(Regions::US).should == "http://us.battle.net/api/wow"
7
+ BattleNet.region(Regions::EU).should == "http://eu.battle.net/api/wow"
8
+ BattleNet.region(Regions::KR).should == "http://kr.battle.net/api/wow"
9
+ BattleNet.region(Regions::TW).should == "http://tw.battle.net/api/wow"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Character do
4
+ describe "#find_by_realm_and_name" do
5
+ before do
6
+ expected_uri = "http://us.battle.net/api/wow/character/uther/malkyth"
7
+ expected_body = '{ lastModified: 1310338638000, name: "Malkyth", realm: "Uther", class: 9, race: 5, gender: 0, level: 85, achievementPoints: 10970, thumbnail: "uther/243/6004211-avatar.jpg" }'
8
+ stub_request(:get, expected_uri).to_return(:body => expected_body, :headers => { 'Content-Type' => 'application/json' })
9
+ end
10
+
11
+ it "gets character by realm and name" do
12
+ character = Character.find_by_realm_and_name("uther", "malkyth")
13
+ character.name.should == "Malkyth"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Guild do
4
+ describe "#find_by_realm_and_name" do
5
+ before do
6
+ expected_uri = "http://us.battle.net/api/wow/guild/uther/nova"
7
+ expected_body = '{ lastModified: 1310345452000, name: "Nova", realm: "Uther", level: 22, side: 0, achievementPoints: 510 }'
8
+ stub_request(:get, expected_uri).to_return(:body => expected_body, :headers => { 'Content-Type' => 'application/json' })
9
+ end
10
+
11
+ it "gets guild by realm and name" do
12
+ guild = Guild.find_by_realm_and_name("uther", "nova")
13
+ guild.name.should == "Nova"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Realm do
4
+ describe "#find_by_name" do
5
+ before do
6
+ expected_uri = "http://us.battle.net/api/wow/realm/status?realms=medivh"
7
+ expected_body = '{ "realms":[{ "type":"pve", "queue":false, "status":true, "population":"medium", "name":"Medivh", "slug":"medivh" }] }'
8
+ stub_request(:get, expected_uri).to_return(:body => expected_body, :headers => { 'Content-Type' => 'application/json' })
9
+ end
10
+
11
+ it "gets the status of a realm by name" do
12
+ realm = Realm.find_by_name("medivh")
13
+ realm.status.should be_true
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Regions do
4
+ describe "valid regions" do
5
+ it "supports the united states" do
6
+ Regions::US.should == "us"
7
+ end
8
+
9
+ it "supports europe" do
10
+ Regions::EU.should == "eu"
11
+ end
12
+
13
+ it "supports korea" do
14
+ Regions::KR.should == "kr"
15
+ end
16
+
17
+ it "supports taiwan" do
18
+ Regions::TW.should == "tw"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ require 'wow_community_api'
2
+
3
+ include WowCommunityApi
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "wow_community_api/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "wow_community_api"
7
+ s.version = WowCommunityApi::VERSION
8
+ s.authors = ["eddie cianci"]
9
+ s.email = ["defeated2k4@gmail.com"]
10
+ s.homepage = "http://github.com/defeated/wow_community_api"
11
+ s.summary = %q{World of Warcraft Community Platform API}
12
+ s.description = %q{a Ruby library for Blizzard's World of Warcraft Community Platform API}
13
+
14
+ s.rubyforge_project = "wow_community_api"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency "httparty"
22
+
23
+ s.add_development_dependency "rspec"
24
+ s.add_development_dependency "webmock"
25
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wow_community_api
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - eddie cianci
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-07-11 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: httparty
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
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: webmock
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
+ description: a Ruby library for Blizzard's World of Warcraft Community Platform API
49
+ email:
50
+ - defeated2k4@gmail.com
51
+ executables: []
52
+
53
+ extensions: []
54
+
55
+ extra_rdoc_files: []
56
+
57
+ files:
58
+ - .autotest
59
+ - .gitignore
60
+ - .rspec
61
+ - Gemfile
62
+ - LICENSE
63
+ - README.mdown
64
+ - Rakefile
65
+ - lib/wow_community_api.rb
66
+ - lib/wow_community_api/battle_net.rb
67
+ - lib/wow_community_api/character.rb
68
+ - lib/wow_community_api/guild.rb
69
+ - lib/wow_community_api/realm.rb
70
+ - lib/wow_community_api/regions.rb
71
+ - lib/wow_community_api/version.rb
72
+ - spec/battle_net_spec.rb
73
+ - spec/character_spec.rb
74
+ - spec/guild_spec.rb
75
+ - spec/realm_spec.rb
76
+ - spec/regions_spec.rb
77
+ - spec/spec_helper.rb
78
+ - wow_community_api.gemspec
79
+ homepage: http://github.com/defeated/wow_community_api
80
+ licenses: []
81
+
82
+ post_install_message:
83
+ rdoc_options: []
84
+
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: "0"
99
+ requirements: []
100
+
101
+ rubyforge_project: wow_community_api
102
+ rubygems_version: 1.8.5
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: World of Warcraft Community Platform API
106
+ test_files:
107
+ - spec/battle_net_spec.rb
108
+ - spec/character_spec.rb
109
+ - spec/guild_spec.rb
110
+ - spec/realm_spec.rb
111
+ - spec/regions_spec.rb
112
+ - spec/spec_helper.rb