acvwilson-currency 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/currency.gemspec +3 -3
- data/spec/ar_spec_helper.rb +125 -0
- metadata +3 -3
data/currency.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{currency}
|
3
|
-
s.version = "0.5.
|
3
|
+
s.version = "0.5.1"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Asa Wilson"]
|
@@ -8,11 +8,11 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.description = %q{Currency conversions for Ruby}
|
9
9
|
s.email = ["acvwilson@gmail.com"]
|
10
10
|
s.extra_rdoc_files = ["ChangeLog", "COPYING.txt", "LICENSE.txt", "Manifest.txt", "README.txt", "Releases.txt", "TODO.txt"]
|
11
|
-
s.files = ["COPYING.txt", "currency.gemspec", "examples/ex1.rb", "examples/xe1.rb", "lib/currency/active_record.rb", "lib/currency/config.rb", "lib/currency/core_extensions.rb", "lib/currency/currency/factory.rb", "lib/currency/currency.rb", "lib/currency/currency_version.rb", "lib/currency/exception.rb", "lib/currency/exchange/rate/deriver.rb", "lib/currency/exchange/rate/source/base.rb", "lib/currency/exchange/rate/source/failover.rb", "lib/currency/exchange/rate/source/federal_reserve.rb", "lib/currency/exchange/rate/source/historical/rate.rb", "lib/currency/exchange/rate/source/historical/rate_loader.rb", "lib/currency/exchange/rate/source/historical/writer.rb", "lib/currency/exchange/rate/source/historical.rb", "lib/currency/exchange/rate/source/new_york_fed.rb", "lib/currency/exchange/rate/source/provider.rb", "lib/currency/exchange/rate/source/test.rb", "lib/currency/exchange/rate/source/the_financials.rb", "lib/currency/exchange/rate/source/timed_cache.rb", "lib/currency/exchange/rate/source/xe.rb", "lib/currency/exchange/rate/source.rb", "lib/currency/exchange/rate.rb", "lib/currency/exchange/time_quantitizer.rb", "lib/currency/exchange.rb", "lib/currency/formatter.rb", "lib/currency/macro.rb", "lib/currency/money.rb", "lib/currency/money_helper.rb", "lib/currency/parser.rb", "lib/currency.rb", "LICENSE.txt", "Manifest.txt", "README.txt", "Releases.txt", "spec/
|
11
|
+
s.files = ["COPYING.txt", "currency.gemspec", "examples/ex1.rb", "examples/xe1.rb", "lib/currency/active_record.rb", "lib/currency/config.rb", "lib/currency/core_extensions.rb", "lib/currency/currency/factory.rb", "lib/currency/currency.rb", "lib/currency/currency_version.rb", "lib/currency/exception.rb", "lib/currency/exchange/rate/deriver.rb", "lib/currency/exchange/rate/source/base.rb", "lib/currency/exchange/rate/source/failover.rb", "lib/currency/exchange/rate/source/federal_reserve.rb", "lib/currency/exchange/rate/source/historical/rate.rb", "lib/currency/exchange/rate/source/historical/rate_loader.rb", "lib/currency/exchange/rate/source/historical/writer.rb", "lib/currency/exchange/rate/source/historical.rb", "lib/currency/exchange/rate/source/new_york_fed.rb", "lib/currency/exchange/rate/source/provider.rb", "lib/currency/exchange/rate/source/test.rb", "lib/currency/exchange/rate/source/the_financials.rb", "lib/currency/exchange/rate/source/timed_cache.rb", "lib/currency/exchange/rate/source/xe.rb", "lib/currency/exchange/rate/source.rb", "lib/currency/exchange/rate.rb", "lib/currency/exchange/time_quantitizer.rb", "lib/currency/exchange.rb", "lib/currency/formatter.rb", "lib/currency/macro.rb", "lib/currency/money.rb", "lib/currency/money_helper.rb", "lib/currency/parser.rb", "lib/currency.rb", "LICENSE.txt", "Manifest.txt", "README.txt", "Releases.txt", "spec/ar_spec_helper.rb", "spec/ar_column_spec.rb", "spec/ar_core_spec.rb", "spec/ar_simple_spec.rb", "spec/config_spec.rb", "spec/federal_reserve_spec.rb", "spec/formatter_spec.rb", "spec/historical_writer_spec.rb", "spec/macro_spec.rb", "spec/money_spec.rb", "spec/new_york_fed_spec.rb", "spec/parser_spec.rb", "spec/spec_helper.rb", "spec/time_quantitizer_spec.rb", "spec/timed_cache_spec.rb", "spec/xe_spec.rb", "TODO.txt"]
|
12
12
|
s.has_rdoc = true
|
13
13
|
s.homepage = %q{http://currency.rubyforge.org/}
|
14
14
|
s.rdoc_options = ["--main", "README.txt"]
|
15
15
|
s.require_paths = ["lib"]
|
16
16
|
s.rubygems_version = %q{1.2.0}
|
17
|
-
s.summary = %q{currency 0.5.
|
17
|
+
s.summary = %q{currency 0.5.1}
|
18
18
|
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# Copyright (C) 2006-2007 Kurt Stephens <ruby-currency(at)umleta.com>
|
2
|
+
# Copyright (C) 2008 Asa Wilson <acvwilson(at)gmail.com>
|
3
|
+
# See LICENSE.txt for details.
|
4
|
+
|
5
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
6
|
+
|
7
|
+
require 'active_record'
|
8
|
+
require 'active_record/migration'
|
9
|
+
require File.dirname(__FILE__) + '/../lib/currency/active_record'
|
10
|
+
|
11
|
+
AR_M = ActiveRecord::Migration
|
12
|
+
AR_B = ActiveRecord::Base
|
13
|
+
|
14
|
+
def ar_setup
|
15
|
+
AR_B.establish_connection(database_spec)
|
16
|
+
|
17
|
+
# Subclasses can override this.
|
18
|
+
@currency_test_migration ||= nil
|
19
|
+
@currency_test ||= nil
|
20
|
+
|
21
|
+
# schema_down
|
22
|
+
|
23
|
+
schema_up
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def database_spec
|
28
|
+
# TODO: Get from ../config/database.yml:test
|
29
|
+
# Create test database on:
|
30
|
+
|
31
|
+
# MYSQL:
|
32
|
+
#
|
33
|
+
# sudo mysqladmin create test;
|
34
|
+
# sudo mysql
|
35
|
+
# grant all on test.* to test@localhost identified by 'test';
|
36
|
+
# flush privileges;
|
37
|
+
|
38
|
+
# POSTGRES:
|
39
|
+
#
|
40
|
+
# CREATE USER test PASSWORD 'test';
|
41
|
+
# CREATE DATABASE test WITH OWNER = test;
|
42
|
+
#
|
43
|
+
|
44
|
+
# @database_spec = {
|
45
|
+
# :adapter => ENV['TEST_DB_ADAPTER'] || 'mysql',
|
46
|
+
# :host => ENV['TEST_DB_HOST'] || 'localhost',
|
47
|
+
# :username => ENV['TEST_DB_USER'] || 'test',
|
48
|
+
# :password => ENV['TEST_DB_PASS'] || 'test',
|
49
|
+
# :database => ENV['TEST_DB_TEST'] || 'test'
|
50
|
+
# }
|
51
|
+
|
52
|
+
@database_spec = {
|
53
|
+
:adapter => ENV['TEST_DB_ADAPTER'] || 'mysql',
|
54
|
+
:host => ENV['TEST_DB_HOST'] || 'localhost',
|
55
|
+
:username => ENV['TEST_DB_USER'] || 'root',
|
56
|
+
:password => ENV['TEST_DB_PASS'] || '',
|
57
|
+
:database => ENV['TEST_DB_TEST'] || 'currency_gem_test'
|
58
|
+
}
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
def schema_up
|
63
|
+
return unless @currency_test_migration
|
64
|
+
begin
|
65
|
+
@currency_test_migration.migrate(:up)
|
66
|
+
rescue Object =>e
|
67
|
+
$stderr.puts "Warning: #{e}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def schema_down
|
72
|
+
return unless @currency_test_migration
|
73
|
+
begin
|
74
|
+
@currency_test_migration.migrate(:down)
|
75
|
+
rescue Object => e
|
76
|
+
$stderr.puts "Warning: #{e}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
##################################################
|
81
|
+
# Scaffold
|
82
|
+
#
|
83
|
+
|
84
|
+
def insert_records
|
85
|
+
delete_records
|
86
|
+
|
87
|
+
@currency_test.reset_column_information
|
88
|
+
|
89
|
+
@usd = @currency_test.new(:name => '#1: USD', :amount => Currency::Money.new("12.34", :USD))
|
90
|
+
@usd.save
|
91
|
+
|
92
|
+
@cad = @currency_test.new(:name => '#2: CAD', :amount => Currency::Money.new("56.78", :CAD))
|
93
|
+
@cad.save
|
94
|
+
end
|
95
|
+
|
96
|
+
def delete_records
|
97
|
+
@currency_test.destroy_all
|
98
|
+
end
|
99
|
+
|
100
|
+
##################################################
|
101
|
+
|
102
|
+
def assert_equal_money(a,b)
|
103
|
+
a.should_not be_nil
|
104
|
+
b.should_not be_nil
|
105
|
+
# Make sure a and b are not the same object.
|
106
|
+
b.object_id.should_not == a.object_id
|
107
|
+
b.id.should == a.id
|
108
|
+
a.amount.should.not == nil
|
109
|
+
a.amount.should be_kind_of(Money)
|
110
|
+
b.amount.should.not == nil
|
111
|
+
b.amount.should be_kind_of(Money)
|
112
|
+
# Make sure that what gets stored in the database comes back out
|
113
|
+
# when converted back to the original currency.
|
114
|
+
b.amount.rep.should == a.amount.convert(b.amount.currency).rep
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
def assert_equal_currency(a,b)
|
119
|
+
assert_equal_money a, b
|
120
|
+
|
121
|
+
b.amount.rep.should == a.amount.rep
|
122
|
+
b.amount.currency.should == a.amount.currency
|
123
|
+
b.amount.currency.code.should == a.amount.currency.code
|
124
|
+
|
125
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acvwilson-currency
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Asa Wilson
|
@@ -68,7 +68,7 @@ files:
|
|
68
68
|
- Manifest.txt
|
69
69
|
- README.txt
|
70
70
|
- Releases.txt
|
71
|
-
- spec/
|
71
|
+
- spec/ar_spec_helper.rb
|
72
72
|
- spec/ar_column_spec.rb
|
73
73
|
- spec/ar_core_spec.rb
|
74
74
|
- spec/ar_simple_spec.rb
|
@@ -112,6 +112,6 @@ rubyforge_project:
|
|
112
112
|
rubygems_version: 1.2.0
|
113
113
|
signing_key:
|
114
114
|
specification_version: 2
|
115
|
-
summary: currency 0.5.
|
115
|
+
summary: currency 0.5.1
|
116
116
|
test_files: []
|
117
117
|
|