wowapi 0.1.1 → 0.1.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: be6791e7a0e1cb8e1b3e493a561e6621cc37e133
4
- data.tar.gz: 8590259e83af1a16622284167b0c98b6c67aab6d
3
+ metadata.gz: 01f7fb2b3b80e6594f57deb3882de162fb879af2
4
+ data.tar.gz: f0b935e7a633887c89d973ffdbb41c6317a6812a
5
5
  SHA512:
6
- metadata.gz: 407ae47b2d7b8c158f2f9544ec4952ac75ff7bfcd46613dd3b5bd046e2b8972b290acff51e75309de53292b4916b65ce6a641dc0c2f08c0b862c61c72f1b216f
7
- data.tar.gz: 47bf975e46da5de2aebe1699b42ed2171f2e3e873241e6feabdc66874b7e52bb8e46afb2fcfcd0ff236ce801f058faae6b055f7d5d586d143ce48320ac6d6b9d
6
+ metadata.gz: e03811c8a93a23217b9546371e41146c8bfa5f09954bbf471d50106561c6fde931592764dc82f2bd105181dc606106362bd826c75741352e9f0d2794af6c079a
7
+ data.tar.gz: e19fd9e9e7998c99840df71cfe2b14e2d5e326b51950f84912991601501869a180f89c1433c4030c8511b34446452c77140d459ad107ab79b30cde35509b2139
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.2.3
5
+ - 2.3.0
6
+ script:
7
+ - bundle install
8
+ - gem build wowapi.gemspec
9
+ notifications:
10
+ email: true
11
+ irc:
12
+ on_success: change
13
+ on_failure: always
14
+ channels:
15
+ - "irc.freenode.org#wowapi"
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # WoWAPI
2
- [![Gem Version](https://badge.fury.io/rb/wowapi.svg)](https://badge.fury.io/rb/wowapi)
2
+ [![Gem Version](https://badge.fury.io/rb/wowapi.svg)](https://badge.fury.io/rb/wowapi)
3
+ [![Build Status](https://travis-ci.org/Marahin/wowapi.svg?branch=master)](https://travis-ci.org/Marahin/wowapi)
4
+ [![Code Climate](https://codeclimate.com/github/Marahin/wowapi/badges/gpa.svg)](https://codeclimate.com/github/Marahin/wowapi)
5
+ [![Dependency Status](https://gemnasium.com/badges/github.com/Marahin/wowapi.svg)](https://gemnasium.com/github.com/Marahin/wowapi)
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)
3
8
 
4
9
  **EARLY STAGE DEVELOPMENT. HERE BE DRAGONS**
5
10
  However, you are welcome to contribute and/or criticise (and/or) show me the way to handle things.
@@ -58,16 +63,60 @@ Every resource is called as a method on `Wowapi` Object.
58
63
  | Resource(s) | query fields | | | |
59
64
  |:-----------: |:------------: |:-------------: |:----------: |:--------: |
60
65
  | .guild | :news | :achievements | :challenge | :members |
61
- | .character |
66
+ | .character | :avatar |
62
67
 
63
68
  ### Examples
69
+
70
+ #### Rails
71
+ * Create initializer called `wowapi.rb` in your Rails app's `config/initializers` directory,
72
+ * fill it with following:
73
+ ```
74
+ require 'wowapi'
75
+
76
+ ## Set region (defaults to :eu)
77
+ ## Wowapi.region = :us
78
+
79
+ ## Create Api variable usable ANYWHERE in your Rails app
80
+ ::Api = Wowapi.new do |config|
81
+ config.public_key = 'your-public-apikey'
82
+ ## config.secret_key = 'your-secret-key'
83
+ end
84
+
85
+ ## Create your Guild name variable, usually GuildName or GuildNameApi that holds information about your guild.
86
+ ## ::YourGuildName = Api.guild('Realm', 'Guild name', :field1, :field2)
87
+ ::Aspects = Api.guild('Argent Dawn', 'The Aspects', :members, :news)
88
+ ```
89
+
90
+ Now, in any controller / view you can do:
91
+
92
+ * controllers/pages_controller.rb
93
+
94
+ ```
95
+ class PagesController < ApplicationController
96
+ def index
97
+ @news = Aspects.news
98
+ end
99
+ end
100
+
101
+ ```
102
+
103
+ * in views:
104
+
105
+ ```
106
+ @news.last(7).each do |news|
107
+ ...
108
+ end
109
+ ```
110
+
111
+
112
+ #### Plain ruby
113
+ You can use simple variables. For more advanced usage with global variables and namespaces, see above (Rails usage).
64
114
  ```
65
115
  require 'wowapi'
66
116
 
67
117
  api = Wowapi.new do |config|
68
118
  config.public_key = 'your-public-apikey'
69
119
  # config.secret_Key = 'optional-secret-key'
70
- # config.region = :us # (optional)
71
120
  end
72
121
 
73
122
  # returns guild profile
@@ -140,6 +189,8 @@ Keep in mind that this is completely optional, and default is **_:eu_**.
140
189
  ## Contributing
141
190
  I'm a single developer here. I'm working student. This is an introduction.
142
191
 
192
+ ### IRC
193
+ `#wowapi` at Freenode
143
194
  ### Bugtracking / I have a question / I have a problem
144
195
  Every problem / feature / bug / anything that concerns you should find place in Issues tab up top.
145
196
  As soon as you get your answer, the issue will also be labeled.
@@ -5,7 +5,20 @@ class Wowapi
5
5
  # CharacterClass
6
6
  module Character
7
7
  # todo: issue-13
8
- class CharacterClass < Wowapi::ResponseData; end
8
+ class CharacterClass < Wowapi::ResponseData
9
+ def initialize(res)
10
+ super
11
+
12
+ if @table
13
+ @table[:character]['thumbnail'] = "http://render-api-#{Wowapi.region}.worldofwarcraft.com/static-render/#{Wowapi.region}/#{@table[:character]['thumbnail']}"
14
+ end
15
+ end
16
+
17
+ ## Character avatar image
18
+ def avatar
19
+ @table[:character]['thumbnail']
20
+ end
21
+ end
9
22
 
10
23
  # Retrieve data about particular Character
11
24
  # For a list of fields visit README.md
@@ -0,0 +1,17 @@
1
+ class Wowapi
2
+ class << self
3
+ # Wowapi.region class variable that holds
4
+ # customer region (:eu, :us, ...)
5
+ # DEFAULTS TO :eu
6
+ attr_accessor :region
7
+ Wowapi.region ||= :eu
8
+ end
9
+
10
+ def region=(region)
11
+ Wowapi.region = region if region.is_a?(Symbol)
12
+ end
13
+
14
+ def region
15
+ Wowapi.region
16
+ end
17
+ end
@@ -1,4 +1,4 @@
1
1
  class Wowapi
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
4
4
 
data/lib/wowapi/wowapi.rb CHANGED
@@ -2,18 +2,18 @@ require 'open-uri'
2
2
  require 'json'
3
3
  require 'wowapi/core_extensions/object/try'
4
4
  require 'wowapi/fail_silently'
5
+ require 'wowapi/region'
5
6
  require 'wowapi/exceptions'
6
7
  require 'wowapi/version'
7
8
  require 'wowapi/response_data'
8
9
  require 'wowapi/modules'
9
10
 
10
11
  class Wowapi
11
- # Instance variables we keep our region, public_key and secret_key in
12
- attr_accessor :region, :public_key, :secret_key
12
+ # Instance variables we keep public_key and secret_key in
13
+ attr_accessor :public_key, :secret_key
13
14
 
14
15
  # Creating an instance of Wowapi class
15
16
  def initialize
16
- self.region ||= :eu
17
17
  yield self if block_given?
18
18
  end
19
19
 
@@ -44,7 +44,7 @@ class Wowapi
44
44
  # Returns URL for particular region
45
45
  # or throws an exception if region is nonexistent
46
46
  def base_url
47
- case self.region
47
+ case Wowapi.region
48
48
  when :eu
49
49
  'eu.api.battle.net/wow/'
50
50
  when :us
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.1
4
+ version: 0.1.2
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 00:00:00.000000000 Z
11
+ date: 2016-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -33,6 +33,7 @@ extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
35
  - ".gitignore"
36
+ - ".travis.yml"
36
37
  - Gemfile
37
38
  - LICENSE.txt
38
39
  - README.md
@@ -47,6 +48,7 @@ files:
47
48
  - lib/wowapi/modules.rb
48
49
  - lib/wowapi/modules/character.rb
49
50
  - lib/wowapi/modules/guild.rb
51
+ - lib/wowapi/region.rb
50
52
  - lib/wowapi/response_data.rb
51
53
  - lib/wowapi/version.rb
52
54
  - lib/wowapi/wowapi.rb