gw2 1.3.0 → 1.4.0

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: d4a38c0493ac5a365d52f38ed9b562fcc0a488a6
4
- data.tar.gz: d565c9a0ef13a4e629a179f1659a37eb3f143bac
3
+ metadata.gz: bc83cd0a1e4bcd78068cdff2c15f1b7b208a17b5
4
+ data.tar.gz: d46ddf5395ff09d4b202bbf97bf2728c95866d37
5
5
  SHA512:
6
- metadata.gz: ea0d5259525107e45f13d5801cfd4e3bac645852b1fbfff2dbca8bfd1d53d3a4478237457cda9366f68eae2875f0daf54fa267098fd4d8e81e115c4557012918
7
- data.tar.gz: d437278ea31762361e43b49e9775cae4473898bbcbdc870fb534c6daa0463e6e36e250b8e099d5082feb3d539c00396c97b5d7b4ee62a50292cfcee96ad80968
6
+ metadata.gz: ab4b0b59ba75bb0bd80514a3a0cf383d35850bf91bf401424a412b898114e02d3e22137952a12ce34029c5f957daca34127d809edc2b0daa7704ed228aea6e86
7
+ data.tar.gz: e511e7f4faaafade2ab0713478fb72071a65ef40a0ce9c364af3390c7fe371601b330883d9526cdb08c27647a02f150fbf381aa2033e28a5dd7291c95d5d7d3c
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "gw2"
3
- s.version = "1.3.0"
4
- s.date = "2015-02-26"
3
+ s.version = "1.4.0"
4
+ s.date = "2015-02-27"
5
5
  s.summary = "Guild Wars 2 API"
6
6
  s.description = "A ruby gem for accessing the Guild Wars 2 API"
7
7
  s.authors = ["Chris Rosario"]
data/lib/gw2.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "gw2/json"
2
2
  require "gw2/https"
3
+ require "gw2/resource"
3
4
  require "gw2/event"
4
5
  require "gw2/wvw"
5
6
  require "gw2/item"
@@ -1,7 +1,6 @@
1
1
  module GW2
2
2
  module Event
3
- extend HTTPS
4
- extend JSON
3
+ extend Resource
5
4
 
6
5
  def self.all
7
6
  raise GW2::Disabled, "This endpoint is disabled due to the implementation of Megaserver technology."
@@ -12,15 +11,15 @@ module GW2
12
11
  end
13
12
 
14
13
  def self.world_names
15
- parse(request("/world_names.json").body)
14
+ get("/world_names.json")
16
15
  end
17
16
 
18
17
  def self.event_names
19
- parse(request("/event_names.json").body)
18
+ get("/event_names.json")
20
19
  end
21
20
 
22
21
  def self.map_names
23
- parse(request("/map_names.json").body)
22
+ get("/map_names.json")
24
23
  end
25
24
  end
26
25
  end
@@ -1,10 +1,9 @@
1
1
  module GW2
2
2
  module Guild
3
- extend HTTPS
4
- extend JSON
3
+ extend Resource
5
4
 
6
- def self.details(query_hash = {})
7
- parse(request("/guild_details.json", query: query_hash).body)
5
+ def self.details(query = {})
6
+ get("/guild_details.json", query)
8
7
  end
9
8
  end
10
9
  end
@@ -1,14 +1,13 @@
1
1
  module GW2
2
2
  module Item
3
- extend HTTPS
4
- extend JSON
3
+ extend Resource
5
4
 
6
5
  def self.all
7
- parse(request("/items.json").body)["items"]
6
+ get("/items.json")["items"]
8
7
  end
9
8
 
10
9
  def self.details(item_id)
11
- parse(request("/item_details.json", query: { item_id: item_id }).body)
10
+ get("/item_details.json", { item_id: item_id })
12
11
  end
13
12
  end
14
13
  end
@@ -1,7 +1,6 @@
1
1
  module GW2
2
2
  module Map
3
- extend HTTPS
4
- extend JSON
3
+ extend Resource
5
4
 
6
5
  PARAMS_FILTER = [:map_id]
7
6
 
@@ -9,16 +8,16 @@ module GW2
9
8
  self.where
10
9
  end
11
10
 
12
- def self.where(query_hash = {})
13
- parse(request("/maps.json", query: query_hash).body)["maps"]
11
+ def self.where(query = {})
12
+ get("/maps.json", query)["maps"]
14
13
  end
15
14
 
16
15
  def self.map_floor(continent_id, floor)
17
- parse(request("/map_floor.json", query: { continent_id: continent_id, floor: floor }).body)
16
+ get("/map_floor.json", { continent_id: continent_id, floor: floor })
18
17
  end
19
18
 
20
19
  def self.continents
21
- parse(request("/continents.json").body)["continents"]
20
+ get("/continents.json")["continents"]
22
21
  end
23
22
  end
24
23
  end
@@ -1,18 +1,17 @@
1
1
  module GW2
2
2
  module Misc
3
- extend HTTPS
4
- extend JSON
3
+ extend Resource
5
4
 
6
5
  def self.build
7
- parse(request("/build.json").body)["build_id"]
6
+ get("/build.json")["build_id"]
8
7
  end
9
8
 
10
9
  def self.colors
11
- parse(request("/colors.json").body)["colors"]
10
+ get("/colors.json")["colors"]
12
11
  end
13
12
 
14
13
  def self.files
15
- parse(request("/files.json").body)
14
+ get("/files.json")
16
15
  end
17
16
  end
18
17
  end
@@ -1,14 +1,13 @@
1
1
  module GW2
2
2
  module Recipe
3
- extend HTTPS
4
- extend JSON
3
+ extend Resource
5
4
 
6
5
  def self.all
7
- parse(request("/recipes.json").body)["recipes"]
6
+ get("/recipes.json")["recipes"]
8
7
  end
9
8
 
10
9
  def self.details(recipe_id)
11
- parse(request("/recipe_details.json", query: { recipe_id: recipe_id }).body)
10
+ get("/recipe_details.json", { recipe_id: recipe_id })
12
11
  end
13
12
  end
14
13
  end
@@ -0,0 +1,15 @@
1
+ require "gw2/json"
2
+ require "gw2/https"
3
+
4
+ module GW2
5
+ module Resource
6
+ include HTTPS
7
+ include JSON
8
+
9
+ BASE_URL = "https://api.guildwars2.com/v1"
10
+
11
+ def get(endpoint, query = {})
12
+ parse(request(endpoint, query: query).body)
13
+ end
14
+ end
15
+ end
@@ -1,18 +1,17 @@
1
1
  module GW2
2
2
  module WvW
3
- extend HTTPS
4
- extend JSON
3
+ extend Resource
5
4
 
6
5
  def self.matches
7
- parse(request("/wvw/matches.json").body)["wvw_matches"]
6
+ get("/wvw/matches.json")["wvw_matches"]
8
7
  end
9
8
 
10
9
  def self.match_details(match_id)
11
- parse(request("/wvw/match_details.json", query: { match_id: match_id }).body)["maps"]
10
+ get("/wvw/match_details.json", match_id: match_id)["maps"]
12
11
  end
13
12
 
14
13
  def self.objective_names
15
- parse(request("/wvw/objective_names.json").body)
14
+ get("/wvw/objective_names.json")
16
15
  end
17
16
  end
18
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gw2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Rosario
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-26 00:00:00.000000000 Z
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A ruby gem for accessing the Guild Wars 2 API
14
14
  email: c.allen.rosario@gmail.com
@@ -30,6 +30,7 @@ files:
30
30
  - lib/gw2/map.rb
31
31
  - lib/gw2/misc.rb
32
32
  - lib/gw2/recipe.rb
33
+ - lib/gw2/resource.rb
33
34
  - lib/gw2/wvw.rb
34
35
  - spec/fixtures/GW2_Event/_event_names/returns_the_names_of_all_events.yml
35
36
  - spec/fixtures/GW2_Event/_map_names/returns_the_names_of_all_maps.yml