tsm-accounting 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +4 -0
- data/lib/tsm-accounting.rb +16 -10
- metadata +3 -3
data/HISTORY
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 0.9.0 ==
|
2
|
+
* I am the worst QA engineer in the entire world. Buyer and seller columns
|
3
|
+
are now correct for purchase transactions.
|
4
|
+
|
1
5
|
== 0.8.0 ==
|
2
6
|
* Initial release. The TSM accounting saved variable file can be transmuted
|
3
7
|
into a CSV. You can also access its contents in a nice (messy) datastructure.
|
data/lib/tsm-accounting.rb
CHANGED
@@ -28,7 +28,7 @@
|
|
28
28
|
require 'csv'
|
29
29
|
|
30
30
|
module TSMAccounting
|
31
|
-
VERSION = '0.
|
31
|
+
VERSION = '0.9.0'
|
32
32
|
|
33
33
|
class Database
|
34
34
|
attr_reader :data
|
@@ -42,8 +42,8 @@ module TSMAccounting
|
|
42
42
|
@data[realm_name] = {} unless @data.has_key? realm_name
|
43
43
|
realm_data.each do |faction_name,faction_data|
|
44
44
|
@data[realm_name][faction_name] = {} unless @data[realm_name].has_key? faction_name
|
45
|
-
@data[realm_name][faction_name]['sale'] = parse_rope(faction_data['sell'])
|
46
|
-
@data[realm_name][faction_name]['purchase'] = parse_rope(faction_data['buy'])
|
45
|
+
@data[realm_name][faction_name]['sale'] = parse_rope(faction_data['sell'],'sale')
|
46
|
+
@data[realm_name][faction_name]['purchase'] = parse_rope(faction_data['buy'],'purchase')
|
47
47
|
end # faction
|
48
48
|
end # realms
|
49
49
|
end # initialize
|
@@ -163,10 +163,10 @@ module TSMAccounting
|
|
163
163
|
return data
|
164
164
|
end # extract_data
|
165
165
|
|
166
|
-
def parse_rope(rope)
|
166
|
+
def parse_rope(rope,type)
|
167
167
|
list = {}
|
168
168
|
rope.split('?').each do |row|
|
169
|
-
item = Item.new(row)
|
169
|
+
item = Item.new(row,type)
|
170
170
|
|
171
171
|
if list.has_key? item.name
|
172
172
|
# merge
|
@@ -182,7 +182,7 @@ module TSMAccounting
|
|
182
182
|
class Item
|
183
183
|
attr_reader :name, :transactions
|
184
184
|
|
185
|
-
def initialize(item)
|
185
|
+
def initialize(item,type)
|
186
186
|
encoded_item, encoded_records = item.split '!'
|
187
187
|
|
188
188
|
if encoded_item[0,1] == 'x'
|
@@ -190,7 +190,7 @@ module TSMAccounting
|
|
190
190
|
else
|
191
191
|
@name = decode_link(encoded_item)
|
192
192
|
end
|
193
|
-
@transactions = encoded_records.split('@').map {|record| Transaction.new(record) }
|
193
|
+
@transactions = encoded_records.split('@').map {|record| Transaction.new(record,type) }
|
194
194
|
@transactions ||= []
|
195
195
|
end # initialize
|
196
196
|
|
@@ -214,15 +214,21 @@ module TSMAccounting
|
|
214
214
|
class Transaction
|
215
215
|
attr_reader :stack_size, :quantity, :datetime, :price, :buyer, :seller
|
216
216
|
|
217
|
-
def initialize(encoded_string)
|
217
|
+
def initialize(encoded_string,type)
|
218
218
|
d = encoded_string.split('#')
|
219
219
|
|
220
220
|
@stack_size = decode(d[0])
|
221
221
|
@quantity = decode(d[1])
|
222
222
|
@datetime = Time.at(decode(d[2]))
|
223
223
|
@price = decode(d[3])
|
224
|
-
|
225
|
-
|
224
|
+
|
225
|
+
if type == 'purchase'
|
226
|
+
@buyer = d[5]
|
227
|
+
@seller = d[4]
|
228
|
+
else
|
229
|
+
@buyer = d[4]
|
230
|
+
@seller = d[5]
|
231
|
+
end
|
226
232
|
end # initialize
|
227
233
|
|
228
234
|
def usable_price
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tsm-accounting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 9
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- owlmanatt
|