percentify 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +2 -0
- data/lib/percentify.rb +6 -3
- data/lib/percentify/core_extensions/numeric.rb +15 -0
- data/lib/percentify/version.rb +3 -1
- data/percentify.gemspec +13 -12
- data/spec/numeric_spec.rb +5 -5
- data/spec/spec_helper.rb +3 -1
- metadata +3 -3
- data/lib/percentify/core_ext.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d05859acbe42878a3bc7893c2cdcf370702c63ad63053aee6390e3483c3f8d5
|
4
|
+
data.tar.gz: 2927ce52d0fd14fecc9900f8cefb711101bfa831068b80b448e264206dc27fbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bea4ff0836c110999e7b91ffb4f09d64a52db3ea523d85ea449f71cf15048b573b0f4aaf30c130fc348e23ef96dd05582ab4136b2281f89ce648a1b027b8c8ee
|
7
|
+
data.tar.gz: '087ce0d7b3771acd006786e5b8e424b4082d0291bfa95fe23bb67acd5b60c04b6e0e50dac6c626e3ed530043a5824226e5fdfc77c6135e632deed2555c689137'
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
data/lib/percentify.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'percentify/version'
|
4
|
+
require 'percentify/core_extensions/numeric'
|
5
|
+
|
6
|
+
Numeric.include(Percentify::CoreExtensions::Numeric)
|
3
7
|
|
4
8
|
module Percentify
|
5
|
-
|
6
9
|
end
|
data/lib/percentify/version.rb
CHANGED
data/percentify.gemspec
CHANGED
@@ -1,24 +1,25 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'percentify/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'percentify'
|
8
9
|
spec.version = Percentify::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
10
|
+
spec.authors = ['Colin Frame']
|
11
|
+
spec.email = ['colin@colinframe.com']
|
12
|
+
spec.summary = 'Lightweight Gem to aid the calculation of percentages in Ruby'
|
12
13
|
spec.description = spec.summary
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
14
|
+
spec.homepage = 'https://github.com/cframe/percentify'
|
15
|
+
spec.license = 'MIT'
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0")
|
17
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
20
|
+
spec.require_paths = ['lib']
|
20
21
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
22
|
+
spec.add_development_dependency 'bundler', '~> 2.0.1'
|
23
|
+
spec.add_development_dependency 'rake', '~> 12.3.2'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.8.0'
|
24
25
|
end
|
data/spec/numeric_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Numeric do
|
4
|
-
subject(:integer) { 2 }
|
5
|
-
|
6
6
|
describe '#as_percentage_of(number)' do
|
7
7
|
context 'as an integer' do
|
8
8
|
subject(:as_percentage_of) { 2.as_percentage_of(10) }
|
@@ -15,16 +15,16 @@ describe Numeric do
|
|
15
15
|
it { is_expected.to eq(20.0) }
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
describe '#percent_of(number)' do
|
20
20
|
context 'as an integer' do
|
21
21
|
subject(:percent_of) { 2.percent_of(10) }
|
22
|
-
|
22
|
+
|
23
23
|
it { is_expected.to eq(0.2) }
|
24
24
|
end
|
25
25
|
context 'as a float' do
|
26
26
|
subject(:percent_of) { 2.0.percent_of(10) }
|
27
|
-
|
27
|
+
|
28
28
|
it { is_expected.to eq(0.2) }
|
29
29
|
end
|
30
30
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
4
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
5
|
# Require this file using `require "spec_helper"` to ensure that it is only
|
@@ -16,4 +18,4 @@ RSpec.configure do |config|
|
|
16
18
|
# the seed, which is printed after each run.
|
17
19
|
# --seed 1234
|
18
20
|
config.order = 'random'
|
19
|
-
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: percentify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin Frame
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,7 +69,7 @@ files:
|
|
69
69
|
- README.md
|
70
70
|
- Rakefile
|
71
71
|
- lib/percentify.rb
|
72
|
-
- lib/percentify/
|
72
|
+
- lib/percentify/core_extensions/numeric.rb
|
73
73
|
- lib/percentify/version.rb
|
74
74
|
- percentify.gemspec
|
75
75
|
- spec/numeric_spec.rb
|