more_money 0.0.6 → 0.0.7
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/Rakefile +15 -11
- data/lib/more_money/more_money.rb +13 -2
- data/lib/more_money/version.rb +1 -1
- data/test/more_money_test.rb +8 -0
- metadata +9 -17
data/Rakefile
CHANGED
@@ -11,24 +11,29 @@ require 'hoe'
|
|
11
11
|
include FileUtils
|
12
12
|
require File.join(File.dirname(__FILE__), 'lib', 'more_money', 'version')
|
13
13
|
|
14
|
-
AUTHOR = "
|
15
|
-
EMAIL = "
|
16
|
-
DESCRIPTION = "handles money objects using just integer as backend"
|
14
|
+
AUTHOR = "Paolo Negri" # can also be an array of Authors
|
15
|
+
EMAIL = "use rubyforge to contact"
|
16
|
+
DESCRIPTION = "handles money objects in any currency using just integer as backend"
|
17
17
|
GEM_NAME = "more_money" # what ppl will type to install your gem
|
18
18
|
RUBYFORGE_PROJECT = "moremoney" # The unix name for your project
|
19
19
|
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
20
|
-
RELEASE_TYPES = %w( gem ) # can use: gem, tar, zip
|
21
20
|
|
22
21
|
|
23
22
|
NAME = "more_money"
|
24
23
|
REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
25
24
|
VERS = ENV['VERSION'] || (MoreMoney::VERSION::STRING + (REV ? ".#{REV}" : ""))
|
26
|
-
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
26
|
+
RDOC_OPTS = ['--quiet', '--title', "more_money documentation",
|
27
|
+
"--opname", "index.html",
|
28
|
+
"--line-numbers",
|
29
|
+
"--main", "README",
|
30
|
+
"--inline-source"]
|
31
|
+
|
32
|
+
class Hoe
|
33
|
+
def extra_deps
|
34
|
+
@extra_deps.reject { |x| Array(x).first == 'hoe' }
|
35
|
+
end
|
36
|
+
end
|
32
37
|
|
33
38
|
# Generate all the Rake tasks
|
34
39
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
@@ -47,4 +52,3 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
47
52
|
#p.extra_deps - An array of rubygem dependencies.
|
48
53
|
#p.spec_extras - A hash of extra values to set in the gemspec.
|
49
54
|
end
|
50
|
-
|
@@ -22,13 +22,15 @@ module MoreMoney
|
|
22
22
|
end
|
23
23
|
|
24
24
|
#set the default currency
|
25
|
+
# MoreMoney::Money.default_currency = 'GBP'
|
26
|
+
#
|
25
27
|
def self.default_currency=(currency)
|
26
28
|
@default_currency = currency
|
27
29
|
end
|
28
30
|
|
29
31
|
#set the exchange rate from a currency to anothe one
|
30
32
|
#
|
31
|
-
# MoreMoney::Money.set_exchange_rate('USD', '
|
33
|
+
# MoreMoney::Money.set_exchange_rate('USD', 'GBP', 0.51)
|
32
34
|
#
|
33
35
|
#the rate can be specified as a callable object which will be called
|
34
36
|
#at the moment of the conversion
|
@@ -107,12 +109,21 @@ module MoreMoney
|
|
107
109
|
add_currency({:code => 'JPY', :symbol => '¥', :description => 'jp_yen'})
|
108
110
|
end
|
109
111
|
|
112
|
+
def self.check_currency(currency)
|
113
|
+
raise MoneyInvalidCurrency, "#{currency} is not defined as a currency" unless CURRENCIES.key?(currency)
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.curr_symbol(currency = Money.default_currency)
|
117
|
+
check_currency(currency)
|
118
|
+
CURRENCIES[currency][:symbol]
|
119
|
+
end
|
120
|
+
|
110
121
|
# Creates a new money object.
|
111
122
|
#
|
112
123
|
# Money.new(100)
|
113
124
|
#
|
114
125
|
def initialize(cents, currency = Money.default_currency)
|
115
|
-
|
126
|
+
self.class.check_currency(currency)
|
116
127
|
@currency = currency
|
117
128
|
@cents = cents.nil? ? nil : cents.round
|
118
129
|
end
|
data/lib/more_money/version.rb
CHANGED
data/test/more_money_test.rb
CHANGED
@@ -85,6 +85,12 @@ class MoreMoneyTest < Test::Unit::TestCase
|
|
85
85
|
assert_equal 'USD', c.currency
|
86
86
|
end
|
87
87
|
|
88
|
+
def test_symbol
|
89
|
+
assert_equal '$', Money.curr_symbol
|
90
|
+
assert_equal '£', Money.curr_symbol('GBP')
|
91
|
+
assert_raise(MoreMoney::MoneyInvalidCurrency) { Money.curr_symbol('LLL') }
|
92
|
+
end
|
93
|
+
|
88
94
|
def test_thousands
|
89
95
|
a = Money.us_dollar(100)
|
90
96
|
assert_equal "$ 1.00", a.format(:with_thousands)
|
@@ -99,6 +105,8 @@ class MoreMoneyTest < Test::Unit::TestCase
|
|
99
105
|
a = Money.us_dollar(100000000)
|
100
106
|
assert_equal "$ 1,000,000.00", a.format(:with_thousands)
|
101
107
|
assert_equal "$ 1,000,000", a.format(:with_thousands, :no_cents)
|
108
|
+
b = Money.gb_pound(100000000)
|
109
|
+
assert_equal "£ 1,000,000", b.format(:with_thousands, :no_cents)
|
102
110
|
end
|
103
111
|
|
104
112
|
def test_exchange
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.1
|
3
3
|
specification_version: 1
|
4
4
|
name: more_money
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2007-01-
|
8
|
-
summary: handles money objects using just integer as backend
|
6
|
+
version: 0.0.7
|
7
|
+
date: 2007-01-21 00:00:00 +00:00
|
8
|
+
summary: handles money objects in any currency using just integer as backend
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
|
-
email:
|
11
|
+
email: use rubyforge to contact
|
12
12
|
homepage: http://moremoney.rubyforge.org
|
13
13
|
rubyforge_project: moremoney
|
14
|
-
description: handles money objects using just integer as backend
|
14
|
+
description: handles money objects in any currency using just integer as backend
|
15
15
|
autorequire:
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
@@ -27,7 +27,7 @@ signing_key:
|
|
27
27
|
cert_chain:
|
28
28
|
post_install_message:
|
29
29
|
authors:
|
30
|
-
-
|
30
|
+
- Paolo Negri
|
31
31
|
files:
|
32
32
|
- Manifest.txt
|
33
33
|
- CHANGELOG.txt
|
@@ -53,13 +53,5 @@ extensions: []
|
|
53
53
|
|
54
54
|
requirements: []
|
55
55
|
|
56
|
-
dependencies:
|
57
|
-
|
58
|
-
name: hoe
|
59
|
-
version_requirement:
|
60
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
61
|
-
requirements:
|
62
|
-
- - ">="
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: 1.1.6
|
65
|
-
version:
|
56
|
+
dependencies: []
|
57
|
+
|