edj 0.1.0
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.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/lib/edj.rb +5 -0
- data/lib/edj/base.rb +63 -0
- data/lib/edj/engineer.rb +21 -0
- data/lib/edj/scan.rb +100 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3a18ca1398dfb47c453ad832ea7672208c74c7ce
|
4
|
+
data.tar.gz: 38d5e9c6b5c9ae70594d37cd3ead8e3b1d1bb285
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '0328372a81c19245e8d0f32b0cdff9c2c782c44f2c1a1525c41393fc943941229116bc4731131d640e27019d3cea3c43e596b3228f746affe74e2d9df5bab977'
|
7
|
+
data.tar.gz: 4a5802a5680c43b2c56e1bcc4c097ad35f78a5afabbc012f04f039e11f3c192a9400d8866725c6036ed9399bef0a771649385d2219dd77a0e82b45f42dbfbcbc
|
data/Gemfile
ADDED
data/lib/edj.rb
ADDED
data/lib/edj/base.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
|
6
|
+
module Edj
|
7
|
+
class Item
|
8
|
+
def self.from(hash)
|
9
|
+
case hash["event"]
|
10
|
+
when "Scan"
|
11
|
+
ScanItem.new(hash)
|
12
|
+
when "EngineerProgress"
|
13
|
+
EngineerProgressItem.new(hash)
|
14
|
+
when "EngineerContributionItem"
|
15
|
+
EngineerContributionItem.new(hash)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(hash)
|
20
|
+
@raw = hash
|
21
|
+
end
|
22
|
+
|
23
|
+
def timestamp()
|
24
|
+
@raw["timestamp"]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Journal
|
29
|
+
attr_reader :tree
|
30
|
+
|
31
|
+
def initialize(f)
|
32
|
+
@f = f
|
33
|
+
@tree = {}
|
34
|
+
end
|
35
|
+
|
36
|
+
def filter(type)
|
37
|
+
File.open(@f).readlines
|
38
|
+
.map {|line| Item.from(JSON.parse(line))}
|
39
|
+
.select {|item| item.is_a? type }
|
40
|
+
end
|
41
|
+
|
42
|
+
def scan_value()
|
43
|
+
total_value = 0
|
44
|
+
File.open(@f).each do |line|
|
45
|
+
item = Item.from(JSON.parse(line))
|
46
|
+
if item.is_a? ScanItem then
|
47
|
+
v = item.value
|
48
|
+
bits = item.bodyName.split(' ')
|
49
|
+
(1..(bits.size-1)).each do |i|
|
50
|
+
entry = bits[0..i].join(' ')
|
51
|
+
o = @tree[entry]
|
52
|
+
@tree[entry] ||= 0
|
53
|
+
@tree[entry] += v
|
54
|
+
end
|
55
|
+
STDOUT.puts("#{item.timestamp} #{item.bodyName} --> #{v}")
|
56
|
+
total_value = total_value + v
|
57
|
+
end
|
58
|
+
end
|
59
|
+
total_value
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
data/lib/edj/engineer.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
module Edj
|
3
|
+
class EngineerItem < Item
|
4
|
+
def engineer()
|
5
|
+
@raw["Engineer"]
|
6
|
+
end
|
7
|
+
end
|
8
|
+
class EngineerProgressItem < EngineerItem
|
9
|
+
def progress()
|
10
|
+
@raw["Progress"]
|
11
|
+
end
|
12
|
+
def rank()
|
13
|
+
@raw["Rank"]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
class EngineerContributionItem < EngineerItem
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
data/lib/edj/scan.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
|
2
|
+
module Edj
|
3
|
+
class ScanItem < Item
|
4
|
+
|
5
|
+
def value()
|
6
|
+
return body_value if @raw["PlanetClass"]
|
7
|
+
return solar_value if @raw["StarType"]
|
8
|
+
return 2000 if @raw["BodyName"] =~ /Belt Cluster/
|
9
|
+
STDERR.puts("#{@raw}")
|
10
|
+
raise
|
11
|
+
end
|
12
|
+
|
13
|
+
def bodyName()
|
14
|
+
@raw["BodyName"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def terraformable?()
|
18
|
+
@raw["TerraformState"] != ""
|
19
|
+
end
|
20
|
+
|
21
|
+
def body_value()
|
22
|
+
case @raw["PlanetClass"]
|
23
|
+
when "High metal content body"
|
24
|
+
return 412249 if terraformable?
|
25
|
+
34310
|
26
|
+
when "Icy body"
|
27
|
+
1246
|
28
|
+
when "Ammonia world"
|
29
|
+
320203
|
30
|
+
when "Water world"
|
31
|
+
return 694971 if terraformable?
|
32
|
+
301410
|
33
|
+
when "Rocky ice body"
|
34
|
+
928
|
35
|
+
when "Sudarsky class I gas giant"
|
36
|
+
7013
|
37
|
+
when "Sudarsky class III gas giant"
|
38
|
+
2693
|
39
|
+
when "Rocky body"
|
40
|
+
return 181104 if terraformable?
|
41
|
+
928
|
42
|
+
when "Metal rich body"
|
43
|
+
65045
|
44
|
+
when "Earthlike body"
|
45
|
+
627885
|
46
|
+
when "Gas giant with water based life"
|
47
|
+
2314
|
48
|
+
when "Sudarsky class II gas giant"
|
49
|
+
53663
|
50
|
+
when "Water giant"
|
51
|
+
1824
|
52
|
+
when "Gas giant with ammonia based life"
|
53
|
+
1721
|
54
|
+
when "Sudarsky class IV gas giant"
|
55
|
+
2799
|
56
|
+
when "Sudarsky class V gas giant"
|
57
|
+
2761
|
58
|
+
else
|
59
|
+
STDERR.puts("#{@raw}")
|
60
|
+
STDERR.puts("when \"#{@raw["PlanetClass"]}\"")
|
61
|
+
raise
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def solar_value()
|
66
|
+
case @raw["StarType"]
|
67
|
+
when "A"
|
68
|
+
2949
|
69
|
+
when "B"
|
70
|
+
3012
|
71
|
+
when "DA"
|
72
|
+
34294
|
73
|
+
when "F"
|
74
|
+
2932
|
75
|
+
when "G"
|
76
|
+
2919
|
77
|
+
when "H"
|
78
|
+
60589
|
79
|
+
when "K"
|
80
|
+
2916
|
81
|
+
when "L"
|
82
|
+
2889
|
83
|
+
when "M"
|
84
|
+
2903
|
85
|
+
when "M_RedGiant"
|
86
|
+
3122
|
87
|
+
when "T"
|
88
|
+
2895
|
89
|
+
when "TTS"
|
90
|
+
2000
|
91
|
+
when "Y"
|
92
|
+
2881
|
93
|
+
else
|
94
|
+
STDERR.puts("#{@raw}")
|
95
|
+
STDERR.puts("when \"#{@raw["StarType"]}\"")
|
96
|
+
raise
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: edj
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- candle
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-08 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: candle@candle.me.uk
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- Gemfile
|
20
|
+
- lib/edj.rb
|
21
|
+
- lib/edj/base.rb
|
22
|
+
- lib/edj/engineer.rb
|
23
|
+
- lib/edj/scan.rb
|
24
|
+
homepage:
|
25
|
+
licenses:
|
26
|
+
- MIT
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.6.13
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Elite Dangerous Journal handling
|
48
|
+
test_files: []
|