wow 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29c1df12f3b692c1612863da7d6044b651423923
4
- data.tar.gz: a28ce99fa8091df0e1310e62f3809c4bcfad5767
3
+ metadata.gz: a459381f372b915a5ef250d8d89e7b0b6efa5f4b
4
+ data.tar.gz: 83d7cd9c31aceb3a72833b46861167ddb0d676aa
5
5
  SHA512:
6
- metadata.gz: a3010a0a1f9411e8127696d9afc2835b45d8a56da773080224c6d930d893df981fa5e4ad8b4e11efb2e0545dde9cfd1db877a538cea74bb8d9ed11dfe7b24069
7
- data.tar.gz: f30a85cbb7112ccfd101285aed663c1be9375b79bcfcda7e364be1b86c49af4c3e6a0d31cff4612d6c123b15fb7ccfc2ec1299d2c4a04d57e07902de4810026b
6
+ metadata.gz: 4ab1380abba450a73d3915866b1661ea3623ec2e861df3916d3d11af7e6986b60d8f65d8ccf0b7010c03a038044a6903c25fb082aa9a971c5011bde26cb73d94
7
+ data.tar.gz: 67d43dbfbb9d9cbcc1af64c86afc57f73d83b540d23c83bae172306e6486e4c62d0780fd2bdf39d195ba439af657e143cfaa09c7ae4fa6545ddd884246c207b1
data/lib/wow/base.rb CHANGED
@@ -1,5 +1,8 @@
1
+ require "cgi"
2
+
1
3
  module WoW
2
4
  class Base < Hash
5
+ include HTTParty
3
6
 
4
7
  def initialize(data)
5
8
  data.each { |k,v| self[k] = v }
@@ -1,6 +1,5 @@
1
1
  module WoW
2
2
  class Achievement < Base
3
- include HTTParty
4
3
  base_uri "#{WoW.host}/api/wow/achievement"
5
4
 
6
5
  def initialize(id, params = {})
@@ -2,7 +2,6 @@ module WoW
2
2
  module BattlePet
3
3
 
4
4
  class Ability < Base
5
- include HTTParty
6
5
  base_uri "#{WoW.host}/api/wow/battlePet/ability"
7
6
 
8
7
  def initialize(id, params = {})
@@ -18,7 +17,6 @@ module WoW
18
17
  end
19
18
 
20
19
  class Species < Base
21
- include HTTParty
22
20
  base_uri "#{WoW.host}/api/wow/battlePet/species"
23
21
 
24
22
  def initialize(id, params = {})
@@ -34,7 +32,6 @@ module WoW
34
32
  end
35
33
 
36
34
  class Stats < Base
37
- include HTTParty
38
35
  base_uri "#{WoW.host}/api/wow/battlePet/stats"
39
36
 
40
37
  # This API accepts optional parameters.
@@ -1,8 +1,7 @@
1
1
  module WoW
2
2
  module ChallengeMode
3
3
 
4
- class Realm
5
- include HTTParty
4
+ class Realm < Base
6
5
  base_uri "#{WoW.host}/api/wow/challenge"
7
6
 
8
7
  def initialize(realm, params = {})
@@ -14,7 +14,6 @@ module WoW
14
14
  11 => :druid,
15
15
  }
16
16
 
17
- include HTTParty
18
17
  base_uri "#{WoW.host}/api/wow/character"
19
18
 
20
19
  def initialize(realm, character_name, fields = [], params = {})
@@ -34,7 +33,8 @@ module WoW
34
33
  class << self
35
34
  def data(realm, character_name, params = {})
36
35
  params.merge!({locale: WoW.locale})
37
- get("/#{realm}/#{character_name}", query: params).parsed_response
36
+ get("/#{CGI::escape(realm)}/#{CGI::escape(character_name)}",
37
+ query: params).parsed_response
38
38
  end
39
39
  end
40
40
  end
@@ -1,6 +1,5 @@
1
1
  module WoW
2
2
  class Guild < Base
3
- include HTTParty
4
3
  base_uri "#{WoW.host}/api/wow/guild"
5
4
 
6
5
  def initialize(realm, guild_name, fields = [], params = {})
@@ -1,6 +1,5 @@
1
1
  module WoW
2
2
  class Item < Base
3
- include HTTParty
4
3
  base_uri "#{WoW.host}/api/wow/item"
5
4
 
6
5
  def initialize(id, params = {})
@@ -1,6 +1,5 @@
1
1
  module WoW
2
2
  class Leaderboard < Base
3
- include HTTParty
4
3
  base_uri "#{WoW.host}/api/wow/leaderboard"
5
4
 
6
5
  def initialize(bracket, params = {})
@@ -1,6 +1,5 @@
1
1
  module WoW
2
2
  class Quest < Base
3
- include HTTParty
4
3
  base_uri "#{WoW.host}/api/wow/quest"
5
4
 
6
5
  def initialize(id, params = {})
@@ -1,6 +1,5 @@
1
1
  module WoW
2
2
  class Recipe < Base
3
- include HTTParty
4
3
  base_uri "#{WoW.host}/api/wow/recipe"
5
4
 
6
5
  def initialize(id, params = {})
@@ -1,6 +1,5 @@
1
1
  module WoW
2
2
  class Spell < Base
3
- include HTTParty
4
3
  base_uri "#{WoW.host}/api/wow/spell"
5
4
 
6
5
  def initialize(id, params = {})
data/lib/wow/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module WoW
2
- VERSION = '0.0.1'
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,50 @@
1
+ require "spec_helper"
2
+
3
+ describe WoW::CharacterProfile do
4
+ subject { WoW::CharacterProfile.new("Stormreaver", "Epicgrim") }
5
+
6
+ describe "#initialize" do
7
+ it "is valid server, and name" do
8
+ expect {
9
+ subject
10
+ }.not_to raise_error
11
+ end
12
+
13
+ it "is valid with special characters in name" do
14
+ expect {
15
+ WoW::CharacterProfile.new("Stormreaver", "Disciplíne")
16
+ }.not_to raise_error
17
+ end
18
+
19
+ it "is invalid server" do
20
+ expect {
21
+ WoW::CharacterProfile.new("Notaserver", "Epicgrim")
22
+ }.to raise_error
23
+ end
24
+
25
+ it "is invalid name" do
26
+ expect {
27
+ WoW::CharacterProfile.new("Stormreaver", "Imnotaguyatalllolplz")
28
+ }.to raise_error
29
+ end
30
+
31
+ it "is invalid server and name" do
32
+ expect {
33
+ WoW::CharacterProfile.new("Notaserver", "Imnotaguyatalllolplz")
34
+ }.to raise_error
35
+ end
36
+ end
37
+
38
+ describe "#lookup" do
39
+ it "looks up class" do
40
+ subject.lookup(:class).should eq(:druid)
41
+ end
42
+ end
43
+
44
+ describe "#[]" do
45
+ it "acts as a hash" do
46
+ subject[:name].should eq("Epicgrim")
47
+ end
48
+ end
49
+
50
+ end
@@ -0,0 +1,8 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+
4
+ require "wow"
5
+
6
+ RSpec.configure do |config|
7
+ # ...
8
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Lilienthal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-21 00:00:00.000000000 Z
11
+ date: 2014-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -92,6 +92,8 @@ files:
92
92
  - lib/wow/features/recipe.rb
93
93
  - lib/wow/features/spell.rb
94
94
  - lib/wow/version.rb
95
+ - spec/features/character_profile_spec.rb
96
+ - spec/spec_helper.rb
95
97
  - wow.gemspec
96
98
  homepage: https://github.com/nixpulvis/wow
97
99
  licenses:
@@ -117,4 +119,6 @@ rubygems_version: 2.2.0
117
119
  signing_key:
118
120
  specification_version: 4
119
121
  summary: World of Warcraft API Access.
120
- test_files: []
122
+ test_files:
123
+ - spec/features/character_profile_spec.rb
124
+ - spec/spec_helper.rb