eu_central_bank 1.5.0 → 1.6.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.
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: f8305b19d4e97311f612dff41676d21546bde2ee5bdf34ca0a11b329681f8cc1
         | 
| 4 | 
            +
              data.tar.gz: 272e8a8bc25af1aca904743b5336865bb40725874a60161fe700c49ebff5e6e3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 43df545b3f015459fd1a10065e4989afe35ab57f0dcc34c989dcf008de739e82887223d1c4fe5d995203b612f33f2ec30c3e252f6d8585f7299484c59bd0117a
         | 
| 7 | 
            +
              data.tar.gz: 511ed0225001148ee8cc84a3a0e9c7d7a6f31663399a762ee98ed5a254589e791320959ef44fde7950949c8cf1274a0310d31b6963f8256cda7352f53cbd08e4
         | 
    
        data/lib/eu_central_bank.rb
    CHANGED
    
    | @@ -36,7 +36,7 @@ class EuCentralBank < Money::Bank::VariableExchange | |
| 36 36 | 
             
              def save_rates(cache, url=ECB_RATES_URL)
         | 
| 37 37 | 
             
                raise InvalidCache unless cache
         | 
| 38 38 | 
             
                File.open(cache, "w") do |file|
         | 
| 39 | 
            -
                  io =  | 
| 39 | 
            +
                  io = open_url(url);
         | 
| 40 40 | 
             
                  io.each_line { |line| file.puts line }
         | 
| 41 41 | 
             
                end
         | 
| 42 42 | 
             
              end
         | 
| @@ -46,7 +46,7 @@ class EuCentralBank < Money::Bank::VariableExchange | |
| 46 46 | 
             
              end
         | 
| 47 47 |  | 
| 48 48 | 
             
              def save_rates_to_s(url=ECB_RATES_URL)
         | 
| 49 | 
            -
                 | 
| 49 | 
            +
                open_url(url).read
         | 
| 50 50 | 
             
              end
         | 
| 51 51 |  | 
| 52 52 | 
             
              def exchange(cents, from_currency, to_currency, date=nil)
         | 
| @@ -164,9 +164,9 @@ class EuCentralBank < Money::Bank::VariableExchange | |
| 164 164 |  | 
| 165 165 | 
             
              def doc(cache, url=ECB_RATES_URL)
         | 
| 166 166 | 
             
                rates_source = !!cache ? cache : url
         | 
| 167 | 
            -
                Nokogiri::XML( | 
| 167 | 
            +
                Nokogiri::XML(open_url(rates_source)).tap { |doc| doc.xpath('gesmes:Envelope/xmlns:Cube/xmlns:Cube//xmlns:Cube') }
         | 
| 168 168 | 
             
              rescue Nokogiri::XML::XPath::SyntaxError
         | 
| 169 | 
            -
                Nokogiri::XML( | 
| 169 | 
            +
                Nokogiri::XML(open_url(url))
         | 
| 170 170 | 
             
              end
         | 
| 171 171 |  | 
| 172 172 | 
             
              def doc_from_s(content)
         | 
| @@ -218,4 +218,12 @@ class EuCentralBank < Money::Bank::VariableExchange | |
| 218 218 | 
             
                money = (decimal_money * from.cents * rate).round
         | 
| 219 219 | 
             
                Money.new(money, to_currency)
         | 
| 220 220 | 
             
              end
         | 
| 221 | 
            +
             | 
| 222 | 
            +
              def open_url(url)
         | 
| 223 | 
            +
                if RUBY_VERSION >= '2.5.0'
         | 
| 224 | 
            +
                  URI.open(url)
         | 
| 225 | 
            +
                else
         | 
| 226 | 
            +
                  open(url)
         | 
| 227 | 
            +
                end
         | 
| 228 | 
            +
              end
         | 
| 221 229 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: eu_central_bank
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.6.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Shane Emmons
         | 
| 8 | 
            -
            autorequire: | 
| 8 | 
            +
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2021-01-17 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: nokogiri
         | 
| @@ -75,7 +75,7 @@ homepage: https://github.com/RubyMoney/eu_central_bank | |
| 75 75 | 
             
            licenses:
         | 
| 76 76 | 
             
            - MIT
         | 
| 77 77 | 
             
            metadata: {}
         | 
| 78 | 
            -
            post_install_message: | 
| 78 | 
            +
            post_install_message:
         | 
| 79 79 | 
             
            rdoc_options: []
         | 
| 80 80 | 
             
            require_paths:
         | 
| 81 81 | 
             
            - lib
         | 
| @@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 91 91 | 
             
                  version: '0'
         | 
| 92 92 | 
             
            requirements: []
         | 
| 93 93 | 
             
            rubygems_version: 3.0.3
         | 
| 94 | 
            -
            signing_key: | 
| 94 | 
            +
            signing_key:
         | 
| 95 95 | 
             
            specification_version: 4
         | 
| 96 96 | 
             
            summary: Calculates exchange rates based on rates from european central bank. Money
         | 
| 97 97 | 
             
              gem compatible.
         |