xiv_lodestone 0.0.2

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.
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Invalid</title>
6
+ </head>
7
+ <body>
8
+ Haha, no character here!!!
9
+ </body>
10
+ </html>
@@ -0,0 +1,12 @@
1
+ require 'codeclimate-test-reporter'
2
+ CodeClimate::TestReporter.start
3
+
4
+ RSpec.configure do |config|
5
+ config.expect_with :rspec do |expectations|
6
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
7
+ end
8
+
9
+ config.mock_with :rspec do |mocks|
10
+ mocks.verify_partial_doubles = true
11
+ end
12
+ end
@@ -0,0 +1,111 @@
1
+ require 'spec_helper'
2
+ require 'xiv_lodestone'
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
+ describe XIVLodestone::Character do
8
+ let(:character) { XIVLodestone::Character.new("Benpi Kancho", "Tonberry") }
9
+
10
+ it 'Character profile found' do
11
+ expect(character.nil?).to eql(false)
12
+ end
13
+ end
14
+
15
+ describe XIVLodestone::Helper do
16
+ it 'Find character from name and server' do
17
+ page = XIVLodestone::Helper.open_url("Benpi Kancho", "Tonberry")
18
+ expect(page.xpath('//h2/a')[0].text).to eql("Benpi Kancho")
19
+ end
20
+
21
+ it 'Invalid character name' do
22
+ expect { XIVLodestone::Helper.open_url("#$%#FG", "Tonberry") }.to raise_error(URI::InvalidURIError)
23
+ end
24
+
25
+ it 'Find multiple characters exception' do
26
+ expect { XIVLodestone::Helper.open_url("Benpi", "") }.to raise_error(XIVLodestone::MoreThanOneCharacter)
27
+ end
28
+
29
+ it 'No character found exception' do
30
+ expect { XIVLodestone::Helper.open_url("Yoloswaggings", "Tonberry") }.to raise_error(XIVLodestone::CharacterNotFound)
31
+ end
32
+
33
+ it 'Find character from id' do
34
+ page = XIVLodestone::Helper.open_id("1549391")
35
+ expect(page.xpath('//h2/a')[0].text).to eql("Benpi Kancho")
36
+ end
37
+ end
38
+
39
+ describe XIVLodestone::Character do
40
+ let(:character) { XIVLodestone::Character.new("Pocket Rocket", "Tonberry") }
41
+
42
+ it 'Character methods check' do
43
+ expect(character.city).to eql("Ul'dah")
44
+ # TODO Add full test of API
45
+ end
46
+
47
+ it 'GearList class check' do
48
+ list = XIVLodestone::GearList.new({:weapon => ["Fist", 110, "Weapon", "http://..."]})
49
+ expect(list.weapon.name).to eql("Fist")
50
+ expect(list.weapon.ilevel).to eql(110)
51
+ expect(list.weapon.slot).to eql("Weapon")
52
+ expect(list.weapon.url).to eql("http://...")
53
+ end
54
+
55
+ it 'DiscipleList class check' do
56
+ list = XIVLodestone::DiscipleList.new({:rogue => ["Rogue", 1, 0, 300, "http://..."]})
57
+ expect(list.rogue.name).to eql("Rogue")
58
+ expect(list.rogue.level).to eql(1)
59
+ expect(list.rogue.current_exp).to eql(0)
60
+ expect(list.rogue.total_exp).to eql(300)
61
+ expect(list.rogue.icon_url).to eql("http://...")
62
+ expect(list.rogue.next_level).to eql(300)
63
+ end
64
+ end
65
+
66
+ describe XIVLodestone::Parser do
67
+ let(:parser) { XIVLodestone::Parser.new(Nokogiri::HTML(File.open(LOCAL_FILE))) }
68
+ let(:invalid) { XIVLodestone::Parser.new(Nokogiri::HTML(File.open(INVALID_FILE))) }
69
+
70
+ it 'Nil initializer to parser' do
71
+ expect { XIVLodestone::Parser.new(nil) }.to raise_error(XIVLodestone::Parser::InvalidDocument)
72
+ end
73
+
74
+ it 'Invalid parse methods' do
75
+ expect(invalid.get_hp()).to eql(nil)
76
+ expect(invalid.get_mp()).to eql(nil)
77
+ expect(invalid.get_tp()).to eql(nil)
78
+ expect(invalid.get_sex()).to eql(nil)
79
+ expect(invalid.get_race()).to eql(nil)
80
+ expect(invalid.get_clan()).to eql(nil)
81
+ expect(invalid.get_nameday()).to eql(nil)
82
+ expect(invalid.get_guardian()).to eql(nil)
83
+ expect(invalid.get_city()).to eql(nil)
84
+ expect(invalid.get_grand_company()).to eql(nil)
85
+ expect(invalid.get_classes()).to eql({})
86
+ expect(invalid.get_attributes()).to eql({})
87
+ expect(invalid.get_gear()).to eql({})
88
+ end
89
+
90
+ it 'Sucessful parse methods' do
91
+ expect(parser.get_item_type("Ring")).to eql("ring")
92
+ expect(parser.get_item_type("Two-handed Conjurer's Arm")).to eql("weapon")
93
+ expect(parser.get_item_type("Shield")).to eql("shield")
94
+ expect(parser.get_classes().count).to eql(20)
95
+ expect(parser.get_attributes().count).to eql(34)
96
+ expect(parser.get_gear().count).to eql (12)
97
+ expect(parser.get_hp()).to eql(4975)
98
+ expect(parser.get_mp()).to eql(4819)
99
+ expect(parser.get_tp()).to eql(1000)
100
+ expect(parser.get_sex()).to eql("Male")
101
+ expect(parser.get_race()).to eql("Miqo'te")
102
+ expect(parser.get_clan()).to eql("Keeper of the Moon")
103
+ expect(parser.get_nameday()).to eql("27th Sun of the 1st Astral Moon")
104
+ expect(parser.get_guardian()).to eql("Oschon, the Wanderer")
105
+ expect(parser.get_city()).to eql("Gridania")
106
+ expect(parser.get_grand_company()).to eql("Immortal Flames/Second Flame Lieutenant")
107
+ expect(parser.get_free_company()).to eql(["Nomad Moogles",
108
+ "http://na.finalfantasyxiv.com/lodestone/freecompany/9233505136016403440/"])
109
+ expect(parser.replace_downcase("Hello World")).to eql("hello_world")
110
+ end
111
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'xiv_lodestone/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "xiv_lodestone"
8
+ spec.version = XIVLodestone::VERSION
9
+ spec.authors = ["Benjamin Evenson"]
10
+ spec.email = ["bevenson@gmail.com"]
11
+ spec.summary = %q{A webscraper for FFXIV:ARR lodestone website.}
12
+ spec.description = %q{A Ruby library for scraping information about a given character from the FFXIV lodestone website. More to come...}
13
+ spec.homepage = "https://github.com/benjiro/XIV-lodestone"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+ spec.required_ruby_version = '~> 2.2'
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.7"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.1"
25
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xiv_lodestone
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Benjamin Evenson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ description: A Ruby library for scraping information about a given character from
56
+ the FFXIV lodestone website. More to come...
57
+ email:
58
+ - bevenson@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".travis.yml"
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - lib/xiv_lodestone.rb
71
+ - lib/xiv_lodestone/lodestone_character.rb
72
+ - lib/xiv_lodestone/lodestone_helper.rb
73
+ - lib/xiv_lodestone/lodestone_parser.rb
74
+ - lib/xiv_lodestone/version.rb
75
+ - spec/resources/character.html
76
+ - spec/resources/invalid.html
77
+ - spec/spec_helper.rb
78
+ - spec/xiv_lodestone_spec.rb
79
+ - xiv_lodestone.gemspec
80
+ homepage: https://github.com/benjiro/XIV-lodestone
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '2.2'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.4.5
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: A webscraper for FFXIV:ARR lodestone website.
104
+ test_files:
105
+ - spec/resources/character.html
106
+ - spec/resources/invalid.html
107
+ - spec/spec_helper.rb
108
+ - spec/xiv_lodestone_spec.rb