gw2 1.0.1 → 1.1.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.
@@ -1,3 +1,7 @@
1
+ 1.0.2
2
+ -----
3
+ * Added Guilds, Map, and Miscellaneous APIs
4
+
1
5
  1.0.1
2
6
  -----
3
7
  * Improved README
data/README.md CHANGED
@@ -6,6 +6,7 @@ A Ruby interface for accessing the Guild Wars 2 API.
6
6
 
7
7
  gem install gw2
8
8
 
9
+
9
10
  ## Dynamic Event API
10
11
 
11
12
  **Get all dynamic events**
@@ -42,6 +43,67 @@ GW2::Event.map_names
42
43
  GW2::Event.world_names
43
44
  ```
44
45
 
46
+ ## Guild API
47
+
48
+ **Get details of a guild**
49
+
50
+ ```ruby
51
+ GW2::Guild.details(guild_id: "16DB5921-CF1B-48D2-A5A0-2F0AADD9765D")
52
+ GW2::Guild.details(guild_name: "Ruinous")
53
+ ```
54
+
55
+ ## Item and Recipe Database API
56
+
57
+ **Get all discovered items**
58
+
59
+ ```ruby
60
+ GW2::Item.all
61
+ ```
62
+
63
+ **Get details of a specific item**
64
+
65
+ ```ruby
66
+ GW2::Item.details(38875)
67
+ ```
68
+
69
+ **Get all discovered recipes**
70
+
71
+ ```ruby
72
+ GW2::Recipe.all
73
+ ```
74
+
75
+ **Get details of a specific recipe**
76
+
77
+ ```ruby
78
+ GW2::Recipe.details(1275)
79
+ ```
80
+
81
+ ## Map Information API
82
+
83
+ **Get details of all the continents**
84
+
85
+ ```ruby
86
+ GW2::Map.continents
87
+ ```
88
+
89
+ **Get all maps**
90
+
91
+ ```ruby
92
+ GW2::Map.all
93
+ ```
94
+
95
+ **Get details about a specific map**
96
+
97
+ ```ruby
98
+ GW2::Map.where(map_id: 80)
99
+ ```
100
+
101
+ **Get details about a map floor**
102
+
103
+ ```ruby
104
+ GW2::Map.map_floor(1, 1)
105
+ ```
106
+
45
107
  ## World vs World API
46
108
 
47
109
  **Get all current matches**
@@ -62,30 +124,25 @@ GW2::WvW.match_details("1-5")
62
124
  GW2::WvW.objective_names
63
125
  ```
64
126
 
65
- ## Item and Recipe Database API
66
127
 
67
- **Get all discovered items**
128
+ ## Miscellaneous API
68
129
 
69
- ```ruby
70
- GW2::Item.all
71
- ```
72
-
73
- **Get details of a specific item**
130
+ **Get the current build id**
74
131
 
75
132
  ```ruby
76
- GW2::Item.details(38875)
133
+ GW2::Misc.build
77
134
  ```
78
135
 
79
- **Get all discovered recipes**
136
+ **Get a list of all dyes**
80
137
 
81
138
  ```ruby
82
- GW2::Recipe.all
139
+ GW2::Misc.colors
83
140
  ```
84
141
 
85
- **Get details of a specific recipe**
142
+ **Get commonly requested assets**
86
143
 
87
144
  ```ruby
88
- GW2::Recipe.details(1275)
145
+ GW2::Misc.files
89
146
  ```
90
147
 
91
148
  ## Copyright
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "gw2"
3
- s.version = "1.0.1"
4
- s.date = "2013-05-22"
3
+ s.version = "1.1.0"
4
+ s.date = "2013-09-28"
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"]
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.files = %w(LICENSE.md CHANGELOG.md README.md gw2.gemspec)
10
10
  s.files += Dir.glob("lib/**/*.rb")
11
11
  s.files += Dir.glob("spec/**/*")
12
- s.homepage = "https://github.com/callenrosario/gw2"
12
+ s.homepage = "https://github.com/parix/gw2"
13
13
  s.licenses = ['MIT']
14
14
  s.require_paths = ['lib']
15
15
  s.test_files = Dir.glob("spec/**/*")
data/lib/gw2.rb CHANGED
@@ -4,6 +4,9 @@ require "gw2/event"
4
4
  require "gw2/wvw"
5
5
  require "gw2/item"
6
6
  require "gw2/recipe"
7
+ require "gw2/guild"
8
+ require "gw2/misc"
9
+ require "gw2/map"
7
10
 
8
11
  module GW2
9
12
  BASE_URL = "https://api.guildwars2.com/v1"
@@ -0,0 +1,7 @@
1
+ require "gw2/guild/guild_details"
2
+
3
+ module GW2
4
+ module Guild
5
+ extend GW2
6
+ end
7
+ end
@@ -0,0 +1,19 @@
1
+ module GW2
2
+ module Guild
3
+ PARAMS_FILTER = [:guild_id, :guild_name]
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)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
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 GW2
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ module GW2
2
+ module Map
3
+ def self.continents
4
+ response = request(
5
+ action: "Get",
6
+ ssl: true,
7
+ url: "#{BASE_URL}/continents.json"
8
+ )
9
+
10
+ return JSON.parse(response.body)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module GW2
2
+ module Map
3
+ def self.map_floor(continent_id, floor)
4
+ response = request(
5
+ action: "Get",
6
+ ssl: true,
7
+ url: "#{BASE_URL}/map_floor.json?continent_id=#{continent_id}&floor=#{floor}"
8
+ )
9
+
10
+ return JSON.parse(response.body)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ module GW2
2
+ module Map
3
+ def self.all
4
+ self.where
5
+ end
6
+
7
+ def self.where(map_id = {})
8
+ url = "#{BASE_URL}/maps.json"
9
+ query_string = map_id.collect { |k,v| "#{v}" }.join
10
+ url += "?map_id=#{query_string}" unless query_string.empty?
11
+
12
+ response = request(
13
+ action: "Get",
14
+ ssl: true,
15
+ url: url
16
+ )
17
+
18
+ return JSON.parse(response.body)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ require "gw2/misc/build"
2
+ require "gw2/misc/colors"
3
+ require "gw2/misc/files"
4
+
5
+ module GW2
6
+ module Misc
7
+ extend GW2
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ module GW2
2
+ module Misc
3
+ def self.build
4
+ response = request(
5
+ action: "Get",
6
+ ssl: true,
7
+ url: "#{BASE_URL}/build.json"
8
+ )
9
+
10
+ return JSON.parse(response.body)
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,13 @@
1
+ module GW2
2
+ module Misc
3
+ def self.colors
4
+ response = request(
5
+ action: "Get",
6
+ ssl: true,
7
+ url: "#{BASE_URL}/colors.json"
8
+ )
9
+
10
+ return JSON.parse(response.body)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module GW2
2
+ module Misc
3
+ def self.files
4
+ response = request(
5
+ action: "Get",
6
+ ssl: true,
7
+ url: "#{BASE_URL}/files.json"
8
+ )
9
+
10
+ return JSON.parse(response.body)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,37 @@
1
+ require "spec_helper"
2
+
3
+ describe GW2::Guild do
4
+ describe "methods" do
5
+ context "#details" do
6
+ before :each do
7
+ @guild_details = {
8
+ "guild_id" => "16DB5921-CF1B-48D2-A5A0-2F0AADD9765D",
9
+ "guild_name" => "Ruinous",
10
+ "tag" => "RUIN",
11
+ "emblem" => {
12
+ "background_id" => 8,
13
+ "foreground_id" => 21,
14
+ "flags" => [],
15
+ "background_color_id" => 473,
16
+ "foreground_primary_color" => 146,
17
+ "foreground_seconary_color" => 146
18
+ }
19
+ }
20
+
21
+ stub_request(:get, "https://api.guildwars2.com/v1/guild_details.json?guild_id=16DB5921-CF1B-48D2-A5A0-2F0AADD9765D").
22
+ to_return(:status => 200, :body => @guild_details.to_json)
23
+ stub_request(:get, "https://api.guildwars2.com/v1/guild_details.json?guild_name=Ruinous").
24
+ to_return(:status => 200, :body => @guild_details.to_json)
25
+ end
26
+
27
+ it "exists" do
28
+ GW2::Guild.respond_to?(:details).should == true
29
+ end
30
+
31
+ it "returns the correct JSON parsed data" do
32
+ GW2::Guild.details(guild_id: "16DB5921-CF1B-48D2-A5A0-2F0AADD9765D").should == @guild_details
33
+ GW2::Guild.details(guild_name: "Ruinous").should == @guild_details
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,40 @@
1
+ require "spec_helper"
2
+
3
+ describe GW2::Map do
4
+ describe "methods" do
5
+ context "#continents" do
6
+ before :each do
7
+ @continents = {
8
+ "1" => {
9
+ "name" => "Tyria",
10
+ "continent_dims" => [ 32768, 32768 ],
11
+ "min_zoom" => 0,
12
+ "max_zoom" => 7,
13
+ "floors" => [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
14
+ 18, 19, 30, -2, -3, -4, -5, -6, -7, -8, -10, -11, -15, -16, -17, 38,
15
+ 20, 21, 22, 23, 24, 25, 26, 27, 34, 36, 37 ]
16
+ },
17
+ "2" => {
18
+ "name" => "Mists",
19
+ "continent_dims" => [ 16384, 16384 ],
20
+ "min_zoom" => 0,
21
+ "max_zoom" => 6,
22
+ "floors" => [ 1, 3, 5, 6, 7, 8, 9, 10, 13, 14, 18, 19, 21, 22, 23, 24, 25,
23
+ 26, -27, -28, -29, -30, -31, -32, -33, 27 ]
24
+ }
25
+ }
26
+
27
+ stub_request(:get, "https://api.guildwars2.com/v1/continents.json").
28
+ to_return(:status => 200, :body => { "continents" => @continents }.to_json)
29
+ end
30
+
31
+ it "exists" do
32
+ GW2::Map.respond_to?(:continents).should == true
33
+ end
34
+
35
+ it "returns the correct JSON parsed data" do
36
+ GW2::Map.continents.should == { "continents" => @continents }
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,76 @@
1
+ require "spec_helper"
2
+
3
+ describe GW2::Map do
4
+ describe "methods" do
5
+ context "#map_floor" do
6
+ before :each do
7
+ @floors = {
8
+ "texture_dims" => [ 32768, 32768 ],
9
+ "regions" => {
10
+ "1" => {
11
+ "name" => "Shiverpeak Mountains",
12
+ "label_coord" => [ 19840, 13568 ],
13
+ "maps" => {
14
+ "31" => {
15
+ "name" => "Snowden Drifts",
16
+ "min_level" => 15,
17
+ "max_level" => 25,
18
+ "default_floor" => 1,
19
+ "map_rect" => [
20
+ [ -49152, -24576 ],
21
+ [ 49152, 24576 ]
22
+ ],
23
+ "continent_rect" => [
24
+ [ 17664, 11264 ],
25
+ [ 21760, 13312 ]
26
+ ],
27
+ "points_of_interest" => [
28
+ {
29
+ "poi_id" => 164,
30
+ "name" => "Blasted Haven",
31
+ "type" => "landmark",
32
+ "floor" => 1,
33
+ "coord" => [ 20768.5, 11893.5 ]
34
+ }
35
+ ],
36
+ "tasks" => [
37
+ {
38
+ "task_id" => 28,
39
+ "objective" => "Help hunters and travelers near the road.",
40
+ "level" => 15,
41
+ "coord" => [ 21326.4, 11982.8 ]
42
+ }
43
+ ],
44
+ "skill_challenges" => [
45
+ {
46
+ "coord" => [ 18922.3, 11445.5 ]
47
+ }
48
+ ],
49
+ "sectors" => [
50
+ {
51
+ "sector_id" => 1015,
52
+ "name" => "King Jalis's Refuge",
53
+ "level" => 19,
54
+ "coord" => [ 21673.8, 12111.8 ]
55
+ }
56
+ ]
57
+ },
58
+ }
59
+ }
60
+ }
61
+ }
62
+
63
+ stub_request(:get, "https://api.guildwars2.com/v1/map_floor.json?continent_id=1&floor=1").
64
+ to_return(:status => 200, :body => @floors.to_json)
65
+ end
66
+
67
+ it "exists" do
68
+ GW2::Map.respond_to?(:map_floor).should == true
69
+ end
70
+
71
+ it "returns the correct JSON parsed data" do
72
+ GW2::Map.map_floor(1, 1).should == @floors
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,79 @@
1
+ require "spec_helper"
2
+
3
+ describe GW2::Map do
4
+ describe "methods" do
5
+ context "#all" do
6
+ before :each do
7
+ @maps = {
8
+ "80" => {
9
+ "map_name" => "A Society Function",
10
+ "min_level" => 8,
11
+ "max_level" => 8,
12
+ "default_floor" => 1,
13
+ "floors" => [1, 2],
14
+ "region_id" => 8,
15
+ "region_name" => "Steamspur Mountains",
16
+ "continent_id" => 1,
17
+ "continent_name" => "Tyria",
18
+ "map_rect" => [
19
+ [-21504, -21504],
20
+ [24576, 21504]
21
+ ],
22
+ "continent_rect" => [
23
+ [10240, 9856],
24
+ [12160, 11648]
25
+ ]
26
+ }
27
+ }
28
+
29
+ stub_request(:get, "https://api.guildwars2.com/v1/maps.json").
30
+ to_return(:status => 200, :body => { "maps" => @maps }.to_json)
31
+ end
32
+
33
+ it "exists" do
34
+ GW2::Map.respond_to?(:all).should == true
35
+ end
36
+
37
+ it "returns the correct JSON parsed data" do
38
+ GW2::Map.all.should == { "maps" => @maps }
39
+ end
40
+ end
41
+
42
+ context "#maps" do
43
+ before :each do
44
+ @maps = {
45
+ "80" => {
46
+ "map_name" => "A Society Function",
47
+ "min_level" => 8,
48
+ "max_level" => 8,
49
+ "default_floor" => 1,
50
+ "floors" => [1, 2],
51
+ "region_id" => 8,
52
+ "region_name" => "Steamspur Mountains",
53
+ "continent_id" => 1,
54
+ "continent_name" => "Tyria",
55
+ "map_rect" => [
56
+ [-21504, -21504],
57
+ [24576, 21504]
58
+ ],
59
+ "continent_rect" => [
60
+ [10240, 9856],
61
+ [12160, 11648]
62
+ ]
63
+ }
64
+ }
65
+
66
+ stub_request(:get, "https://api.guildwars2.com/v1/maps.json?map_id=80").
67
+ to_return(:status => 200, :body => { "maps" => @maps }.to_json)
68
+ end
69
+
70
+ it "exists" do
71
+ GW2::Map.respond_to?(:where).should == true
72
+ end
73
+
74
+ it "returns the correct JSON parsed data" do
75
+ GW2::Map.where(map_id: 80).should == { "maps" => @maps }
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe GW2::Misc do
4
+ describe "methods" do
5
+ context "#build" do
6
+ before :each do
7
+ @build = { "build_id" => 22120 }
8
+
9
+ stub_request(:get, "https://api.guildwars2.com/v1/build.json").
10
+ to_return(:status => 200, :body => @build.to_json)
11
+ end
12
+
13
+ it "exists" do
14
+ GW2::Misc.respond_to?(:build).should == true
15
+ end
16
+
17
+ it "returns the correct JSON parsed data" do
18
+ GW2::Misc.build.should == @build
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,51 @@
1
+ require "spec_helper"
2
+
3
+ describe GW2::Misc do
4
+ describe "methods" do
5
+ context "#colors" do
6
+ before :each do
7
+ @colors = {
8
+ "126" => {
9
+ "name" => "Hot Pink",
10
+ "base_rgb" => [ 128, 26, 26 ],
11
+ "cloth" => {
12
+ "brightness" => 14,
13
+ "contrast" => 1.21094,
14
+ "hue" => 340,
15
+ "saturation" => 0.820313,
16
+ "lightness" => 1.44531,
17
+ "rgb" => [ 169, 54, 94 ]
18
+ },
19
+ "leather" => {
20
+ "brightness" => 14,
21
+ "contrast" => 1.21094,
22
+ "hue" => 340,
23
+ "saturation" => 0.703125,
24
+ "lightness" => 1.44531,
25
+ "rgb" => [ 160, 62, 96 ]
26
+ },
27
+ "metal" => {
28
+ "brightness" => 14,
29
+ "contrast" => 1.21094,
30
+ "hue" => 340,
31
+ "saturation" => 0.585938,
32
+ "lightness" => 1.44531,
33
+ "rgb" => [ 151, 69, 98 ]
34
+ }
35
+ }
36
+ }
37
+
38
+ stub_request(:get, "https://api.guildwars2.com/v1/colors.json").
39
+ to_return(:status => 200, :body => { "colors" => @colors }.to_json)
40
+ end
41
+
42
+ it "exists" do
43
+ GW2::Misc.respond_to?(:colors).should == true
44
+ end
45
+
46
+ it "returns the correct JSON parsed data" do
47
+ GW2::Misc.colors.should == { "colors" => @colors }
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ describe GW2::Misc do
4
+ describe "methods" do
5
+ context "#files" do
6
+ before :each do
7
+ @files = {
8
+ "map_complete" => { "file_id" => 528724, "signature" => "5A4E663071250EC72668C09E3C082E595A380BF7" },
9
+ "map_dungeon" => { "file_id" => 102478, "signature" => "943538394A94A491C8632FBEF6203C2013443555" },
10
+ "map_heart_empty" => { "file_id" => 102440, "signature" => "09ACBA53B7412CC3C76E7FEF39929843C20CB0E4" }
11
+ }
12
+
13
+ stub_request(:get, "https://api.guildwars2.com/v1/files.json").
14
+ to_return(:status => 200, :body => @files.to_json)
15
+ end
16
+
17
+ it "exists" do
18
+ GW2::Misc.respond_to?(:files).should == true
19
+ end
20
+
21
+ it "returns the correct JSON parsed data" do
22
+ GW2::Misc.files.should == @files
23
+ end
24
+ end
25
+ end
26
+ 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.0.1
4
+ version: 1.1.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: 2013-05-22 00:00:00.000000000 Z
12
+ date: 2013-09-28 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
@@ -26,9 +26,19 @@ files:
26
26
  - lib/gw2/event/map_names.rb
27
27
  - lib/gw2/event/world_names.rb
28
28
  - lib/gw2/event.rb
29
+ - lib/gw2/guild/guild_details.rb
30
+ - lib/gw2/guild.rb
29
31
  - lib/gw2/item/item_details.rb
30
32
  - lib/gw2/item/items.rb
31
33
  - lib/gw2/item.rb
34
+ - lib/gw2/map/continents.rb
35
+ - lib/gw2/map/map_floor.rb
36
+ - lib/gw2/map/maps.rb
37
+ - lib/gw2/map.rb
38
+ - lib/gw2/misc/build.rb
39
+ - lib/gw2/misc/colors.rb
40
+ - lib/gw2/misc/files.rb
41
+ - lib/gw2/misc.rb
32
42
  - lib/gw2/recipe/recipe_details.rb
33
43
  - lib/gw2/recipe/recipes.rb
34
44
  - lib/gw2/recipe.rb
@@ -41,15 +51,22 @@ files:
41
51
  - spec/event/events_spec.rb
42
52
  - spec/event/map_names_spec.rb
43
53
  - spec/event/world_names_spec.rb
54
+ - spec/guild/guild_details_spec.rb
44
55
  - spec/item/item_details_spec.rb
45
56
  - spec/item/items_spec.rb
57
+ - spec/map/continents_spec.rb
58
+ - spec/map/map_floor_spec.rb
59
+ - spec/map/maps_spec.rb
60
+ - spec/misc/build_spec.rb
61
+ - spec/misc/colors_spec.rb
62
+ - spec/misc/files_spec.rb
46
63
  - spec/recipe/recipe_details_spec.rb
47
64
  - spec/recipe/recipes_spec.rb
48
65
  - spec/spec_helper.rb
49
66
  - spec/wvw/match_details_spec.rb
50
67
  - spec/wvw/matches_spec.rb
51
68
  - spec/wvw/objective_names_spec.rb
52
- homepage: https://github.com/callenrosario/gw2
69
+ homepage: https://github.com/parix/gw2
53
70
  licenses:
54
71
  - MIT
55
72
  post_install_message:
@@ -79,8 +96,15 @@ test_files:
79
96
  - spec/event/events_spec.rb
80
97
  - spec/event/map_names_spec.rb
81
98
  - spec/event/world_names_spec.rb
99
+ - spec/guild/guild_details_spec.rb
82
100
  - spec/item/item_details_spec.rb
83
101
  - spec/item/items_spec.rb
102
+ - spec/map/continents_spec.rb
103
+ - spec/map/map_floor_spec.rb
104
+ - spec/map/maps_spec.rb
105
+ - spec/misc/build_spec.rb
106
+ - spec/misc/colors_spec.rb
107
+ - spec/misc/files_spec.rb
84
108
  - spec/recipe/recipe_details_spec.rb
85
109
  - spec/recipe/recipes_spec.rb
86
110
  - spec/spec_helper.rb