latinum 1.4.1 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -2
- data/.travis.yml +16 -14
- data/Gemfile +0 -4
- data/README.md +1 -1
- data/Rakefile +2 -10
- data/latinum.gemspec +6 -7
- data/lib/latinum/collection.rb +12 -0
- data/lib/latinum/resource.rb +1 -1
- data/lib/latinum/version.rb +1 -1
- data/spec/latinum/collection_spec.rb +36 -0
- data/spec/spec_helper.rb +11 -0
- metadata +23 -9
- data/.simplecov +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3571f7728673389092f0ad54528e038ed15f7b9a5943b909ba355c3e9c96ad54
|
4
|
+
data.tar.gz: 4ab949df4e4666b2ed782a82efde0386186655ffe370ffbe028c8fc79d9f8dee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de2de3d69cadf33628b97c74d57a524f0148805804b351b7164080d0fa43b900cc0e385de33f92ca899275b240e93beb2c0517a51d194bd0115f2cdebd48ad8b
|
7
|
+
data.tar.gz: ac41080a9e0f74116020e69850d57614f713934dd318f6664fec1b111a6cd3fd36103608e89f059bcbe80695fe1b10df55ea900b6aa1c3a35ab785890747f786
|
data/.rspec
CHANGED
data/.travis.yml
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
3
|
-
|
4
|
-
rvm:
|
5
|
-
- 2.1
|
6
|
-
- 2.2
|
7
|
-
- 2.3
|
8
|
-
- 2.4
|
9
|
-
- 2.5
|
10
|
-
- 2.6
|
11
|
-
- ruby-head
|
12
|
-
- rbx-3
|
13
|
-
|
14
|
-
env: COVERAGE=true
|
2
|
+
dist: xenial
|
3
|
+
cache: bundler
|
15
4
|
|
16
5
|
matrix:
|
6
|
+
include:
|
7
|
+
- rvm: 2.3
|
8
|
+
- rvm: 2.4
|
9
|
+
- rvm: 2.5
|
10
|
+
- rvm: 2.6
|
11
|
+
- rvm: 2.6
|
12
|
+
os: osx
|
13
|
+
- rvm: 2.6
|
14
|
+
env: COVERAGE=BriefSummary,Coveralls
|
15
|
+
- rvm: truffleruby
|
16
|
+
- rvm: jruby-head
|
17
|
+
- rvm: ruby-head
|
17
18
|
allow_failures:
|
18
|
-
- rvm:
|
19
|
+
- rvm: ruby-head
|
20
|
+
- rvm: jruby-head
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Latinum is a library for resource and currency calculations. It provides immutable `Resource` objects for dealing with quantities of named resources with an arbitrary number of decimal places, and `Bank` objects for converting resources and formatting them for output. Latinum doesn't include any global state by default and thus is ideal for integration with other frameworks/libraries.
|
4
4
|
|
5
|
-
[![Build Status](https://travis-ci.
|
5
|
+
[![Build Status](https://travis-ci.com/ioquatix/latinum.svg?branch=master)](https://travis-ci.com/ioquatix/latinum)
|
6
6
|
[![Code Climate](https://codeclimate.com/github/ioquatix/latinum.svg)](https://codeclimate.com/github/ioquatix/latinum)
|
7
7
|
[![Coverage Status](https://coveralls.io/repos/ioquatix/latinum/badge.svg)](https://coveralls.io/r/ioquatix/latinum)
|
8
8
|
|
data/Rakefile
CHANGED
@@ -1,14 +1,6 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
3
|
|
4
|
-
RSpec::Core::RakeTask.new(:
|
5
|
-
if ENV['COVERAGE']
|
6
|
-
begin
|
7
|
-
require('simplecov/version')
|
8
|
-
task.rspec_opts = %w{--require simplecov}
|
9
|
-
rescue LoadError
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
4
|
+
RSpec::Core::RakeTask.new(:test)
|
13
5
|
|
14
|
-
task :default => :
|
6
|
+
task :default => :test
|
data/latinum.gemspec
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'latinum/version'
|
1
|
+
|
2
|
+
require_relative "lib/latinum/version"
|
5
3
|
|
6
4
|
Gem::Specification.new do |spec|
|
7
5
|
spec.name = "latinum"
|
@@ -11,13 +9,14 @@ Gem::Specification.new do |spec|
|
|
11
9
|
spec.summary = %q{Latinum is a simple gem for managing resource computations, including money and minerals.}
|
12
10
|
spec.homepage = "https://github.com/ioquatix/latinum"
|
13
11
|
spec.license = "MIT"
|
14
|
-
|
12
|
+
|
15
13
|
spec.files = `git ls-files`.split($/)
|
16
14
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
15
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
16
|
spec.require_paths = ["lib"]
|
19
|
-
|
20
|
-
spec.add_development_dependency "
|
17
|
+
|
18
|
+
spec.add_development_dependency "covered"
|
19
|
+
spec.add_development_dependency "bundler"
|
21
20
|
spec.add_development_dependency "rspec", "~> 3.4"
|
22
21
|
spec.add_development_dependency "rake"
|
23
22
|
end
|
data/lib/latinum/collection.rb
CHANGED
@@ -94,6 +94,14 @@ module Latinum
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
+
def empty?
|
98
|
+
@resources.empty?
|
99
|
+
end
|
100
|
+
|
101
|
+
def include?(key)
|
102
|
+
@resources.include?(key)
|
103
|
+
end
|
104
|
+
|
97
105
|
# Generate a new collection but ignore zero values.
|
98
106
|
def compact
|
99
107
|
collection = self.class.new
|
@@ -106,5 +114,9 @@ module Latinum
|
|
106
114
|
|
107
115
|
return collection
|
108
116
|
end
|
117
|
+
|
118
|
+
def to_s
|
119
|
+
@resources.map{|name, amount| "#{amount.to_s('F')} #{name}"}.join("; ")
|
120
|
+
end
|
109
121
|
end
|
110
122
|
end
|
data/lib/latinum/resource.rb
CHANGED
data/lib/latinum/version.rb
CHANGED
@@ -101,4 +101,40 @@ RSpec.describe Latinum::Collection do
|
|
101
101
|
|
102
102
|
expect(collection.each.to_a).to be == resources
|
103
103
|
end
|
104
|
+
|
105
|
+
describe '#-@' do
|
106
|
+
it "can subtract itself" do
|
107
|
+
subject << Latinum::Resource.new("10.0", "NZD")
|
108
|
+
|
109
|
+
result = (subject - subject).compact
|
110
|
+
|
111
|
+
expect(result).to be_empty
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe '#compact' do
|
116
|
+
it "can remove zero value resources" do
|
117
|
+
subject << Latinum::Resource.new("0.0", "NZD")
|
118
|
+
|
119
|
+
expect(subject).to include "NZD"
|
120
|
+
expect(subject.compact).to_not include "NZD"
|
121
|
+
end
|
122
|
+
|
123
|
+
it "doesn't remove non-zero value resources" do
|
124
|
+
subject << Latinum::Resource.new("1.0", "NZD")
|
125
|
+
|
126
|
+
expect(subject).to include "NZD"
|
127
|
+
expect(subject.compact).to include "NZD"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe '#to_s' do
|
132
|
+
it "can geneate formatted output" do
|
133
|
+
subject << Latinum::Resource.new("5.0", "NZD")
|
134
|
+
subject << Latinum::Resource.new("10.0", "AUD")
|
135
|
+
subject << Latinum::Resource.new("20", "JPY")
|
136
|
+
|
137
|
+
expect(subject.to_s).to be == "5.0 NZD; 10.0 AUD; 20.0 JPY"
|
138
|
+
end
|
139
|
+
end
|
104
140
|
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: latinum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: covered
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- - "
|
31
|
+
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
33
|
+
version: '0'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- - "
|
38
|
+
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rspec
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,7 +74,6 @@ extensions: []
|
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
62
76
|
- ".rspec"
|
63
|
-
- ".simplecov"
|
64
77
|
- ".travis.yml"
|
65
78
|
- Gemfile
|
66
79
|
- README.md
|
@@ -79,6 +92,7 @@ files:
|
|
79
92
|
- spec/latinum/formatters_spec.rb
|
80
93
|
- spec/latinum/integrals_spec.rb
|
81
94
|
- spec/latinum/resource_spec.rb
|
95
|
+
- spec/spec_helper.rb
|
82
96
|
homepage: https://github.com/ioquatix/latinum
|
83
97
|
licenses:
|
84
98
|
- MIT
|
@@ -98,8 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
112
|
- !ruby/object:Gem::Version
|
99
113
|
version: '0'
|
100
114
|
requirements: []
|
101
|
-
|
102
|
-
rubygems_version: 2.7.6
|
115
|
+
rubygems_version: 3.0.6
|
103
116
|
signing_key:
|
104
117
|
specification_version: 4
|
105
118
|
summary: Latinum is a simple gem for managing resource computations, including money
|
@@ -111,3 +124,4 @@ test_files:
|
|
111
124
|
- spec/latinum/formatters_spec.rb
|
112
125
|
- spec/latinum/integrals_spec.rb
|
113
126
|
- spec/latinum/resource_spec.rb
|
127
|
+
- spec/spec_helper.rb
|