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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f722a58ca6239cee932bac966ca510c4c04e863f20f4d46f003c2d523755c8a
4
- data.tar.gz: 05a0a502f56ef79ae947b2f1780a6a7268c623709c1839036dfa17a3e29d0971
3
+ metadata.gz: 3571f7728673389092f0ad54528e038ed15f7b9a5943b909ba355c3e9c96ad54
4
+ data.tar.gz: 4ab949df4e4666b2ed782a82efde0386186655ffe370ffbe028c8fc79d9f8dee
5
5
  SHA512:
6
- metadata.gz: a4e199ad91783ff445ea357a24873d9e4fd37c3c54cdbef4ad24cd12bc801d6505fadea717834b0b0d698049f279331b4f01b5a3acbb3d88aa47f0e3189e593c
7
- data.tar.gz: 8230e834c0d1106967daa0b8d40082f0bb5a5e4e85798f03f33b2941ec9ab720d55213f4a0827f38f2fdda3b95bbff8860b2328dc23369f2c5afbdc3c059e2c6
6
+ metadata.gz: de2de3d69cadf33628b97c74d57a524f0148805804b351b7164080d0fa43b900cc0e385de33f92ca899275b240e93beb2c0517a51d194bd0115f2cdebd48ad8b
7
+ data.tar.gz: ac41080a9e0f74116020e69850d57614f713934dd318f6664fec1b111a6cd3fd36103608e89f059bcbe80695fe1b10df55ea900b6aa1c3a35ab785890747f786
data/.rspec CHANGED
@@ -1,4 +1,3 @@
1
- --color
2
1
  --format documentation
3
- --backtrace
4
2
  --warnings
3
+ --require spec_helper
@@ -1,18 +1,20 @@
1
1
  language: ruby
2
- sudo: false
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: rbx-3
19
+ - rvm: ruby-head
20
+ - rvm: jruby-head
data/Gemfile CHANGED
@@ -1,7 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
-
5
- group :test do
6
- gem 'coveralls', platforms: [:mri]
7
- end
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.org/ioquatix/latinum.svg?branch=master)](https://travis-ci.org/ioquatix/latinum)
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(:spec) do |task|
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 => :spec
6
+ task :default => :test
@@ -1,7 +1,5 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
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 "bundler", "~> 1.3"
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
@@ -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
@@ -82,7 +82,7 @@ module Latinum
82
82
  end
83
83
 
84
84
  def to_s
85
- @amount.to_s('F') + ' ' + @name.to_s
85
+ "#{@amount.to_s('F')} #{@name}"
86
86
  end
87
87
 
88
88
  def inspect
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Latinum
22
- VERSION = "1.4.1"
22
+ VERSION = "1.4.2"
23
23
  end
@@ -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
@@ -0,0 +1,11 @@
1
+
2
+ require 'covered/rspec'
3
+
4
+ RSpec.configure do |config|
5
+ # Enable flags like --only-failures and --next-failure
6
+ config.example_status_persistence_file_path = ".rspec_status"
7
+
8
+ config.expect_with :rspec do |c|
9
+ c.syntax = :expect
10
+ end
11
+ end
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.1
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: 2018-06-30 00:00:00.000000000 Z
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: '1.3'
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: '1.3'
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
- rubyforge_project:
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
data/.simplecov DELETED
@@ -1,9 +0,0 @@
1
-
2
- SimpleCov.start do
3
- add_filter "/spec/"
4
- end
5
-
6
- if ENV['TRAVIS']
7
- require 'coveralls'
8
- Coveralls.wear!
9
- end