wowapi 0.0.3 → 0.0.4

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: e686e355a23bee293048d3ad3763e1b095b76fb8
4
- data.tar.gz: 925371780e6d9bd96ce59ce4226e1da0b13324ca
3
+ metadata.gz: a815973b1eb6200d1975606140a55a3345d0efc8
4
+ data.tar.gz: d8cabaf6a239f7f35c34904f12a86fcb999fc042
5
5
  SHA512:
6
- metadata.gz: 0561ca37e80e469de28109c003c92dc410a55996c01d287c9a4903002453cf1a2441aac3bcc26b0002e75d50678af4cf492f00c5847f6ba8548b949b12d615bf
7
- data.tar.gz: 0a886207b1266b9d841d6a080133acc427d71581fb98e17e12db2844a253b7e1022065513f02e0e1f068a40e12204f61fad27760b6a86ba10b952a48ef78d827
6
+ metadata.gz: 805819f1915045afc074052dff53e43dc2b74ab521e68e7f3773cdaca14d7460d6147146f7c2ce781e0d73f47b4034144d534dbddaea74f2ee4e82c7ee7ed205
7
+ data.tar.gz: bab72ba9e28aad5a3188b914f6f655ecf7ca95dbfaba295bb62deba0503784a638d64a9fe9751de02e78d6dcee8dc983546efef8ff591f2c8d8b574dd94c5a85
data/.gitignore CHANGED
@@ -1,4 +1,10 @@
1
1
  # Gem itself should not be included
2
2
  *.gem
3
+
3
4
  # JetBrains IDE
4
5
  .idea
6
+
7
+ # rDOC-generated documentation
8
+ # run `rdoc` in order to generate .html files
9
+ doc/
10
+ .DS_Store
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
- # GEMS SOURCE
2
1
  source 'https://rubygems.org'
3
2
 
4
-
5
- gem 'pry'
3
+ gemspec
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # WoWAPI
2
- **EARLY STAGE DEVELOPMENT. HERE BE DRAGONS**
2
+ [![Gem Version](https://badge.fury.io/rb/wowapi.svg)](https://badge.fury.io/rb/wowapi)
3
+
4
+ **EARLY STAGE DEVELOPMENT. HERE BE DRAGONS**
3
5
  However, you are welcome to contribute and/or criticise (and/or) show me the way to handle things.
4
6
 
5
7
  # What this is
@@ -11,24 +13,25 @@ This project began during a search for an easy-to-use gem that allows to access
11
13
 
12
14
  ## What does it do?
13
15
 
14
- **WoWAPI** is a library that's dependant on _open-uri_ and _json_. Both are built-in Ruby libraries. Nothing more than that, just plain Ruby.
16
+ It gives you a pretty interface to Blizzard's Community API.
15
17
 
16
18
  ## How do I use this?
17
19
 
20
+ Before you start tinkering, I suggest generating *rDOC* documentation.
21
+ 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.
18
22
 
19
- ### Guilds
20
-
21
- Guilds can take couple of arguments to query:
23
+ You may also browse *ri* documentation which installs by default when you install the gem. Just type `ri Wowapi`.
24
+ ### Resources
22
25
 
23
- * news
24
- * achievements
25
- * challenge
26
- * members
27
-
28
- Each of these will expand (temporarily*) returned Hash.
29
-
30
- _* temporarily_ - in the end-stage of development I dream of having a `GuildClass` which would have a standardized structure. For now it just returns a `JSON.parse(obj)`, which is a simple `Hash`.
31
- Please keep in mind that I am a working student. (:
26
+ We have different resources for different parts of the API. Each resource can be queried with query fields.
27
+ Currently, everything is returned as a Hash(*)
28
+
29
+ | Resource(s) | query fields | | | |
30
+ |:-----------: |:------------: |:-------------: |:----------: |:--------: |
31
+ | Guilds | :news | :achievements | :challenge | :members |
32
+ | | | | | |
33
+ | | | | | | _
34
+ * temporarily_ - see #1, #2, #3 @ ([git.3lab.re](https://git.3lab.re/marahin/wowapi/issues))
32
35
 
33
36
  ```
34
37
  require 'wowapi'
@@ -44,32 +47,6 @@ api.guild('Argent Dawn', 'The Aspects')
44
47
 
45
48
  ```
46
49
 
47
- #### Guild fields
48
-
49
- * news ([pastebin](http://d.gimb.us/b/fe26c9f380477d3a0293072385e61cab.txt))
50
-
51
- ```
52
- irb(main):005:0> api.guild 'Argent Dawn', 'The Aspects', :news
53
- => {"lastModified"=>1472853622000, "name"=>"The Aspects", "realm"=>"Argent Dawn", "battlegroup"=>"Reckoning / Abrechnung", "level"=>25, "side"=>1, "achievementPoints"=>1590, "emblem"=>{"icon"=>140, "iconColor"=>"ffdfa55a", "iconColorId"=>16, "border"=>1, "borderColor"=>"fff9cc30", "borderColorId"=>16, "backgroundColor"=>"ff232323", "backgroundColorId"=>45}, "news"=>[{"type"=>"itemLoot", "character"=>"Tormenthowl", "timestamp"=>1472858400000, "itemId"=>124325, "context"=>"raid-mythic", "bonusLists"=>[1799, 1502]}, {"type"=>"itemLoot", "character"=>"Tormenthowl", "timestamp"=>1472858400000, "itemId"=>113900, "context"=>"raid-mythic", "bonusLists"=>[567]}, {"type"=>"itemLoot", "character"=>"Humbakos", "timestamp"=>1472857980000, "itemId"=>130132, "context"=>"", "bonusLists"=>[1794, 1735]}, {"type"=>"itemLoot", "character"=>"Seszel", "timestamp"=>1472854680000, "itemId"=>131799, "context"=>"", "bonusLists"=>[1794, 1735]}, {"type"=>"itemLoot", "character"=>"Kurrash", "timestamp"=>1472854500000, "itemId"=>132970, "context"=>"quest-reward", "bonusLists"=>[767, 1734]}, {"type"=>"itemLoot", "character"=>"Greenzog", "timestamp"=>1472853960000, "itemId"=>131921, "context"=>"", "bonusLists"=>[1794, 1735]}, {"type"=>"itemLoot", "character"=>"Humbakos", "timestamp"=>1472853480000, "itemId"=>121660, "context"=>"quest-reward", "bonusLists"=>[768, 1740]}, {"type"=>"itemLoot", "character"=>"Dzidu", "timestamp"=>1472853060000, "itemId"=>138418, "context"=>"", "bonusLists"=>[1794, 1735]}, $$__***<<< A LOT OF DATA ... >>>***__$$ {"type"=>"itemLoot", "character"=>"Olvarus", "timestamp"=>1472248680000, "itemId"=>109970, "context"=>"dungeon-mythic", "bonusLists"=>[43, 642, 643]}, {"type"=>"playerAchievement", "character"=>"Guldav", "timestamp"=>1472247960000, "context"=>"", "bonusLists"=>[], "achievement"=>{"id"=>13, "title"=>"Level 80", "points"=>10, "description"=>"Reach level 80.", "rewardItems"=>[], "icon"=>"achievement_level_80", "criteria"=>[{"id"=>5212, "description"=>"Reach level 80", "orderIndex"=>1, "max"=>80}], "accountWide"=>false, "factionId"=>2}}]}
54
-
55
- ```
56
-
57
- * achievements
58
-
59
- (to be filled)
60
-
61
- * challenge
62
-
63
- (to be filled)
64
-
65
- * members
66
-
67
- (to be filled)
68
-
69
- * __combined__
70
-
71
- (to be filled)
72
-
73
50
 
74
51
  You can easily combine fields.
75
52
  # Support & requirements
@@ -1,8 +1,8 @@
1
- # A simple .try method for Object,
2
- # which mimics the Rails one (probably poorly)
3
-
4
1
  module CoreExtensions
5
2
  module Object
3
+ # Simple shim that adds .try(:symbol)
4
+ # method for Object, mimicing ActiveSupport one
5
+ # (probably poorly, todo: rewrite?)
6
6
  def try(method)
7
7
  begin
8
8
  self.send(method)
@@ -1,4 +1,5 @@
1
1
  class Wowapi
2
+ # Thrown when API does not return any data / something goes wrong
2
3
  class ApiException < Exception
3
4
  def initialize(msg = 'API request failed.')
4
5
  super
@@ -1,4 +1,5 @@
1
1
  class Wowapi
2
+ # Currently unused; deprecated?
2
3
  class AuthException < Exception
3
4
  def initialize(msg = 'Could not authenticate.')
4
5
  super
@@ -1,4 +1,5 @@
1
1
  class Wowapi
2
+ # Thrown when either public and/or secret key was not provided
2
3
  class NoCredentialsException < Exception
3
4
  def initialize(msg = 'Public and/or secret key was not provided.')
4
5
  super
@@ -1,4 +1,5 @@
1
1
  class Wowapi
2
+ # Thrown when supplied Region is unsupported
2
3
  class RegionException < Exception
3
4
  def initialize(msg = 'Provided unsupported region.')
4
5
  super
@@ -1,11 +1,17 @@
1
1
  class Wowapi
2
2
  module Modules
3
+ # Guild module which handles all guild API actions
4
+ # note: this _probably_ should be handled with
5
+ # some kind of GuildClass, see:
6
+ # https://git.3lab.re/marahin/wowapi/issues/1
3
7
  module Guild
4
- # this should probably include
5
- # a GuildClass definition which would properly
6
- # handle blizzard apis' response.
7
- # for now it returns just a simple JSON
8
- # (also, written while drunk. sorry. )
8
+ # Asks Blizzard API for Guild resource
9
+ # with (any) given fields
10
+ # Example:
11
+ # ```
12
+ # api.guild 'Argent Dawn', 'The Aspects', :members, :news, ...
13
+ # ```
14
+ # Currently returns Hash
9
15
  def guild(realm, name, *args)
10
16
  args = args.map{|n| n.to_s if n.is_a?(Symbol) }
11
17
  res = get 'guild/', "#{realm}/#{name}?fields=#{args.join('%2C')}"
@@ -1,4 +1,4 @@
1
1
  class Wowapi
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
4
4
 
data/lib/wowapi/wowapi.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'open-uri'
2
2
  require 'json'
3
- require 'pry'
4
3
  require 'wowapi/core_extensions/object/try'
5
4
  require 'wowapi/exceptions'
6
5
  require 'wowapi/version'
@@ -27,6 +26,8 @@ class Wowapi
27
26
  yield self if block_given?
28
27
  end
29
28
 
29
+ # Method to handle all requests, properly
30
+ # interpreting HTTP answer & returning it's response
30
31
  def get(path, params = {})
31
32
  res = make_request(path, params)
32
33
  if !(res.status.include?('200') or res.status.include?(200)) && ! Wowapi.fail_silently
@@ -37,6 +38,8 @@ class Wowapi
37
38
 
38
39
  private
39
40
 
41
+ # Making open-uri request, catching exceptions
42
+ # and returning data back to #get method
40
43
  def make_request(path, params)
41
44
  begin
42
45
  raise Wowapi::NoCredentialsException unless public_key
@@ -47,6 +50,8 @@ class Wowapi
47
50
  end
48
51
  end
49
52
 
53
+ # Returns URL for particular region
54
+ # or throws an exception if region is nonexistent
50
55
  def base_url
51
56
  case self.region
52
57
  when :eu
data/wowapi.gemspec CHANGED
@@ -18,8 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ['lib']
19
19
 
20
20
  spec.add_development_dependency 'bundler', '~> 0'
21
- spec.add_development_dependency 'rake', '~> 0'
22
21
  spec.add_development_dependency 'pry', '~> 0'
23
-
24
22
  end
25
23
 
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.0.3
4
+ version: 0.0.4
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-02 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: pry
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -96,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
82
  version: '0'
97
83
  requirements: []
98
84
  rubyforge_project:
99
- rubygems_version: 2.6.6
85
+ rubygems_version: 2.4.5.1
100
86
  signing_key:
101
87
  specification_version: 4
102
88
  summary: World of Warcraft API