moneybook 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/bin/moneybook +18 -4
  3. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -13,6 +13,7 @@ require 'pp'
13
13
 
14
14
  REGEXP_COMP_LINE = /^\s*([\w\ \']+?)\s*\((.+)\)\s*(.+)?/
15
15
  REGEXP_PAYBACK_LINE = /\A\s*(.+)\s*\-+\>\s*(.+)\Z/
16
+ REGEXP_DEBT_LINE = /\A\s*(.+)\s*\@\s*(.+)\Z/
16
17
 
17
18
  class Array
18
19
  def normalize_length
@@ -45,7 +46,7 @@ def process_command(cmd)
45
46
  end.parse!(args)
46
47
  command_parse(options, args.last)
47
48
  else
48
- puts "unknown command: #{command}"
49
+ puts "unknown command: #{command}.. available commmands: new, parse\ndo moneybook parse --help for more help"
49
50
  end
50
51
  end
51
52
 
@@ -69,6 +70,13 @@ def command_new(title)
69
70
  # - ... you can write ...
70
71
  # 20L -> T
71
72
  # - ... and since it's a payback it won't count on the spent amount
73
+ # - another synctactic sugar, instead of ...
74
+ # undefined past debt (20T) L
75
+ # - ... you can write ...
76
+ # 20L @ T
77
+ # which means the opposite of 20L -> T
78
+ # it means that L owes T 20$
79
+ # and it doesn't count on the spent amount
72
80
  #######
73
81
 
74
82
  PEOPLE: #{people.join(' ')}"
@@ -91,7 +99,7 @@ def get_final(sq, people)
91
99
  final[person] += value
92
100
  }
93
101
  c[:virtual].each_pair{|person, value|
94
- spent[person] += value unless c[:name] == 'PAYBACK'
102
+ spent[person] += value unless (c[:name] == 'PAYBACK' || c[:name] == 'DEBT')
95
103
  }
96
104
  c[:true].each_pair{|person, value|
97
105
  given[person] += value
@@ -136,6 +144,12 @@ def command_parse(options, filename)
136
144
  original_str = line.strip
137
145
  line = "PAYBACK (#{temp[1].to_s}) #{temp[2].to_s}"
138
146
  end
147
+ if temp=line.match(REGEXP_DEBT_LINE) then
148
+ temp2 = temp[1].to_s.match(/([\d\.]+)\s*([A-Za-z]+)/)
149
+ original_str = line.strip
150
+ line = "DEBT (#{temp2[1]}#{temp[2].to_s}) #{temp2[2].to_s}"
151
+ puts line
152
+ end
139
153
  x = line.strip.match(REGEXP_COMP_LINE).to_a.map{|z| z.to_s}
140
154
  sq << {:name => x[1].to_s, :original_str => original_str || line.strip, :true_str => x[2].to_s, :virtual_str => x[3].to_s, :true => {}, :virtual => {}, :balance => {},
141
155
  :true_total => 0, :virtual_total => 0}
@@ -143,8 +157,8 @@ def command_parse(options, filename)
143
157
  people.each{|person| c[:true][person]=0;c[:virtual][person]=0;c[:balance][person]=0}
144
158
 
145
159
  # parsing of true_str
146
- c[:true_str].split(/\s+/).each{|y|
147
- temp = y.match(/([\d\.]+)([A-Za-z]+)/)
160
+ c[:true_str].split(/\s+(?=\d)/).each{|y|
161
+ temp = y.match(/([\d\.]+)\s*([A-Za-z]+)/)
148
162
  if (person=people_abbreviations[temp[2].to_s.downcase]) != nil
149
163
  c[:true][person] += temp[1].to_f
150
164
  c[:true_total] += temp[1].to_f
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: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - luca cioria
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-18 00:00:00 +01:00
18
+ date: 2011-02-21 00:00:00 +01:00
19
19
  default_executable: moneybook
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency