mram-evedata 0.1.inferno11.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +40 -0
- data/Gemfile +14 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +40 -0
- data/app/assets/images/mram-evedata/.gitkeep +0 -0
- data/app/assets/javascripts/mram-evedata/application.js +15 -0
- data/app/assets/stylesheets/mram-evedata/application.css +13 -0
- data/app/controllers/mram-evedata/application_controller.rb +4 -0
- data/app/helpers/mram-evedata/application_helper.rb +4 -0
- data/app/models/eve_data/activity.rb +15 -0
- data/app/models/eve_data/attribute_type.rb +9 -0
- data/app/models/eve_data/blueprint_type.rb +106 -0
- data/app/models/eve_data/category.rb +13 -0
- data/app/models/eve_data/eve_data_dump.rb +17 -0
- data/app/models/eve_data/graphic.rb +8 -0
- data/app/models/eve_data/group.rb +11 -0
- data/app/models/eve_data/icon.rb +6 -0
- data/app/models/eve_data/market_group.rb +22 -0
- data/app/models/eve_data/meta_group.rb +6 -0
- data/app/models/eve_data/meta_type.rb +10 -0
- data/app/models/eve_data/race.rb +8 -0
- data/app/models/eve_data/region.rb +10 -0
- data/app/models/eve_data/solar_system.rb +11 -0
- data/app/models/eve_data/type.rb +76 -0
- data/app/models/eve_data/type_attribute.rb +9 -0
- data/app/models/eve_data/type_material.rb +9 -0
- data/app/models/eve_data/type_reaction.rb +9 -0
- data/app/models/eve_data/type_requirement.rb +15 -0
- data/app/views/layouts/mram-evedata/application.html.erb +14 -0
- data/config/routes.rb +2 -0
- data/data/mysql55-inferno11-extended.sql.bz2 +0 -0
- data/lib/generators/eve_data/sample_db_config/sample_db_config_generator.rb +48 -0
- data/lib/mram-evedata.rb +2 -0
- data/lib/mram-evedata/engine.rb +5 -0
- data/lib/mram-evedata/version.rb +4 -0
- data/lib/tasks/mram-evedata_tasks.rake +36 -0
- data/mram-evedata.gemspec +25 -0
- data/script/rails +8 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/mram-evedata_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +113 -0
data/.gitignore
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile ~/.gitignore_global
|
6
|
+
|
7
|
+
# Ignore bundler stuff
|
8
|
+
/.bundle
|
9
|
+
*.gem
|
10
|
+
*.rbc
|
11
|
+
.bundle
|
12
|
+
doc/
|
13
|
+
pkg
|
14
|
+
lib/bundler/man
|
15
|
+
|
16
|
+
# Ignore the default SQLite database.
|
17
|
+
/db/*.sqlite3
|
18
|
+
|
19
|
+
# schema gets recreated anyway
|
20
|
+
db/schema.rb
|
21
|
+
|
22
|
+
# no apple crap
|
23
|
+
.DS_Store
|
24
|
+
|
25
|
+
# no logs and temp files
|
26
|
+
log/*.log
|
27
|
+
tmp/**/*
|
28
|
+
|
29
|
+
# no assets (can be recreated anyway)
|
30
|
+
public/assets
|
31
|
+
|
32
|
+
# other stuff
|
33
|
+
Gemfile.lock
|
34
|
+
.config
|
35
|
+
public/cache/**/*
|
36
|
+
.*.swp
|
37
|
+
|
38
|
+
# no database config in git
|
39
|
+
database.yml
|
40
|
+
config/database.yml
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in mram-evedata.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# Declare any dependencies that are still in development here instead of in
|
9
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
10
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
11
|
+
# your gem to rubygems.org.
|
12
|
+
|
13
|
+
# To use debugger
|
14
|
+
# gem 'debugger'
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 YOURNAME
|
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.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'EveData'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
Bundler::GemHelper.install_tasks
|
29
|
+
|
30
|
+
require 'rake/testtask'
|
31
|
+
|
32
|
+
Rake::TestTask.new(:test) do |t|
|
33
|
+
t.libs << 'lib'
|
34
|
+
t.libs << 'test'
|
35
|
+
t.pattern = 'test/**/*_test.rb'
|
36
|
+
t.verbose = false
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
task :default => :test
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module EveData
|
2
|
+
class Activity < EveData::EveDataDump
|
3
|
+
self.table_name = 'ramActivities'
|
4
|
+
self.primary_key = :activityID
|
5
|
+
|
6
|
+
has_many :materials, :class_name => 'EddTypeRequirements', :foreign_key => :activityID
|
7
|
+
|
8
|
+
module EveData
|
9
|
+
class << self
|
10
|
+
def [](act)
|
11
|
+
self.find_by_activityName(act)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module EveData
|
2
|
+
class AttributeType < EveData::EveDataDump
|
3
|
+
self.table_name = 'dgmAttributeTypes'
|
4
|
+
self.primary_keys = :typeID, :attributeID
|
5
|
+
|
6
|
+
has_many :eve_type_attrs, :class_name => 'EddAttributeType', :foreign_key => :attributeID, :primary_key => :attributeID
|
7
|
+
has_many :types, :class_name => 'EddType', :foreign_key => :typeID, :primary_key => :typeID
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module EveData
|
2
|
+
class BlueprintType < EveData::EveDataDump
|
3
|
+
self.table_name = 'invBlueprintTypes'
|
4
|
+
self.primary_key = :blueprintTypeID
|
5
|
+
|
6
|
+
belongs_to :blueprint, :class_name => 'EddType', :foreign_key => :blueprintTypeID, :primary_key => :typeID
|
7
|
+
belongs_to :parent_blueprint, :class_name => 'EddType', :foreign_key => :parentBlueprintTypeID, :primary_key => :typeID
|
8
|
+
belongs_to :product, :class_name => 'EddType', :foreign_key => :productTypeID, :primary_key => :typeID
|
9
|
+
|
10
|
+
has_many :type_requirements, :class_name => 'EddTypeRequirement', :foreign_key => :typeID
|
11
|
+
# has_many :req_types, :through => :type_requirements, :source => :required_type
|
12
|
+
|
13
|
+
def raw_materials(uopts = {})
|
14
|
+
defopts = { :resolve => false }
|
15
|
+
opts = defopts.merge uopts
|
16
|
+
bill = MaterialBill.new(self)
|
17
|
+
|
18
|
+
self.product.materials.each do |x|
|
19
|
+
bill << MaterialBillEntry.new(:type => x.material_type, :quantity => x.quantity)
|
20
|
+
end
|
21
|
+
|
22
|
+
if opts[:resolve] then
|
23
|
+
newbill = MaterialBill.new(self)
|
24
|
+
bill.entries.each_index do |idx|
|
25
|
+
# if bill.entries[idx].type.made_from_blueprint then
|
26
|
+
if bill.entries[idx].type.made_from_blueprint and bill.entries[idx].type.id != 11483 then
|
27
|
+
itembill = bill.entries[idx].type.made_from_blueprint.all_materials(opts.merge({:me => nil}))
|
28
|
+
itembill.multiply!(bill.entries[idx].quantity)
|
29
|
+
newbill.add!(itembill)
|
30
|
+
else
|
31
|
+
newbill << bill.entries[idx]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
puts "RAW_before #{bill}"
|
35
|
+
puts "RAW_after #{newbill}"
|
36
|
+
bill = newbill.stack
|
37
|
+
end
|
38
|
+
|
39
|
+
bill
|
40
|
+
end
|
41
|
+
|
42
|
+
def extra_materials(uopts = {})
|
43
|
+
defopts = { :resolve => false }
|
44
|
+
opts = defopts.merge uopts
|
45
|
+
bill = MaterialBill.new(self)
|
46
|
+
|
47
|
+
bill.entries = self.type_requirements.for_manuf.joins(:required_type => :group).where('invGroups.categoryID != 16').collect do |x|
|
48
|
+
# { :type => x.required_type, :quantity => x.quantity, :damage_per_job => x.damagePerJob, :recycle => x.recycle }
|
49
|
+
MaterialBillEntry.new(:type => x.required_type, :quantity => x.quantity, :damage_per_job => x.damagePerJob, :recycle => x.recycle)
|
50
|
+
end
|
51
|
+
|
52
|
+
if opts[:resolve] then
|
53
|
+
newbill = MaterialBill.new(self)
|
54
|
+
bill.entries.each_index do |idx|
|
55
|
+
# if bill.entries[idx].type.made_from_blueprint then
|
56
|
+
if bill.entries[idx].type.made_from_blueprint and bill.entries[idx].type.id != 11483 then
|
57
|
+
itembill = bill.entries[idx].type.made_from_blueprint.all_materials(opts.merge({:me => nil}))
|
58
|
+
itembill.multiply!(bill.entries[idx].quantity * bill.entries[idx].damage_per_job)
|
59
|
+
newbill.add!(itembill)
|
60
|
+
else
|
61
|
+
newbill << bill.entries[idx]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
puts "XTR_before #{bill}"
|
65
|
+
puts "XTR_after #{newbill}"
|
66
|
+
bill = newbill.stack
|
67
|
+
end
|
68
|
+
|
69
|
+
bill
|
70
|
+
end
|
71
|
+
|
72
|
+
def all_materials(uopts = {})
|
73
|
+
defopts = { :resolve => false, :me => nil, :stack => true }
|
74
|
+
opts = defopts.merge uopts
|
75
|
+
|
76
|
+
bill = nil
|
77
|
+
raw_bill = self.raw_materials(opts)
|
78
|
+
|
79
|
+
case self.techLevel
|
80
|
+
when 0,1
|
81
|
+
bill = raw_bill
|
82
|
+
when 2
|
83
|
+
if self.product.meta_type then
|
84
|
+
t1_raw_bill = self.product.meta_type.parent_type.made_from_blueprint.raw_materials
|
85
|
+
bill = raw_bill.subtract(t1_raw_bill)
|
86
|
+
else
|
87
|
+
bill = raw_bill
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
if opts[:me] != nil then
|
92
|
+
if opts[:me] >= 0 then
|
93
|
+
bill.multiply!(1 + self.wasteFactor/100.0 * (1.0 / (opts[:me] + 1.0)) )
|
94
|
+
else
|
95
|
+
bill.multiply!(1 + self.wasteFactor/100.0 * (1.0 - opts[:me]) )
|
96
|
+
end
|
97
|
+
end
|
98
|
+
totalbill = bill.add(self.extra_materials(opts))
|
99
|
+
opts[:stack] ? totalbill.stack : totalbill
|
100
|
+
end
|
101
|
+
|
102
|
+
def req_skills
|
103
|
+
self.type_requirements.joins(:required_type => :group).where(:invGroups => {:categoryID => 16})
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module EveData
|
2
|
+
class Category < EveData::EveDataDump
|
3
|
+
self.table_name = 'invCategories'
|
4
|
+
self.primary_key = :categoryID
|
5
|
+
|
6
|
+
has_many :edd_groups, :foreign_key => :categoryID
|
7
|
+
has_many :edd_types, :through => :edd_groups
|
8
|
+
|
9
|
+
def ec_update(opts = {})
|
10
|
+
EcPriceData.update_multiple(self.edd_types, opts)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module EveData
|
2
|
+
class EveDataDump < ActiveRecord::Base
|
3
|
+
self.abstract_class = true
|
4
|
+
|
5
|
+
if ActiveRecord::Base.configurations.has_key?('eve_data_dump') then
|
6
|
+
establish_connection(:eve_data_dump)
|
7
|
+
else
|
8
|
+
raise IOError, "missing 'eve_data_dump' block in config/database.yml"
|
9
|
+
end
|
10
|
+
|
11
|
+
unless connection.table_exists?('invTypes') then
|
12
|
+
raise IOError, "unable to find EDD DB table 'InvTypes'. did you run 'rake eve_data:importdb' yet?"
|
13
|
+
end
|
14
|
+
|
15
|
+
default_timezone = :utc
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module EveData
|
2
|
+
class Group < EveData::EveDataDump
|
3
|
+
self.table_name = 'invGroups'
|
4
|
+
self.primary_key = :groupID
|
5
|
+
|
6
|
+
belongs_to :category, :class_name => 'EddCategory', :foreign_key => :categoryID, :primary_key => :categoryID
|
7
|
+
belongs_to :icon, :class_name => 'EddIcon', :foreign_key => :iconID, :primary_key => :iconID
|
8
|
+
|
9
|
+
has_many :edd_types, :foreign_key => :groupID
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module EveData
|
2
|
+
class MarketGroup < EveData::EveDataDump
|
3
|
+
self.table_name = 'invMarketGroups'
|
4
|
+
self.primary_key = :marketGroupID
|
5
|
+
|
6
|
+
has_ancestry :cache_depth => true
|
7
|
+
has_many :edd_types, :foreign_key => :marketGroupID
|
8
|
+
|
9
|
+
def self.build_ancestry_from_parent_ids! parent_id = nil, ancestry = nil
|
10
|
+
self.base_class.all(:conditions => {:parentGroupID => parent_id}).each do |node|
|
11
|
+
node.without_ancestry_callbacks do
|
12
|
+
node.update_attribute ancestry_column, ancestry
|
13
|
+
end
|
14
|
+
build_ancestry_from_parent_ids! node.id, if ancestry.nil? then "#{node.id}" else "#{ancestry}/#{node.id}" end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def ec_update(opts = {})
|
19
|
+
EcPriceData.update_multiple(self.edd_types, opts)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module EveData
|
2
|
+
class MetaType < EveData::EveDataDump
|
3
|
+
self.table_name = 'invMetaTypes'
|
4
|
+
self.primary_key = :typeID
|
5
|
+
|
6
|
+
belongs_to :edd_type, :foreign_key => :typeID
|
7
|
+
belongs_to :parent_type, :class_name => 'EddType', :foreign_key => :parentTypeID
|
8
|
+
belongs_to :meta_group, :class_name => 'EddMetaGroup', :foreign_key => :metaGroupID
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module EveData
|
2
|
+
class Region < EveData::EveDataDump
|
3
|
+
self.table_name = 'mapRegions'
|
4
|
+
self.primary_key = :regionID
|
5
|
+
|
6
|
+
belongs_to :faction, :class_name => 'EddFaction', :foreign_key => :factionID, :primary_key => :factionID
|
7
|
+
|
8
|
+
has_many :solar_systems
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module EveData
|
2
|
+
class SolarSystem < EveData::EveDataDump
|
3
|
+
self.table_name = 'mapSolarSystems'
|
4
|
+
self.primary_key = :solarSystemID
|
5
|
+
|
6
|
+
belongs_to :region, :class_name => 'EddRegion', :foreign_key => :regionID, :primary_key => :regionID
|
7
|
+
belongs_to :constellation, :class_name => 'EddConstellation', :foreign_key => :constellationID, :primary_key => :constellationID
|
8
|
+
belongs_to :faction, :class_name => 'EddFaction', :foreign_key => :factionID, :primary_key => :factionID
|
9
|
+
belongs_to :sun_type, :class_name => 'EddType', :foreign_key => :sunTypeID, :primary_key => :typeID
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module EveData
|
2
|
+
class Type < EveData::EveDataDump
|
3
|
+
self.table_name = 'invTypes'
|
4
|
+
|
5
|
+
belongs_to :group, :class_name => 'EddGroup', :foreign_key => :groupID, :primary_key => :groupID
|
6
|
+
belongs_to :graphic, :class_name => 'EddGraphic', :foreign_key => :graphicID, :primary_key => :graphicID
|
7
|
+
belongs_to :race, :class_name => 'EddRace', :foreign_key => :raceID, :primary_key => :raceID
|
8
|
+
belongs_to :category, :class_name => 'EddCategory', :foreign_key => :categoryID, :primary_key => :categoryID
|
9
|
+
belongs_to :market_group, :class_name => 'EddMarketGroup', :foreign_key => :marketGroupID, :primary_key => :marketGroupID
|
10
|
+
belongs_to :icon, :class_name => 'EddIcon', :foreign_key => :iconID, :primary_key => :iconID
|
11
|
+
|
12
|
+
has_one :made_from_blueprint, :class_name => 'EddBlueprintType', :foreign_key => :productTypeID
|
13
|
+
has_one :meta_type, :class_name => 'EddMetaType', :foreign_key => :typeID
|
14
|
+
|
15
|
+
has_many :meta_parent_for, :class_name => 'EddMetaType', :foreign_key => :parentTypeID
|
16
|
+
has_many :materials, :class_name => 'EddTypeMaterial', :foreign_key => :typeID
|
17
|
+
has_many :type_requirements, :class_name => 'EddTypeRequirement', :foreign_key => :typeID
|
18
|
+
has_many :ec_prices, :class_name => 'EcPriceData', :foreign_key => :typeID
|
19
|
+
|
20
|
+
has_many :eve_type_attrs, :class_name => 'EddTypeAttribute', :foreign_key => :typeID
|
21
|
+
has_many :eve_attrs, :class_name => 'EddAttributeType', :through => :eve_type_attrs
|
22
|
+
|
23
|
+
has_many :reaction_components, :class_name => 'EddTypeReaction', :foreign_key => :reactionTypeID
|
24
|
+
|
25
|
+
def ec_update(opts = {})
|
26
|
+
EcPriceData.update_single(self, opts)
|
27
|
+
end
|
28
|
+
|
29
|
+
def ec_price(uopts = {})
|
30
|
+
defopts = { :system_id => 30000142, :mode => :sell, :type => :min }
|
31
|
+
opts = defopts.merge uopts
|
32
|
+
|
33
|
+
ecp = self.ec_prices.freshest_nonstale
|
34
|
+
return false unless ecp and ecp.length > 0
|
35
|
+
BigDecimal.new(ecp.first.send("#{opts[:mode]}_#{opts[:type]}").to_s).round(2)
|
36
|
+
end
|
37
|
+
|
38
|
+
def build_price(uopts = {})
|
39
|
+
return false unless self.made_from_blueprint
|
40
|
+
mybp = self.made_from_blueprint
|
41
|
+
|
42
|
+
puts "debug: techlevel = #{mybp.techLevel}"
|
43
|
+
case mybp.techLevel
|
44
|
+
when 1
|
45
|
+
mybp.all_materials(:resolve => true).total_price / self.portionSize
|
46
|
+
when 2
|
47
|
+
t1_parent = self.meta_type.parent_type
|
48
|
+
t1_cost = t1_parent.made_from_blueprint.all_materials.(:resolve => true).total_price / t1_parent.portionSize
|
49
|
+
#puts mybp.all_materials(:resolve => true)
|
50
|
+
puts mybp.all_materials(:resolve => true, :me => -4)
|
51
|
+
# t2_cost = mybp.all_materials.total_price / self.portionSize
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def reaction
|
57
|
+
comps = self.reaction_components
|
58
|
+
return nil unless comps.length > 0
|
59
|
+
|
60
|
+
bill_in = MaterialBill.new(self)
|
61
|
+
bill_out = MaterialBill.new(self)
|
62
|
+
comps.each do |x|
|
63
|
+
moon_mining_attr = x.component_type.eve_type_attrs.find_by_attributeID(726)
|
64
|
+
moon_mining_amount = moon_mining_attr ? (moon_mining_attr.valueInt ? moon_mining_attr.valueInt : moon_mining_attr.valueFloat) : 1
|
65
|
+
real_quant = x.quantity * moon_mining_amount
|
66
|
+
if x.input then
|
67
|
+
bill_in << MaterialBillEntry.new(:type => x.component_type, :quantity => real_quant)
|
68
|
+
else
|
69
|
+
bill_out << MaterialBillEntry.new(:type => x.component_type, :quantity => real_quant)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
puts bill_in
|
73
|
+
puts bill_out
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module EveData
|
2
|
+
class TypeAttribute < EveData::EveDataDump
|
3
|
+
self.table_name = 'dgmTypeAttributes'
|
4
|
+
self.primary_keys = :typeID, :attributeID
|
5
|
+
|
6
|
+
belongs_to :type, :class_name => 'EddType', :foreign_key => :typeID, :primary_key => :typeID
|
7
|
+
belongs_to :eve_attr, :class_name => 'EddAttributeType', :foreign_key => :attributeID, :primary_key => :attributeID
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module EveData
|
2
|
+
class TypeMaterial < EveData::EveDataDump
|
3
|
+
self.table_name = 'invTypeMaterials'
|
4
|
+
self.primary_keys = :typeID, :materialTypeID
|
5
|
+
|
6
|
+
belongs_to :type, :class_name => 'EddType', :foreign_key => :typeID, :primary_key => :typeID
|
7
|
+
belongs_to :material_type, :class_name => 'EddType', :foreign_key => :materialTypeID, :primary_key => :typeID
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module EveData
|
2
|
+
class TypeReaction < EveData::EveDataDump
|
3
|
+
self.table_name = 'invTypeReactions'
|
4
|
+
self.primary_keys = :reactionTypeID, :typeID, :input
|
5
|
+
|
6
|
+
belongs_to :type, :class_name => 'EddType', :foreign_key => :reactionTypeID, :primary_key => :typeID
|
7
|
+
belongs_to :component_type, :class_name => 'EddType', :foreign_key => :typeID, :primary_key => :typeID
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module EveData
|
2
|
+
class TypeRequirement < EveData::EveDataDump
|
3
|
+
self.table_name = 'ramTypeRequirements'
|
4
|
+
self.primary_key = :typeID, :activityID, :requiredTypeID
|
5
|
+
|
6
|
+
belongs_to :type, :class_name => 'EddType', :foreign_key => :typeID, :primary_key => :typeID
|
7
|
+
belongs_to :required_type, :class_name => 'EddType', :foreign_key => :requiredTypeID, :primary_key => :typeID
|
8
|
+
belongs_to :activity, :class_name => 'EddActivity', :foreign_key => :activityID, :primary_key => :ActivityID
|
9
|
+
|
10
|
+
belongs_to :bptype, :class_name => 'EddBlueprintType', :foreign_key => :typeID, :primary_key => :blueprintTypeID
|
11
|
+
|
12
|
+
scope :for_manuf, where(:activityID => EddActivity[:Manufacturing].id)
|
13
|
+
scope :for_inv, where(:activityID => EddActivity[:Invention].id)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>EveData</title>
|
5
|
+
<%= stylesheet_link_tag "mram-evedata/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "mram-evedata/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
Binary file
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require "mram-evedata/version"
|
3
|
+
|
4
|
+
module EveData
|
5
|
+
class SampleDbConfigGenerator < Rails::Generators::Base
|
6
|
+
|
7
|
+
source_root File.expand_path("../templates", __FILE__)
|
8
|
+
desc "generate sample evedata block in config/database.yml"
|
9
|
+
|
10
|
+
def create_sample_db_config
|
11
|
+
ver = {}
|
12
|
+
dbname = "everails_" +
|
13
|
+
if ver = EveData::VERSION.match(/^(?<major>\d+)\.(?<minor>\d+)\.(?<eve_name>[a-zA-Z]+)(?<eve_ver>\d+)\.(?<patch>\d+)$/) then
|
14
|
+
"#{ver[:eve_name][0..2]}#{ver[:eve_ver]}"
|
15
|
+
else
|
16
|
+
"datadump"
|
17
|
+
end
|
18
|
+
|
19
|
+
db_cfg_path = Rails.root.join('config', 'database.yml')
|
20
|
+
append_to_file(db_cfg_path) do
|
21
|
+
"
|
22
|
+
eve_data_dump:
|
23
|
+
adapter: mysql2
|
24
|
+
encoding: utf8
|
25
|
+
reconnect: false
|
26
|
+
database: #{dbname}
|
27
|
+
username: everails
|
28
|
+
password: mypassword
|
29
|
+
pool: 5
|
30
|
+
socket: /var/run/mysqld/mysqld.sock
|
31
|
+
"
|
32
|
+
end
|
33
|
+
puts <<-EOF
|
34
|
+
**************************************************************************
|
35
|
+
you will still need to manually create the database that you specified
|
36
|
+
(default: #{dbname}) in order for the next step to work!
|
37
|
+
**************************************************************************
|
38
|
+
|
39
|
+
in mysql, you can do that like this:
|
40
|
+
mysql> CREATE DATABASE #{dbname};
|
41
|
+
|
42
|
+
after making sure that #{dbname} exists, please run:
|
43
|
+
shell> rake eve_data:importdb
|
44
|
+
|
45
|
+
EOF
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/mram-evedata.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
namespace :eve_data do
|
2
|
+
desc "Import Eve Online Static Data Dump to EDD database"
|
3
|
+
task :importdb => :environment do
|
4
|
+
require 'mram-evedata/version'
|
5
|
+
require 'tempfile'
|
6
|
+
|
7
|
+
data_absolute = EveData::Engine.root.join('data', EveData::DATAFILE)
|
8
|
+
|
9
|
+
unless cfg = ActiveRecord::Base.configurations['eve_data_dump'] then
|
10
|
+
raise IOError, "missing 'eve_data_dump' block in config/database.yml"
|
11
|
+
end
|
12
|
+
|
13
|
+
Tempfile.open('edd_mysql_import.', Rails.root.join('tmp')) do |f|
|
14
|
+
f.printf("[client]\n")
|
15
|
+
f.printf("host=%s\n", cfg["host"]) if cfg["host"]
|
16
|
+
f.printf("socket=%s\n", cfg["socket"]) if cfg["socket"]
|
17
|
+
f.printf("port=%s\n", cfg["port"]) if cfg["port"]
|
18
|
+
f.printf("user=%s\n", cfg["username"]) if cfg["username"]
|
19
|
+
f.printf("password=%s\n", cfg["password"]) if cfg["password"]
|
20
|
+
f.flush
|
21
|
+
|
22
|
+
puts "trying to connect to mysql server:"
|
23
|
+
ret = system("mysqladmin --defaults-extra-file=#{f.path} status")
|
24
|
+
unless ret then
|
25
|
+
raise IOError, "unable to connect to mysql server (mysqladmin status failed; maybe incorrect pw?"
|
26
|
+
return false
|
27
|
+
end
|
28
|
+
|
29
|
+
puts "now trying to import dump from '#{data_absolute}':"
|
30
|
+
ret = system("bzcat #{data_absolute} | mysql --defaults-extra-file=#{f.path} #{cfg["database"]}")
|
31
|
+
puts (ret ? "success!" : "failed!")
|
32
|
+
end
|
33
|
+
|
34
|
+
true
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
# Maintain your gem's version:
|
5
|
+
require "mram-evedata/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "mram-evedata"
|
9
|
+
s.version = EveData::VERSION
|
10
|
+
s.authors = ["Markus Rambossek"]
|
11
|
+
s.email = ["git@rambossek.at"]
|
12
|
+
s.description = %q{this gem will import the EVE Online Static Data Dump into your database and provide a framework for accessing it}
|
13
|
+
s.summary = %q{EVE Online Static Data Dump Rails Integration}
|
14
|
+
s.homepage = "https://github.com/mrambossek/mram-evedata"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split($\)
|
17
|
+
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.required_rubygems_version = "> 1.3.6"
|
22
|
+
|
23
|
+
s.add_dependency 'rails', "~> 3.2.0"
|
24
|
+
s.add_dependency 'composite_primary_keys', '~> 5.0'
|
25
|
+
end
|
data/script/rails
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
#!/usr/bin/env ruby1.9.1
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/mram-evedata/engine', __FILE__)
|
6
|
+
|
7
|
+
require 'rails/all'
|
8
|
+
require 'rails/engine/commands'
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
# Load support files
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
+
|
12
|
+
# Load fixtures from the engine
|
13
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mram-evedata
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.inferno11.3
|
5
|
+
prerelease: 4
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Markus Rambossek
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: &13670160 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *13670160
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: composite_primary_keys
|
27
|
+
requirement: &13669700 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *13669700
|
36
|
+
description: this gem will import the EVE Online Static Data Dump into your database
|
37
|
+
and provide a framework for accessing it
|
38
|
+
email:
|
39
|
+
- git@rambossek.at
|
40
|
+
executables: []
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- Gemfile
|
46
|
+
- MIT-LICENSE
|
47
|
+
- README.rdoc
|
48
|
+
- Rakefile
|
49
|
+
- app/assets/images/mram-evedata/.gitkeep
|
50
|
+
- app/assets/javascripts/mram-evedata/application.js
|
51
|
+
- app/assets/stylesheets/mram-evedata/application.css
|
52
|
+
- app/controllers/mram-evedata/application_controller.rb
|
53
|
+
- app/helpers/mram-evedata/application_helper.rb
|
54
|
+
- app/models/eve_data/activity.rb
|
55
|
+
- app/models/eve_data/attribute_type.rb
|
56
|
+
- app/models/eve_data/blueprint_type.rb
|
57
|
+
- app/models/eve_data/category.rb
|
58
|
+
- app/models/eve_data/eve_data_dump.rb
|
59
|
+
- app/models/eve_data/graphic.rb
|
60
|
+
- app/models/eve_data/group.rb
|
61
|
+
- app/models/eve_data/icon.rb
|
62
|
+
- app/models/eve_data/market_group.rb
|
63
|
+
- app/models/eve_data/meta_group.rb
|
64
|
+
- app/models/eve_data/meta_type.rb
|
65
|
+
- app/models/eve_data/race.rb
|
66
|
+
- app/models/eve_data/region.rb
|
67
|
+
- app/models/eve_data/solar_system.rb
|
68
|
+
- app/models/eve_data/type.rb
|
69
|
+
- app/models/eve_data/type_attribute.rb
|
70
|
+
- app/models/eve_data/type_material.rb
|
71
|
+
- app/models/eve_data/type_reaction.rb
|
72
|
+
- app/models/eve_data/type_requirement.rb
|
73
|
+
- app/views/layouts/mram-evedata/application.html.erb
|
74
|
+
- config/routes.rb
|
75
|
+
- data/mysql55-inferno11-extended.sql.bz2
|
76
|
+
- lib/generators/eve_data/sample_db_config/sample_db_config_generator.rb
|
77
|
+
- lib/mram-evedata.rb
|
78
|
+
- lib/mram-evedata/engine.rb
|
79
|
+
- lib/mram-evedata/version.rb
|
80
|
+
- lib/tasks/mram-evedata_tasks.rake
|
81
|
+
- mram-evedata.gemspec
|
82
|
+
- script/rails
|
83
|
+
- test/integration/navigation_test.rb
|
84
|
+
- test/mram-evedata_test.rb
|
85
|
+
- test/test_helper.rb
|
86
|
+
homepage: https://github.com/mrambossek/mram-evedata
|
87
|
+
licenses: []
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ! '>'
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.3.6
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.8.11
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: EVE Online Static Data Dump Rails Integration
|
110
|
+
test_files:
|
111
|
+
- test/integration/navigation_test.rb
|
112
|
+
- test/mram-evedata_test.rb
|
113
|
+
- test/test_helper.rb
|