gw2 1.1.0 → 1.2.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.
- data/CHANGELOG.md +5 -1
- data/README.md +1 -0
- data/gw2.gemspec +2 -2
- data/lib/gw2.rb +3 -19
- data/lib/gw2/event.rb +2 -1
- data/lib/gw2/event/event_names.rb +1 -7
- data/lib/gw2/event/events.rb +2 -14
- data/lib/gw2/event/map_names.rb +1 -7
- data/lib/gw2/event/world_names.rb +1 -7
- data/lib/gw2/guild.rb +3 -2
- data/lib/gw2/guild/guild_details.rb +3 -15
- data/lib/gw2/https.rb +31 -0
- data/lib/gw2/item.rb +2 -1
- data/lib/gw2/item/item_details.rb +2 -8
- data/lib/gw2/item/items.rb +1 -7
- data/lib/gw2/json.rb +9 -0
- data/lib/gw2/map.rb +10 -9
- data/lib/gw2/map/continents.rb +7 -13
- data/lib/gw2/map/map_floor.rb +7 -13
- data/lib/gw2/map/maps.rb +13 -21
- data/lib/gw2/misc.rb +10 -9
- data/lib/gw2/misc/build.rb +8 -14
- data/lib/gw2/misc/colors.rb +7 -13
- data/lib/gw2/misc/files.rb +7 -13
- data/lib/gw2/recipe.rb +2 -1
- data/lib/gw2/recipe/recipe_details.rb +2 -8
- data/lib/gw2/recipe/recipes.rb +1 -7
- data/lib/gw2/wvw.rb +2 -1
- data/lib/gw2/wvw/match_details.rb +1 -7
- data/lib/gw2/wvw/matches.rb +1 -7
- data/lib/gw2/wvw/objective_names.rb +1 -7
- metadata +4 -2
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/gw2.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "gw2"
|
3
|
-
s.version = "1.
|
4
|
-
s.date = "
|
3
|
+
s.version = "1.2.0"
|
4
|
+
s.date = "2014-02-05"
|
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,5 @@
|
|
1
|
-
require "
|
2
|
-
require "
|
1
|
+
require "gw2/json"
|
2
|
+
require "gw2/https"
|
3
3
|
require "gw2/event"
|
4
4
|
require "gw2/wvw"
|
5
5
|
require "gw2/item"
|
@@ -9,21 +9,5 @@ require "gw2/misc"
|
|
9
9
|
require "gw2/map"
|
10
10
|
|
11
11
|
module GW2
|
12
|
-
BASE_URL = "https://api.guildwars2.com/v1"
|
13
|
-
|
14
|
-
def request(attr = { action: "Get" })
|
15
|
-
uri = URI.parse(attr[:url])
|
16
|
-
|
17
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
18
|
-
http.use_ssl = attr[:ssl]
|
19
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if attr[:ssl] # need to get a cert -_____-
|
20
|
-
|
21
|
-
net_http = Net::HTTP
|
22
|
-
request = net_http.const_get(attr[:action]).new(uri.request_uri)
|
23
|
-
attr[:headers].each { |key, value| request[key.to_s] = value } if attr[:headers]
|
24
|
-
|
25
|
-
request.set_form_data(attr[:form_data]) if attr[:form_data]
|
26
|
-
|
27
|
-
http.request(request)
|
28
|
-
end
|
12
|
+
BASE_URL = "https://api.guildwars2.com/v1"
|
29
13
|
end
|
data/lib/gw2/event.rb
CHANGED
data/lib/gw2/event/events.rb
CHANGED
@@ -1,23 +1,11 @@
|
|
1
1
|
module GW2
|
2
2
|
module Event
|
3
|
-
PARAMS_FILTER = [:world_id, :map_id, :event_id]
|
4
|
-
|
5
3
|
def self.all
|
6
4
|
self.where
|
7
5
|
end
|
8
6
|
|
9
|
-
def self.where(
|
10
|
-
|
11
|
-
query_string = query_params.select{ |k,v| PARAMS_FILTER.include?(k) }.collect{ |k,v| "#{k}=#{v}" }.join("&")
|
12
|
-
url += "?#{query_string}" unless query_string.empty?
|
13
|
-
|
14
|
-
response = request(
|
15
|
-
action: "Get",
|
16
|
-
ssl: true,
|
17
|
-
url: url
|
18
|
-
)
|
19
|
-
|
20
|
-
return JSON.parse(response.body)
|
7
|
+
def self.where(query_hash = {})
|
8
|
+
parse(request("/events.json", query: query_hash).body)
|
21
9
|
end
|
22
10
|
end
|
23
11
|
end
|
data/lib/gw2/event/map_names.rb
CHANGED
data/lib/gw2/guild.rb
CHANGED
@@ -1,19 +1,7 @@
|
|
1
1
|
module GW2
|
2
2
|
module Guild
|
3
|
-
|
4
|
-
|
5
|
-
def self.details(query_params)
|
6
|
-
url = "#{BASE_URL}/guild_details.json"
|
7
|
-
query_string = query_params.select{ |k,v| PARAMS_FILTER.include?(k) }.collect { |k,v| "#{k}=#{v}" }.join("&")
|
8
|
-
url += "?#{query_string}"
|
9
|
-
|
10
|
-
response = request(
|
11
|
-
action: "Get",
|
12
|
-
ssl: true,
|
13
|
-
url: url
|
14
|
-
)
|
15
|
-
|
16
|
-
return JSON.parse(response.body)
|
3
|
+
def self.details(query_hash = {})
|
4
|
+
parse(request("/guild_details.json", query: query_hash).body)
|
17
5
|
end
|
18
6
|
end
|
19
|
-
end
|
7
|
+
end
|
data/lib/gw2/https.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "net/https"
|
2
|
+
|
3
|
+
module GW2
|
4
|
+
module HTTPS
|
5
|
+
DEFAULT_REQUEST = { action: "Get", ssl: true }
|
6
|
+
|
7
|
+
def query_string(query_hash = {})
|
8
|
+
string = query_hash.collect{ |k,v| "#{k}=#{v}" }.join("&")
|
9
|
+
string.prepend("?") unless string.empty?
|
10
|
+
|
11
|
+
string
|
12
|
+
end
|
13
|
+
|
14
|
+
def request(end_point = "", attr = {})
|
15
|
+
attr = DEFAULT_REQUEST.merge(attr)
|
16
|
+
uri = URI.parse(BASE_URL + end_point + query_string(attr[:query] || {}))
|
17
|
+
|
18
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
19
|
+
http.use_ssl = attr[:ssl]
|
20
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if attr[:ssl] # need to get a cert -_____-
|
21
|
+
|
22
|
+
net_http = Net::HTTP
|
23
|
+
request = Net::HTTP.const_get(attr[:action]).new(uri.request_uri)
|
24
|
+
attr[:headers].each { |key, value| request[key.to_s] = value } if attr[:headers]
|
25
|
+
|
26
|
+
request.set_form_data(attr[:form_data]) if attr[:form_data]
|
27
|
+
|
28
|
+
http.request(request)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/gw2/item.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
module GW2
|
2
|
-
module Item
|
2
|
+
module Item
|
3
3
|
def self.details(item_id)
|
4
|
-
|
5
|
-
action: "Get",
|
6
|
-
ssl: true,
|
7
|
-
url: "#{BASE_URL}/item_details.json?item_id=#{item_id}"
|
8
|
-
)
|
9
|
-
|
10
|
-
return JSON.parse(response.body)
|
4
|
+
parse(request("/item_details.json", query: { item_id: item_id }).body)
|
11
5
|
end
|
12
6
|
end
|
13
7
|
end
|
data/lib/gw2/item/items.rb
CHANGED
data/lib/gw2/json.rb
ADDED
data/lib/gw2/map.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
require "gw2/map/continents"
|
2
|
-
require "gw2/map/maps"
|
3
|
-
require "gw2/map/map_floor"
|
4
|
-
|
5
|
-
module GW2
|
6
|
-
module Map
|
7
|
-
extend
|
8
|
-
|
9
|
-
end
|
1
|
+
require "gw2/map/continents"
|
2
|
+
require "gw2/map/maps"
|
3
|
+
require "gw2/map/map_floor"
|
4
|
+
|
5
|
+
module GW2
|
6
|
+
module Map
|
7
|
+
extend HTTPS
|
8
|
+
extend JSON
|
9
|
+
end
|
10
|
+
end
|
data/lib/gw2/map/continents.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
|
-
module GW2
|
2
|
-
module Map
|
3
|
-
def self.continents
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
)
|
9
|
-
|
10
|
-
return JSON.parse(response.body)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
module GW2
|
2
|
+
module Map
|
3
|
+
def self.continents
|
4
|
+
parse(request("/continents.json").body)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
data/lib/gw2/map/map_floor.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
|
-
module GW2
|
2
|
-
module Map
|
3
|
-
def self.map_floor(continent_id, floor)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
)
|
9
|
-
|
10
|
-
return JSON.parse(response.body)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
module GW2
|
2
|
+
module Map
|
3
|
+
def self.map_floor(continent_id, floor)
|
4
|
+
parse(request("/map_floor.json", query: { continent_id: continent_id, floor: floor }).body)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
data/lib/gw2/map/maps.rb
CHANGED
@@ -1,21 +1,13 @@
|
|
1
|
-
module GW2
|
2
|
-
module Map
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
ssl: true,
|
15
|
-
url: url
|
16
|
-
)
|
17
|
-
|
18
|
-
return JSON.parse(response.body)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
1
|
+
module GW2
|
2
|
+
module Map
|
3
|
+
PARAMS_FILTER = [:map_id]
|
4
|
+
|
5
|
+
def self.all
|
6
|
+
self.where
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.where(query_hash = {})
|
10
|
+
parse(request("/maps.json", query: query_hash).body)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/gw2/misc.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
require "gw2/misc/build"
|
2
|
-
require "gw2/misc/colors"
|
3
|
-
require "gw2/misc/files"
|
4
|
-
|
5
|
-
module GW2
|
6
|
-
module Misc
|
7
|
-
extend
|
8
|
-
|
9
|
-
end
|
1
|
+
require "gw2/misc/build"
|
2
|
+
require "gw2/misc/colors"
|
3
|
+
require "gw2/misc/files"
|
4
|
+
|
5
|
+
module GW2
|
6
|
+
module Misc
|
7
|
+
extend HTTPS
|
8
|
+
extend JSON
|
9
|
+
end
|
10
|
+
end
|
data/lib/gw2/misc/build.rb
CHANGED
@@ -1,14 +1,8 @@
|
|
1
|
-
module GW2
|
2
|
-
module Misc
|
3
|
-
def self.build
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
return JSON.parse(response.body)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
1
|
+
module GW2
|
2
|
+
module Misc
|
3
|
+
def self.build
|
4
|
+
parse(request("/build.json").body)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
data/lib/gw2/misc/colors.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
|
-
module GW2
|
2
|
-
module Misc
|
3
|
-
def self.colors
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
)
|
9
|
-
|
10
|
-
return JSON.parse(response.body)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
module GW2
|
2
|
+
module Misc
|
3
|
+
def self.colors
|
4
|
+
parse(request("/colors.json").body)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
data/lib/gw2/misc/files.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
|
-
module GW2
|
2
|
-
module Misc
|
3
|
-
def self.files
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
)
|
9
|
-
|
10
|
-
return JSON.parse(response.body)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
module GW2
|
2
|
+
module Misc
|
3
|
+
def self.files
|
4
|
+
parse(request("/files.json").body)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
data/lib/gw2/recipe.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
module GW2
|
2
|
-
module Recipe
|
2
|
+
module Recipe
|
3
3
|
def self.details(recipe_id)
|
4
|
-
|
5
|
-
action: "Get",
|
6
|
-
ssl: true,
|
7
|
-
url: "#{BASE_URL}/recipe_details.json?recipe_id=#{recipe_id}"
|
8
|
-
)
|
9
|
-
|
10
|
-
return JSON.parse(response.body)
|
4
|
+
parse(request("/recipe_details.json", query: { recipe_id: recipe_id }).body)
|
11
5
|
end
|
12
6
|
end
|
13
7
|
end
|
data/lib/gw2/recipe/recipes.rb
CHANGED
data/lib/gw2/wvw.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
module GW2
|
2
2
|
module WvW
|
3
3
|
def self.match_details(match_id)
|
4
|
-
|
5
|
-
action: "Get",
|
6
|
-
ssl: true,
|
7
|
-
url: "#{BASE_URL}/wvw/match_details.json?match_id=#{match_id}"
|
8
|
-
)
|
9
|
-
|
10
|
-
return JSON.parse(response.body)
|
4
|
+
parse(request("/wvw/match_details.json", query: { match_id: match_id }).body)
|
11
5
|
end
|
12
6
|
end
|
13
7
|
end
|
data/lib/gw2/wvw/matches.rb
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
module GW2
|
2
2
|
module WvW
|
3
3
|
def self.objective_names
|
4
|
-
|
5
|
-
action: "Get",
|
6
|
-
ssl: true,
|
7
|
-
url: "#{BASE_URL}/wvw/objective_names.json"
|
8
|
-
)
|
9
|
-
|
10
|
-
return JSON.parse(response.body)
|
4
|
+
parse(request("/wvw/objective_names.json").body)
|
11
5
|
end
|
12
6
|
end
|
13
7
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gw2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-02-05 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A ruby gem for accessing the Guild Wars 2 API
|
15
15
|
email: c.allen.rosario@gmail.com
|
@@ -28,9 +28,11 @@ files:
|
|
28
28
|
- lib/gw2/event.rb
|
29
29
|
- lib/gw2/guild/guild_details.rb
|
30
30
|
- lib/gw2/guild.rb
|
31
|
+
- lib/gw2/https.rb
|
31
32
|
- lib/gw2/item/item_details.rb
|
32
33
|
- lib/gw2/item/items.rb
|
33
34
|
- lib/gw2/item.rb
|
35
|
+
- lib/gw2/json.rb
|
34
36
|
- lib/gw2/map/continents.rb
|
35
37
|
- lib/gw2/map/map_floor.rb
|
36
38
|
- lib/gw2/map/maps.rb
|