reckon 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require "spec_helper"
5
+ require 'rubygems'
6
+ require 'reckon'
7
+
8
+ describe Reckon::Money do
9
+ describe "from_s" do
10
+ it "should handle currency indicators" do
11
+ Reckon::Money::from_s( "$2.00" ).should == 2.00
12
+ Reckon::Money::from_s( "-$1025.67" ).should == -1025.67
13
+ Reckon::Money::from_s( "$-1025.67" ).should == -1025.67
14
+ end
15
+
16
+ it "should handle the comma_separates_cents option correctly" do
17
+ Reckon::Money::from_s( "$2,00", :comma_separates_cents => true ).should == 2.00
18
+ Reckon::Money::from_s( "-$1025,67", :comma_separates_cents => true ).should == -1025.67
19
+ Reckon::Money::from_s( "$-1025,67", :comma_separates_cents => true ).should == -1025.67
20
+ end
21
+
22
+ it "should return nil for an empty string" do
23
+ Reckon::Money::from_s( "" ).should == nil
24
+ Reckon::Money::from_s( "" ).should_not == 0
25
+ end
26
+
27
+ it "should handle 1000 indicators correctly" do
28
+ Reckon::Money::from_s( "$2.000,00", :comma_separates_cents => true ).should == 2000.00
29
+ Reckon::Money::from_s( "-$1,025.67" ).should == -1025.67
30
+ end
31
+ end
32
+
33
+ describe "pretty" do
34
+ it "work with negative and positive numbers" do
35
+ Reckon::Money.new( -20.00 ).pretty.should == "-$20.00"
36
+ Reckon::Money.new( 1558.52 ).pretty.should == " $1558.52"
37
+ end
38
+
39
+ it "work with other currencies such as €" do
40
+ Reckon::Money.new( -20.00, :currency => "€", :suffixed => false ).pretty.should == "-€20.00"
41
+ Reckon::Money.new( 1558.52, :currency => "€", :suffixed => false ).pretty.should == " €1558.52"
42
+ end
43
+
44
+ it "work with suffixed currencies such as SEK" do
45
+ Reckon::Money.new( -20.00, :currency => "SEK", :suffixed => true ).pretty.should == "-20.00 SEK"
46
+ Reckon::Money.new( 1558.52, :currency => "SEK", :suffixed => true ).pretty.should == " 1558.52 SEK"
47
+ end
48
+ end
49
+
50
+ describe "likelihood" do
51
+ it "should return the likelihood that a string represents money" do
52
+ Reckon::Money::likelihood( "$20.00" ).should == 45
53
+ end
54
+ end
55
+
56
+ describe "equality" do
57
+ it "should be comparable to other money" do
58
+ Reckon::Money.new( 2.0 ).should == Reckon::Money.new( 2.0 )
59
+ Reckon::Money.new( 1.0 ).should <= Reckon::Money.new( 2.0 )
60
+ Reckon::Money.new( 3.0 ).should > Reckon::Money.new( 2.0 )
61
+ end
62
+ it "should be comparable to other float" do
63
+ Reckon::Money.new( 2.0 ).should == 2.0
64
+ Reckon::Money.new( 1.0 ).should <= 2.0
65
+ Reckon::Money.new( 3.0 ).should > 2.0
66
+ end
67
+ end
68
+ end
metadata CHANGED
@@ -1,94 +1,84 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reckon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
5
- prerelease:
4
+ version: 0.3.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - Andrew Cantino
8
+ - BlackEdder
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-03 00:00:00.000000000 Z
12
+ date: 2014-02-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
16
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
17
  requirements:
19
- - - ! '>='
18
+ - - '>='
20
19
  - !ruby/object:Gem::Version
21
20
  version: 1.2.9
22
21
  type: :development
23
22
  prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
- - - ! '>='
25
+ - - '>='
28
26
  - !ruby/object:Gem::Version
29
27
  version: 1.2.9
30
28
  - !ruby/object:Gem::Dependency
31
29
  name: fastercsv
32
30
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
31
  requirements:
35
- - - ! '>='
32
+ - - '>='
36
33
  - !ruby/object:Gem::Version
37
34
  version: 1.5.1
38
35
  type: :runtime
39
36
  prerelease: false
40
37
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
38
  requirements:
43
- - - ! '>='
39
+ - - '>='
44
40
  - !ruby/object:Gem::Version
45
41
  version: 1.5.1
46
42
  - !ruby/object:Gem::Dependency
47
43
  name: chronic
48
44
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
45
  requirements:
51
- - - ! '>='
46
+ - - '>='
52
47
  - !ruby/object:Gem::Version
53
48
  version: 0.3.0
54
49
  type: :runtime
55
50
  prerelease: false
56
51
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
52
  requirements:
59
- - - ! '>='
53
+ - - '>='
60
54
  - !ruby/object:Gem::Version
61
55
  version: 0.3.0
62
56
  - !ruby/object:Gem::Dependency
63
57
  name: highline
64
58
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
59
  requirements:
67
- - - ! '>='
60
+ - - '>='
68
61
  - !ruby/object:Gem::Version
69
62
  version: 1.5.2
70
63
  type: :runtime
71
64
  prerelease: false
72
65
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
66
  requirements:
75
- - - ! '>='
67
+ - - '>='
76
68
  - !ruby/object:Gem::Version
77
69
  version: 1.5.2
78
70
  - !ruby/object:Gem::Dependency
79
71
  name: terminal-table
80
72
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
73
  requirements:
83
- - - ! '>='
74
+ - - '>='
84
75
  - !ruby/object:Gem::Version
85
76
  version: 1.4.2
86
77
  type: :runtime
87
78
  prerelease: false
88
79
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
80
  requirements:
91
- - - ! '>='
81
+ - - '>='
92
82
  - !ruby/object:Gem::Version
93
83
  version: 1.4.2
94
84
  description: Reckon automagically converts CSV files for use with the command-line
@@ -115,47 +105,50 @@ files:
115
105
  - bin/reckon
116
106
  - lib/reckon.rb
117
107
  - lib/reckon/app.rb
108
+ - lib/reckon/csv_parser.rb
118
109
  - lib/reckon/ledger_parser.rb
110
+ - lib/reckon/money.rb
119
111
  - reckon.gemspec
120
112
  - spec/data_fixtures/extratofake.csv
121
113
  - spec/reckon/app_spec.rb
114
+ - spec/reckon/csv_parser_spec.rb
115
+ - spec/reckon/date_column_spec.rb
122
116
  - spec/reckon/ledger_parser_spec.rb
117
+ - spec/reckon/money_column_spec.rb
118
+ - spec/reckon/money_spec.rb
123
119
  - spec/spec.opts
124
120
  - spec/spec_helper.rb
125
121
  homepage: https://github.com/cantino/reckon
126
122
  licenses: []
123
+ metadata: {}
127
124
  post_install_message:
128
125
  rdoc_options: []
129
126
  require_paths:
130
127
  - lib
131
128
  required_ruby_version: !ruby/object:Gem::Requirement
132
- none: false
133
129
  requirements:
134
- - - ! '>='
130
+ - - '>='
135
131
  - !ruby/object:Gem::Version
136
132
  version: '0'
137
- segments:
138
- - 0
139
- hash: -1602098812968474489
140
133
  required_rubygems_version: !ruby/object:Gem::Requirement
141
- none: false
142
134
  requirements:
143
- - - ! '>='
135
+ - - '>='
144
136
  - !ruby/object:Gem::Version
145
137
  version: '0'
146
- segments:
147
- - 0
148
- hash: -1602098812968474489
149
138
  requirements: []
150
139
  rubyforge_project:
151
- rubygems_version: 1.8.25
140
+ rubygems_version: 2.1.11
152
141
  signing_key:
153
- specification_version: 3
142
+ specification_version: 4
154
143
  summary: Utility for interactively converting and labeling CSV files for the Ledger
155
144
  accounting tool.
156
145
  test_files:
157
146
  - spec/data_fixtures/extratofake.csv
158
147
  - spec/reckon/app_spec.rb
148
+ - spec/reckon/csv_parser_spec.rb
149
+ - spec/reckon/date_column_spec.rb
159
150
  - spec/reckon/ledger_parser_spec.rb
151
+ - spec/reckon/money_column_spec.rb
152
+ - spec/reckon/money_spec.rb
160
153
  - spec/spec.opts
161
154
  - spec/spec_helper.rb