eve_static 0.0.1 → 0.0.2
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.
- data/lib/eve_static.rb +1 -0
- data/lib/eve_static/database.rb +1 -0
- data/lib/eve_static/manipulate.rb +53 -0
- data/lib/eve_static/queries/basic.rb +29 -0
- data/lib/eve_static/queries/industry.rb +12 -0
- data/lib/eve_static/version.rb +1 -1
- metadata +2 -1
data/lib/eve_static.rb
CHANGED
data/lib/eve_static/database.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
module EveStatic
|
2
|
+
module Manipulate
|
3
|
+
def add_category_id(input)
|
4
|
+
input.merge({ :categoryID => typeCategory(input[:typeID])[:categoryID]})
|
5
|
+
end
|
6
|
+
|
7
|
+
def add_category_ids(input)
|
8
|
+
input.map { |i| add_category_id i }
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_group_id(input)
|
12
|
+
input.merge({ :groupID => typeGroup(input[:typeID])[:groupID]})
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_group_ids(input)
|
16
|
+
input.map { |i| add_group_id i }
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_human(input)
|
20
|
+
if input.is_a? Array
|
21
|
+
output = input.map { |i| to_human(i) }
|
22
|
+
elsif input.is_a? Hash
|
23
|
+
if primitive?(input)
|
24
|
+
output = add_category_id(input)
|
25
|
+
output = add_group_id(input)
|
26
|
+
output = output.merge({:categoryName => typeCategory(input[:typeID])[:categoryName]})
|
27
|
+
output = output.merge({:groupName => typeGroup(input[:typeID])[:groupName]})
|
28
|
+
else
|
29
|
+
output = input.map do |k, v|
|
30
|
+
if primitive?(v)
|
31
|
+
[k, v]
|
32
|
+
else
|
33
|
+
[k, to_human(v)]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
output = Hash[output]
|
38
|
+
end
|
39
|
+
else
|
40
|
+
output = input
|
41
|
+
end
|
42
|
+
|
43
|
+
output
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
def primitive?(input)
|
48
|
+
return false if input.is_a?(Array)
|
49
|
+
output = input.values.map { |i| i.is_a?(Array) || i.is_a?(Hash) }
|
50
|
+
output = !output.reduce(:|)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -16,6 +16,35 @@ module EveStatic
|
|
16
16
|
|
17
17
|
instance[:invTypes].where(:typeID => typeID).select(Sequel.lit('typeName')).first[:typeName]
|
18
18
|
end
|
19
|
+
|
20
|
+
def groupName(groupID)
|
21
|
+
instance[:invGroups].where(:groupID => groupID).select(Sequel.lit('groupName')).first[:groupName]
|
22
|
+
end
|
23
|
+
|
24
|
+
def groupID(groupName)
|
25
|
+
instance[:invGroups].where(:groupName => groupName).select(Sequel.lit('groupID')).first[:groupID]
|
26
|
+
end
|
27
|
+
|
28
|
+
def typeGroup(type)
|
29
|
+
typeID = coerce_type_id(type)
|
30
|
+
|
31
|
+
instance[:invTypes].inner_join(:invGroups, :groupID => :groupID).where(:typeID => typeID).select_all(:invGroups).first
|
32
|
+
end
|
33
|
+
|
34
|
+
def categoryName(categoryID)
|
35
|
+
instance[:invCategories].where(:categoryID => categoryID).select(Sequel.lit('categoryName')).first[:categoryName]
|
36
|
+
end
|
37
|
+
|
38
|
+
def categoryID(categoryName)
|
39
|
+
instance[:invCategories].where(:categoryName => categoryName).select(Sequel.lit('categoryID')).first[:categoryID]
|
40
|
+
end
|
41
|
+
|
42
|
+
def typeCategory(type)
|
43
|
+
typeID = coerce_type_id(type)
|
44
|
+
|
45
|
+
instance[:invTypes].inner_join(:invGroups, :groupID => :groupID).inner_join(:invCategories, :categoryID => :categoryID).where(:typeID => typeID).select_all(:invCategories).first
|
46
|
+
end
|
47
|
+
|
19
48
|
end
|
20
49
|
end
|
21
50
|
end
|
@@ -116,6 +116,9 @@ module EveStatic
|
|
116
116
|
end
|
117
117
|
|
118
118
|
raw = raw.map { |r| r.merge({ :waste => waste(r[:quantity], bp[:wasteFactor], me) }) }
|
119
|
+
|
120
|
+
raw = raw.map { |r| normalize_materials r }
|
121
|
+
extra = extra.map { |e| normalize_materials e }
|
119
122
|
|
120
123
|
{ :raw => raw,
|
121
124
|
:extra => extra }
|
@@ -141,6 +144,15 @@ module EveStatic
|
|
141
144
|
result = base * (base_waste.to_f/100.0) * me
|
142
145
|
result.to_i
|
143
146
|
end
|
147
|
+
|
148
|
+
def normalize_materials(input)
|
149
|
+
output = input.map do |k, v|
|
150
|
+
k = :typeID if k == :materialTypeID || k == :requiredTypeID
|
151
|
+
[ k, v ]
|
152
|
+
end
|
153
|
+
|
154
|
+
Hash[output]
|
155
|
+
end
|
144
156
|
end
|
145
157
|
end
|
146
158
|
end
|
data/lib/eve_static/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eve_static
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -28,6 +28,7 @@ files:
|
|
28
28
|
- lib/eve_static.rb
|
29
29
|
- lib/eve_static/coerce.rb
|
30
30
|
- lib/eve_static/database.rb
|
31
|
+
- lib/eve_static/manipulate.rb
|
31
32
|
- lib/eve_static/queries/basic.rb
|
32
33
|
- lib/eve_static/queries/industry.rb
|
33
34
|
- lib/eve_static/version.rb
|