currency 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +18 -17
- data/Rakefile +1 -1
- data/Releases +10 -0
- data/lib/currency/currency_version.rb +1 -1
- data/test/ar_test_base.rb +140 -0
- metadata +19 -18
data/Manifest.txt
CHANGED
@@ -1,25 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
lib/currency/money_helper.rb
|
5
|
-
lib/currency/exception.rb
|
6
|
-
lib/currency/currency_version.rb
|
7
|
-
lib/currency/currency_factory.rb
|
8
|
-
lib/currency/core_extensions.rb
|
9
|
-
lib/currency/money.rb
|
1
|
+
ChangeLog
|
2
|
+
examples/ex1.rb
|
3
|
+
examples/xe1.rb
|
10
4
|
lib/currency/active_record.rb
|
5
|
+
lib/currency/core_extensions.rb
|
6
|
+
lib/currency/currency_factory.rb
|
11
7
|
lib/currency/currency.rb
|
12
|
-
lib/currency/
|
8
|
+
lib/currency/currency_version.rb
|
9
|
+
lib/currency/exception.rb
|
13
10
|
lib/currency/exchange/base.rb
|
11
|
+
lib/currency/exchange/rate.rb
|
12
|
+
lib/currency/exchange.rb
|
14
13
|
lib/currency/exchange/test.rb
|
15
14
|
lib/currency/exchange/xe.rb
|
16
|
-
lib/currency/
|
15
|
+
lib/currency/money_helper.rb
|
16
|
+
lib/currency/money.rb
|
17
17
|
lib/currency.rb
|
18
|
-
|
19
|
-
examples/ex1.rb
|
20
|
-
ChangeLog
|
18
|
+
Manifest.txt
|
21
19
|
Rakefile
|
22
|
-
TODO
|
23
|
-
Releases
|
24
20
|
README
|
25
|
-
|
21
|
+
Releases
|
22
|
+
test/ar_test_base.rb
|
23
|
+
test/money_test.rb
|
24
|
+
test/test_base.rb
|
25
|
+
test/xe_test.rb
|
26
|
+
TODO
|
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ require 'hoe'
|
|
12
12
|
PKG_Name = 'Currency'
|
13
13
|
PKG_NAME = PKG_Name.gsub(/[a-z][A-Z]/) {|x| "#{x[0,1]}_#{x[1,1]}"}.downcase
|
14
14
|
|
15
|
-
hoe = Hoe.new("currency", '0.2.
|
15
|
+
hoe = Hoe.new("currency", '0.2.1') do |p|
|
16
16
|
p.author = 'Kurt Stephens'
|
17
17
|
p.description = %{Currency models currencies, monetary values, foreign exchanges.}
|
18
18
|
p.email = "ruby-#{PKG_NAME}@umleta.com"
|
data/Releases
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
= Currency Release History
|
2
2
|
|
3
|
+
== Release 0.2.1: 2006/10/31
|
4
|
+
|
5
|
+
* Fixed Manifest.txt
|
6
|
+
|
7
|
+
== Release 0.2.0: 2006/10/31
|
8
|
+
|
9
|
+
* Restructured namespace
|
10
|
+
* Added more documentation
|
11
|
+
* Added ActiveRecord tests
|
12
|
+
|
3
13
|
== Release 0.1.2: 2006/10/30
|
4
14
|
|
5
15
|
* Rakefile now uses Hoe
|
@@ -0,0 +1,140 @@
|
|
1
|
+
require 'test/test_base'
|
2
|
+
require 'currency'
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'active_record'
|
6
|
+
require 'active_record/migration'
|
7
|
+
require 'currency/active_record'
|
8
|
+
|
9
|
+
AR_M = ActiveRecord::Migration
|
10
|
+
AR_B = ActiveRecord::Base
|
11
|
+
|
12
|
+
module Currency
|
13
|
+
|
14
|
+
class ArTestBase < TestBase
|
15
|
+
|
16
|
+
##################################################
|
17
|
+
# Basic CurrenyTest AR::B class
|
18
|
+
#
|
19
|
+
|
20
|
+
TABLE_NAME = 'currency_test'
|
21
|
+
|
22
|
+
class CurrencyTestMigration < AR_M
|
23
|
+
def self.up
|
24
|
+
begin
|
25
|
+
down
|
26
|
+
rescue Object => e
|
27
|
+
announce("Warning: #{e}")
|
28
|
+
end
|
29
|
+
|
30
|
+
create_table TABLE_NAME.intern do |t|
|
31
|
+
t.column :name, :string
|
32
|
+
t.column :amount, :integer # Money
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.down
|
37
|
+
drop_table TABLE_NAME.intern
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class CurrencyTest < AR_B
|
42
|
+
set_table_name TABLE_NAME
|
43
|
+
money :amount
|
44
|
+
end
|
45
|
+
|
46
|
+
##################################################
|
47
|
+
|
48
|
+
def setup
|
49
|
+
super
|
50
|
+
AR_B.establish_connection(database_spec)
|
51
|
+
|
52
|
+
# Subclasses can override this.
|
53
|
+
@currency_test_migration ||= CurrencyTestMigration
|
54
|
+
@currency_test ||= CurrencyTest
|
55
|
+
|
56
|
+
schema_up
|
57
|
+
end
|
58
|
+
|
59
|
+
def teardown
|
60
|
+
super
|
61
|
+
schema_down
|
62
|
+
end
|
63
|
+
|
64
|
+
def database_spec
|
65
|
+
# TODO: Get from ../config/database.yml:test
|
66
|
+
@database_spec = {
|
67
|
+
:adapter => "mysql",
|
68
|
+
:host => "localhost",
|
69
|
+
:username => "test",
|
70
|
+
:password => "test",
|
71
|
+
:database => "test"
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
def schema_up
|
76
|
+
@currency_test_migration.migrate(:up)
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
def schema_down
|
81
|
+
#@currency_test_migration.migrate(:down)
|
82
|
+
end
|
83
|
+
|
84
|
+
##################################################
|
85
|
+
# Scaffold
|
86
|
+
#
|
87
|
+
|
88
|
+
def insert_records
|
89
|
+
@currency_test.reset_column_information
|
90
|
+
|
91
|
+
@usd = @currency_test.new(:name => '#1: USD', :amount => Money.new("12.34", :USD))
|
92
|
+
@usd.save
|
93
|
+
|
94
|
+
@cad = @currency_test.new(:name => '#2: CAD', :amount => Money.new("56.78", :CAD))
|
95
|
+
@cad.save
|
96
|
+
end
|
97
|
+
|
98
|
+
def delete_records
|
99
|
+
# Simp
|
100
|
+
end
|
101
|
+
|
102
|
+
##################################################
|
103
|
+
|
104
|
+
def assert_currency_test(a,b)
|
105
|
+
assert_not_nil a
|
106
|
+
assert_not_nil b
|
107
|
+
# Make sure a and b are not the same object.
|
108
|
+
assert_not_equal a.object_id, b.object_id
|
109
|
+
assert_equal a.id, b.id
|
110
|
+
assert_not_nil a.amount
|
111
|
+
assert_kind_of Money, a.amount
|
112
|
+
assert_not_nil b.amount
|
113
|
+
assert_kind_of Money, b.amount
|
114
|
+
# Make sure that what gets stored in the database comes back out
|
115
|
+
# when converted back to the original currency.
|
116
|
+
assert_equal a.amount.convert(b.amount.currency).rep, b.amount.rep
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_simple
|
120
|
+
insert_records
|
121
|
+
|
122
|
+
assert_not_nil usd = @currency_test.find(@usd.id)
|
123
|
+
assert_currency_test usd, @usd
|
124
|
+
|
125
|
+
assert_equal usd.amount.rep, @usd.amount.rep
|
126
|
+
assert_equal usd.amount.currency, @usd.amount.currency
|
127
|
+
assert_equal usd.amount.currency.code, @usd.amount.currency.code
|
128
|
+
|
129
|
+
assert_not_nil cad = @currency_test.find(@cad.id)
|
130
|
+
assert_currency_test cad, @cad
|
131
|
+
|
132
|
+
assert_equal cad.amount.currency.code, :USD
|
133
|
+
|
134
|
+
delete_records
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
end # module
|
140
|
+
|
metadata
CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: currency
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
6
|
+
version: 0.2.1
|
7
7
|
date: 2006-10-31 00:00:00 -05:00
|
8
8
|
summary: Currency models currencies, monetary values, foreign exchanges.
|
9
9
|
require_paths:
|
@@ -30,31 +30,32 @@ post_install_message:
|
|
30
30
|
authors:
|
31
31
|
- Kurt Stephens
|
32
32
|
files:
|
33
|
-
-
|
34
|
-
-
|
35
|
-
-
|
36
|
-
- lib/currency/money_helper.rb
|
37
|
-
- lib/currency/exception.rb
|
38
|
-
- lib/currency/currency_version.rb
|
39
|
-
- lib/currency/currency_factory.rb
|
40
|
-
- lib/currency/core_extensions.rb
|
41
|
-
- lib/currency/money.rb
|
33
|
+
- ChangeLog
|
34
|
+
- examples/ex1.rb
|
35
|
+
- examples/xe1.rb
|
42
36
|
- lib/currency/active_record.rb
|
37
|
+
- lib/currency/core_extensions.rb
|
38
|
+
- lib/currency/currency_factory.rb
|
43
39
|
- lib/currency/currency.rb
|
44
|
-
- lib/currency/
|
40
|
+
- lib/currency/currency_version.rb
|
41
|
+
- lib/currency/exception.rb
|
45
42
|
- lib/currency/exchange/base.rb
|
43
|
+
- lib/currency/exchange/rate.rb
|
44
|
+
- lib/currency/exchange.rb
|
46
45
|
- lib/currency/exchange/test.rb
|
47
46
|
- lib/currency/exchange/xe.rb
|
48
|
-
- lib/currency/
|
47
|
+
- lib/currency/money_helper.rb
|
48
|
+
- lib/currency/money.rb
|
49
49
|
- lib/currency.rb
|
50
|
-
-
|
51
|
-
- examples/ex1.rb
|
52
|
-
- ChangeLog
|
50
|
+
- Manifest.txt
|
53
51
|
- Rakefile
|
54
|
-
- TODO
|
55
|
-
- Releases
|
56
52
|
- README
|
57
|
-
-
|
53
|
+
- Releases
|
54
|
+
- test/ar_test_base.rb
|
55
|
+
- test/money_test.rb
|
56
|
+
- test/test_base.rb
|
57
|
+
- test/xe_test.rb
|
58
|
+
- TODO
|
58
59
|
test_files: []
|
59
60
|
|
60
61
|
rdoc_options: []
|