d3skills 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in d3skills.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Varun Murali
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,38 @@
1
+ # D3skills
2
+
3
+ This gem is used to get the skills unlocked at a certain level for a Diablo 3 character. It takes the information of skills and levels unlocked from "http://www.diablowiki.net".
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'd3skills'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install d3skills
18
+
19
+ ## Usage
20
+
21
+ d3skills Barbarian 55
22
+
23
+ d3skills Witch_Doctor 30
24
+
25
+ d3skills Demon_Hunter 44
26
+
27
+ d3skills Wizard 60
28
+
29
+ d3skills Monk 1
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
38
+
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'd3skills'
4
+ require 'rubygems'
5
+ require 'nokogiri'
6
+ require 'open-uri'
7
+
8
+ puts D3skills.get_skills(ARGV[0],ARGV[1])
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/d3skills/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Varun Murali"]
6
+ gem.email = ["varun.murali93@gmail.com"]
7
+ gem.description = "Finds all skills unlocked at a level for diablo"
8
+ gem.summary = "Shows skills unlocked at level for diablo 3 hero"
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "d3skills"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = D3skills::VERSION
17
+ gem.executables << 'd3skills'
18
+ gem.add_dependency 'nokogiri'
19
+ end
@@ -0,0 +1,39 @@
1
+ require "d3skills/version"
2
+ require 'open-uri'
3
+
4
+ module D3skills
5
+ def self.get_skills(hero_type, level)
6
+ name = hero_type #"Barbarian"
7
+ hero_level = level #"55"
8
+ page = Nokogiri::HTML(open("http://www.diablowiki.net/" + name + "_skills"))
9
+
10
+ skills = {}
11
+
12
+
13
+ page.css('table').each do |table|
14
+ unless table.nil?
15
+
16
+ ## finds the tables with 4 columns
17
+ if table.css('tr').css('td').length == 4
18
+
19
+ ## The skill name is usually the title of first link (which is an image) in the row
20
+ name = table.css('tr').css('a')[0]['title'].strip
21
+
22
+ ## The level is found in the text of the third table data in the row
23
+ level = table.css('tr').css('td')[2].text.strip
24
+
25
+ # make a new array if this skill level has been encountered for the first time
26
+ skills[level] = [] if skills[level].nil?
27
+
28
+ skills[level] << name
29
+ end
30
+ end
31
+ end
32
+ skills_unlocked = skills[hero_level]
33
+ if skills_unlocked == nil
34
+ puts "No skill unlocked"
35
+ else
36
+ puts skills_unlocked
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,3 @@
1
+ module D3skills
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: d3skills
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Varun Murali
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nokogiri
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Finds all skills unlocked at a level for diablo
31
+ email:
32
+ - varun.murali93@gmail.com
33
+ executables:
34
+ - d3skills
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - Gemfile
40
+ - LICENSE
41
+ - README.md
42
+ - Rakefile
43
+ - bin/d3skills
44
+ - d3skills.gemspec
45
+ - lib/d3skills.rb
46
+ - lib/d3skills/version.rb
47
+ homepage: ''
48
+ licenses: []
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 1.8.24
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Shows skills unlocked at level for diablo 3 hero
71
+ test_files: []