currency 0.1.0
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.tar.gz.sig +1 -0
- data/ChangeLog +5 -0
- data/README +33 -0
- data/Rakefile +349 -0
- data/Releases +6 -0
- data/TODO +0 -0
- data/examples/ex1.rb +13 -0
- data/examples/xe1.rb +19 -0
- data/lib/currency.rb +13 -0
- data/lib/currency/active_record.rb +70 -0
- data/lib/currency/core_extensions.rb +25 -0
- data/lib/currency/currency.rb +203 -0
- data/lib/currency/currency_exchange.rb +50 -0
- data/lib/currency/currency_exchange_test.rb +27 -0
- data/lib/currency/currency_exchange_xe.rb +140 -0
- data/lib/currency/currency_factory.rb +73 -0
- data/lib/currency/currency_version.rb +6 -0
- data/lib/currency/exception.rb +10 -0
- data/lib/currency/exchange_rate.rb +47 -0
- data/lib/currency/money.rb +190 -0
- data/lib/currency/money_helper.rb +12 -0
- data/scripts/gemdoc.rb +62 -0
- data/test/money_test.rb +166 -0
- data/test/test_base.rb +31 -0
- data/test/xe_test.rb +33 -0
- metadata +90 -0
- metadata.gz.sig +0 -0
    
        data/test/test_base.rb
    ADDED
    
    | @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            # Base Test class
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'test/unit'
         | 
| 4 | 
            +
            require 'currency'
         | 
| 5 | 
            +
            require 'currency/currency_exchange_test'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module Currency
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            class TestBase < Test::Unit::TestCase
         | 
| 10 | 
            +
              def setup
         | 
| 11 | 
            +
                super
         | 
| 12 | 
            +
                # Force XE Exchange.
         | 
| 13 | 
            +
                CurrencyExchange.default = CurrencyExchangeTest.instance
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              # Avoid "No test were specified" error.
         | 
| 17 | 
            +
              def test_foo
         | 
| 18 | 
            +
                assert true
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              # Helpers.
         | 
| 22 | 
            +
              def assert_equal_float(x, y, eps = 1.0e-8)
         | 
| 23 | 
            +
                d = (x * eps).abs
         | 
| 24 | 
            +
                assert (x - d) <= y
         | 
| 25 | 
            +
                assert y <= (x + d)
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            end # class
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            end # module
         | 
| 31 | 
            +
             | 
    
        data/test/xe_test.rb
    ADDED
    
    | @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            # REAL
         | 
| 2 | 
            +
            #require File.dirname(__FILE__) + '/../test_helper'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require 'test/test_base'
         | 
| 5 | 
            +
            require 'currency' # For :type => :money
         | 
| 6 | 
            +
            require 'currency/currency_exchange_xe'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            module Currency
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            class XeTest < TestBase
         | 
| 11 | 
            +
              def setup
         | 
| 12 | 
            +
                super
         | 
| 13 | 
            +
                # Force XE Exchange.
         | 
| 14 | 
            +
                CurrencyExchange.default = CurrencyExchangeXe.instance
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              def test_xe_usd_cad
         | 
| 18 | 
            +
                assert_not_nil rates = CurrencyExchange.default.rates
         | 
| 19 | 
            +
                assert_not_nil rates[:USD]
         | 
| 20 | 
            +
                assert_not_nil usd_cad = rates[:USD][:CAD]
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                assert_not_nil usd = Money.new(123.45, :USD)
         | 
| 23 | 
            +
                assert_not_nil cad = usd.convert(:CAD)
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                assert_kind_of Numeric, m = (cad.rep.to_f / usd.rep.to_f)
         | 
| 26 | 
            +
                # $stderr.puts "m = #{m}"
         | 
| 27 | 
            +
                assert_equal_float usd_cad, m, 0.001
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            end # module
         | 
| 33 | 
            +
             | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,90 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            rubygems_version: 0.8.11
         | 
| 3 | 
            +
            specification_version: 1
         | 
| 4 | 
            +
            name: currency
         | 
| 5 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 6 | 
            +
              version: 0.1.0
         | 
| 7 | 
            +
            date: 2006-10-29 00:00:00 -04:00
         | 
| 8 | 
            +
            summary: Currency GEM
         | 
| 9 | 
            +
            require_paths: 
         | 
| 10 | 
            +
            - lib
         | 
| 11 | 
            +
            email: ruby-currency@umleta.com
         | 
| 12 | 
            +
            homepage: http://currency.rubyforge.org
         | 
| 13 | 
            +
            rubyforge_project: currency
         | 
| 14 | 
            +
            description: Currency models currencies, monetary values, foreign exchanges.
         | 
| 15 | 
            +
            autorequire: 
         | 
| 16 | 
            +
            default_executable: 
         | 
| 17 | 
            +
            bindir: bin
         | 
| 18 | 
            +
            has_rdoc: false
         | 
| 19 | 
            +
            required_ruby_version: !ruby/object:Gem::Version::Requirement 
         | 
| 20 | 
            +
              requirements: 
         | 
| 21 | 
            +
              - - ">"
         | 
| 22 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 23 | 
            +
                  version: 0.0.0
         | 
| 24 | 
            +
              version: 
         | 
| 25 | 
            +
            platform: ruby
         | 
| 26 | 
            +
            signing_key: 
         | 
| 27 | 
            +
            cert_chain: 
         | 
| 28 | 
            +
            - |
         | 
| 29 | 
            +
              -----BEGIN CERTIFICATE-----
         | 
| 30 | 
            +
              MIIDNDCCAhygAwIBAgIBADANBgkqhkiG9w0BAQUFADBAMREwDwYDVQQDDAhydWJ5
         | 
| 31 | 
            +
              Z2VtczEWMBQGCgmSJomT8ixkARkWBnVtbGV0YTETMBEGCgmSJomT8ixkARkWA2Nv
         | 
| 32 | 
            +
              bTAeFw0wNjEwMjkxMjQwMTFaFw0wNzEwMjkxMjQwMTFaMEAxETAPBgNVBAMMCHJ1
         | 
| 33 | 
            +
              YnlnZW1zMRYwFAYKCZImiZPyLGQBGRYGdW1sZXRhMRMwEQYKCZImiZPyLGQBGRYD
         | 
| 34 | 
            +
              Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuFJ/j1P9qdyQ0yDn
         | 
| 35 | 
            +
              M3a2D0OY/48fMtYnHRMBw77VVe1r0fh3K6mHQ4KMhokq+tYmpLZA6R7zDPyqgmq+
         | 
| 36 | 
            +
              MLIjgm3BG/4MRMwMDjQpAlMUzhivhEUbi/3TwDGzm0BKAwx1QZJGxX5hBuNT0IC4
         | 
| 37 | 
            +
              39UrfF6Rp3JYO2V3315VNhRnTzSy7mTywMvcdFDHtqJMwS7dxog3Zk0GEwFOpgSh
         | 
| 38 | 
            +
              YZWpRtxEyNkFZFhzu2f6Ay+W8KICTDoKZLXWuih7WLeZ+jjMmcuw+fMmAgK5twel
         | 
| 39 | 
            +
              NedBtKBIddWwFYdSWUY0aM8llCUSF2K0DlMCf5MIa/KU9SFCEvPFgyL0mhp7J4rM
         | 
| 40 | 
            +
              8iZvpQIDAQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU
         | 
| 41 | 
            +
              hF6+rNXLnYshcQYq5+OZ5ymAepMwDQYJKoZIhvcNAQEFBQADggEBAIQeOwoJ8119
         | 
| 42 | 
            +
              sq6gSomz4hlmn/UKChxhl2dvv3LaHO1n2O537+9rVs6rvUZ4kANaZVzsclptovsS
         | 
| 43 | 
            +
              k8H52y5nv4KXhd5IYVIin8q4rL15CYuRE/F2axWVtXBev1g24qyrIDOPhXNruG5q
         | 
| 44 | 
            +
              CCmbkyVneSonHVJ5/aEqCK3NHTzxV3uM9gWjUjX1QoKLMV3tIm3umPFxmcq45YPZ
         | 
| 45 | 
            +
              anMAtfW19iRYBV2iaage8GmLFbc8zl3GuTHYYHDKMVfOGRWgam36a95kXvkHI403
         | 
| 46 | 
            +
              lXIJO2glhnPbub1eX+KnUMK3iocqB1qAC3hCk3Qgul+Q9mrTPyuSrOPHJB4aU1wk
         | 
| 47 | 
            +
              +Wg1asFvX0E=
         | 
| 48 | 
            +
              -----END CERTIFICATE-----
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            authors: 
         | 
| 51 | 
            +
            - Kurt Stephens
         | 
| 52 | 
            +
            files: 
         | 
| 53 | 
            +
            - Rakefile
         | 
| 54 | 
            +
            - ChangeLog
         | 
| 55 | 
            +
            - Releases
         | 
| 56 | 
            +
            - TODO
         | 
| 57 | 
            +
            - README
         | 
| 58 | 
            +
            - examples/xe1.rb
         | 
| 59 | 
            +
            - examples/ex1.rb
         | 
| 60 | 
            +
            - lib/currency.rb
         | 
| 61 | 
            +
            - lib/currency/money_helper.rb
         | 
| 62 | 
            +
            - lib/currency/exception.rb
         | 
| 63 | 
            +
            - lib/currency/currency_version.rb
         | 
| 64 | 
            +
            - lib/currency/currency_factory.rb
         | 
| 65 | 
            +
            - lib/currency/core_extensions.rb
         | 
| 66 | 
            +
            - lib/currency/money.rb
         | 
| 67 | 
            +
            - lib/currency/active_record.rb
         | 
| 68 | 
            +
            - lib/currency/currency.rb
         | 
| 69 | 
            +
            - lib/currency/currency_exchange.rb
         | 
| 70 | 
            +
            - lib/currency/exchange_rate.rb
         | 
| 71 | 
            +
            - lib/currency/currency_exchange_test.rb
         | 
| 72 | 
            +
            - lib/currency/currency_exchange_xe.rb
         | 
| 73 | 
            +
            - scripts/gemdoc.rb
         | 
| 74 | 
            +
            - test/xe_test.rb
         | 
| 75 | 
            +
            - test/money_test.rb
         | 
| 76 | 
            +
            - test/test_base.rb
         | 
| 77 | 
            +
            test_files: []
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            rdoc_options: []
         | 
| 80 | 
            +
             | 
| 81 | 
            +
            extra_rdoc_files: []
         | 
| 82 | 
            +
             | 
| 83 | 
            +
            executables: []
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            extensions: []
         | 
| 86 | 
            +
             | 
| 87 | 
            +
            requirements: []
         | 
| 88 | 
            +
             | 
| 89 | 
            +
            dependencies: []
         | 
| 90 | 
            +
             | 
    
        metadata.gz.sig
    ADDED
    
    | Binary file |