latinum 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3571f7728673389092f0ad54528e038ed15f7b9a5943b909ba355c3e9c96ad54
4
- data.tar.gz: 4ab949df4e4666b2ed782a82efde0386186655ffe370ffbe028c8fc79d9f8dee
3
+ metadata.gz: 8884a3ef10ea2656d2c0016be0a46808783d66f6b6245cfadf3df03e5352e452
4
+ data.tar.gz: 6ee07cd171635e5cc879b2dada4d52d2a0e31911090c125feb239093bc8850c2
5
5
  SHA512:
6
- metadata.gz: de2de3d69cadf33628b97c74d57a524f0148805804b351b7164080d0fa43b900cc0e385de33f92ca899275b240e93beb2c0517a51d194bd0115f2cdebd48ad8b
7
- data.tar.gz: ac41080a9e0f74116020e69850d57614f713934dd318f6664fec1b111a6cd3fd36103608e89f059bcbe80695fe1b10df55ea900b6aa1c3a35ab785890747f786
6
+ metadata.gz: c38564220688bd0bb5e920bf3159bfedfef3d044e5d0073d0cbb294617c3fdb5f676f2da315a5e17363e10dc406775f156614bc18a3cbebaaa58ce899fe7b880
7
+ data.tar.gz: cd68db69fc29c633611f3b96c7af99b29fcf1283db4ad6a861712f713863de4d2339dec789b3e1551e51b069282fea3ea4ca8a6178918bddab7d1a9b953739ca
@@ -4,7 +4,6 @@ cache: bundler
4
4
 
5
5
  matrix:
6
6
  include:
7
- - rvm: 2.3
8
7
  - rvm: 2.4
9
8
  - rvm: 2.5
10
9
  - rvm: 2.6
@@ -12,6 +11,7 @@ matrix:
12
11
  os: osx
13
12
  - rvm: 2.6
14
13
  env: COVERAGE=BriefSummary,Coveralls
14
+ - rvm: 2.7
15
15
  - rvm: truffleruby
16
16
  - rvm: jruby-head
17
17
  - rvm: ruby-head
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
data/README.md CHANGED
@@ -148,7 +148,7 @@ Formatting an amount is typically required for presentation to the end user:
148
148
  > bank.format(nzd)
149
149
  => "$10.00 NZD"
150
150
 
151
- > bank.format(aud, :format => :compact)
151
+ > bank.format(aud, name: nil)
152
152
  => "$5.00"
153
153
 
154
154
  The bank can also be used to parse currency, which will depend on the priority of currencies if a symbol that matches multiple currencies is supplied:
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -102,13 +104,15 @@ module Latinum
102
104
  parts = string.strip.split(/\s+/, 2)
103
105
 
104
106
  if parts.size == 2
105
- Resource.new(parts[0].gsub(/[^\.0-9]/, ''), parts[1])
107
+ Resource.new(parts[0].gsub(/[^\-\.0-9]/, ''), parts[1])
106
108
  else
107
109
  # Lookup the named symbol, e.g. '$', and get the highest priority name:
108
- symbol = @symbols.fetch(string.gsub(/[\-\.,0-9]/, ''), []).last || default_name
110
+ symbol = @symbols.fetch(string.gsub(/[\-\.,0-9]/, ''), []).last
109
111
 
110
112
  if symbol
111
- Resource.new(string.gsub(/[^\.0-9]/, ''), symbol.last.to_s)
113
+ Resource.new(string.gsub(/[^\-\.0-9]/, ''), symbol.last.to_s)
114
+ elsif default_name
115
+ Resource.new(string.gsub(/[^\-\.0-9]/, ''), default_name.to_s)
112
116
  else
113
117
  raise ArgumentError.new("Could not parse #{string}, could not determine currency!")
114
118
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # encoding: UTF-8
2
4
  #
3
5
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -21,7 +23,6 @@
21
23
  module Latinum
22
24
  module Formatters
23
25
  DEFAULT_OPTIONS = {
24
- :format => :full
25
26
  }
26
27
 
27
28
  class PlainFormatter
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -19,5 +21,5 @@
19
21
  # THE SOFTWARE.
20
22
 
21
23
  module Latinum
22
- VERSION = "1.4.2"
24
+ VERSION = "1.5.0"
23
25
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -69,12 +71,19 @@ RSpec.describe Latinum::Bank do
69
71
  expect(aud).to be == Latinum::Resource.new("5", "AUD")
70
72
  end
71
73
 
72
- it "should parser strings into resources" do
74
+ it "should parse strings into resources" do
73
75
  expect(@bank.parse("$5")).to be == Latinum::Resource.new("5", "USD")
74
76
  expect(@bank.parse("$5 NZD")).to be == Latinum::Resource.new("5", "NZD")
75
77
  expect(@bank.parse("€5")).to be == Latinum::Resource.new("5", "EUR")
76
78
 
77
79
  expect(@bank.parse("5 NZD")).to be == Latinum::Resource.new("5", "NZD")
80
+
81
+ expect(@bank.parse("-$5")).to be == Latinum::Resource.new("-5", "USD")
82
+ expect(@bank.parse("-$5 NZD")).to be == Latinum::Resource.new("-5", "NZD")
83
+ expect(@bank.parse("-€5")).to be == Latinum::Resource.new("-5", "EUR")
84
+
85
+ expect(@bank.parse("5", default_name: "EUR")).to be == Latinum::Resource.new("5", "EUR")
86
+ expect(@bank.parse("-5", default_name: "EUR")).to be == Latinum::Resource.new("-5", "EUR")
78
87
  end
79
88
 
80
89
  it "should fail to parse unknown resource" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'covered/rspec'
3
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: latinum
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-20 00:00:00.000000000 Z
11
+ date: 2020-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: covered
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  requirements: []
115
- rubygems_version: 3.0.6
115
+ rubygems_version: 3.1.2
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: Latinum is a simple gem for managing resource computations, including money