xiv_lodestone 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a432c0ad6b311ba278eb7f9dd6b955f7e871a3e
4
- data.tar.gz: 57ce133ac2807b8f95bb33e728753ccdb0541e21
3
+ metadata.gz: 7f1bf8d0c6f4dcc49e331b28bfc3f94d222f1128
4
+ data.tar.gz: b04e3acc0ac3ff917ce5d7fdc7273632dbac1b60
5
5
  SHA512:
6
- metadata.gz: ddd77ff25fdc421423e8f47447e1e456adbb08cf0462c21cb74fe104b590aef64934d81b274fa544a919ef644ccc59632570fb05c7240aa691adb5ab3740da0b
7
- data.tar.gz: acd1e309345ec4d6555b09771efafe865c510926a80bd355751e833e96d3939747bef716e8a4676178a35f81def9b23c374281b6a11b19ad03ef14f520d405d8
6
+ metadata.gz: 44b54c61f2e69813af22345415b3d93f2c5ae9d772b67043ecc7197e660c82025203c10ed8dd372689f035e3db9a12804a3ed4474d6c978d27e5ad6d558f5358
7
+ data.tar.gz: 19e54b62a6febe1c7ea5bfdb875a7e246080fe5e9e70d7f12a6a22cfb8bbb339c7591a38b10030fee310cb3f3c57e56e4fafc802077a2d20c04b1860d15d860c
data/CHANGELOG.md ADDED
@@ -0,0 +1,23 @@
1
+ ## Alpha: 0.0.1 (yanked)
2
+
3
+ Features:
4
+ - Added for Character search via Character name, Server or Character ID
5
+ - Character Profile
6
+ - HP, MP, TP
7
+ - Race, Sex, Clan, Nameday, Guardian, City, Grand Company, Free Company
8
+ - Gear List - Shows item name, ilevel, slot, ffxiv db url, calculates total ilevel
9
+ - Disciple List(Classes) - Shows class name, level, current exp, total exp, icon url, calculates experience to next level
10
+ - All character attributes
11
+
12
+ ## Alpha: 0.0.2 (2015-01-05)
13
+
14
+ Bugfixes:
15
+ - Added required Ruby version to gemspec
16
+
17
+ ## Alpha: 0.0.3 (2015-01-06)
18
+
19
+ Bugfixes:
20
+ - Added nokogiri dependency to gemspec
21
+ - Remove rake dependency from spec
22
+ - Fixed ilevel calculation, forgot to double 2handed ilevel as offhand
23
+ - Refactored Paser#get_classes()., Parser#get_gear
data/Gemfile CHANGED
@@ -2,10 +2,10 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'nokogiri'
6
- gem 'json'
5
+ gem 'nokogiri', '~> 1.6.5'
7
6
 
8
7
  group :test do
9
- gem 'rake'
8
+ gem 'rake', '~> 10.0'
9
+ gem 'rspec', '~> 3.1'
10
10
  gem 'codeclimate-test-reporter', require: nil
11
11
  end
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
- # XIVLodestone - A simple FFXIV lodestone scraper [![Build Status](https://travis-ci.org/benjiro/XIV-lodestone.svg)](https://travis-ci.org/benjiro/XIV-lodestone) [![Code Climate](https://codeclimate.com/github/benjiro/XIV-lodestone/badges/gpa.svg)](https://codeclimate.com/github/benjiro/XIV-lodestone) [![Test Coverage](https://codeclimate.com/github/benjiro/XIV-lodestone/badges/coverage.svg)](https://codeclimate.com/github/benjiro/XIV-lodestone)
1
+ # XIVLodestone - A simple FFXIV lodestone scraper [![Build Status](https://travis-ci.org/benjiro/XIV-lodestone.svg)](https://travis-ci.org/benjiro/XIV-lodestone) [![Code Climate](https://codeclimate.com/github/benjiro/XIV-lodestone/badges/gpa.svg)](https://codeclimate.com/github/benjiro/XIV-lodestone) [![Test Coverage](https://codeclimate.com/github/benjiro/XIV-lodestone/badges/coverage.svg)](https://codeclimate.com/github/benjiro/XIV-lodestone) [![Dependency Status](https://gemnasium.com/benjiro/XIV-lodestone.svg)](https://gemnasium.com/benjiro/XIV-lodestone)
2
2
 
3
3
  A simple API for scraping information from FFXIV lodestone community website.
4
4
 
5
+ Please note this gem is currently in Alpha stage of development expect bugs, submit a issue for bug or feature requests.
6
+
5
7
  ## Features
6
8
  - Character Search (via ID number or Name and Server)
7
9
  - Character profile
@@ -55,10 +55,11 @@ module XIVLodestone
55
55
  # returns a #Integer
56
56
  def ilevel()
57
57
  ilevel = 0
58
+ ilevel = @list[:weapon].ilevel if Helper.is_2hand_weapon(@list[:weapon].slot)
58
59
  @list.each_value do |value|
59
60
  ilevel += value.ilevel
60
61
  end
61
- (@list.key?(:shield)) ? (ilevel/13).round : (ilevel/12).round
62
+ (ilevel/13).round
62
63
  end
63
64
  # Generates access methods for each item slot
64
65
  def method_missing(method)
@@ -25,6 +25,11 @@ module XIVLodestone
25
25
  def self.open_id(id)
26
26
  Nokogiri::HTML(open_id_url(id))
27
27
  end
28
+ # Checks string if two handed weapon type
29
+ # returns true if two handed weapon type
30
+ def self.is_2hand_weapon(name)
31
+ (name =~ /(Arm|Arms|Grimoire|Primary Tool)/i) ? true : false
32
+ end
28
33
  # Open a URL with the given name and server.
29
34
  # Returns a file stream.
30
35
  def self.open_character_url(name, server)
@@ -20,14 +20,13 @@ module XIVLodestone
20
20
  @page.xpath('//table[@class="class_list"]/tr/td').each_slice(3) do |td|
21
21
  # Not a valid class
22
22
  next if td[0].text.empty?
23
-
24
- name = td[0].text
25
- level = td[1].text.to_i
26
23
  exp = td[2].text.split(/\//)
27
- icon = td[0].at_css('img')['src']
28
24
 
29
- class_list[name.downcase.to_sym] = [name, level, exp[0].to_i,
30
- exp[1].to_i, icon]
25
+ class_list[td[0].text.downcase.to_sym] = [td[0].text,
26
+ td[1].text.to_i,
27
+ exp[0].to_i,
28
+ exp[1].to_i,
29
+ td[0].at_css('img')['src']]
31
30
  end
32
31
  class_list
33
32
  end
@@ -50,31 +49,16 @@ module XIVLodestone
50
49
  # Example { :head => [ "item_name", "item_url" ], ... }
51
50
  # If no gear found returns a empty #Hash
52
51
  def get_gear()
53
- # TODO: Smelly code, rewrite
54
52
  items = Hash.new
55
- ring_count = 1
56
- @page.xpath("(//div[@class='item_detail_box'])[position() < 13]").each_with_index do |item, index|
53
+ @page.xpath("(//div[@class='item_detail_box'])[position() < 13]").each do |item|
57
54
  type = get_item_type(item.at_css('h3.category_name').text)
58
- level = item.xpath('//div[@class="pt3 pb3"]')[index].text.split(/ /).last.to_i
59
- if type.eql? "ring"
60
- items["#{type}#{ring_count}".to_sym] = [item.css('h2').text, level, type, "http://na.finalfantasyxiv.com#{item.css('a')[0]['href']}"]
61
- ring_count += 1
62
- else
63
- items[replace_downcase(type).to_sym] = [item.css('h2').text, level, type, "http://na.finalfantasyxiv.com#{item.css('a')[0]['href']}"]
64
- end
55
+ items[type.to_sym] = [ item.css('h2').text,
56
+ item.at_css('div.pt3.pb3').text.split(/ /).last.to_i,
57
+ item.at_css('h3.category_name').text,
58
+ "http://na.finalfantasyxiv.com#{item.css('a')[0]['href']}" ]
65
59
  end
66
60
  items
67
61
  end
68
- # Returns a string representing what item it is
69
- def get_item_type(item_name)
70
- if item_name =~ /(Arm|Arms|Grimoire|Primary Tool)/i
71
- return "weapon"
72
- elsif item_name =~ /Shield/i
73
- return "shield"
74
- else
75
- return item_name.downcase
76
- end
77
- end
78
62
  # Returns a #Integer of the characters hp
79
63
  # otherwise returns nil
80
64
  def get_hp()
@@ -151,5 +135,24 @@ module XIVLodestone
151
135
  def replace_downcase(string)
152
136
  string.gsub(" ", "_").downcase
153
137
  end
138
+ # Auto-increaments between 1 and 2
139
+ def ring
140
+ @num ||= 0
141
+ @num = 0 if @num >= 2
142
+ @num += 1
143
+ end
144
+ # Returns a string representing what item type it is
145
+ def get_item_type(item_name)
146
+ if item_name =~ /(Arm|Arms|Grimoire|Primary Tool)/i
147
+ return "weapon"
148
+ elsif item_name =~ /Shield/i
149
+ return "shield"
150
+ elsif item_name.eql?("Ring")
151
+ return "ring#{ring}"
152
+ else
153
+ return item_name.downcase
154
+ end
155
+ end
156
+ private :replace_downcase, :ring, :get_item_type
154
157
  end
155
158
  end
@@ -1,4 +1,4 @@
1
1
  # Stores the current version number of the gem
2
2
  module XIVLodestone
3
- VERSION = '0.0.2'
3
+ VERSION = '0.0.3'
4
4
  end
@@ -88,9 +88,6 @@ describe XIVLodestone::Parser do
88
88
  end
89
89
 
90
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
91
  expect(parser.get_classes().count).to eql(20)
95
92
  expect(parser.get_attributes().count).to eql(34)
96
93
  expect(parser.get_gear().count).to eql (12)
@@ -106,6 +103,5 @@ describe XIVLodestone::Parser do
106
103
  expect(parser.get_grand_company()).to eql("Immortal Flames/Second Flame Lieutenant")
107
104
  expect(parser.get_free_company()).to eql(["Nomad Moogles",
108
105
  "http://na.finalfantasyxiv.com/lodestone/freecompany/9233505136016403440/"])
109
- expect(parser.replace_downcase("Hello World")).to eql("hello_world")
110
106
  end
111
107
  end
@@ -17,9 +17,12 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
- spec.required_ruby_version = '~> 2.2'
21
20
 
22
- spec.add_development_dependency "bundler", "~> 1.7"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "rspec", "~> 3.1"
21
+ spec.required_ruby_version = "~> 2.2"
22
+
23
+ spec.add_dependency("nokogiri", "~> 1.6")
24
+
25
+ spec.add_development_dependency("bundler", "~> 1.7")
26
+ spec.add_development_dependency("rspec", "~> 3.1")
27
+ spec.add_development_dependency("rake", "~> 10.0")
25
28
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xiv_lodestone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-04 00:00:00.000000000 Z
11
+ date: 2015-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -25,33 +39,33 @@ dependencies:
25
39
  - !ruby/object:Gem::Version
26
40
  version: '1.7'
27
41
  - !ruby/object:Gem::Dependency
28
- name: rake
42
+ name: rspec
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '10.0'
47
+ version: '3.1'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '10.0'
54
+ version: '3.1'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rspec
56
+ name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '3.1'
61
+ version: '10.0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '3.1'
68
+ version: '10.0'
55
69
  description: A Ruby library for scraping information about a given character from
56
70
  the FFXIV lodestone website. More to come...
57
71
  email:
@@ -63,6 +77,7 @@ files:
63
77
  - ".gitignore"
64
78
  - ".rspec"
65
79
  - ".travis.yml"
80
+ - CHANGELOG.md
66
81
  - Gemfile
67
82
  - LICENSE.txt
68
83
  - README.md