wowapi 0.0.4 → 0.1.1
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.
- checksums.yaml +4 -4
- data/.gitignore +7 -1
- data/README.md +87 -14
- data/lib/wowapi/fail_silently.rb +11 -0
- data/lib/wowapi/modules.rb +11 -0
- data/lib/wowapi/modules/character.rb +19 -0
- data/lib/wowapi/modules/guild.rb +17 -9
- data/lib/wowapi/response_data.rb +26 -0
- data/lib/wowapi/version.rb +1 -1
- data/lib/wowapi/wowapi.rb +5 -14
- data/wowapi.gemspec +16 -14
- metadata +9 -20
- data/Gemfile.lock +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be6791e7a0e1cb8e1b3e493a561e6621cc37e133
|
4
|
+
data.tar.gz: 8590259e83af1a16622284167b0c98b6c67aab6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 407ae47b2d7b8c158f2f9544ec4952ac75ff7bfcd46613dd3b5bd046e2b8972b290acff51e75309de53292b4916b65ce6a641dc0c2f08c0b862c61c72f1b216f
|
7
|
+
data.tar.gz: 47bf975e46da5de2aebe1699b42ed2171f2e3e873241e6feabdc66874b7e52bb8e46afb2fcfcd0ff236ce801f058faae6b055f7d5d586d143ce48320ac6d6b9d
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -17,22 +17,50 @@ It gives you a pretty interface to Blizzard's Community API.
|
|
17
17
|
|
18
18
|
## How do I use this?
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
### Installation
|
21
|
+
|
22
|
+
#### Rubygems
|
23
|
+
This gem is available on Rubygems: https://rubygems.org/gems/wowapi
|
24
|
+
```
|
25
|
+
gem install wowapi
|
26
|
+
```
|
27
|
+
And everything should work just fine. For a list of compatible (tested) Rubies, see 'Support' at the bottom.
|
28
|
+
#### Download & build yourself
|
29
|
+
You can also build it from scratch.
|
30
|
+
* clone the repo:
|
31
|
+
```
|
32
|
+
git clone https://git.3lab.re/marahin/wowapi.git
|
33
|
+
```
|
34
|
+
* enter the directory:
|
35
|
+
```
|
36
|
+
cd wowapi
|
37
|
+
```
|
38
|
+
* run bundler, so you have everything you need already:
|
39
|
+
```
|
40
|
+
bundle install
|
41
|
+
```
|
42
|
+
* build gem:
|
43
|
+
```
|
44
|
+
gem build wowapi.gemspec
|
45
|
+
```
|
46
|
+
* if build passes, install it from your local environment:
|
47
|
+
```
|
48
|
+
gem install --local wowapi*.gem
|
49
|
+
```
|
24
50
|
### Resources
|
25
51
|
|
52
|
+
<< DUE TO FAST DEVELOPMENT CYCLE THIS PART OF DOCUMENTATION IS LACKING. >>
|
53
|
+
|
26
54
|
We have different resources for different parts of the API. Each resource can be queried with query fields.
|
27
|
-
|
28
|
-
|
55
|
+
|
56
|
+
Every resource is called as a method on `Wowapi` Object.
|
57
|
+
|
29
58
|
| Resource(s) | query fields | | | |
|
30
59
|
|:-----------: |:------------: |:-------------: |:----------: |:--------: |
|
31
|
-
|
|
32
|
-
|
|
33
|
-
| | | | | | _
|
34
|
-
* temporarily_ - see #1, #2, #3 @ ([git.3lab.re](https://git.3lab.re/marahin/wowapi/issues))
|
60
|
+
| .guild | :news | :achievements | :challenge | :members |
|
61
|
+
| .character |
|
35
62
|
|
63
|
+
### Examples
|
36
64
|
```
|
37
65
|
require 'wowapi'
|
38
66
|
|
@@ -42,8 +70,19 @@ api = Wowapi.new do |config|
|
|
42
70
|
# config.region = :us # (optional)
|
43
71
|
end
|
44
72
|
|
45
|
-
|
46
|
-
|
73
|
+
# returns guild profile
|
74
|
+
guild = api.guild('Argent Dawn', 'The Aspects')
|
75
|
+
|
76
|
+
# returns guild profile & members list
|
77
|
+
guild = api.guild('Argent Dawn', 'The Aspects', :members)
|
78
|
+
guild.members # Array of CharacterClass objects
|
79
|
+
|
80
|
+
# returns guild profile, members list & news
|
81
|
+
guild = api.guild('Argent Dawn', 'The Aspects', :members, :news)
|
82
|
+
guild.news # array of Hashes containing news
|
83
|
+
|
84
|
+
# returns character profile
|
85
|
+
character = api.character('Argent Dawn', 'Marahin')
|
47
86
|
|
48
87
|
```
|
49
88
|
|
@@ -60,7 +99,27 @@ Make sure your Wowapi instance contains `public_key` (and/or, if necessary - `se
|
|
60
99
|
If you fail to authenticate, you will most likely step upon `Wowapi::AuthException` error. This means either your credentials are invalid, or something is wrong with Blizzard services. Nonetheless, you have a problem.
|
61
100
|
|
62
101
|
## Ruby
|
63
|
-
|
102
|
+
Everything >= 2.0.0 should work just fine. Below you can see a table with different MRI Ruby versions which we tested the gem on:
|
103
|
+
|
104
|
+
| Ruby (MRI) | Does it work? |
|
105
|
+
|------------|-------------------------------------------------|
|
106
|
+
| 1.9.3 | **NO**. Some flow in Object class is different. |
|
107
|
+
| 2.0.0 | Hell **YES**. |
|
108
|
+
| 2.2.3 | Sure, **YES**. |
|
109
|
+
| 2.3.0 | Just fine, **YES**. |
|
110
|
+
| 2.3.1 | **YES**, uh huh. |
|
111
|
+
|
112
|
+
As it's early stage development, and as it's stated in the LICENSE, I do not guarantee that any other Rubies will make allow you to use this library.
|
113
|
+
Hell, I do not guarantee _anything_.
|
114
|
+
|
115
|
+
## Documentation
|
116
|
+
Before you start tinkering, I suggest generating *rDOC* documentation.
|
117
|
+
To do so, run `rdoc` in the root directory of Wowapi. Then navigate to doc/index.html in your browser, and voila - you have your offline documentation with all methods, classes and pretty-displayed README.md.
|
118
|
+
|
119
|
+
You may also browse *ri* documentation which installs by default when you install the gem. Just type `ri Wowapi`.
|
120
|
+
|
121
|
+
**But it should work just fine on Rubies >= 2.0.0.**
|
122
|
+
|
64
123
|
## Regions
|
65
124
|
### Region defaults to :eu!
|
66
125
|
List of currently supported regions:
|
@@ -77,5 +136,19 @@ end
|
|
77
136
|
```
|
78
137
|
|
79
138
|
Keep in mind that this is completely optional, and default is **_:eu_**.
|
139
|
+
|
140
|
+
## Contributing
|
141
|
+
I'm a single developer here. I'm working student. This is an introduction.
|
142
|
+
|
143
|
+
### Bugtracking / I have a question / I have a problem
|
144
|
+
Every problem / feature / bug / anything that concerns you should find place in Issues tab up top.
|
145
|
+
As soon as you get your answer, the issue will also be labeled.
|
146
|
+
|
147
|
+
### I want to help
|
148
|
+
If you want to help, make sure you understand how the library works. Ask me, don't feel shy. As a beginner, making me know that someone actually uses it will make my heart warm.
|
149
|
+
If you already know what you're doing, and you know how to fix the bug / make something work better / improve the library, create a pull request.
|
150
|
+
|
151
|
+
Or either create an issue with the code, explaining how it works and why is it better / how does it fix stuff. I don't really care, whatever is easier / friendlier for you.
|
80
152
|
## Games
|
81
|
-
**There is no plan of supporting anything but World of Warcraft. Sorry.**
|
153
|
+
**There is no plan of supporting anything but World of Warcraft. Sorry.**
|
154
|
+
Unless money is involved. :^)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'wowapi/modules/character'
|
2
|
+
require 'wowapi/modules/guild'
|
3
|
+
|
4
|
+
class Wowapi
|
5
|
+
# Wowapi::Modules is a namespace which we keep our
|
6
|
+
# particular methods for different parts of Blizzard's
|
7
|
+
# World of Warcraft Community API handling
|
8
|
+
module Modules; end
|
9
|
+
include Wowapi::Modules::Character
|
10
|
+
include Wowapi::Modules::Guild
|
11
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Wowapi
|
2
|
+
module Modules
|
3
|
+
# Character module containing methods for
|
4
|
+
# character data retrieval & definition of
|
5
|
+
# CharacterClass
|
6
|
+
module Character
|
7
|
+
# todo: issue-13
|
8
|
+
class CharacterClass < Wowapi::ResponseData; end
|
9
|
+
|
10
|
+
# Retrieve data about particular Character
|
11
|
+
# For a list of fields visit README.md
|
12
|
+
def character(realm, name, *args)
|
13
|
+
args = args.map{|n| n if n.is_a?(Symbol) }
|
14
|
+
res = get 'character/', "#{realm}/#{name}?fields=#{args.join(',')}"
|
15
|
+
Wowapi::Modules::Character::CharacterClass.new(JSON.parse(res))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/wowapi/modules/guild.rb
CHANGED
@@ -5,17 +5,25 @@ class Wowapi
|
|
5
5
|
# some kind of GuildClass, see:
|
6
6
|
# https://git.3lab.re/marahin/wowapi/issues/1
|
7
7
|
module Guild
|
8
|
+
|
9
|
+
# GuildClass - represents the Guild resource
|
10
|
+
class GuildClass < Wowapi::ResponseData
|
11
|
+
def initialize(data={})
|
12
|
+
super
|
13
|
+
if @table
|
14
|
+
@table[:members].map!{ |player_hash|
|
15
|
+
Wowapi::Modules::Character::CharacterClass.new(player_hash)
|
16
|
+
} if @table[:members]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
8
21
|
# Asks Blizzard API for Guild resource
|
9
|
-
#
|
10
|
-
# Example:
|
11
|
-
# ```
|
12
|
-
# api.guild 'Argent Dawn', 'The Aspects', :members, :news, ...
|
13
|
-
# ```
|
14
|
-
# Currently returns Hash
|
22
|
+
# for list of fields visit README.md
|
15
23
|
def guild(realm, name, *args)
|
16
|
-
args = args.map{|n| n
|
17
|
-
res = get 'guild/', "#{realm}/#{name}?fields=#{args.join('
|
18
|
-
JSON.parse(res)
|
24
|
+
args = args.map{|n| n if n.is_a?(Symbol) }
|
25
|
+
res = get 'guild/', "#{realm}/#{name}?fields=#{args.join(',')}"
|
26
|
+
Wowapi::Modules::Guild::GuildClass.new(JSON.parse(res))
|
19
27
|
end
|
20
28
|
end
|
21
29
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Wowapi
|
2
|
+
# Every ModuleClass inherits from this object,
|
3
|
+
# so GuildClass, AchievementClass etc.
|
4
|
+
# ResponseData class inherits from OpenStruct which makes it easy to
|
5
|
+
# define arbitrary fields, using a Hash (so a default response object)
|
6
|
+
# http://www.ruby-doc.org/stdlib-2.0/libdoc/ostruct/rdoc/OpenStruct.html
|
7
|
+
class ResponseData < OpenStruct
|
8
|
+
# Raw holds the response Hash, untouched
|
9
|
+
attr_accessor :raw
|
10
|
+
|
11
|
+
def initialize(data={})
|
12
|
+
unless data.is_a?(Hash)
|
13
|
+
raise ArgumentError, 'Data has to be passed as a Hash object.'
|
14
|
+
end
|
15
|
+
@raw = data # Assign raw data to @raw instance variable
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
# Override default .to_json method
|
20
|
+
# this one returns raw data that was assigned
|
21
|
+
# during initialization
|
22
|
+
def to_json
|
23
|
+
@raw
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/wowapi/version.rb
CHANGED
data/lib/wowapi/wowapi.rb
CHANGED
@@ -1,26 +1,17 @@
|
|
1
1
|
require 'open-uri'
|
2
2
|
require 'json'
|
3
3
|
require 'wowapi/core_extensions/object/try'
|
4
|
+
require 'wowapi/fail_silently'
|
4
5
|
require 'wowapi/exceptions'
|
5
6
|
require 'wowapi/version'
|
6
|
-
require 'wowapi/
|
7
|
+
require 'wowapi/response_data'
|
8
|
+
require 'wowapi/modules'
|
7
9
|
|
8
10
|
class Wowapi
|
11
|
+
# Instance variables we keep our region, public_key and secret_key in
|
9
12
|
attr_accessor :region, :public_key, :secret_key
|
10
13
|
|
11
|
-
#
|
12
|
-
# particular methods for different parts of Blizzard's
|
13
|
-
# World of Warcraft Community API handling
|
14
|
-
module Modules; end
|
15
|
-
include Wowapi::Modules::Guild
|
16
|
-
|
17
|
-
class << self
|
18
|
-
# Raise exceptions on error responses from API endpoint?
|
19
|
-
attr_accessor :fail_silently
|
20
|
-
end
|
21
|
-
|
22
|
-
@fail_silently = false
|
23
|
-
|
14
|
+
# Creating an instance of Wowapi class
|
24
15
|
def initialize
|
25
16
|
self.region ||= :eu
|
26
17
|
yield self if block_given?
|
data/wowapi.gemspec
CHANGED
@@ -4,20 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'wowapi/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.
|
10
|
-
spec.
|
11
|
-
spec.
|
12
|
-
spec.
|
13
|
-
spec.
|
14
|
-
spec.
|
15
|
-
spec.
|
16
|
-
spec.
|
17
|
-
spec.
|
18
|
-
spec.
|
7
|
+
spec.name = 'wowapi'
|
8
|
+
spec.version = Wowapi::VERSION
|
9
|
+
spec.required_ruby_version = '>= 2.0.0'
|
10
|
+
spec.authors = ['Jan Matusz']
|
11
|
+
spec.email = ['me@marahin.pl']
|
12
|
+
spec.description = %q{An easy-to-use gem providing access to World of Warcraft part of Blizzard Community API.}
|
13
|
+
spec.summary = %q{World of Warcraft API}
|
14
|
+
spec.homepage = 'https://git.3lab.re/marahin/wowapi'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
19
20
|
|
20
|
-
spec.add_development_dependency
|
21
|
-
|
21
|
+
if spec.respond_to?(:add_development_dependency)
|
22
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
23
|
+
end
|
22
24
|
end
|
23
25
|
|
metadata
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wowapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Matusz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: pry
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
17
|
- - "~>"
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
19
|
+
version: '0.10'
|
34
20
|
type: :development
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
24
|
- - "~>"
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
26
|
+
version: '0.10'
|
41
27
|
description: An easy-to-use gem providing access to World of Warcraft part of Blizzard
|
42
28
|
Community API.
|
43
29
|
email:
|
@@ -48,7 +34,6 @@ extra_rdoc_files: []
|
|
48
34
|
files:
|
49
35
|
- ".gitignore"
|
50
36
|
- Gemfile
|
51
|
-
- Gemfile.lock
|
52
37
|
- LICENSE.txt
|
53
38
|
- README.md
|
54
39
|
- lib/wowapi.rb
|
@@ -58,7 +43,11 @@ files:
|
|
58
43
|
- lib/wowapi/exceptions/auth_exception.rb
|
59
44
|
- lib/wowapi/exceptions/no_credentials_exception.rb
|
60
45
|
- lib/wowapi/exceptions/region_exception.rb
|
46
|
+
- lib/wowapi/fail_silently.rb
|
47
|
+
- lib/wowapi/modules.rb
|
48
|
+
- lib/wowapi/modules/character.rb
|
61
49
|
- lib/wowapi/modules/guild.rb
|
50
|
+
- lib/wowapi/response_data.rb
|
62
51
|
- lib/wowapi/version.rb
|
63
52
|
- lib/wowapi/wowapi.rb
|
64
53
|
- wowapi.gemspec
|
@@ -74,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
63
|
requirements:
|
75
64
|
- - ">="
|
76
65
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
66
|
+
version: 2.0.0
|
78
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
68
|
requirements:
|
80
69
|
- - ">="
|
data/Gemfile.lock
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
coderay (1.1.1)
|
5
|
-
method_source (0.8.2)
|
6
|
-
pry (0.10.4)
|
7
|
-
coderay (~> 1.1.0)
|
8
|
-
method_source (~> 0.8.1)
|
9
|
-
slop (~> 3.4)
|
10
|
-
slop (3.6.0)
|
11
|
-
|
12
|
-
PLATFORMS
|
13
|
-
ruby
|
14
|
-
|
15
|
-
DEPENDENCIES
|
16
|
-
pry
|
17
|
-
|
18
|
-
BUNDLED WITH
|
19
|
-
1.12.5
|