xiv_lodestone 0.0.4 → 0.0.5
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 +4 -4
- data/CHANGELOG.md +13 -0
- data/LICENSE.txt +1 -1
- data/OUTLINE.md +37 -0
- data/README.md +45 -11
- data/lib/xiv_lodestone/lodestone_character.rb +17 -12
- data/lib/xiv_lodestone/lodestone_character_attribute.rb +5 -5
- data/lib/xiv_lodestone/lodestone_character_collectable.rb +29 -0
- data/lib/xiv_lodestone/lodestone_character_disciple.rb +11 -21
- data/lib/xiv_lodestone/lodestone_character_gear.rb +11 -19
- data/lib/xiv_lodestone/lodestone_helper.rb +42 -27
- data/lib/xiv_lodestone/lodestone_server.rb +34 -0
- data/lib/xiv_lodestone/version.rb +1 -1
- data/lib/xiv_lodestone.rb +1 -0
- data/spec/resources/status.html +2151 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/xiv_lodestone_character_attribute_spec.rb +26 -0
- data/spec/xiv_lodestone_character_collectable_spec.rb +28 -0
- data/spec/xiv_lodestone_character_disciple_spec.rb +33 -0
- data/spec/xiv_lodestone_character_gear_spec.rb +37 -0
- data/spec/xiv_lodestone_helper_spec.rb +52 -0
- data/spec/xiv_lodestone_server_spec.rb +28 -0
- data/spec/xiv_lodestone_spec.rb +13 -72
- data/xiv_lodestone.gemspec +0 -1
- metadata +19 -17
- data/lib/xiv_lodestone/lodestone_character_mount.rb +0 -35
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'codeclimate-test-reporter'
|
2
2
|
CodeClimate::TestReporter.start
|
3
3
|
|
4
|
+
LOCAL_FILE = File.join(File.dirname(__FILE__), "resources/character.html")
|
5
|
+
INVALID_FILE = File.join(File.dirname(__FILE__), "resources/invalid.html")
|
6
|
+
SERVER_FILE = File.join(File.dirname(__FILE__), "resources/status.html")
|
7
|
+
|
4
8
|
RSpec.configure do |config|
|
5
9
|
config.expect_with :rspec do |expectations|
|
6
10
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'xiv_lodestone/lodestone_character_attribute'
|
3
|
+
|
4
|
+
describe XIVLodestone::AttributeList do
|
5
|
+
let (:valid) {
|
6
|
+
XIVLodestone::AttributeList.new(Nokogiri::HTML(open(LOCAL_FILE)).
|
7
|
+
xpath('//div[starts-with(@class,"param_left_area_inner")]/ul/li'))
|
8
|
+
}
|
9
|
+
|
10
|
+
let (:invalid) {
|
11
|
+
XIVLodestone::AttributeList.new(Nokogiri::HTML(open(INVALID_FILE)).
|
12
|
+
xpath('//div[starts-with(@class, "param_left_area_inner")]/ul/li'))
|
13
|
+
}
|
14
|
+
|
15
|
+
it 'to json dump check' do
|
16
|
+
expect(valid.to_json).to eq("{\"str\":109,\"dex\":213,\"vit\":422,\"int\":211,\"mnd\":539,\"pie\":408,\"fire\":270,\"ice\":267,\"wind\":271,\"earth\":269,\"lightning\":269,\"water\":269,\"accuracy\":405,\"critical_hit_rate\":424,\"determination\":320,\"defense\":318,\"parry\":341,\"magic_defense\":545,\"attack_power\":109,\"skill_speed\":341,\"attack_magic_potency\":211,\"healing_magic_potency\":539,\"spell_speed\":415,\"slow_resistance\":0,\"silence_resistance\":0,\"blind_resistance\":0,\"poison_resistance\":0,\"stun_resistance\":0,\"sleep_resistance\":0,\"bind_resistance\":0,\"heavy_resistance\":0,\"slashing\":100,\"piercing\":100,\"blunt\":100}")
|
17
|
+
expect(invalid.to_json).to eq("{}")
|
18
|
+
expect(valid.to_json.is_a?(String)).to eq(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'method missing check' do
|
22
|
+
expect(valid.method_missing(:str)).to eql(109)
|
23
|
+
expect(valid.method_missing(:dex)).to eql(213)
|
24
|
+
expect(valid.method_missing(:fire)).to eql(270)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'xiv_lodestone/lodestone_character_collectable'
|
3
|
+
|
4
|
+
describe XIVLodestone::CollectableList do
|
5
|
+
let (:valid) {
|
6
|
+
XIVLodestone::CollectableList.new(Nokogiri::HTML(open(LOCAL_FILE)).xpath('(//div[@class="minion_box clearfix"])[1]/a'))
|
7
|
+
}
|
8
|
+
let (:invalid) {
|
9
|
+
XIVLodestone::CollectableList.new(Nokogiri::HTML(open(INVALID_FILE)).xpath('(//div[@class="minion_box clearfix"])[1]/a'))
|
10
|
+
}
|
11
|
+
|
12
|
+
it 'Get array of collectables' do
|
13
|
+
expect(valid.list.is_a?(Array)).to eq(true)
|
14
|
+
expect(valid.list.size).to eq(9)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'Dump json of collectables' do
|
18
|
+
expect(valid.to_json).to eq("[{\"name\":\"Company Chocobo\",\"icon_url\":\"http://img.finalfantasyxiv.com/lds/pc/global/images/itemicon/49/4911a5bb2afb40de2a737cac98ecbe734698d26d.png?1376540423\"},{\"name\":\"Fat Chocobo\",\"icon_url\":\"http://img.finalfantasyxiv.com/lds/pc/global/images/itemicon/f2/f20a405d9db772c0d429b19b11248d7e32785b87.png?1392180296\"},{\"name\":\"Magitek Armor\",\"icon_url\":\"http://img.finalfantasyxiv.com/lds/pc/global/images/itemicon/1c/1ce3841890b1d22b689545ccba1c9572fe89c230.png?1376540423\"},{\"name\":\"Laurel Goobbue\",\"icon_url\":\"http://img.finalfantasyxiv.com/lds/pc/global/images/itemicon/30/307a840fd965b95e2f81ba0ba68bf0ba8e3a8763.png?1382588534\"},{\"name\":\"Coeurl\",\"icon_url\":\"http://img.finalfantasyxiv.com/lds/pc/global/images/itemicon/4c/4cad467d11b008e63567bdca93543f791baafa9c.png?1376540423\"},{\"name\":\"Ahriman\",\"icon_url\":\"http://img.finalfantasyxiv.com/lds/pc/global/images/itemicon/fa/facbad5e6cf82ed4d43d243367dffbac270b1d6b.png?1376540423\"},{\"name\":\"Behemoth\",\"icon_url\":\"http://img.finalfantasyxiv.com/lds/pc/global/images/itemicon/44/44911f30e4f853cf10ed00da286240dd6e649e7d.png?1382588533\"},{\"name\":\"Bomb Palanquin\",\"icon_url\":\"http://img.finalfantasyxiv.com/lds/pc/global/images/itemicon/92/92fb151ac9596bc548ccbe0ffb13d7c587921697.png?1392208413\"},{\"name\":\"Unicorn\",\"icon_url\":\"http://img.finalfantasyxiv.com/lds/pc/global/images/itemicon/eb/eb9cc5fd160b25f2dd9438937589628c6a7ae029.png?1376540423\"}]")
|
19
|
+
expect(invalid.to_json).to eq("[]")
|
20
|
+
expect(valid.to_json.is_a?(String)).to eq(true)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'Build a collectable' do
|
24
|
+
mount = XIVLodestone::CollectableList::Collectable.new("Bomb Palanquin", "http")
|
25
|
+
expect(mount.name).to eq("Bomb Palanquin")
|
26
|
+
expect(mount.icon_url).to eq("http")
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'xiv_lodestone/lodestone_character_disciple'
|
3
|
+
|
4
|
+
describe XIVLodestone::DiscipleList do
|
5
|
+
let (:valid) {
|
6
|
+
XIVLodestone::DiscipleList.new(Nokogiri::HTML(open(LOCAL_FILE)).xpath("//table[@class='class_list']/tr/td"))
|
7
|
+
}
|
8
|
+
let (:invalid) {
|
9
|
+
XIVLodestone::DiscipleList.new(Nokogiri::HTML(open(INVALID_FILE)).xpath("//table[@class='class_list']/tr/td"))
|
10
|
+
}
|
11
|
+
|
12
|
+
it 'Dump json of disciples' do
|
13
|
+
expect(valid.to_json).to eq("{\"gladiator\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Gladiator\\\", level=1, current_exp=0, total_exp=300, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/ec5d264e53ea7749d916d7d8bc235ec9c8bb7b51.png?1367039495\\\">\",\"pugilist\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Pugilist\\\", level=6, current_exp=429, total_exp=4200, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/9fe08b7e2827a51fc216e6407646ffba716a44b8.png?1367039495\\\">\",\"marauder\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Marauder\\\", level=1, current_exp=0, total_exp=300, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/5ca476c2166b399e3ec92e8008544fdbea75b6a2.png?1367039495\\\">\",\"lancer\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Lancer\\\", level=1, current_exp=0, total_exp=300, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/924ded09293b2a04c4cd662afbf7cda7b0576888.png?1367039495\\\">\",\"archer\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Archer\\\", level=1, current_exp=0, total_exp=300, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/d39804e8810aa3d8e467b7a476d01965510c5d18.png?1367039495\\\">\",\"rogue\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Rogue\\\", level=0, current_exp=0, total_exp=0, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/2d0ac2fdb4fd432d6b91acd7afbc335e87e877fb.png?1414484314\\\">\",\"conjurer\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Conjurer\\\", level=50, current_exp=0, total_exp=0, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/6157497a98f55a73af4c277f383d0a23551e9e98.png?1367039495\\\">\",\"thaumaturge\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Thaumaturge\\\", level=26, current_exp=244, total_exp=109800, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/e2a98c81ca279607fc1706e5e1b11bc08cac2578.png?1367039495\\\">\",\"arcanist\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Arcanist\\\", level=50, current_exp=0, total_exp=0, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/59fde9fca303490477962039f6cd0d0101caeabe.png?1367039495\\\">\",\"carpenter\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Carpenter\\\", level=1, current_exp=0, total_exp=300, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/d41cb306af74bb5407bc74fa865e9207a5ce4899.png?1367039495\\\">\",\"blacksmith\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Blacksmith\\\", level=1, current_exp=0, total_exp=300, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/6e0223f41a926eab7e6bc42af7dd29b915999db1.png?1367039495\\\">\",\"armorer\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Armorer\\\", level=1, current_exp=0, total_exp=300, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/aab4391a4a5633684e1b93174713c1c52f791930.png?1367039495\\\">\",\"goldsmith\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Goldsmith\\\", level=22, current_exp=1910, total_exp=71400, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/605aa74019178eef7d8ba790b3db10ac8e9cd4ca.png?1367039495\\\">\",\"leatherworker\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Leatherworker\\\", level=1, current_exp=0, total_exp=300, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/f358b50ff0a1b1dcb67490ba8f4c480e01e4edd7.png?1367039495\\\">\",\"weaver\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Weaver\\\", level=16, current_exp=26199, total_exp=35400, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/131b914b2be4563ec76b870d1fa44aa8da0f1ee6.png?1367039495\\\">\",\"alchemist\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Alchemist\\\", level=20, current_exp=36457, total_exp=56600, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/343bce834add76f5d714f33154d0c70e99d495a3.png?1367039495\\\">\",\"culinarian\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Culinarian\\\", level=1, current_exp=0, total_exp=300, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/86f1875ebc31f88eb917283665be128689a9669b.png?1367039495\\\">\",\"miner\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Miner\\\", level=1, current_exp=0, total_exp=300, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/8e82259fcd979378632cde0c9767c15dba3790af.png?1367039495\\\">\",\"botanist\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Botanist\\\", level=50, current_exp=0, total_exp=0, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/937d3313d9d7ef491319c38a4d4cde4035eb1ab3.png?1367039495\\\">\",\"fisher\":\"#<struct XIVLodestone::DiscipleList::Disciple name=\\\"Fisher\\\", level=5, current_exp=1025, total_exp=2300, icon_url=\\\"http://img.finalfantasyxiv.com/lds/pc/global/images/class/24/289dbc0b50956ce10a2195a75a22b500a648284e.png?1367039495\\\">\"}")
|
14
|
+
expect(invalid.to_json).to eq("{}")
|
15
|
+
expect(valid.to_json.is_a?(String)).to eq(true)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'method missing check' do
|
19
|
+
expect(valid.method_missing(:rogue).is_a?(XIVLodestone::DiscipleList::Disciple)).to eql(true)
|
20
|
+
expect(valid.method_missing(:goldsmith).is_a?(XIVLodestone::DiscipleList::Disciple)).to eql(true)
|
21
|
+
expect(valid.method_missing(:arcanist).is_a?(XIVLodestone::DiscipleList::Disciple)).to eql(true)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'Build a disciple' do
|
25
|
+
d = XIVLodestone::DiscipleList::Disciple.new("Rogue", 1, 0, 300, "http")
|
26
|
+
expect(d.name).to eq("Rogue")
|
27
|
+
expect(d.level).to eq(1)
|
28
|
+
expect(d.current_exp).to eq(0)
|
29
|
+
expect(d.total_exp).to eq(300)
|
30
|
+
expect(d.icon_url).to eq("http")
|
31
|
+
expect(d.next_level).to eq(300)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'xiv_lodestone/lodestone_character_gear'
|
3
|
+
|
4
|
+
describe XIVLodestone::GearList do
|
5
|
+
let (:valid) {
|
6
|
+
XIVLodestone::GearList.new(Nokogiri::HTML(open(LOCAL_FILE)).
|
7
|
+
xpath("(//div[@class='item_detail_box'])[position() < 13]"))
|
8
|
+
}
|
9
|
+
let (:invalid) {
|
10
|
+
XIVLodestone::GearList.new(Nokogiri::HTML(open(INVALID_FILE)).
|
11
|
+
xpath("(//div[@class='item_detail_box'])[position() < 13]"))
|
12
|
+
}
|
13
|
+
|
14
|
+
it 'Dump json of items' do
|
15
|
+
expect(valid.to_json).to eq("{\"weapon\":\"#<struct XIVLodestone::GearList::Gear name=\\\"Yagrush\\\", ilevel=110, slot=\\\"Two-handed Conjurer's Arm\\\", url=\\\"http://na.finalfantasyxiv.com/lodestone/playguide/db/item/774f3c096da/\\\">\",\"head\":\"#<struct XIVLodestone::GearList::Gear name=\\\"Weathered Daystar Circlet\\\", ilevel=100, slot=\\\"Head\\\", url=\\\"http://na.finalfantasyxiv.com/lodestone/playguide/db/item/0bb88cb2693/\\\">\",\"body\":\"#<struct XIVLodestone::GearList::Gear name=\\\"Scylla's Robe of Healing\\\", ilevel=100, slot=\\\"Body\\\", url=\\\"http://na.finalfantasyxiv.com/lodestone/playguide/db/item/0c45cdcda37/\\\">\",\"hands\":\"#<struct XIVLodestone::GearList::Gear name=\\\"Weathered Daystar Gloves\\\", ilevel=100, slot=\\\"Hands\\\", url=\\\"http://na.finalfantasyxiv.com/lodestone/playguide/db/item/ec2ddbdcd47/\\\">\",\"waist\":\"#<struct XIVLodestone::GearList::Gear name=\\\"Daystar Belt\\\", ilevel=110, slot=\\\"Waist\\\", url=\\\"http://na.finalfantasyxiv.com/lodestone/playguide/db/item/9804bb03aaf/\\\">\",\"legs\":\"#<struct XIVLodestone::GearList::Gear name=\\\"Daystar Breeches\\\", ilevel=110, slot=\\\"Legs\\\", url=\\\"http://na.finalfantasyxiv.com/lodestone/playguide/db/item/9280701e6ba/\\\">\",\"feet\":\"#<struct XIVLodestone::GearList::Gear name=\\\"High Allagan Thighboots of Healing\\\", ilevel=110, slot=\\\"Feet\\\", url=\\\"http://na.finalfantasyxiv.com/lodestone/playguide/db/item/77060a25e03/\\\">\",\"necklace\":\"#<struct XIVLodestone::GearList::Gear name=\\\"Daystar Necklace\\\", ilevel=110, slot=\\\"Necklace\\\", url=\\\"http://na.finalfantasyxiv.com/lodestone/playguide/db/item/534d3e2f0fd/\\\">\",\"earrings\":\"#<struct XIVLodestone::GearList::Gear name=\\\"High Allagan Earrings of Healing\\\", ilevel=110, slot=\\\"Earrings\\\", url=\\\"http://na.finalfantasyxiv.com/lodestone/playguide/db/item/ba581d18070/\\\">\",\"bracelets\":\"#<struct XIVLodestone::GearList::Gear name=\\\"Daystar Armillae\\\", ilevel=110, slot=\\\"Bracelets\\\", url=\\\"http://na.finalfantasyxiv.com/lodestone/playguide/db/item/d0f33b5c4bf/\\\">\",\"ring1\":\"#<struct XIVLodestone::GearList::Gear name=\\\"Ironworks Ring of Healing\\\", ilevel=120, slot=\\\"Ring\\\", url=\\\"http://na.finalfantasyxiv.com/lodestone/playguide/db/item/7beab721371/\\\">\",\"ring2\":\"#<struct XIVLodestone::GearList::Gear name=\\\"Daystar Ring\\\", ilevel=110, slot=\\\"Ring\\\", url=\\\"http://na.finalfantasyxiv.com/lodestone/playguide/db/item/5b78525af6f/\\\">\"}")
|
16
|
+
expect(invalid.to_json).to eq("{}")
|
17
|
+
expect(valid.to_json.is_a?(String)).to eq(true)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'calculate ilevel' do
|
21
|
+
expect(valid.ilevel).to eq(108)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'method missing check' do
|
25
|
+
expect(valid.method_missing(:head).is_a?(XIVLodestone::GearList::Gear)).to eql(true)
|
26
|
+
expect(valid.method_missing(:weapon).is_a?(XIVLodestone::GearList::Gear)).to eql(true)
|
27
|
+
expect(valid.method_missing(:ring1).is_a?(XIVLodestone::GearList::Gear)).to eql(true)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'Build a Gear' do
|
31
|
+
d = XIVLodestone::GearList::Gear.new("Sword", 100, "Two Hand", "http")
|
32
|
+
expect(d.name).to eq("Sword")
|
33
|
+
expect(d.ilevel).to eq(100)
|
34
|
+
expect(d.slot).to eq("Two Hand")
|
35
|
+
expect(d.url).to eq("http")
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'xiv_lodestone/lodestone_helper'
|
3
|
+
|
4
|
+
describe XIVLodestone::Helper do
|
5
|
+
let(:helper) { XIVLodestone::Helper }
|
6
|
+
|
7
|
+
it 'Find character from name and server' do
|
8
|
+
page = helper.open_url("Benpi Kancho", "Tonberry")
|
9
|
+
expect(page.xpath('//h2/a')[0].text).to eq("Benpi Kancho")
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'Invalid character name' do
|
13
|
+
expect { helper.open_url("#$%#FG", "Tonberry") }.to raise_error(URI::InvalidURIError)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'No character found exception' do
|
17
|
+
expect { helper.open_url("Yoloswaggings", "Tonberry") }.to raise_error(XIVLodestone::CharacterNotFound)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'Find character from id' do
|
21
|
+
page = helper.open_id("1549391")
|
22
|
+
expect(page.xpath('//h2/a')[0].text).to eql("Benpi Kancho")
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'invalid character id' do
|
26
|
+
expect { helper.open_id("154") }.to raise_error(OpenURI::HTTPError)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'invalid arguments' do
|
30
|
+
expect { helper.process_args(:server => "Tonberry")}. to raise_error(ArgumentError)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'replace_downcase case test' do
|
34
|
+
expect(helper.replace_downcase("HELLO WORLD")).to eq("hello_world")
|
35
|
+
expect(helper.replace_downcase("well_yea")).to eq("well_yea")
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'sucessful call of get methods' do
|
39
|
+
valid = Nokogiri::HTML(open(LOCAL_FILE))
|
40
|
+
expect(helper.get_hp(valid)).to eq(4975)
|
41
|
+
expect(helper.get_mp(valid)).to eq(4819)
|
42
|
+
expect(helper.get_tp(valid)).to eq(1000)
|
43
|
+
expect(helper.get_sex(valid)).to eq("Male")
|
44
|
+
expect(helper.get_race(valid)).to eq("Miqo'te")
|
45
|
+
expect(helper.get_clan(valid)).to eq("Keeper of the Moon")
|
46
|
+
expect(helper.get_nameday(valid)).to eq("27th Sun of the 1st Astral Moon")
|
47
|
+
expect(helper.get_guardian(valid)).to eq("Oschon, the Wanderer")
|
48
|
+
expect(helper.get_city(valid)).to eq("Gridania")
|
49
|
+
expect(helper.get_grand_company(valid)).to eq("Immortal Flames/Second Flame Lieutenant")
|
50
|
+
expect(helper.get_free_company(valid)).to eq(["Nomad Moogles", "http://na.finalfantasyxiv.com/lodestone/freecompany/9233505136016403440/"])
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'xiv_lodestone/lodestone_helper'
|
3
|
+
require 'xiv_lodestone/lodestone_server'
|
4
|
+
|
5
|
+
describe XIVLodestone::ServerStatus do
|
6
|
+
let (:server) { XIVLodestone::ServerStatus.new }
|
7
|
+
|
8
|
+
it 'Pull server status' do
|
9
|
+
expect(server.nil?).not_to be
|
10
|
+
expect(server.tonberry.nil?).not_to be
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'method missing check' do
|
14
|
+
expect(server.method_missing(:aegis).is_a?(XIVLodestone::ServerStatus::Server)).to eql(true)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'updating server information' do
|
18
|
+
server.fetch_server_status(Nokogiri::HTML(open(SERVER_FILE)))
|
19
|
+
expect(server.tonberry.status).to eq("Offline")
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'build a server' do
|
23
|
+
s = XIVLodestone::ServerStatus::Server.new("Hello", "World", "Yay")
|
24
|
+
expect(s.name).to eq("Hello")
|
25
|
+
expect(s.status).to eq("World")
|
26
|
+
expect(s.registration).to eq("Yay")
|
27
|
+
end
|
28
|
+
end
|
data/spec/xiv_lodestone_spec.rb
CHANGED
@@ -1,80 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'xiv_lodestone'
|
3
3
|
|
4
|
-
LOCAL_FILE = File.join(File.dirname(__FILE__), "resources/character.html")
|
5
|
-
INVALID_FILE = File.join(File.dirname(__FILE__), "resources/invalid.html")
|
6
|
-
|
7
4
|
describe XIVLodestone::Character do
|
8
|
-
let(:character) { XIVLodestone::Character.new(:
|
5
|
+
let(:character) { XIVLodestone::Character.new(name: "Benpi Kancho", server: "Tonberry") }
|
9
6
|
|
10
7
|
it 'Character profile found' do
|
11
|
-
expect(character.nil?).to
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
it '
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
it 'Invalid character name' do
|
24
|
-
expect { helper.open_url("#$%#FG", "Tonberry") }.to raise_error(URI::InvalidURIError)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'Find multiple characters exception' do
|
28
|
-
expect { helper.open_url("Benpi", "") }.to raise_error(XIVLodestone::MoreThanOneCharacter)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'No character found exception' do
|
32
|
-
expect { helper.open_url("Yoloswaggings", "Tonberry") }.to raise_error(XIVLodestone::CharacterNotFound)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'Find character from id' do
|
36
|
-
page = helper.open_id("1549391")
|
37
|
-
expect(page.xpath('//h2/a')[0].text).to eql("Benpi Kancho")
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'invalid character id' do
|
41
|
-
expect { helper.open_id("154") }.to raise_error(OpenURI::HTTPError)
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'invalid arguments' do
|
45
|
-
expect { helper.process_args(:server => "Tonberry")}. to raise_error(ArgumentError)
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'Should/Shouldnt be a 2hand weapon' do
|
49
|
-
expect(helper.is_2hand_weapon("Two-handed Conjurer's Arm")).to be
|
50
|
-
expect(helper.is_2hand_weapon("Dogs Brekkie")).not_to be
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'replace_downcase case test' do
|
54
|
-
expect(helper.replace_downcase("HELLO WORLD")).to eq("hello_world")
|
55
|
-
expect(helper.replace_downcase("well_yea")).to eq("well_yea")
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'sucessful call of get methods' do
|
59
|
-
valid = Nokogiri::HTML(open(LOCAL_FILE))
|
60
|
-
expect(helper.get_hp(valid)).to eq(4975)
|
61
|
-
expect(helper.get_mp(valid)).to eq(4819)
|
62
|
-
expect(helper.get_tp(valid)).to eq(1000)
|
63
|
-
expect(helper.get_sex(valid)).to eq("Male")
|
64
|
-
expect(helper.get_race(valid)).to eq("Miqo'te")
|
65
|
-
expect(helper.get_clan(valid)).to eq("Keeper of the Moon")
|
66
|
-
expect(helper.get_nameday(valid)).to eq("27th Sun of the 1st Astral Moon")
|
67
|
-
expect(helper.get_guardian(valid)).to eq("Oschon, the Wanderer")
|
68
|
-
expect(helper.get_city(valid)).to eq("Gridania")
|
69
|
-
expect(helper.get_grand_company(valid)).to eq("Immortal Flames/Second Flame Lieutenant")
|
70
|
-
expect(helper.get_free_company(valid)).to eq(["Nomad Moogles", "http://na.finalfantasyxiv.com/lodestone/freecompany/9233505136016403440/"])
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe XIVLodestone::Character do
|
75
|
-
let(:character) { XIVLodestone::Character.new(:name => "Pocket Rocket", :server =>"Tonberry") }
|
76
|
-
|
77
|
-
it 'Character methods check' do
|
78
|
-
# TODO Add full test of API
|
8
|
+
expect(character.nil?).to eq(false)
|
9
|
+
expect(character.first_name).to eq("Benpi")
|
10
|
+
expect(character.last_name).to eq("Kancho")
|
11
|
+
expect(character.mounts.is_a?(Array)).to be
|
12
|
+
expect(character.minions.is_a?(Array)).to be
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'Randomly opens a profile' do
|
16
|
+
letter = (0...1).map { (65 + rand(26)).chr }.join
|
17
|
+
random = XIVLodestone::Character.new(name: letter)
|
18
|
+
expect(random.nil?).to eq(false)
|
19
|
+
expect(random.name.nil?).to eq(false)
|
79
20
|
end
|
80
21
|
end
|
data/xiv_lodestone.gemspec
CHANGED
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.required_ruby_version = "~> 2.2"
|
22
22
|
|
23
23
|
spec.add_dependency("nokogiri", "~> 1.6")
|
24
|
-
spec.add_dependency("oj", "~> 2.11")
|
25
24
|
|
26
25
|
spec.add_development_dependency("bundler", "~> 1.7")
|
27
26
|
spec.add_development_dependency("rspec", "~> 3.1")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xiv_lodestone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Evenson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: oj
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '2.11'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '2.11'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,19 +80,28 @@ files:
|
|
94
80
|
- CHANGELOG.md
|
95
81
|
- Gemfile
|
96
82
|
- LICENSE.txt
|
83
|
+
- OUTLINE.md
|
97
84
|
- README.md
|
98
85
|
- Rakefile
|
99
86
|
- lib/xiv_lodestone.rb
|
100
87
|
- lib/xiv_lodestone/lodestone_character.rb
|
101
88
|
- lib/xiv_lodestone/lodestone_character_attribute.rb
|
89
|
+
- lib/xiv_lodestone/lodestone_character_collectable.rb
|
102
90
|
- lib/xiv_lodestone/lodestone_character_disciple.rb
|
103
91
|
- lib/xiv_lodestone/lodestone_character_gear.rb
|
104
|
-
- lib/xiv_lodestone/lodestone_character_mount.rb
|
105
92
|
- lib/xiv_lodestone/lodestone_helper.rb
|
93
|
+
- lib/xiv_lodestone/lodestone_server.rb
|
106
94
|
- lib/xiv_lodestone/version.rb
|
107
95
|
- spec/resources/character.html
|
108
96
|
- spec/resources/invalid.html
|
97
|
+
- spec/resources/status.html
|
109
98
|
- spec/spec_helper.rb
|
99
|
+
- spec/xiv_lodestone_character_attribute_spec.rb
|
100
|
+
- spec/xiv_lodestone_character_collectable_spec.rb
|
101
|
+
- spec/xiv_lodestone_character_disciple_spec.rb
|
102
|
+
- spec/xiv_lodestone_character_gear_spec.rb
|
103
|
+
- spec/xiv_lodestone_helper_spec.rb
|
104
|
+
- spec/xiv_lodestone_server_spec.rb
|
110
105
|
- spec/xiv_lodestone_spec.rb
|
111
106
|
- xiv_lodestone.gemspec
|
112
107
|
homepage: https://github.com/benjiro/XIV-lodestone
|
@@ -136,5 +131,12 @@ summary: A webscraper for FFXIV:ARR lodestone website.
|
|
136
131
|
test_files:
|
137
132
|
- spec/resources/character.html
|
138
133
|
- spec/resources/invalid.html
|
134
|
+
- spec/resources/status.html
|
139
135
|
- spec/spec_helper.rb
|
136
|
+
- spec/xiv_lodestone_character_attribute_spec.rb
|
137
|
+
- spec/xiv_lodestone_character_collectable_spec.rb
|
138
|
+
- spec/xiv_lodestone_character_disciple_spec.rb
|
139
|
+
- spec/xiv_lodestone_character_gear_spec.rb
|
140
|
+
- spec/xiv_lodestone_helper_spec.rb
|
141
|
+
- spec/xiv_lodestone_server_spec.rb
|
140
142
|
- spec/xiv_lodestone_spec.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'xiv_lodestone/lodestone_helper'
|
2
|
-
require 'oj'
|
3
|
-
|
4
|
-
module XIVLodestone
|
5
|
-
class MountList
|
6
|
-
attr_reader :list
|
7
|
-
|
8
|
-
def initialize(mount_path)
|
9
|
-
@list = Array.new
|
10
|
-
parse_mount(mount_path)
|
11
|
-
end
|
12
|
-
# Uses gem Oj to dump MountList to JSON
|
13
|
-
def to_json()
|
14
|
-
Oj.dump(@list)
|
15
|
-
end
|
16
|
-
#### Private Methods ####
|
17
|
-
def parse_mount(mount_path)
|
18
|
-
mount_path.each do |mount|
|
19
|
-
@list.push(Mount.new(mount['title'],
|
20
|
-
mount.at_xpath('img')['src']))
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
private :parse_mount
|
25
|
-
|
26
|
-
class Mount
|
27
|
-
attr_reader :name, :icon_url
|
28
|
-
|
29
|
-
def initialize(name, icon_url)
|
30
|
-
@name = name.split.map(&:capitalize)*' '
|
31
|
-
@icon_url = icon_url
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|