xiv_lodestone 0.0.5 → 0.0.7
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/.travis.yml +1 -1
- data/lib/xiv_lodestone/lodestone_character.rb +1 -1
- data/lib/xiv_lodestone/lodestone_character_attribute.rb +41 -39
- data/lib/xiv_lodestone/lodestone_character_collectable.rb +29 -29
- data/lib/xiv_lodestone/lodestone_character_disciple.rb +44 -44
- data/lib/xiv_lodestone/lodestone_character_gear.rb +70 -70
- data/lib/xiv_lodestone/lodestone_helper.rb +4 -4
- data/lib/xiv_lodestone/lodestone_server.rb +33 -33
- data/lib/xiv_lodestone/version.rb +1 -1
- data/spec/resources/character.html +1446 -957
- data/spec/xiv_lodestone_character_attribute_spec.rb +26 -26
- data/spec/xiv_lodestone_character_collectable_spec.rb +28 -28
- data/spec/xiv_lodestone_character_disciple_spec.rb +33 -33
- data/spec/xiv_lodestone_character_gear_spec.rb +37 -37
- data/spec/xiv_lodestone_helper_spec.rb +52 -52
- data/spec/xiv_lodestone_server_spec.rb +27 -27
- data/spec/xiv_lodestone_spec.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a92571930948bd80f2cea06378f6e4fe4eb6b017
|
4
|
+
data.tar.gz: 3d89acd7ca2b5791daa40fe6441fe479d70a1378
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0c15baf24184bf633f8b6a495a3c4c2369ac049f549ac20068ff576026389ebe20737d265fb1e3240ef7bb7e0e7206de043e411e0157384fcaf23b225fb45b5
|
7
|
+
data.tar.gz: bab943d7731b5201be6a1232d6d9c07258b7549c7b2ad4a4c41b6b3f77fd8ad62b1ecff958c7d89db3f6c1be5e3a18f00f21afe38775825ab515d8abda49ddad
|
data/.travis.yml
CHANGED
@@ -35,7 +35,7 @@ module XIVLodestone
|
|
35
35
|
end
|
36
36
|
# Returns the current character job
|
37
37
|
def job
|
38
|
-
@profile[:gear].soul_crystal.name.gsub("Soul of the ", "")
|
38
|
+
@profile[:gear].soul_crystal.name.gsub("Soul of the ", "").delete!("\n\t")
|
39
39
|
end
|
40
40
|
# Generates missing methods from @profile hash keys
|
41
41
|
def method_missing(method)
|
@@ -1,39 +1,41 @@
|
|
1
|
-
require 'xiv_lodestone/lodestone_helper'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
module XIVLodestone
|
5
|
-
# A Object that represents a set of atrributes from
|
6
|
-
# lodestone website. The class parsers a given xpath
|
7
|
-
# for attributes and stores them in a Hash. All method
|
8
|
-
# names are based of names of attributes from lodestone website
|
9
|
-
class AttributeList
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
1
|
+
require 'xiv_lodestone/lodestone_helper'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module XIVLodestone
|
5
|
+
# A Object that represents a set of atrributes from
|
6
|
+
# lodestone website. The class parsers a given xpath
|
7
|
+
# for attributes and stores them in a Hash. All method
|
8
|
+
# names are based of names of attributes from lodestone website
|
9
|
+
class AttributeList
|
10
|
+
@@attribute_hash = [ "strength", "dexterity", "vitality", "intelligence", "mind", "piety" ]
|
11
|
+
|
12
|
+
def initialize(attribute_path)
|
13
|
+
@attributes = {}
|
14
|
+
parse_attributes(attribute_path)
|
15
|
+
end
|
16
|
+
# Generate methods from each key in the @attribute hash
|
17
|
+
def method_missing(method)
|
18
|
+
return @attributes[method] if @attributes.key?(method)
|
19
|
+
super
|
20
|
+
end
|
21
|
+
# Converts t
|
22
|
+
def to_json()
|
23
|
+
@attributes.to_json
|
24
|
+
end
|
25
|
+
#### Private Methods ####
|
26
|
+
# Parsers attributes from a document into @attribute hash
|
27
|
+
def parse_attributes(attribute_path)
|
28
|
+
attribute_path.each_with_index do |li, index|
|
29
|
+
# For some weird reason the first 6 elements don't use span tags like the rest.
|
30
|
+
if index < 6
|
31
|
+
@attributes[@@attribute_hash[index].to_sym] = li.text.to_i
|
32
|
+
else
|
33
|
+
ele = li.text.split(/(?<=\D)(?=\d)/)
|
34
|
+
@attributes[Helper.replace_downcase(ele[0]).to_sym] = ele[1].to_i
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private :parse_attributes
|
40
|
+
end
|
41
|
+
end
|
@@ -1,29 +1,29 @@
|
|
1
|
-
require 'xiv_lodestone/lodestone_helper'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
module XIVLodestone
|
5
|
-
class CollectableList
|
6
|
-
attr_reader :list
|
7
|
-
|
8
|
-
Collectable = Struct.new(:name, :icon_url)
|
9
|
-
|
10
|
-
def initialize(collectable_path)
|
11
|
-
@list = []
|
12
|
-
parse_collectable(collectable_path)
|
13
|
-
end
|
14
|
-
# Uses gem Oj to dump MountList to JSON
|
15
|
-
def to_json()
|
16
|
-
@list.map { |obj| Hash[obj.each_pair.to_a] }.to_json
|
17
|
-
end
|
18
|
-
#### Private Methods ####
|
19
|
-
def parse_collectable(collectable_path)
|
20
|
-
collectable_path.each do |collectable|
|
21
|
-
@list.push(Collectable.new(
|
22
|
-
collectable['title'].split.map(&:capitalize)*' ',
|
23
|
-
collectable.at_xpath('img')['src']))
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
private :parse_collectable
|
28
|
-
end
|
29
|
-
end
|
1
|
+
require 'xiv_lodestone/lodestone_helper'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module XIVLodestone
|
5
|
+
class CollectableList
|
6
|
+
attr_reader :list
|
7
|
+
|
8
|
+
Collectable = Struct.new(:name, :icon_url)
|
9
|
+
|
10
|
+
def initialize(collectable_path)
|
11
|
+
@list = []
|
12
|
+
parse_collectable(collectable_path)
|
13
|
+
end
|
14
|
+
# Uses gem Oj to dump MountList to JSON
|
15
|
+
def to_json()
|
16
|
+
@list.map { |obj| Hash[obj.each_pair.to_a] }.to_json
|
17
|
+
end
|
18
|
+
#### Private Methods ####
|
19
|
+
def parse_collectable(collectable_path)
|
20
|
+
collectable_path.each do |collectable|
|
21
|
+
@list.push(Collectable.new(
|
22
|
+
collectable['title'].split.map(&:capitalize)*' ',
|
23
|
+
collectable.at_xpath('img')['src']))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private :parse_collectable
|
28
|
+
end
|
29
|
+
end
|
@@ -1,44 +1,44 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
module XIVLodestone
|
5
|
-
# A object representation of disciples(classes)
|
6
|
-
# The initialiser takes a hash of Disciple, that layout follows
|
7
|
-
# { :rogue => ["Rogue", 1, 0, 300, "http://..."] }
|
8
|
-
class DiscipleList
|
9
|
-
# This strct representents a disciple
|
10
|
-
Disciple = Struct.new(:name, :level, :current_exp, :total_exp, :icon_url) do
|
11
|
-
def next_level
|
12
|
-
total_exp - current_exp
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(disciple_path)
|
17
|
-
@disciple = {}
|
18
|
-
parse_disciple(disciple_path)
|
19
|
-
end
|
20
|
-
# Returns a json repsentation of all disciples
|
21
|
-
def to_json()
|
22
|
-
@disciple.to_json
|
23
|
-
end
|
24
|
-
# Generates missing methods using @disciple hash keys
|
25
|
-
def method_missing(method)
|
26
|
-
return @disciple[method] if @disciple.key?(method)
|
27
|
-
super
|
28
|
-
end
|
29
|
-
#### Private Methods ####
|
30
|
-
def parse_disciple(disciple_path)
|
31
|
-
disciple_path.each_slice(3) do |table|
|
32
|
-
next if table[0].text.empty? #skip empty cols
|
33
|
-
@disciple[table[0].text.downcase.to_sym] = Disciple.new(
|
34
|
-
table[0].text,
|
35
|
-
table[1].text.to_i,
|
36
|
-
table[2].text.split(/\//)[0].to_i,
|
37
|
-
table[2].text.split(/\//)[1].to_i,
|
38
|
-
table[0].at_css('img')['src'])
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
private :parse_disciple
|
43
|
-
end
|
44
|
-
end
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module XIVLodestone
|
5
|
+
# A object representation of disciples(classes)
|
6
|
+
# The initialiser takes a hash of Disciple, that layout follows
|
7
|
+
# { :rogue => ["Rogue", 1, 0, 300, "http://..."] }
|
8
|
+
class DiscipleList
|
9
|
+
# This strct representents a disciple
|
10
|
+
Disciple = Struct.new(:name, :level, :current_exp, :total_exp, :icon_url) do
|
11
|
+
def next_level
|
12
|
+
total_exp - current_exp
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(disciple_path)
|
17
|
+
@disciple = {}
|
18
|
+
parse_disciple(disciple_path)
|
19
|
+
end
|
20
|
+
# Returns a json repsentation of all disciples
|
21
|
+
def to_json()
|
22
|
+
@disciple.to_json
|
23
|
+
end
|
24
|
+
# Generates missing methods using @disciple hash keys
|
25
|
+
def method_missing(method)
|
26
|
+
return @disciple[method] if @disciple.key?(method)
|
27
|
+
super
|
28
|
+
end
|
29
|
+
#### Private Methods ####
|
30
|
+
def parse_disciple(disciple_path)
|
31
|
+
disciple_path.each_slice(3) do |table|
|
32
|
+
next if table[0].text.empty? #skip empty cols
|
33
|
+
@disciple[table[0].text.downcase.gsub(" ", "_").to_sym] = Disciple.new(
|
34
|
+
table[0].text,
|
35
|
+
table[1].text.to_i,
|
36
|
+
table[2].text.split(/\//)[0].to_i,
|
37
|
+
table[2].text.split(/\//)[1].to_i,
|
38
|
+
table[0].at_css('img')['src'])
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private :parse_disciple
|
43
|
+
end
|
44
|
+
end
|
@@ -1,70 +1,70 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
require 'json'
|
3
|
-
require 'xiv_lodestone/lodestone_helper'
|
4
|
-
|
5
|
-
module XIVLodestone
|
6
|
-
# A Object that represents a list of Gear pieces
|
7
|
-
# The initialiser takes a hash of items in the following layout
|
8
|
-
# { :weapon => ["Fist", 110, "Weapon", "http://...."], ... }
|
9
|
-
class GearList
|
10
|
-
# This struct representation a piece of gear.
|
11
|
-
Gear = Struct.new(:name, :ilevel, :slot, :url)
|
12
|
-
|
13
|
-
def initialize(gear_path)
|
14
|
-
@items = {}
|
15
|
-
parse_gear(gear_path)
|
16
|
-
end
|
17
|
-
# Calculates the total gear list ilevel
|
18
|
-
# Rounds to the nearest whole number like FFXIV ingame calculation
|
19
|
-
# returns a #Integer
|
20
|
-
def ilevel()
|
21
|
-
ilevel = 0
|
22
|
-
ilevel = @items[:weapon].ilevel if @items[:shield].nil?
|
23
|
-
@items.each_value do |value|
|
24
|
-
ilevel += value.ilevel unless value.name =~ /Soul of the/i
|
25
|
-
end
|
26
|
-
(ilevel/13).round
|
27
|
-
end
|
28
|
-
# Returns a JSON string of all items
|
29
|
-
def to_json()
|
30
|
-
@items.to_json
|
31
|
-
end
|
32
|
-
# Generates access methods for each item slot
|
33
|
-
def method_missing(method)
|
34
|
-
return @items[method] if @items.key?(method)
|
35
|
-
super
|
36
|
-
end
|
37
|
-
#### Private Methods ####
|
38
|
-
# Parses each piece of gear and stores it in @items hash
|
39
|
-
def parse_gear(gear_path)
|
40
|
-
gear_path.each do |item|
|
41
|
-
@items[type(item.at_css('h3.category_name').text).to_sym] = Gear.new(
|
42
|
-
item.css('h2').text,
|
43
|
-
item.at_css('div.pt3.pb3').text.split(/ /).last.to_i,
|
44
|
-
item.at_css('h3').text,
|
45
|
-
"http://na.finalfantasyxiv.com#{item.at_css('a')['href']}")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
# Returns a string representation of item slot
|
49
|
-
def type(name)
|
50
|
-
if name =~ /(Arm|Arms|Grimoire|Primary Tool)/i
|
51
|
-
return "weapon"
|
52
|
-
elsif name =~ /Shield/i
|
53
|
-
return "shield"
|
54
|
-
elsif name.eql?("Ring")
|
55
|
-
return "ring#{ring_inc}"
|
56
|
-
else
|
57
|
-
return Helper.replace_downcase(name)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
# Initialise @num and count upwards, if @num >= 2 reset to 1
|
61
|
-
# @num += 1 reset if @num >= 2
|
62
|
-
def ring_inc()
|
63
|
-
@num ||= 0
|
64
|
-
@num = 0 if @num >= 2
|
65
|
-
@num += 1
|
66
|
-
end
|
67
|
-
|
68
|
-
private :parse_gear, :type, :ring_inc
|
69
|
-
end
|
70
|
-
end
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'json'
|
3
|
+
require 'xiv_lodestone/lodestone_helper'
|
4
|
+
|
5
|
+
module XIVLodestone
|
6
|
+
# A Object that represents a list of Gear pieces
|
7
|
+
# The initialiser takes a hash of items in the following layout
|
8
|
+
# { :weapon => ["Fist", 110, "Weapon", "http://...."], ... }
|
9
|
+
class GearList
|
10
|
+
# This struct representation a piece of gear.
|
11
|
+
Gear = Struct.new(:name, :ilevel, :slot, :url)
|
12
|
+
|
13
|
+
def initialize(gear_path)
|
14
|
+
@items = {}
|
15
|
+
parse_gear(gear_path)
|
16
|
+
end
|
17
|
+
# Calculates the total gear list ilevel
|
18
|
+
# Rounds to the nearest whole number like FFXIV ingame calculation
|
19
|
+
# returns a #Integer
|
20
|
+
def ilevel()
|
21
|
+
ilevel = 0
|
22
|
+
ilevel = @items[:weapon].ilevel if @items[:shield].nil?
|
23
|
+
@items.each_value do |value|
|
24
|
+
ilevel += value.ilevel unless value.name =~ /Soul of the/i
|
25
|
+
end
|
26
|
+
(ilevel/13).round
|
27
|
+
end
|
28
|
+
# Returns a JSON string of all items
|
29
|
+
def to_json()
|
30
|
+
@items.to_json
|
31
|
+
end
|
32
|
+
# Generates access methods for each item slot
|
33
|
+
def method_missing(method)
|
34
|
+
return @items[method] if @items.key?(method)
|
35
|
+
super
|
36
|
+
end
|
37
|
+
#### Private Methods ####
|
38
|
+
# Parses each piece of gear and stores it in @items hash
|
39
|
+
def parse_gear(gear_path)
|
40
|
+
gear_path.each do |item|
|
41
|
+
@items[type(item.at_css('h3.category_name').text).to_sym] = Gear.new(
|
42
|
+
item.css('h2').text.delete!("\n\t"),
|
43
|
+
item.at_css('div.pt3.pb3').text.split(/ /).last.to_i,
|
44
|
+
item.at_css('h3').text,
|
45
|
+
"http://na.finalfantasyxiv.com#{item.at_css('a')['href']}")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
# Returns a string representation of item slot
|
49
|
+
def type(name)
|
50
|
+
if name =~ /(Arm|Arms|Grimoire|Primary Tool)/i
|
51
|
+
return "weapon"
|
52
|
+
elsif name =~ /Shield/i
|
53
|
+
return "shield"
|
54
|
+
elsif name.eql?("Ring")
|
55
|
+
return "ring#{ring_inc}"
|
56
|
+
else
|
57
|
+
return Helper.replace_downcase(name)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
# Initialise @num and count upwards, if @num >= 2 reset to 1
|
61
|
+
# @num += 1 reset if @num >= 2
|
62
|
+
def ring_inc()
|
63
|
+
@num ||= 0
|
64
|
+
@num = 0 if @num >= 2
|
65
|
+
@num += 1
|
66
|
+
end
|
67
|
+
|
68
|
+
private :parse_gear, :type, :ring_inc
|
69
|
+
end
|
70
|
+
end
|
@@ -102,22 +102,22 @@ module XIVLodestone
|
|
102
102
|
end
|
103
103
|
# Returns a #String with the nameday
|
104
104
|
def self.get_nameday(page)
|
105
|
-
nameday = page.at_xpath('(//
|
105
|
+
nameday = page.at_xpath('(//dd[@class="txt_name"])[1]')
|
106
106
|
nameday ? nameday.text : ""
|
107
107
|
end
|
108
108
|
# Returns a #String with the guardian name
|
109
109
|
def self.get_guardian(page)
|
110
|
-
guardian = page.at_xpath('(//
|
110
|
+
guardian = page.at_xpath('(//dd[@class="txt_name"])[2]')
|
111
111
|
guardian ? guardian.text : ""
|
112
112
|
end
|
113
113
|
# Returns a #String the city name
|
114
114
|
def self.get_city(page)
|
115
|
-
city = page.at_xpath('(//dd[@class="txt_name"])[
|
115
|
+
city = page.at_xpath('(//dd[@class="txt_name"])[3]')
|
116
116
|
city ? city.text : ""
|
117
117
|
end
|
118
118
|
# Returns a #String with the grandcompany
|
119
119
|
def self.get_grand_company(page)
|
120
|
-
company = page.at_xpath('(//dd[@class="txt_name"])[
|
120
|
+
company = page.at_xpath('(//dd[@class="txt_name"])[4]')
|
121
121
|
company ? company.text : ""
|
122
122
|
end
|
123
123
|
# Returns a #Array with the freecompany name and url
|
@@ -1,34 +1,34 @@
|
|
1
|
-
require 'xiv_lodestone/lodestone_helper'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
module XIVLodestone
|
5
|
-
# This is a basic class fetchs the server status from
|
6
|
-
# lodestone.
|
7
|
-
class ServerStatus
|
8
|
-
Server = Struct.new(:name, :status, :registration)
|
9
|
-
|
10
|
-
def initialize()
|
11
|
-
@list = {}
|
12
|
-
fetch_server_status(Helper.open_server_status)
|
13
|
-
end
|
14
|
-
# Generates methods from @server hash keys
|
15
|
-
def method_missing(method)
|
16
|
-
return @list[method] if @list.key?(method)
|
17
|
-
super
|
18
|
-
end
|
19
|
-
# Fills the @server hash with each servers status
|
20
|
-
def fetch_server_status(page)
|
21
|
-
rego = Helper.open_registration_status
|
22
|
-
page.xpath('//td').each_slice(2) do |elem|
|
23
|
-
@list[elem[0].text.strip.downcase.to_sym] = Server.new(
|
24
|
-
elem[0].text.strip,
|
25
|
-
elem[1].text.strip,
|
26
|
-
rego.css('div.area_inner_cont').text[/○ #{elem[0].text.strip}/] ? "Open" : "Closed")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
# Returns a JSON string of server list
|
30
|
-
def to_json
|
31
|
-
@list.to_json
|
32
|
-
end
|
33
|
-
end
|
1
|
+
require 'xiv_lodestone/lodestone_helper'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module XIVLodestone
|
5
|
+
# This is a basic class fetchs the server status from
|
6
|
+
# lodestone.
|
7
|
+
class ServerStatus
|
8
|
+
Server = Struct.new(:name, :status, :registration)
|
9
|
+
|
10
|
+
def initialize()
|
11
|
+
@list = {}
|
12
|
+
fetch_server_status(Helper.open_server_status)
|
13
|
+
end
|
14
|
+
# Generates methods from @server hash keys
|
15
|
+
def method_missing(method)
|
16
|
+
return @list[method] if @list.key?(method)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
# Fills the @server hash with each servers status
|
20
|
+
def fetch_server_status(page)
|
21
|
+
rego = Helper.open_registration_status
|
22
|
+
page.xpath('//td').each_slice(2) do |elem|
|
23
|
+
@list[elem[0].text.strip.downcase.to_sym] = Server.new(
|
24
|
+
elem[0].text.strip,
|
25
|
+
elem[1].text.strip,
|
26
|
+
rego.css('div.area_inner_cont').text[/○ #{elem[0].text.strip}/] ? "Open" : "Closed")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
# Returns a JSON string of server list
|
30
|
+
def to_json
|
31
|
+
@list.to_json
|
32
|
+
end
|
33
|
+
end
|
34
34
|
end
|