Sha256: d67f7b3977fb9010478dc456e855753c415f38fcb924f3764cbdeca25f4a6e21

Contents?: true

Size: 671 Bytes

Versions: 16

Compression:

Stored size: 671 Bytes

Contents

require 'json'

class Money
  class Currency
    module Loader
      extend self

      CURRENCY_DATA_PATH = File.expand_path("../../../../config", __FILE__)

      def load_currencies
        currencies = {}
        currencies.merge! parse_currency_file("currency_historic.json")
        currencies.merge! parse_currency_file("currency_non_iso.json")
        currencies.merge! parse_currency_file("currency_iso.json")
      end

      private

      def parse_currency_file(filename)
        json = File.read("#{CURRENCY_DATA_PATH}/#{filename}")
        json.force_encoding(::Encoding::UTF_8) if defined?(::Encoding)
        JSON.parse(json)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
shopify-money-0.14.1 lib/money/currency/loader.rb
shopify-money-0.14.0 lib/money/currency/loader.rb
shopify-money-0.13.1 lib/money/currency/loader.rb
shopify-money-0.13.0 lib/money/currency/loader.rb
shopify-money-0.12.0 lib/money/currency/loader.rb
shopify-money-0.11.9 lib/money/currency/loader.rb
shopify-money-0.11.8 lib/money/currency/loader.rb
shopify-money-0.11.7 lib/money/currency/loader.rb
shopify-money-0.11.6 lib/money/currency/loader.rb
shopify-money-0.11.5 lib/money/currency/loader.rb
shopify-money-0.11.4 lib/money/currency/loader.rb
shopify-money-0.11.3 lib/money/currency/loader.rb
shopify-money-0.11.2 lib/money/currency/loader.rb
shopify-money-0.11.1 lib/money/currency/loader.rb
shopify-money-0.11.0 lib/money/currency/loader.rb
shopify-money-0.10.0 lib/money/currency/loader.rb