moneybook 0.1.1 → 0.1.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/VERSION +1 -1
- data/bin/moneybook +16 -8
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/bin/moneybook
CHANGED
@@ -46,6 +46,17 @@ PEOPLE: #{people.join(' ')}"
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
def get_final(sq, people)
|
50
|
+
final = {}
|
51
|
+
people.each{|person| final[person]=0;}
|
52
|
+
sq.each {|c|
|
53
|
+
c[:balance].each_pair{|person, value|
|
54
|
+
final[person] += value
|
55
|
+
}
|
56
|
+
}
|
57
|
+
final
|
58
|
+
end
|
59
|
+
|
49
60
|
command :parse do |c|
|
50
61
|
c.syntax = 'moneybook parse [options] [file]'
|
51
62
|
c.description = 'calculate total debts for everyone'
|
@@ -87,6 +98,7 @@ command :parse do |c|
|
|
87
98
|
# parsing of virtual_str
|
88
99
|
if c[:virtual_str] =~ /\A\s*\Z/ then
|
89
100
|
c[:virtual].each_key{|person|c[:virtual][person] = c[:true_total]/people.length}
|
101
|
+
c[:virtual_total] = c[:true_total]
|
90
102
|
else
|
91
103
|
avoid = []
|
92
104
|
people_to_complete = []
|
@@ -148,6 +160,9 @@ command :parse do |c|
|
|
148
160
|
t << c[:virtual].sort.map{|z|z[1] == 0 ? "" : "%.1f" % z[1]}
|
149
161
|
t.add_separator
|
150
162
|
t << c[:balance].sort.map{|z|z[1] == 0 ? "" : "%.1f" % z[1]}
|
163
|
+
t.add_separator
|
164
|
+
final = get_final(sq, people)
|
165
|
+
t << final.sort.map{|z|z[1] == 0 ? "" : "%.1f" % z[1]}
|
151
166
|
end
|
152
167
|
puts mytable
|
153
168
|
end
|
@@ -155,14 +170,7 @@ command :parse do |c|
|
|
155
170
|
end
|
156
171
|
}
|
157
172
|
### PRINT FINAL RESULTS ###
|
158
|
-
|
159
|
-
people.each{|person| final[person]=0;}
|
160
|
-
sq.each {|c|
|
161
|
-
c[:balance].each_pair{|person, value|
|
162
|
-
final[person] += value
|
163
|
-
}
|
164
|
-
}
|
165
|
-
final.each_pair {|person, value|
|
173
|
+
get_final(sq, people).each_pair {|person, value|
|
166
174
|
puts "#{person} \t #{value > 0 ? 'receives' : 'gives '} #{"%.1f" % value}"
|
167
175
|
}
|
168
176
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moneybook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- luca cioria
|