Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'pry', require: false
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rake/clean"
require "rspec/core/rake_task"
Expand Down
2 changes: 2 additions & 0 deletions lib/money.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "bigdecimal"
require "bigdecimal/util"
require "set"
Expand Down
2 changes: 2 additions & 0 deletions lib/money/bank/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Money
# Provides classes that aid in the ability of exchange one currency with
# another.
Expand Down
2 changes: 2 additions & 0 deletions lib/money/bank/single_currency.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'money/bank/base'

class Money
Expand Down
2 changes: 2 additions & 0 deletions lib/money/bank/variable_exchange.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'money/bank/base'
require 'money/rates_store/memory'
require 'json'
Expand Down
2 changes: 2 additions & 0 deletions lib/money/currency.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "json"
require "money/currency/loader"
require "money/currency/heuristics"
Expand Down
2 changes: 2 additions & 0 deletions lib/money/currency/heuristics.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Money
class Currency
module Heuristics
Expand Down
2 changes: 2 additions & 0 deletions lib/money/currency/loader.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Money
class Currency
module Loader
Expand Down
2 changes: 2 additions & 0 deletions lib/money/locale_backend/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'money/locale_backend/errors'

class Money
Expand Down
2 changes: 2 additions & 0 deletions lib/money/locale_backend/currency.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'money/locale_backend/base'

class Money
Expand Down
2 changes: 2 additions & 0 deletions lib/money/locale_backend/errors.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Money
module LocaleBackend
class NotSupported < StandardError; end
Expand Down
2 changes: 2 additions & 0 deletions lib/money/locale_backend/i18n.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'money/locale_backend/base'

class Money
Expand Down
2 changes: 2 additions & 0 deletions lib/money/locale_backend/legacy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'money/locale_backend/base'
require 'money/locale_backend/i18n'

Expand Down
2 changes: 2 additions & 0 deletions lib/money/money.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "money/bank/variable_exchange"
require "money/bank/single_currency"
require "money/money/arithmetic"
Expand Down
2 changes: 2 additions & 0 deletions lib/money/money/allocation.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Money
class Allocation
# Splits a given amount in parts. The allocation is based on the parts' proportions
Expand Down
2 changes: 2 additions & 0 deletions lib/money/money/arithmetic.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Money
module Arithmetic
# Wrapper for coerced numeric values to distinguish
Expand Down
2 changes: 2 additions & 0 deletions lib/money/money/constructors.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Money
module Constructors

Expand Down
22 changes: 13 additions & 9 deletions lib/money/money/formatter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'money/money/formatting_rules'

class Money
Expand Down Expand Up @@ -315,17 +317,19 @@ def append_sign(formatted_number)

def append_currency_symbol(formatted_number)
if rules[:with_currency]
formatted_number << " "
currency_part =
if rules[:html]
"<span class=\"currency\">#{currency}</span>"
elsif rules[:html_wrap]
html_wrap(currency.to_s, "currency")
else
currency.to_s
end

if rules[:html]
formatted_number << "<span class=\"currency\">#{currency.to_s}</span>"
elsif rules[:html_wrap]
formatted_number << html_wrap(currency.to_s, "currency")
else
formatted_number << currency.to_s
end
"#{formatted_number} #{currency_part}"
else
formatted_number
end
formatted_number
end

def show_free_text?
Expand Down
2 changes: 2 additions & 0 deletions lib/money/money/formatting_rules.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Money
class FormattingRules
def initialize(currency, *raw_rules)
Expand Down
2 changes: 2 additions & 0 deletions lib/money/money/locale_backend.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'money/locale_backend/errors'
require 'money/locale_backend/legacy'
require 'money/locale_backend/i18n'
Expand Down
2 changes: 2 additions & 0 deletions lib/money/rates_store/memory.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'monitor'

class Money
Expand Down
2 changes: 2 additions & 0 deletions lib/money/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Money
VERSION = '6.19.0'.freeze
end
2 changes: 2 additions & 0 deletions money.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "money/version"
Expand Down
2 changes: 2 additions & 0 deletions spec/bank/base_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money::Bank::Base do

describe ".instance" do
Expand Down
2 changes: 2 additions & 0 deletions spec/bank/single_currency_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money::Bank::SingleCurrency do
describe "#exchange_with" do
it "raises when called" do
Expand Down
2 changes: 2 additions & 0 deletions spec/bank/variable_exchange_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'json'
require 'yaml'

Expand Down
2 changes: 2 additions & 0 deletions spec/currency/heuristics_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money::Currency::Heuristics do
describe "#analyze_string" do
it "it raises deprecation error" do
Expand Down
2 changes: 2 additions & 0 deletions spec/currency/loader_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money::Currency::Loader do
it "returns a currency table hash" do
expect(subject.load_currencies).to be_a Hash
Expand Down
2 changes: 2 additions & 0 deletions spec/currency_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money::Currency do
FOO = '{ "priority": 1, "iso_code": "FOO", "iso_numeric": "840", "name": "United States Dollar", "symbol": "$", "subunit": "Cent", "subunit_to_unit": 1000, "symbol_first": true, "html_entity": "$", "decimal_mark": ".", "thousands_separator": ",", "smallest_denomination": 1 }'

Expand Down
2 changes: 2 additions & 0 deletions spec/locale_backend/currency_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money::LocaleBackend::Currency do
describe '#lookup' do
let(:currency) { Money::Currency.new('EUR') }
Expand Down
2 changes: 2 additions & 0 deletions spec/locale_backend/i18n_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money::LocaleBackend::I18n do
describe '#initialize' do
it 'raises an error when I18n is not defined' do
Expand Down
2 changes: 2 additions & 0 deletions spec/locale_backend/legacy_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money::LocaleBackend::Legacy do
after { Money.use_i18n = true }

Expand Down
2 changes: 2 additions & 0 deletions spec/money/allocation_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money::Allocation do
describe 'given number as argument' do
it 'raises an error when invalid argument is given' do
Expand Down
2 changes: 2 additions & 0 deletions spec/money/arithmetic_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money::Arithmetic do
describe "-@" do
it "changes the sign of a number" do
Expand Down
2 changes: 2 additions & 0 deletions spec/money/constructors_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money::Constructors do

describe "::empty" do
Expand Down
2 changes: 2 additions & 0 deletions spec/money/formatting_rules_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money::FormattingRules do
it 'does not modify frozen rules in place' do
expect {
Expand Down
2 changes: 2 additions & 0 deletions spec/money/formatting_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money, "formatting" do

BAR = '{ "priority": 1, "iso_code": "BAR", "iso_numeric": "840", "name": "Dollar with 4 decimal places", "symbol": "$", "subunit": "Cent", "subunit_to_unit": 10000, "symbol_first": true, "html_entity": "$", "decimal_mark": ".", "thousands_separator": ",", "smallest_denomination": 1 }'
Expand Down
2 changes: 2 additions & 0 deletions spec/money/locale_backend_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money::LocaleBackend do
describe '.find' do
it 'returns an initialized backend' do
Expand Down
2 changes: 2 additions & 0 deletions spec/money_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money do
describe '.locale_backend' do
after { Money.locale_backend = :legacy }
Expand Down
2 changes: 2 additions & 0 deletions spec/rates_store/memory_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

describe Money::RatesStore::Memory do
let(:subject) { described_class.new }

Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.dirname(__FILE__)
require "rspec"
require "money"
Expand Down
2 changes: 2 additions & 0 deletions spec/support/shared_examples/money_examples.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.shared_examples 'instance with custom bank' do |operation, value|
let(:custom_bank) { Money::Bank::VariableExchange.new }
let(:instance) { Money.new(1, :usd, custom_bank) }
Expand Down