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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 511eab7c9c54f953a49c3794a0b4feab9240a67aac886e63846c2da65c2ad745
4
- data.tar.gz: bbef1ec84070bde89fc5fef6471baaddad2a91b3beb1d92e5ca6f9e01f43e710
3
+ metadata.gz: 7d05859acbe42878a3bc7893c2cdcf370702c63ad63053aee6390e3483c3f8d5
4
+ data.tar.gz: 2927ce52d0fd14fecc9900f8cefb711101bfa831068b80b448e264206dc27fbe
5
5
  SHA512:
6
- metadata.gz: d8e93b20176826a008617cfc258ba2f6ca55951bedc0854f2d480727739e894b6f94f4f249c42c01a64449c1b722fccf91b6eab4e7ff38e7a46b0ba21f32cbe6
7
- data.tar.gz: 3235ab2615b992a448d339ba0eae67b7ba2e637bb6bdf66fe6dc2752c65d83531632efc3164c458dcd1bb9db5f4d2196367a0a5f4ae2c70aff3f93365a3235b2
6
+ metadata.gz: bea4ff0836c110999e7b91ffb4f09d64a52db3ea523d85ea449f71cf15048b573b0f4aaf30c130fc348e23ef96dd05582ab4136b2281f89ce648a1b027b8c8ee
7
+ data.tar.gz: '087ce0d7b3771acd006786e5b8e424b4082d0291bfa95fe23bb67acd5b60c04b6e0e50dac6c626e3ed530043a5824226e5fdfc77c6135e632deed2555c689137'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- percentify (0.0.1)
4
+ percentify (0.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
 
3
5
  begin
data/lib/percentify.rb CHANGED
@@ -1,6 +1,9 @@
1
- require "percentify/version"
2
- require "percentify/core_ext"
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
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Percentify
4
+ module CoreExtensions
5
+ module Numeric
6
+ def as_percentage_of(number)
7
+ (to_f / number.to_f) * 100
8
+ end
9
+
10
+ def percent_of(number)
11
+ (to_f / 100.to_f) * number.to_f
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Percentify
2
- VERSION = "0.0.1"
4
+ VERSION = '0.1.0'
3
5
  end
data/percentify.gemspec CHANGED
@@ -1,24 +1,25 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
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 = "percentify"
8
+ spec.name = 'percentify'
8
9
  spec.version = Percentify::VERSION
9
- spec.authors = ["Colin Frame"]
10
- spec.email = ["colin@colinframe.com"]
11
- spec.summary = %q{Lightweight Gem to aid the calculation of percentages in Ruby}
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 = "https://github.com/cframe/percentify"
14
- spec.license = "MIT"
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 = ["lib"]
20
+ spec.require_paths = ['lib']
20
21
 
21
- spec.add_development_dependency "bundler", "~> 2.0.1"
22
- spec.add_development_dependency "rake", "~> 12.3.2"
23
- spec.add_development_dependency "rspec", "~> 3.8.0"
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.1
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-21 00:00:00.000000000 Z
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/core_ext.rb
72
+ - lib/percentify/core_extensions/numeric.rb
73
73
  - lib/percentify/version.rb
74
74
  - percentify.gemspec
75
75
  - spec/numeric_spec.rb
@@ -1,9 +0,0 @@
1
- Numeric.class_eval do
2
- def as_percentage_of(number)
3
- (self.to_f / number.to_f) * 100
4
- end
5
-
6
- def percent_of(number)
7
- (self.to_f / 100.to_f) * number.to_f
8
- end
9
- end