everoute 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +14 -0
- data/Gemfile.lock +50 -0
- data/LICENSE.txt +20 -0
- data/README +0 -0
- data/README.rdoc +19 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/everoute.gemspec +71 -0
- data/lib/everoute.rb +35 -0
- data/lib/evesystem.rb +14 -0
- data/spec/everoute_spec.rb +39 -0
- data/spec/evesystem_spec.rb +24 -0
- data/spec/spec_helper.rb +3 -0
- metadata +141 -0
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Add dependencies to develop your gem here.
|
4
|
+
# Include everything needed to run rake, tests, features, etc.
|
5
|
+
group :development do
|
6
|
+
gem "shoulda", ">= 0"
|
7
|
+
gem "bundler", "~> 1.0.0"
|
8
|
+
gem "jeweler", "~> 1.6.4"
|
9
|
+
gem "rcov", ">= 0"
|
10
|
+
gem 'rspec'
|
11
|
+
end
|
12
|
+
|
13
|
+
gem 'nokogiri'
|
14
|
+
gem 'mechanize'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.3)
|
5
|
+
domain_name (0.5.1)
|
6
|
+
unf (~> 0.0.3)
|
7
|
+
git (1.2.5)
|
8
|
+
jeweler (1.6.4)
|
9
|
+
bundler (~> 1.0)
|
10
|
+
git (>= 1.2.5)
|
11
|
+
rake
|
12
|
+
mechanize (2.1)
|
13
|
+
domain_name (~> 0.5, >= 0.5.1)
|
14
|
+
net-http-digest_auth (~> 1.1, >= 1.1.1)
|
15
|
+
net-http-persistent (~> 2.3, >= 2.3.2)
|
16
|
+
nokogiri (~> 1.4)
|
17
|
+
ntlm-http (~> 0.1, >= 0.1.1)
|
18
|
+
webrobots (~> 0.0, >= 0.0.9)
|
19
|
+
net-http-digest_auth (1.2)
|
20
|
+
net-http-persistent (2.3.3)
|
21
|
+
nokogiri (1.5.0)
|
22
|
+
ntlm-http (0.1.1)
|
23
|
+
rake (0.9.2.2)
|
24
|
+
rcov (0.9.11)
|
25
|
+
rspec (2.7.0)
|
26
|
+
rspec-core (~> 2.7.0)
|
27
|
+
rspec-expectations (~> 2.7.0)
|
28
|
+
rspec-mocks (~> 2.7.0)
|
29
|
+
rspec-core (2.7.1)
|
30
|
+
rspec-expectations (2.7.0)
|
31
|
+
diff-lcs (~> 1.1.2)
|
32
|
+
rspec-mocks (2.7.0)
|
33
|
+
shoulda (2.11.3)
|
34
|
+
unf (0.0.4)
|
35
|
+
unf_ext
|
36
|
+
unf_ext (0.0.4)
|
37
|
+
webrobots (0.0.12)
|
38
|
+
nokogiri (>= 1.4.4)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
bundler (~> 1.0.0)
|
45
|
+
jeweler (~> 1.6.4)
|
46
|
+
mechanize
|
47
|
+
nokogiri
|
48
|
+
rcov
|
49
|
+
rspec
|
50
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Daniel Trierweiler
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
File without changes
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= everoute
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to everoute
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Daniel Trierweiler. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "everoute"
|
18
|
+
gem.homepage = "http://github.com/DTrierweiler/everoute"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = "A small gem to find routes in Eve Online"
|
21
|
+
gem.description = "Parses the evemaps website and makes these information available in Ruby"
|
22
|
+
gem.email = "trierweiler@dievision.de"
|
23
|
+
gem.authors = ["Daniel Trierweiler"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "everoute #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/everoute.gemspec
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "everoute"
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Daniel Trierweiler"]
|
12
|
+
s.date = "2011-12-28"
|
13
|
+
s.description = "Parses the evemaps website and makes these information available in Ruby"
|
14
|
+
s.email = "trierweiler@dievision.de"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"everoute.gemspec",
|
29
|
+
"lib/everoute.rb",
|
30
|
+
"lib/evesystem.rb",
|
31
|
+
"spec/everoute_spec.rb",
|
32
|
+
"spec/evesystem_spec.rb",
|
33
|
+
"spec/spec_helper.rb"
|
34
|
+
]
|
35
|
+
s.homepage = "http://github.com/DTrierweiler/everoute"
|
36
|
+
s.licenses = ["MIT"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = "1.8.10"
|
39
|
+
s.summary = "A small gem to find routes in Eve Online"
|
40
|
+
|
41
|
+
if s.respond_to? :specification_version then
|
42
|
+
s.specification_version = 3
|
43
|
+
|
44
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
46
|
+
s.add_runtime_dependency(%q<mechanize>, [">= 0"])
|
47
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
48
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
49
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
50
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
51
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
54
|
+
s.add_dependency(%q<mechanize>, [">= 0"])
|
55
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
56
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
57
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
58
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
59
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
60
|
+
end
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<nokogiri>, [">= 0"])
|
63
|
+
s.add_dependency(%q<mechanize>, [">= 0"])
|
64
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
65
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
66
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
67
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
68
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
data/lib/everoute.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'mechanize'
|
4
|
+
|
5
|
+
class Everoute
|
6
|
+
|
7
|
+
BASE_URL = 'http://evemaps.dotlan.net/route/'
|
8
|
+
|
9
|
+
attr_accessor :route
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@agent = Mechanize.new
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def travel(system_arr)
|
17
|
+
sys_string = system_arr[0]
|
18
|
+
system_arr.each_with_index do |sys, i|
|
19
|
+
next if i == 0
|
20
|
+
sys_string << ":" + sys
|
21
|
+
end
|
22
|
+
page = @agent.get BASE_URL+sys_string
|
23
|
+
arr = page.parser.xpath('//html/body/div/div/div[2]/div[2]/div/div/table/tr')
|
24
|
+
@route = []
|
25
|
+
arr.each_with_index do |a, i|
|
26
|
+
next if i == 0
|
27
|
+
scan = [i]
|
28
|
+
scan.concat a.to_s.scan(/<tr.*?>\n<td.*?<\/td>\n.*?<td>(.*?)<\/td>\n.*?<a.*?<a.*?>(.*?)<\/a>.*?<span.*?>(.*?)<\/span>.*?<i>(.*?)<\/i>.*?<td.*?>/m)[0]
|
29
|
+
scan[1] = scan[1].scan(/.*?<a.*?<a.*?>(.*?)<\/a>.*?/m)[0][0] if scan[1].scan(/.*?<a.*?<a.*?>(.*?)<\/a>.*?/m)[0]
|
30
|
+
route << Evesystem.new(scan)
|
31
|
+
end
|
32
|
+
route
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/lib/evesystem.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Everoute do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@routeplaner = Everoute.new
|
7
|
+
@sys_arr = ['Jita', 'Dodixie']
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#new" do
|
11
|
+
it "should return a Everoute object" do
|
12
|
+
@routeplaner.should be_an_instance_of Everoute
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#travel" do
|
17
|
+
it "should return an array" do
|
18
|
+
@routeplaner.travel(@sys_arr).should be_an_instance_of Array
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return an array containing evesystem objects" do
|
22
|
+
routes = @routeplaner.travel(@sys_arr)
|
23
|
+
routes.each do |jump|
|
24
|
+
jump.should be_an_instance_of Evesystem
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should contain 13 jumps" do
|
29
|
+
@routeplaner.travel(@sys_arr).size == 13
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should jump over Tama as 5th jump" do
|
33
|
+
routes = @routeplaner.travel(@sys_arr)
|
34
|
+
routes[4].solarsystem == "Tama"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Evesystem do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@attributes = [1, "The Forge", "Jita", "0.9", "Caldari State"]
|
7
|
+
@system = Evesystem.new @attributes
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#new" do
|
11
|
+
it "should return a Evesystem object" do
|
12
|
+
@system.should be_an_instance_of Evesystem
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have valid attributes" do
|
17
|
+
@system.jump == 1
|
18
|
+
@system.region == "The Forge"
|
19
|
+
@system.solarsystem == "Jita"
|
20
|
+
@system.sec == "0.9"
|
21
|
+
@system.holder == "Caldari State"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: everoute
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Daniel Trierweiler
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-28 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: &72803020 !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: *72803020
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: mechanize
|
27
|
+
requirement: &72802700 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *72802700
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: shoulda
|
38
|
+
requirement: &72802400 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *72802400
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: &72802070 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *72802070
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: jeweler
|
60
|
+
requirement: &72801680 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.6.4
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *72801680
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rcov
|
71
|
+
requirement: &72801330 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *72801330
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: rspec
|
82
|
+
requirement: &72801020 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *72801020
|
91
|
+
description: Parses the evemaps website and makes these information available in Ruby
|
92
|
+
email: trierweiler@dievision.de
|
93
|
+
executables: []
|
94
|
+
extensions: []
|
95
|
+
extra_rdoc_files:
|
96
|
+
- LICENSE.txt
|
97
|
+
- README
|
98
|
+
- README.rdoc
|
99
|
+
files:
|
100
|
+
- Gemfile
|
101
|
+
- Gemfile.lock
|
102
|
+
- LICENSE.txt
|
103
|
+
- README
|
104
|
+
- README.rdoc
|
105
|
+
- Rakefile
|
106
|
+
- VERSION
|
107
|
+
- everoute.gemspec
|
108
|
+
- lib/everoute.rb
|
109
|
+
- lib/evesystem.rb
|
110
|
+
- spec/everoute_spec.rb
|
111
|
+
- spec/evesystem_spec.rb
|
112
|
+
- spec/spec_helper.rb
|
113
|
+
homepage: http://github.com/DTrierweiler/everoute
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
segments:
|
127
|
+
- 0
|
128
|
+
hash: 152743891
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ! '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
requirements: []
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 1.8.10
|
138
|
+
signing_key:
|
139
|
+
specification_version: 3
|
140
|
+
summary: A small gem to find routes in Eve Online
|
141
|
+
test_files: []
|