ffxiv-lodestone 0.7.0 → 0.8.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/lib/ffxiv-lodestone.rb +9 -3
- metadata +20 -5
data/lib/ffxiv-lodestone.rb
CHANGED
@@ -4,9 +4,12 @@ require 'open-uri'
|
|
4
4
|
require 'json'
|
5
5
|
|
6
6
|
module FFXIVLodestone
|
7
|
-
VERSION = '0.
|
7
|
+
VERSION = '0.8.0'
|
8
8
|
|
9
9
|
class Character
|
10
|
+
class NotFoundException < RuntimeError
|
11
|
+
end
|
12
|
+
|
10
13
|
class StatList
|
11
14
|
include Enumerable
|
12
15
|
attr_reader :stats
|
@@ -131,12 +134,15 @@ module FFXIVLodestone
|
|
131
134
|
|
132
135
|
attr_reader :skills, :stats, :resistances, :profile
|
133
136
|
def initialize(character_id)
|
134
|
-
# TODO exception if ID isn't an integer
|
135
|
-
# TODO exception if we don't have a valid char ID
|
136
137
|
@character_id = character_id
|
137
138
|
|
138
139
|
doc = Nokogiri::HTML(open("http://lodestone.finalfantasyxiv.com/rc/character/status?cicuid=#{@character_id}", {'Accept-Language' => 'en-us,en;q=0.5', 'Accept-Charset' => 'utf-8;q=0.5'}))
|
139
140
|
|
141
|
+
# Did we get an error page? Invalid ID, etc.
|
142
|
+
if !((doc.search('head title').first.content.match /error/i) == nil)
|
143
|
+
raise NotFoundException, 'Bad character ID or Lodestone is broken.'
|
144
|
+
end
|
145
|
+
|
140
146
|
# The skills table doesn't have a unqiue ID or class to find it by, so take the first skill lable and go up two elements (table -> tr -> th.mianskill-lable)
|
141
147
|
@skills = SkillList.new(doc.search('th.mainskill-label').first.parent.parent)
|
142
148
|
@stats = StatList.new(doc.search("div.contents-subheader[contains('Attributes')]").first.next_sibling.next_sibling)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffxiv-lodestone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 8
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.8.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- owlmanatt
|
@@ -17,8 +17,23 @@ cert_chain: []
|
|
17
17
|
|
18
18
|
date: 2010-09-23 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: nokogiri
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 1
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 4
|
33
|
+
- 3
|
34
|
+
version: 1.4.3
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
22
37
|
description: A nice Ruby library for accessing character data on the FFXIV community site. It's a screen scraper, but you can PRETEND you're using something nice.
|
23
38
|
email:
|
24
39
|
- owlmanatt@gmail.com
|