currency 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt ADDED
@@ -0,0 +1,25 @@
1
+ test/xe_test.rb
2
+ test/money_test.rb
3
+ test/test_base.rb
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
10
+ lib/currency/active_record.rb
11
+ lib/currency/currency.rb
12
+ lib/currency/exchange.rb
13
+ lib/currency/exchange/base.rb
14
+ lib/currency/exchange/test.rb
15
+ lib/currency/exchange/xe.rb
16
+ lib/currency/exchange/rate.rb
17
+ lib/currency.rb
18
+ examples/xe1.rb
19
+ examples/ex1.rb
20
+ ChangeLog
21
+ Rakefile
22
+ TODO
23
+ Releases
24
+ README
25
+ Manifest.txt
data/Rakefile CHANGED
@@ -4,324 +4,57 @@
4
4
 
5
5
  #################################################################
6
6
 
7
- PKG_Name = 'Currency'
8
- def package_version
9
- '0.1.1'
10
- end
11
- def package_description
12
- %{Currency models currencies, monetary values, foreign exchanges.}
13
- end
14
-
15
- #################################################################
16
-
17
- #require 'rubygems'
18
- require 'rake/clean'
19
- require 'rake/testtask'
20
- require 'rake/packagetask'
21
- require 'rake/gempackagetask'
22
- require 'rake/rdoctask'
7
+ require 'rubygems'
8
+ require 'hoe'
23
9
 
24
10
  #################################################################
25
11
 
26
- def announce(msg='')
27
- STDERR.puts msg
28
- end
29
-
12
+ PKG_Name = 'Currency'
30
13
  PKG_NAME = PKG_Name.gsub(/[a-z][A-Z]/) {|x| "#{x[0,1]}_#{x[1,1]}"}.downcase
31
- RUBY_FORGE_PROJECT = PKG_NAME
32
-
33
- if ENV['REL']
34
- PKG_VERSION = ENV['REL']
35
- CURRENT_VERSION = package_version
36
- else
37
- PKG_VERSION = package_version
38
- CURRENT_VERSION = PKG_VERSION
39
- end
40
-
41
- CLEAN.include("COMMENTS")
42
- CLOBBER.include(
43
- "test/data",
44
- "test/temp",
45
- 'scripts/*.hieraki',
46
- 'data__',
47
- 'html',
48
- 'pkgs/sources/sources*.gem',
49
- '.config',
50
- '**/debug.log',
51
- '**/development.log',
52
- 'logs'
53
- )
54
-
55
- task :default => [:test]
56
-
57
- Rake::TestTask.new(:test) do |t|
58
- t.test_files = FileList['test/*test*.rb']
59
- end
60
-
61
- Rake::TestTask.new(:functional) do |t|
62
- t.test_files = FileList['test/functional*.rb']
63
- end
64
-
65
- Rake::TestTask.new(:alltests) do |t|
66
- t.test_files = FileList['test/{*test,functional}*.rb']
67
- end
68
14
 
69
- desc "Run the tests for a build"
70
- task :build_tests do
71
- html_dir = ENV['TESTRESULTS'] || 'html/tests'
72
- ruby %{-Ilib scripts/buildtests.rb #{html_dir}}
73
- open("#{html_dir}/summary.html") do |inf|
74
- open("#{html_dir}/summary.new", "w") do |outf|
75
- inf.each do |line|
76
- if line =~ /td align/
77
- line = " <td align=\"left\">#{Time.now}</td><td align=\"right\">"
78
- end
79
- outf.puts line
80
- end
81
- end
82
- end
83
- mv "#{html_dir}/summary.html", "#{html_dir}/summary.old"
84
- mv "#{html_dir}/summary.new", "#{html_dir}/summary.html"
85
- end
86
-
87
- # Shortcuts for test targets
88
- task :tf => [:functional]
89
- task :tu => [:test]
90
- task :ta => [:alltests]
91
-
92
- task :gemtest do
93
- ruby %{-Ilib -rscripts/runtest -e 'run_tests("test/test_gempaths.rb", true)'}
94
- end
95
-
96
- # --------------------------------------------------------------------
97
- # Creating a release
98
-
99
- desc "Make a new release"
100
- task :release => [
101
- :prerelease,
102
- :clobber,
103
- :alltests,
104
- :update_version,
105
- :package,
106
- :tag] do
15
+ hoe = Hoe.new("currency", '0.1.2') do |p|
16
+ p.author = 'Kurt Stephens'
17
+ p.description = %{Currency models currencies, monetary values, foreign exchanges.}
18
+ p.email = "ruby-#{PKG_NAME}@umleta.com"
19
+ p.summary = p.description
20
+ p.url = "http://rubyforge.org/projects/#{PKG_NAME}"
107
21
 
108
- announce
109
- announce "**************************************************************"
110
- announce "* Release #{PKG_VERSION} Complete."
111
- announce "* Packages ready to upload."
112
- announce "**************************************************************"
113
- announce
22
+ p.test_globs = ['test/**/*.rb']
114
23
  end
115
24
 
116
- # Validate that everything is ready to go for a release.
117
- task :prerelease do
118
- announce
119
- announce "**************************************************************"
120
- announce "* Making #{PKG_Name} Release #{PKG_VERSION}"
121
- announce "* (current version #{CURRENT_VERSION})"
122
- announce "**************************************************************"
123
- announce
25
+ PKG_VERSION = hoe.version
124
26
 
125
- # Is a release number supplied?
126
- unless ENV['REL']
127
- fail "Usage: rake release REL=x.y.z [REUSE=tag_suffix]"
128
- end
129
-
130
- # Is the release different than the current release.
131
- # (or is REUSE set?)
132
- if PKG_VERSION == CURRENT_VERSION && ! ENV['REUSE']
133
- fail "Current version is #{PKG_VERSION}, must specify REUSE=tag_suffix to reuse version"
134
- end
27
+ #################################################################
28
+ # Version file
29
+ #
135
30
 
136
- # Are all source files checked in?
137
- if ENV['RELTEST']
138
- announce "Release Task Testing, skipping checked-in file test"
139
- else
140
- announce "Checking for unchecked-in files..."
141
- data = `svn status`
142
- unless data =~ /^$/
143
- fail "svn status is not clean ... do you have unchecked-in files?"
144
- end
145
- announce "No outstanding checkins found ... OK"
146
- end
31
+ def announce(msg='')
32
+ STDERR.puts msg
147
33
  end
148
34
 
149
- task :update_version => [:prerelease] do
150
- if PKG_VERSION == CURRENT_VERSION && ! ENV['FORCE']
151
- announce "No version change ... skipping version update"
152
- else
153
- announce "Updating #{PKG_Name} version to #{PKG_VERSION}"
154
- version_rb = "lib/#{PKG_NAME}/#{PKG_NAME}_version.rb"
155
- open(version_rb, "w") do |f|
156
- f.puts "# DO NOT EDIT"
157
- f.puts "# This file is auto-generated by build scripts."
158
- f.puts "# See: rake update_version"
159
- f.puts "module #{PKG_Name}"
160
- f.puts " #{PKG_Name}Version = '#{PKG_VERSION}'"
161
- f.puts "end"
162
- end
163
- if ENV['RELTEST']
164
- announce "Release Task Testing, skipping commiting of new version"
165
- else
166
- sh %{svn commit -m "Updated to version #{PKG_VERSION}" #{version_rb}}
167
- end
168
- end
169
- end
35
+ version_rb = "lib/#{PKG_NAME}/#{PKG_NAME}_version.rb"
170
36
 
171
- # FIX ME for SVN
172
- task :tag => [:prerelease] do
173
- reltag = "REL_#{PKG_VERSION.gsub(/\./, '_')}"
174
- reltag << ENV['REUSE'].gsub(/\./, '_') if ENV['REUSE']
175
- announce "Tagging repo with [#{reltag}]"
37
+ task :update_version => 'Rakefile' do
38
+ announce "Updating #{PKG_Name} version to #{PKG_VERSION}: #{version_rb}"
39
+ open(version_rb, "w") do |f|
40
+ f.puts "# DO NOT EDIT"
41
+ f.puts "# This file is auto-generated by build scripts."
42
+ f.puts "# See: rake update_version"
43
+ f.puts "module #{PKG_Name}"
44
+ f.puts " #{PKG_Name}Version = '#{PKG_VERSION}'"
45
+ f.puts "end"
46
+ end
176
47
  if ENV['RELTEST']
177
- announce "Release Task Testing, skipping repo tagging"
48
+ announce "Release Task Testing, skipping commiting of new version"
178
49
  else
179
- sh %{echo cvs tag #{reltag}}
50
+ sh %{svn commit -m "Updated to version #{PKG_VERSION}" #{version_rb}}
180
51
  end
181
52
  end
182
53
 
183
- # --------------------------------------------------------------------
184
- # Create a task to build the RDOC documentation tree.
185
-
186
- desc "Create the RDOC html files"
187
- rd = Rake::RDocTask.new("rdoc") { |rdoc|
188
- rdoc.rdoc_dir = 'html'
189
- rdoc.title = "#{PKG_Name}"
190
- rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README'
191
- rdoc.rdoc_files.include('README', 'TODO', 'Releases')
192
- rdoc.rdoc_files.include('lib/**/*.rb')
193
- # rdoc.rdoc_files.include('test/**/*.rb')
194
- }
195
-
196
- file "html/index.html" => [:rdoc]
197
-
198
- desc "Publish the RDOCs on RubyForge"
199
- task :publish_rdoc => ["html/index.html"] do
200
- # NOTE: This task assumes that you have an SSH alias setup for rubyforge.
201
- mkdir_p "emptydir"
202
- sh "scp -rq emptydir rubyforge:/var/www/gforge-projects/#{RUBY_FORGE_PROJECT}/rdoc"
203
- sh "scp -rq html/* rubyforge:/var/www/gforge-projects/#{RUBY_FORGE_PROJECT}/rdoc"
204
- rm_r "emptydir"
205
- end
206
-
207
- # Wiki Doc Targets
208
-
209
- desc "Upload the Hieraki Data"
210
- task :upload => [:upload_gemdoc]
211
-
212
- task :upload_gemdoc => ['scripts/gemdoc.hieraki'] do
213
- ruby %{scripts/upload_gemdoc.rb}
214
- end
215
-
216
- desc "Build the Hieraki documentation"
217
- task :hieraki => ['scripts/gemdoc.hieraki', 'scripts/specdoc.hieraki']
218
-
219
- file 'scripts/gemdoc.hieraki' => ['scripts/gemdoc.rb', 'scripts/gemdoc.data'] do
220
- chdir('scripts') do
221
- ruby %{-I../lib gemdoc.rb <gemdoc.data >gemdoc.hieraki}
222
- end
223
- end
224
-
225
- file 'scripts/specdoc.hieraki' =>
226
- ['scripts/specdoc.rb', 'scripts/specdoc.data', 'scripts/specdoc.yaml'] do
227
- chdir('scripts') do
228
- ruby %{-I../lib specdoc.rb >specdoc.hieraki}
229
- end
230
- end
54
+ task version_rb => :update_version
231
55
 
232
- # Package tasks
56
+ # task :test => :update_version
233
57
 
234
- PKG_FILES = FileList[
235
- "Rakefile", "ChangeLog", "Releases", "TODO", "README",
236
- # "setup.rb",
237
- # "post-install.rb",
238
- "bin/*",
239
- "doc/*.css", "doc/*.rb",
240
- "examples/**/*",
241
- # "gemspecs/**/*",
242
- "lib/**/*.rb",
243
- # "pkgs/**/*",
244
- "redist/*.gem",
245
- "scripts/*.rb",
246
- "test/**/*"
247
- ]
248
- PKG_FILES.exclude(%r(^(test/temp|examples/.*/*.log)(/|$)))
249
-
250
- Rake::PackageTask.new("package") do |p|
251
- p.name = PKG_NAME
252
- p.version = PKG_VERSION
253
- p.need_tar = true
254
- p.need_zip = true
255
- p.package_files = PKG_FILES
256
- end
257
-
258
- Spec = Gem::Specification.new do |s|
259
- s.name = PKG_NAME
260
- s.version = PKG_VERSION
261
- s.summary = "#{PKG_Name} GEM"
262
- s.description = package_description
263
- s.files = PKG_FILES.to_a
264
- s.require_path = 'lib'
265
- s.author = "Kurt Stephens"
266
- s.email = "ruby-#{PKG_NAME}@umleta.com"
267
- s.homepage = "http://#{PKG_NAME}.rubyforge.org"
268
- s.rubyforge_project = "#{RUBY_FORGE_PROJECT}"
269
- #s.bindir = "bin" # Use these for applications.
270
- #s.executables = ["update_rubygems"]
271
- certdir = ENV['CERT_DIR']
272
- if certdir
273
- s.signing_key = File.join(certdir, 'gem-umleta-private_key.pem')
274
- s.cert_chain = [File.join(certdir, 'gem-umleta-public_cert.pem')]
275
- end
276
- end
277
-
278
- # Add console output about signing the Gem
279
- file "pkg/#{Spec.full_name}.gem" do
280
- puts "Signed with certificates in '#{ENV['CERT_DIR']}'" if ENV['CERT_DIR']
281
- end
282
-
283
- Rake::GemPackageTask.new(Spec) do |p| end
284
-
285
- GEMSPEC = "pkg/#{PKG_NAME}.gemspec"
286
- desc "Build the Gem spec file for the #{PKG_NAME} package"
287
- task :gemspec => GEMSPEC
288
- file "pkg/#{PKG_NAME}.gemspec" => ["pkg", "Rakefile"] do |t|
289
- open(t.name, "w") do |f| f.puts Spec.to_yaml end
290
- end
291
-
292
- # Automated upload to rubyforge.org
293
- PACKAGE_FILES = FileList["pkg/#{PKG_NAME}-#{PKG_VERSION}.*"]
294
- task :upload_package do
295
- # From activesuport/Rakefile,
296
- # See: http://dev.rubyonrails.org/svn/rails/tags/rel_1-1-6/activesupport/Rakefile
297
- `rubyforge login`
298
-
299
- files = PACKAGE_FILES
300
- files.each do |filename|
301
- basename = File.basename(filename)
302
- puts "Releasing #{basename}..."
303
-
304
- release_command = "rubyforge add_release #{RUBY_FORGE_PROJECT} #{RUBY_FORGE_PROJECT} 'REL #{PKG_VERSION}' #{filename}"
305
- puts release_command
306
- system(release_command)
307
- end
308
- end
309
-
310
-
311
- desc "Install #{PKG_Name}"
312
- task :install do
313
- ruby 'install.rb'
314
- end
315
-
316
- # Run 'gem' (using local bin and lib directories).
317
- # e.g.
318
- # rake rungem -- install -r blahblah --test
319
-
320
- desc "Run local 'gem'"
321
- task :rungem do
322
- ARGV.shift
323
- exec "ruby -Ilib bin/gem #{ARGV.join(' ')}"
324
- end
325
58
 
326
59
  # Misc Tasks ---------------------------------------------------------
327
60
 
data/Releases CHANGED
@@ -1,5 +1,9 @@
1
1
  = Currency Release History
2
2
 
3
+ == Release 0.1.2: 2006/10/30
4
+
5
+ * Rakefile now uses Hoe
6
+
3
7
  == Release 0.1.1: 2006/10/30
4
8
 
5
9
  * Fixes gem packaging errors.
data/lib/currency.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # -*- ruby -*-
1
2
 
2
3
  $:.unshift(File.dirname(__FILE__)) unless
3
4
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
@@ -10,3 +11,59 @@ require 'currency/money'
10
11
  require 'currency/exchange'
11
12
  require 'currency/core_extensions'
12
13
 
14
+ # The Currency package provides an object-oriented model of:
15
+ #
16
+ # * currencies
17
+ # * exchanges
18
+ # * exchange rates
19
+ # * monetary values
20
+ #
21
+ # The core classes are:
22
+ #
23
+ # * Currency::Money - uses a scaled integer representation of a monetary value and performs accurate conversions to and from string values.
24
+ # * Currency::Currency - provides an object-oriented representation of a currency.
25
+ # * Currency::Exchange::Base - the base class for a "currency exchange rate" provider.
26
+ # * Currency::Exchange::Rate - represents a exchange rate between two currencies.
27
+ #
28
+ # Below is a basic example:
29
+ #
30
+ # require 'currency'
31
+ # require 'currency/exchange/xe'
32
+ #
33
+ # usd = Currency::Money('6.78', :USD)
34
+ # puts "usd = #{usd.format}"
35
+ # cad = usd.convert(:CAD)
36
+ # puts "cad = #{cad.format}"
37
+ #
38
+ # The example above uses Currency::Exchange::Xe automatically get exchange rates from http://xe.com/.
39
+ #
40
+ # == ActiveRecord Suppport
41
+ #
42
+ # This package also contains ActiveRecord support for money values:
43
+ #
44
+ # require 'currency'
45
+ # require 'currency/active_record'
46
+ #
47
+ # class Entry < ActiveRecord::Base
48
+ # money :amount
49
+ # end
50
+ #
51
+ # In the example above, the entries.amount database column is an INTEGER that represents US cents.
52
+ # The currency code of the money value can be stored in an additional database column or a default currency can be used.
53
+ #
54
+ # == Future Enhancements
55
+ #
56
+ # * storage and retrival of historical exchange rates
57
+ # * exchange rate polling for population of historical rates
58
+ # * support for inflationary rates within a currency, e.g. $10 USD in the year 1955 in 2006 USD.
59
+ #
60
+ # == SVN Repo
61
+ #
62
+ # svn checkout svn://rubyforge.org/var/svn/currency/currency/trunk
63
+ #
64
+ # == Examples
65
+ #
66
+ # * The "test programs":http://rubyforge.org/cgi-bin/viewvc.cgi/currency/trunk/examples?root=currency
67
+ # * The "test cases":http://rubyforge.org/cgi-bin/viewvc.cgi/currency/trunk/test/?root=currency
68
+ #
69
+
@@ -2,5 +2,5 @@
2
2
  # This file is auto-generated by build scripts.
3
3
  # See: rake update_version
4
4
  module Currency
5
- CurrencyVersion = '0.1.0'
5
+ CurrencyVersion = '0.1.2'
6
6
  end
metadata CHANGED
@@ -3,19 +3,20 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: currency
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.1
6
+ version: 0.1.2
7
7
  date: 2006-10-30 00:00:00 -05:00
8
- summary: Currency GEM
8
+ summary: Currency models currencies, monetary values, foreign exchanges.
9
9
  require_paths:
10
10
  - lib
11
+ - test
11
12
  email: ruby-currency@umleta.com
12
- homepage: http://currency.rubyforge.org
13
+ homepage: http://rubyforge.org/projects/currency
13
14
  rubyforge_project: currency
14
15
  description: Currency models currencies, monetary values, foreign exchanges.
15
16
  autorequire:
16
17
  default_executable:
17
18
  bindir: bin
18
- has_rdoc: false
19
+ has_rdoc: true
19
20
  required_ruby_version: !ruby/object:Gem::Version::Requirement
20
21
  requirements:
21
22
  - - ">"
@@ -28,14 +29,9 @@ cert_chain:
28
29
  authors:
29
30
  - Kurt Stephens
30
31
  files:
31
- - Rakefile
32
- - ChangeLog
33
- - Releases
34
- - TODO
35
- - README
36
- - examples/xe1.rb
37
- - examples/ex1.rb
38
- - lib/currency.rb
32
+ - test/xe_test.rb
33
+ - test/money_test.rb
34
+ - test/test_base.rb
39
35
  - lib/currency/money_helper.rb
40
36
  - lib/currency/exception.rb
41
37
  - lib/currency/currency_version.rb
@@ -49,10 +45,15 @@ files:
49
45
  - lib/currency/exchange/test.rb
50
46
  - lib/currency/exchange/xe.rb
51
47
  - lib/currency/exchange/rate.rb
52
- - scripts/gemdoc.rb
53
- - test/xe_test.rb
54
- - test/money_test.rb
55
- - test/test_base.rb
48
+ - lib/currency.rb
49
+ - examples/xe1.rb
50
+ - examples/ex1.rb
51
+ - ChangeLog
52
+ - Rakefile
53
+ - TODO
54
+ - Releases
55
+ - README
56
+ - Manifest.txt
56
57
  test_files: []
57
58
 
58
59
  rdoc_options: []
@@ -65,5 +66,13 @@ extensions: []
65
66
 
66
67
  requirements: []
67
68
 
68
- dependencies: []
69
-
69
+ dependencies:
70
+ - !ruby/object:Gem::Dependency
71
+ name: hoe
72
+ version_requirement:
73
+ version_requirements: !ruby/object:Gem::Version::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: 1.1.2
78
+ version:
data/scripts/gemdoc.rb DELETED
@@ -1,62 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'rubygems'
4
- Gem.manage_gems
5
- require 'rubygems/user_interaction'
6
-
7
- include Gem::DefaultUserInteraction
8
-
9
- $gm = Gem::CommandManager.instance
10
-
11
- class CaptureSay
12
- attr_reader :string
13
- def initialize
14
- @string = ''
15
- end
16
- def say(msg)
17
- @string << msg << "\n"
18
- end
19
- end
20
-
21
- def pre(cmd, opts)
22
- puts "<pre>"
23
- cmd.invoke opts
24
- puts "</pre>"
25
- end
26
-
27
- def table_of_contents
28
- cs = CaptureSay.new
29
- use_ui(cs) do
30
- $gm['help'].invoke 'commands'
31
- end
32
- # We're only interested in the lines that actually describe a command.
33
- out = cs.string.grep(/^\s+(\w+)\s+(.*)$/).join("\n")
34
- # Add a link to the relevant section in the margin.
35
- out.gsub(/^\s+(\w+)/) {
36
- cmd_name = $1
37
- " [http://currency.rubyforge.org/wiki/wiki.pl?CurrencyReference##{cmd_name} -] #{cmd_name}"
38
- }
39
- end
40
-
41
- while line = gets
42
- if line =~ /^!/
43
- cmd, arg = line.split
44
- case cmd
45
- when "!usage"
46
- begin
47
- cmdobj = $gm[arg]
48
- pre(cmdobj, "--help")
49
- rescue NoMethodError
50
- puts "Usage of command #{arg} failed"
51
- end
52
- when "!toc"
53
- puts table_of_contents()
54
- when "!toc-link"
55
- puts "\"Table of Contents\":http://currency.rubyforge.org/read/chapter/10#toc"
56
- when "!version"
57
- puts Gem::RubyGemsPackageVersion
58
- end
59
- else
60
- puts line
61
- end
62
- end