evestatic 0.0.43

Sign up to get free protection for your applications and to get access to all the features.
data/evestatic.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'evestatic/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "evestatic"
8
+ spec.version = Evestatic::VERSION
9
+ spec.authors = ["Marv Cool"]
10
+ spec.email = ["marv@hostin.is"]
11
+ spec.description = %q{A Ruby gem with CCPs EVE-Online static dump data}
12
+ spec.summary = %q{A Ruby gem with CCPs EVE-Online static dump data
13
+ encapsulated in an easy to use ruby interface.
14
+ Has Regions, Stations and Itemtypes.
15
+ }
16
+ spec.homepage = ""
17
+ spec.license = "MIT and CCPs License for their static dumps"
18
+
19
+ spec.files = `git ls-files`.split($/)
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ end
@@ -0,0 +1,62 @@
1
+ require 'csv'
2
+
3
+ module Evestatic
4
+ class ItemType
5
+
6
+ attr_accessor :type_id, :group_id, :type_name, :mass, :volume
7
+
8
+ @@item_types_by_id = {}
9
+ @@item_types_by_name = {}
10
+
11
+ def self.load!
12
+ ItemType.load_from_file(File.expand_path("../../../data/invTypes.csv", __FILE__))
13
+ end
14
+
15
+ def self.load_from_file(path)
16
+ begin
17
+ CSV.foreach(path, {col_sep: ";", headers: true}) do |row|
18
+ @@item_types_by_id[row[0].to_i] = self.new(row[0].to_i, row[1].to_i, row[2], row[3].to_i, row[4].gsub(",",".").to_f)
19
+ @@item_types_by_name[row[2]] = @@item_types_by_id[row[0].to_i]
20
+ end
21
+ rescue CSV::MalformedCSVError
22
+ #trololol do nothing, we have all data, dont care if the newlines are windows mess or whatever
23
+ end
24
+ end
25
+
26
+
27
+ # INDEXED BY TYPE_ID! Static::ItemType[34].type_name => "Tritanium"
28
+ def self.[](key=nil)
29
+ unless key
30
+ @@item_types_by_id
31
+ else
32
+ @@item_types_by_id[key] || self.new(key, 0, "UKNOWN TYPE (#{key})",0,0.0)
33
+ end
34
+ end
35
+
36
+ def self.by_id(id=nil)
37
+ self.[](id)
38
+ end
39
+
40
+ # INDEXED BY NAME! Static::ItemType["Tritanium"].type_id => 34
41
+ def self.by_name(key=nil)
42
+ unless key
43
+ @@item_types_by_name
44
+ else
45
+ res = @@item_types_by_name[key]
46
+ raise NameError.new "Type not found #{key}" unless res
47
+ res
48
+ end
49
+ end
50
+
51
+ def initialize(type_id, group_id, type_name, mass, volume)
52
+ self.type_id = type_id
53
+ self.group_id = group_id
54
+ self.type_name = type_name
55
+ self.mass = mass
56
+ self.volume = volume
57
+ end
58
+
59
+ load!
60
+ end
61
+
62
+ end
@@ -0,0 +1,53 @@
1
+ require 'csv'
2
+
3
+ module Evestatic
4
+ class MapRegion
5
+
6
+ attr_accessor :region_id, :region_name
7
+
8
+ @@map_regions = {}
9
+
10
+ def self.load!
11
+ MapRegion.load_from_file(File.expand_path("../../../data/mapRegions.csv", __FILE__))
12
+ end
13
+
14
+ def self.load_from_file(path)
15
+ begin
16
+ CSV.foreach(path, {col_sep: ";", headers: true}) do |row|
17
+ @@map_regions[row[0].to_i] = self.new(row[0].to_i, row[1])
18
+ end
19
+ rescue CSV::MalformedCSVError
20
+ #trololol do nothing, we have all data, dont care if the newlines are windows mess or whatever
21
+ end
22
+ end
23
+
24
+ # INDEXED BY REGION_ID! Static::MapRegion[10000002].region_name => "The Forge"
25
+ def self.[](key=nil)
26
+ unless key
27
+ @@map_regions
28
+ else
29
+ @@map_regions[key] || self.new(key,"UKNOWN REGION (#{key})")
30
+ end
31
+ end
32
+
33
+ def initialize(region_id, region_name)
34
+ self.region_id = region_id
35
+ self.region_name = region_name
36
+ end
37
+
38
+ def self.by_id(id=nil)
39
+ @@map_regions[id]
40
+ end
41
+
42
+ def self.by_name(name)
43
+ @@map_regions.values.collect { |v| v if v.region_name == name }.compact[0]
44
+ end
45
+
46
+ def self.find_by_name(name)
47
+ @@map_regions.values.collect { |v| v if v.region_name.include? name }.compact
48
+ end
49
+
50
+ load!
51
+ end
52
+
53
+ end
@@ -0,0 +1,53 @@
1
+ require 'csv'
2
+
3
+ module Evestatic
4
+ class Station
5
+
6
+ attr_accessor :station_id, :station_name
7
+
8
+ @@stations = {}
9
+
10
+ def self.load!
11
+ Station.load_from_file(File.expand_path("../../../data/staStations.csv", __FILE__))
12
+ end
13
+
14
+ def self.load_from_file(path)
15
+ begin
16
+ CSV.foreach(path, {col_sep: ";", headers: true}) do |row|
17
+ @@stations[row[0].to_i] = self.new(row[0].to_i, row[11])
18
+ end
19
+ rescue CSV::MalformedCSVError
20
+ #trololol do nothing, we have all data, dont care if the newlines are windows mess or whatever
21
+ end
22
+ end
23
+
24
+
25
+ def self.[](key=nil)
26
+ unless key
27
+ @@stations
28
+ else
29
+ @@stations[key]
30
+ end
31
+ end
32
+
33
+ def self.by_id(id=nil)
34
+ Station[id]
35
+ end
36
+
37
+ def self.by_name(name)
38
+ @@stations.values.collect { |v| v if v.station_name.include? name }.compact[0]
39
+ end
40
+
41
+ def self.find_by_name(name)
42
+ @@stations.values.collect { |v| v if v.station_name.include? name }.compact
43
+ end
44
+
45
+ def initialize(station_id, station_name)
46
+ self.station_id = station_id
47
+ self.station_name = station_name
48
+ end
49
+
50
+ load!
51
+ end
52
+
53
+ end
@@ -0,0 +1,4 @@
1
+ module Evestatic
2
+ VERSION = "0.0.43"
3
+ EVEVERSION = "Odyssey1.1"
4
+ end
data/lib/evestatic.rb ADDED
@@ -0,0 +1,8 @@
1
+ require_relative "evestatic/version"
2
+ require_relative "evestatic/mapregions"
3
+ require_relative "evestatic/stations"
4
+ require_relative "evestatic/itemtypes"
5
+
6
+ module Evestatic
7
+
8
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: evestatic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.43
5
+ platform: ruby
6
+ authors:
7
+ - Marv Cool
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-29 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A Ruby gem with CCPs EVE-Online static dump data
42
+ email:
43
+ - marv@hostin.is
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - data/invTypes.csv
54
+ - data/mapRegions.csv
55
+ - data/staStations.csv
56
+ - evestatic.gemspec
57
+ - lib/evestatic.rb
58
+ - lib/evestatic/itemtypes.rb
59
+ - lib/evestatic/mapregions.rb
60
+ - lib/evestatic/stations.rb
61
+ - lib/evestatic/version.rb
62
+ homepage: ''
63
+ licenses:
64
+ - MIT and CCPs License for their static dumps
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.0.0
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: A Ruby gem with CCPs EVE-Online static dump data encapsulated in an easy
86
+ to use ruby interface. Has Regions, Stations and Itemtypes.
87
+ test_files: []