wowapi 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01f7fb2b3b80e6594f57deb3882de162fb879af2
4
- data.tar.gz: f0b935e7a633887c89d973ffdbb41c6317a6812a
3
+ metadata.gz: 40f58251088f0c504e35e57d005aeb01b4971dd9
4
+ data.tar.gz: 6c31a0b62e357cdaf9a13593eda7aa6d6f532084
5
5
  SHA512:
6
- metadata.gz: e03811c8a93a23217b9546371e41146c8bfa5f09954bbf471d50106561c6fde931592764dc82f2bd105181dc606106362bd826c75741352e9f0d2794af6c079a
7
- data.tar.gz: e19fd9e9e7998c99840df71cfe2b14e2d5e326b51950f84912991601501869a180f89c1433c4030c8511b34446452c77140d459ad107ab79b30cde35509b2139
6
+ metadata.gz: eee91355e730b0cfcf7b743e9e0993e62c30fa26481065b4c9a174a2e0c0fc6de7d4566b19af99fd233718fe315d5884e7f81fae09d4e50e697c903dd7ae13e8
7
+ data.tar.gz: 913c286c5a2cc034b5cbbcffa3f59ce9cae96230cca87ca86b2938ffde0e3b14ff0d87e1efdeb35c9d5029490940ba3c6335d146556f2193bc9e41c62d3e55ae
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Code Climate](https://codeclimate.com/github/Marahin/wowapi/badges/gpa.svg)](https://codeclimate.com/github/Marahin/wowapi)
5
5
  [![Dependency Status](https://gemnasium.com/badges/github.com/Marahin/wowapi.svg)](https://gemnasium.com/github.com/Marahin/wowapi)
6
6
  [![security](https://hakiri.io/github/Marahin/wowapi/master.svg)](https://hakiri.io/github/Marahin/wowapi/master)
7
- [![Inline docs](http://inch-ci.org/github/Marahin/wowapi.svg?branch=master)](http://inch-ci.org/github/Marahin/wowapi)
7
+ [![Inline docs](https://inch-ci.org/github/Marahin/wowapi.svg?branch=master)](https://inch-ci.org/github/Marahin/wowapi)
8
8
 
9
9
  **EARLY STAGE DEVELOPMENT. HERE BE DRAGONS**
10
10
  However, you are welcome to contribute and/or criticise (and/or) show me the way to handle things.
@@ -50,26 +50,55 @@ It gives you a pretty interface to Blizzard's Community API.
50
50
  ```
51
51
  * if build passes, install it from your local environment:
52
52
  ```
53
- gem install --local wowapi*.gem
53
+ gem install --local wowapi**.gem
54
54
  ```
55
- ### Resources
55
+
56
+
57
+ ### Resources, query fields and fields
58
+
59
+ **<< DUE TO FAST DEVELOPMENT CYCLE THIS PART OF DOCUMENTATION IS LACKING. >>**
60
+
61
+ We have different **resources** for different parts of the API. Each **resource** can be queried with **query fields**, and after being queried, object has **fields**.
62
+
63
+ Every **resource** is called as a method on `Wowapi` Object. Please note that resource is **not** a field.
64
+ **Query field** can be defined as "what do we exactly want to know about the resource". See following example:
65
+
66
+
67
+ ```
68
+ api.guild('Argent Dawn', 'The Aspects') ## this returns only basic Guild info (guild resource with no query fields)
69
+
70
+ api.guild('Argent Dawn', 'The Aspects', :news, :members) ## whereas this returns guild info AND members array (guild resource with :members, :news query fields)
71
+ ```
56
72
 
57
- << DUE TO FAST DEVELOPMENT CYCLE THIS PART OF DOCUMENTATION IS LACKING. >>
73
+ In above example we passed `:news` and `:members` **query fields** for the Guild **resource**. However, `:members` is a special example, because **not only this is a query field, but also a special field**.
74
+ **Special field** is a **field** that is additionally processed. See, in case of `:members` Blizzard returns JSON array that contains some Character data (an array of Characters that are members of the Guild). However, Wowapi is so cool that every record inside becomes a `CharacterClass` object.
75
+ In different words, **special fields contain A PROCESSED BLIZZARD RESPONSE**. These are enhanced and can be managed Ruby-way.
58
76
 
59
- We have different resources for different parts of the API. Each resource can be queried with query fields.
77
+ **SPECIAL FIELD DOESN'T NECESSARILY HAVE TO BE A QUERY FIELD. SEE `.avatar` ON `CharacterClass`**
78
+ **SPECIAL FIELDS ARE MENTIONED ONLY BECAUSE PART OF THE API IS NOT YET FULLY COVERED. SOME "FIELDS" THAT ARE NOT _SPECIAL_ MAY CONTAIN RAW JSON RESPONSE.**
60
79
 
61
- Every resource is called as a method on `Wowapi` Object.
80
+ #### Query fields table
62
81
 
63
82
  | Resource(s) | query fields | | | |
64
83
  |:-----------: |:------------: |:-------------: |:----------: |:--------: |
65
84
  | .guild | :news | :achievements | :challenge | :members |
66
- | .character | :avatar |
85
+ | .character |
86
+
87
+ #### Special fields table
88
+
89
+ | Resource | field | special field?| description |
90
+ | :-----------: | :-----------: | :-----------: | :-----------: |
91
+ | guild | .members | yes |Becomes array of `CharacterClass` objects |
92
+ | character | .avatar | yes |Returns ready-to-render link for avatar image of the character.|
93
+
67
94
 
68
95
  ### Examples
69
96
 
70
97
  #### Rails
71
98
  * Create initializer called `wowapi.rb` in your Rails app's `config/initializers` directory,
72
99
  * fill it with following:
100
+
101
+
73
102
  ```
74
103
  require 'wowapi'
75
104
 
@@ -91,6 +120,7 @@ Now, in any controller / view you can do:
91
120
 
92
121
  * controllers/pages_controller.rb
93
122
 
123
+
94
124
  ```
95
125
  class PagesController < ApplicationController
96
126
  def index
@@ -102,6 +132,7 @@ end
102
132
 
103
133
  * in views:
104
134
 
135
+
105
136
  ```
106
137
  @news.last(7).each do |news|
107
138
  ...
@@ -162,10 +193,10 @@ As it's early stage development, and as it's stated in the LICENSE, I do not gua
162
193
  Hell, I do not guarantee _anything_.
163
194
 
164
195
  ## Documentation
165
- Before you start tinkering, I suggest generating *rDOC* documentation.
196
+ Before you start tinkering, I suggest generating **rDOC** documentation.
166
197
  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.
167
198
 
168
- You may also browse *ri* documentation which installs by default when you install the gem. Just type `ri Wowapi`.
199
+ You may also browse **ri** documentation which installs by default when you install the gem. Just type `ri Wowapi`.
169
200
 
170
201
  **But it should work just fine on Rubies >= 2.0.0.**
171
202
 
@@ -175,13 +206,16 @@ List of currently supported regions:
175
206
  - Europe (**_:eu_**)
176
207
  - United States (**_:us_**)
177
208
 
178
- API region can be changed by passing proper symbol to the configuration, example:
209
+ API region can be changed by passing proper symbol:
179
210
 
180
211
  ```
181
- api = Wowapi.new do |config|
182
- config.region = :us
183
- ...
184
- end
212
+ ## Change through Wowapi class variable,
213
+ Wowapi.region = :us
214
+
215
+ ## Change through Wowapi object
216
+ myvar = Wowapi.new{ |c| ... }
217
+ myvar.region = :us
218
+
185
219
  ```
186
220
 
187
221
  Keep in mind that this is completely optional, and default is **_:eu_**.
@@ -1,7 +1,6 @@
1
1
  class Wowapi
2
2
  module Modules
3
- # Character module containing methods for
4
- # character data retrieval & definition of
3
+ # Character module containing methods for character data retrieval & definition of
5
4
  # CharacterClass
6
5
  module Character
7
6
  # todo: issue-13
@@ -9,8 +8,15 @@ class Wowapi
9
8
  def initialize(res)
10
9
  super
11
10
 
11
+ # Likely requires refactoring. This reassigns unsufficient thumbnail address
12
+ # returned by World of Warcraft API and sets it to proper thumbnail URL
13
+ # that you can use to download / display image from Blizzards' servers
12
14
  if @table
13
- @table[:character]['thumbnail'] = "http://render-api-#{Wowapi.region}.worldofwarcraft.com/static-render/#{Wowapi.region}/#{@table[:character]['thumbnail']}"
15
+ if @table.key?(:character) && @table[:character].key?('thumbnail')
16
+ @table[:character]['thumbnail'] = "http://render-api-#{Wowapi.region}.worldofwarcraft.com/static-render/#{Wowapi.region}/#{@table[:character]['thumbnail']}"
17
+ elsif @table.key?(:thumbnail)
18
+ @table[:thumbnail] = "http://render-api-#{Wowapi.region}.worldofwarcraft.com/static-render/#{Wowapi.region}/#{@table[:thumbnail]}"
19
+ end
14
20
  end
15
21
  end
16
22
 
@@ -20,8 +26,7 @@ class Wowapi
20
26
  end
21
27
  end
22
28
 
23
- # Retrieve data about particular Character
24
- # For a list of fields visit README.md
29
+ # Retrieve data about particular Character. For a list of fields visit README.md
25
30
  def character(realm, name, *args)
26
31
  args = args.map{|n| n if n.is_a?(Symbol) }
27
32
  res = get 'character/', "#{realm}/#{name}?fields=#{args.join(',')}"
@@ -1,4 +1,4 @@
1
1
  class Wowapi
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wowapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
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-11-05 00:00:00.000000000 Z
11
+ date: 2016-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  version: '0'
74
74
  requirements: []
75
75
  rubyforge_project:
76
- rubygems_version: 2.4.5.1
76
+ rubygems_version: 2.5.1
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: World of Warcraft API