gw2 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.md +1 -1
  3. data/README.md +4 -1
  4. data/gw2.gemspec +2 -2
  5. data/lib/gw2.rb +1 -0
  6. data/lib/gw2/disabled.rb +4 -0
  7. data/lib/gw2/event.rb +20 -5
  8. data/lib/gw2/guild.rb +4 -2
  9. data/lib/gw2/item.rb +8 -3
  10. data/lib/gw2/map.rb +18 -4
  11. data/lib/gw2/misc.rb +12 -4
  12. data/lib/gw2/recipe.rb +8 -3
  13. data/lib/gw2/wvw.rb +12 -4
  14. data/spec/fixtures/GW2_Event/_event_names/returns_the_names_of_all_events.yml +2060 -0
  15. data/spec/fixtures/GW2_Event/_map_names/returns_the_names_of_all_maps.yml +53 -0
  16. data/spec/fixtures/GW2_Event/_world_names/returns_the_names_of_all_worlds.yml +60 -0
  17. data/spec/fixtures/GW2_Guild/_details/returns_the_guild_based_on_id.yml +40 -0
  18. data/spec/fixtures/GW2_Guild/_details/returns_the_guild_based_on_name.yml +40 -0
  19. data/spec/fixtures/GW2_Item/_all/returns_all_items.yml +40 -0
  20. data/spec/fixtures/GW2_Item/_details/returns_the_details_of_the_item.yml +40 -0
  21. data/spec/fixtures/GW2_Map/_all/returns_all_maps.yml +1107 -0
  22. data/spec/fixtures/GW2_Map/_continents/returns_all_continents.yml +40 -0
  23. data/spec/fixtures/GW2_Map/_map_floor/returns_a_specific_map_floor.yml +3441 -0
  24. data/spec/fixtures/GW2_Map/_maps/returns_the_map_by_id.yml +41 -0
  25. data/spec/fixtures/GW2_Misc/_build/returns_the_build.yml +40 -0
  26. data/spec/fixtures/GW2_Misc/_colors/returns_all_colors.yml +239 -0
  27. data/spec/fixtures/GW2_Misc/_files/returns_all_files.yml +40 -0
  28. data/spec/fixtures/GW2_Recipe/_all/returns_all_recipes.yml +40 -0
  29. data/spec/fixtures/GW2_Recipe/_details/returns_the_details_of_a_recipe_by_id.yml +40 -0
  30. data/spec/fixtures/GW2_WvW/_match_details/returns_the_details_of_a_match.yml +40 -0
  31. data/spec/fixtures/GW2_WvW/_matches/returns_all_matches.yml +40 -0
  32. data/spec/fixtures/GW2_WvW/_objective_names/returns_all_objectives.yml +59 -0
  33. data/spec/gw2/event_spec.rb +66 -0
  34. data/spec/gw2/guild_spec.rb +33 -0
  35. data/spec/gw2/item_spec.rb +44 -0
  36. data/spec/gw2/map_spec.rb +102 -0
  37. data/spec/gw2/misc_spec.rb +72 -0
  38. data/spec/gw2/recipe_spec.rb +45 -0
  39. data/spec/gw2/wvw_spec.rb +55 -0
  40. data/spec/spec_helper.rb +10 -0
  41. metadata +62 -65
  42. data/lib/gw2/event/event_names.rb +0 -7
  43. data/lib/gw2/event/events.rb +0 -11
  44. data/lib/gw2/event/map_names.rb +0 -7
  45. data/lib/gw2/event/world_names.rb +0 -7
  46. data/lib/gw2/guild/guild_details.rb +0 -7
  47. data/lib/gw2/item/item_details.rb +0 -7
  48. data/lib/gw2/item/items.rb +0 -7
  49. data/lib/gw2/map/continents.rb +0 -7
  50. data/lib/gw2/map/map_floor.rb +0 -7
  51. data/lib/gw2/map/maps.rb +0 -13
  52. data/lib/gw2/misc/build.rb +0 -8
  53. data/lib/gw2/misc/colors.rb +0 -7
  54. data/lib/gw2/misc/files.rb +0 -7
  55. data/lib/gw2/recipe/recipe_details.rb +0 -7
  56. data/lib/gw2/recipe/recipes.rb +0 -7
  57. data/lib/gw2/wvw/match_details.rb +0 -7
  58. data/lib/gw2/wvw/matches.rb +0 -7
  59. data/lib/gw2/wvw/objective_names.rb +0 -7
  60. data/spec/event/event_names_spec.rb +0 -22
  61. data/spec/event/events_spec.rb +0 -55
  62. data/spec/event/map_names_spec.rb +0 -22
  63. data/spec/event/world_names_spec.rb +0 -22
  64. data/spec/guild/guild_details_spec.rb +0 -37
  65. data/spec/item/item_details_spec.rb +0 -34
  66. data/spec/item/items_spec.rb +0 -22
  67. data/spec/map/continents_spec.rb +0 -40
  68. data/spec/map/map_floor_spec.rb +0 -76
  69. data/spec/map/maps_spec.rb +0 -79
  70. data/spec/misc/build_spec.rb +0 -22
  71. data/spec/misc/colors_spec.rb +0 -51
  72. data/spec/misc/files_spec.rb +0 -26
  73. data/spec/recipe/recipe_details_spec.rb +0 -34
  74. data/spec/recipe/recipes_spec.rb +0 -22
  75. data/spec/wvw/match_details_spec.rb +0 -108
  76. data/spec/wvw/matches_spec.rb +0 -25
  77. data/spec/wvw/objective_names_spec.rb +0 -25
@@ -1,55 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe GW2::Event do
4
- describe "methods" do
5
- context "#all" do
6
- before :each do
7
- @events = [
8
- { "world_id" => 1013, "map_id" => 873, "event_id" => "659149D4-43EC-4DCB-A6BB-0B2D402B537B", "state" => "Active" },
9
- { "world_id" => 1014, "map_id" => 874, "event_id" => "659149D4-43EC-4DCB-A6BB-0B2D402B537C", "state" => "Success" },
10
- { "world_id" => 1015, "map_id" => 875, "event_id" => "659149D4-43EC-4DCB-A6BB-0B2D402B537D", "state" => "Fail" },
11
- { "world_id" => 1016, "map_id" => 876, "event_id" => "659149D4-43EC-4DCB-A6BB-0B2D402B537E", "state" => "Warmup" },
12
- { "world_id" => 1017, "map_id" => 877, "event_id" => "659149D4-43EC-4DCB-A6BB-0B2D402B537F", "state" => "Preperation" }
13
- ]
14
-
15
- stub_request(:get, "https://api.guildwars2.com/v1/events.json").
16
- to_return(:status => 200, :body => { "events" => @events }.to_json)
17
- end
18
-
19
- it "exists" do
20
- GW2::Event.respond_to?(:all).should == true
21
- end
22
-
23
- it "returns the correct JSON parsed data" do
24
- GW2::Event.all.should == { "events" => @events }
25
- end
26
- end
27
-
28
- context "#events" do
29
- before :each do
30
- @events = [
31
- { "world_id" => 1013, "map_id" => 873, "event_id" => "659149D4-43EC-4DCB-A6BB-0B2D402B537B", "state" => "Active" },
32
- { "world_id" => 1014, "map_id" => 874, "event_id" => "659149D4-43EC-4DCB-A6BB-0B2D402B537C", "state" => "Success" },
33
- { "world_id" => 1015, "map_id" => 875, "event_id" => "659149D4-43EC-4DCB-A6BB-0B2D402B537D", "state" => "Fail" },
34
- { "world_id" => 1016, "map_id" => 876, "event_id" => "659149D4-43EC-4DCB-A6BB-0B2D402B537E", "state" => "Warmup" },
35
- { "world_id" => 1017, "map_id" => 877, "event_id" => "659149D4-43EC-4DCB-A6BB-0B2D402B537F", "state" => "Preperation" }
36
- ]
37
-
38
- stub_request(:get, "https://api.guildwars2.com/v1/events.json?world_id=1014").
39
- to_return(:status => 200, :body => { "events" => @events.select{ |n| n[:world_id] == 1014 } }.to_json)
40
- stub_request(:get, "https://api.guildwars2.com/v1/events.json?map_id=875").
41
- to_return(:status => 200, :body => { "events" => @events.select{ |n| n[:map_id] == 875 } }.to_json)
42
- stub_request(:get, "https://api.guildwars2.com/v1/events.json?event_id=875").
43
- to_return(:status => 200, :body => { "events" => @events.select{ |n| n[:event_id] == "659149D4-43EC-4DCB-A6BB-0B2D402B537E" } }.to_json)
44
- end
45
-
46
- it "exists" do
47
- GW2::Event.respond_to?(:where).should == true
48
- end
49
-
50
- it "returns the correct JSON parsed data" do
51
- GW2::Event.where(world_id: 1014).should == { "events" => @events.select{ |n| n[:world_id] == 1014 } }
52
- end
53
- end
54
- end
55
- end
@@ -1,22 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe GW2::Event do
4
- describe "methods" do
5
- context "#map_names" do
6
- before :each do
7
- @map_names = %Q([{"id":"15","name":"Queensdale"}])
8
-
9
- stub_request(:get, "https://api.guildwars2.com/v1/map_names.json").
10
- to_return(:status => 200, :body => @map_names)
11
- end
12
-
13
- it "exists" do
14
- GW2::Event.respond_to?(:map_names).should == true
15
- end
16
-
17
- it "returns the correct JSON parsed data" do
18
- GW2::Event.map_names.should == JSON.parse(@map_names)
19
- end
20
- end
21
- end
22
- end
@@ -1,22 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe GW2::Event do
4
- describe "methods" do
5
- context "#world_names" do
6
- before :each do
7
- @world_names = %Q([{"id":"1004","name":"Henge of Denravi"}])
8
-
9
- stub_request(:get, "https://api.guildwars2.com/v1/world_names.json").
10
- to_return(:status => 200, :body => @world_names)
11
- end
12
-
13
- it "exists" do
14
- GW2::Event.respond_to?(:world_names).should == true
15
- end
16
-
17
- it "returns the correct JSON parsed data" do
18
- GW2::Event.world_names.should == JSON.parse(@world_names)
19
- end
20
- end
21
- end
22
- end
@@ -1,37 +0,0 @@
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
@@ -1,34 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe GW2::Item do
4
- describe "methods" do
5
- context "#details" do
6
- before :each do
7
- @item_details = {
8
- "item_id" => "12546",
9
- "name" => "Lemongrass",
10
- "description" => "Ingredient",
11
- "type" => "CraftingMaterial",
12
- "level" => "80",
13
- "rarity" => "Basic",
14
- "vendor_value" => "9",
15
- "game_types" => ["Activity","Dungeon","Pve","Wvw"],
16
- "flags" => [],
17
- "restrictions" => [],
18
- "crafting_material" => ""
19
- }
20
-
21
- stub_request(:get, "https://api.guildwars2.com/v1/item_details.json?item_id=12546").
22
- to_return(:status => 200, :body => @item_details.to_json)
23
- end
24
-
25
- it "exists" do
26
- GW2::Item.respond_to?(:details).should == true
27
- end
28
-
29
- it "returns the correct JSON parsed data" do
30
- GW2::Item.details(12546).should == @item_details
31
- end
32
- end
33
- end
34
- end
@@ -1,22 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe GW2::Item do
4
- describe "methods" do
5
- context "#all" do
6
- before :each do
7
- @items = [12546, 12547, 12548, 12549, 12550]
8
-
9
- stub_request(:get, "https://api.guildwars2.com/v1/items.json").
10
- to_return(:status => 200, :body => { "items" => @items }.to_json)
11
- end
12
-
13
- it "exists" do
14
- GW2::Item.respond_to?(:all).should == true
15
- end
16
-
17
- it "returns the correct JSON parsed data" do
18
- GW2::Item.all.should == { "items" => @items }
19
- end
20
- end
21
- end
22
- end
@@ -1,40 +0,0 @@
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
@@ -1,76 +0,0 @@
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
@@ -1,79 +0,0 @@
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
@@ -1,22 +0,0 @@
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
@@ -1,51 +0,0 @@
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