percent_of 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9cbe6d77cd05d23d21e5f733e470247bba3c996e
4
+ data.tar.gz: 70211bce47ab3448de7e116e76f840ab191410ba
5
+ SHA512:
6
+ metadata.gz: 8392a1396e3d2f7a023c9f327f396c259c5a5d57e89fbd677555a6efe62b8e0a5fffbb7f87abd78b33b9ab2aa812a7f8ef8cc1fb52ef84842c30e2442cd0ba88
7
+ data.tar.gz: 12d2a213da1b95c6af307b526a332963d56cf5f1b11dce6c6d6a8174ec5e50e976bf9d2cd1c9071f2f86a307276374affaa21a9d2dedeb065586e1816489d114
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,2 @@
1
+ rvm:
2
+ - 2.0.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## v0.0.1
2
+
3
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in env_status.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ percent_of (0.0.1)
5
+ bundler (~> 1.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.2.5)
11
+ given_core (3.5.4)
12
+ sorcerer (>= 0.3.7)
13
+ rake (10.3.1)
14
+ rspec (2.14.1)
15
+ rspec-core (~> 2.14.0)
16
+ rspec-expectations (~> 2.14.0)
17
+ rspec-mocks (~> 2.14.0)
18
+ rspec-core (2.14.8)
19
+ rspec-expectations (2.14.5)
20
+ diff-lcs (>= 1.1.3, < 2.0)
21
+ rspec-given (3.5.4)
22
+ given_core (= 3.5.4)
23
+ rspec (>= 2.12)
24
+ rspec-mocks (2.14.6)
25
+ sorcerer (1.0.2)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ percent_of!
32
+ rake
33
+ rspec (~> 2.0)
34
+ rspec-given
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Catalin Ilinca
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # PercentOf
2
+
3
+ [![Build Status](https://travis-ci.org/ducknorris/percent_of.svg?branch=master)](https://travis-ci.org/ducknorris/percent_of)
4
+
5
+ Module that implements ```percent_of``` for Fixnum and Float classes in Ruby.
6
+
7
+ ## How to use
8
+
9
+ Add it to your ```Gemfile```.
10
+
11
+ ```
12
+ # ...
13
+ gem 'percent_of'
14
+ # ...
15
+ ```
16
+
17
+ You can use ```#percent_of``` by invoking:
18
+
19
+ ```
20
+ 20.percent_of 100 # => "20.00%"
21
+ 24.44.percent_of 123.45 # => "19.80%"
22
+ ```
23
+
24
+ ## Contributing
25
+
26
+ Thanks to our [contributors](https://github.com/ducknorris/percent_of/graphs/contributors).
27
+
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/lib/percent_of.rb ADDED
@@ -0,0 +1,9 @@
1
+ module PercentOf
2
+ def percent_of(total)
3
+ raise RuntimeError, 'total cand be 0' if total.to_f == 0.0
4
+ sprintf '%.2f%', self / total.to_f * 100
5
+ end
6
+ end
7
+
8
+ class Float ; include PercentOf ; end
9
+ class Fixnum ; include PercentOf ; end
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "percent_of"
6
+ spec.version = "0.0.1"
7
+ spec.authors = ["Catalin Ilinca"]
8
+ spec.email = ["c@talin.ro"]
9
+ spec.description = %q{Output the percent of a number from another number.}
10
+ spec.summary = %q{Output the percent of a number from another number.}
11
+ spec.homepage = "https://github.com/ducknorris/percent_of"
12
+ spec.license = "MIT"
13
+ spec.extra_rdoc_files = [
14
+ "README.md",
15
+ "CHANGELOG.md"
16
+ ]
17
+
18
+ spec.files = `git ls-files`.split($/)
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency 'rspec', '~> 2.0'
24
+ spec.add_development_dependency "rspec-given"
25
+ spec.add_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+ require 'percent_of'
3
+
4
+ describe PercentOf do
5
+ Then { expect(20.percent_of(100)).to eq('20.00%') }
6
+ Then { expect(23.percent_of(80)).to eq('28.75%') }
7
+ Then { expect(234.55.percent_of(899)).to eq('26.09%') }
8
+ Then { expect(455.74.percent_of(5552.42)).to eq('8.21%') }
9
+ Then { expect { 55.percent_of(0) }.to raise_error }
10
+ Then { expect { 0.percent_of(0) }.to raise_error }
11
+ end
12
+
@@ -0,0 +1,2 @@
1
+ require 'percent_of'
2
+ require 'rspec-given'
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: percent_of
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Catalin Ilinca
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-given
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Output the percent of a number from another number.
70
+ email:
71
+ - c@talin.ro
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files:
75
+ - README.md
76
+ - CHANGELOG.md
77
+ files:
78
+ - .gitignore
79
+ - .rspec
80
+ - .travis.yml
81
+ - CHANGELOG.md
82
+ - Gemfile
83
+ - Gemfile.lock
84
+ - LICENSE
85
+ - README.md
86
+ - Rakefile
87
+ - lib/percent_of.rb
88
+ - percent_of.gemspec
89
+ - spec/percent_of_spec.rb
90
+ - spec/spec_helper.rb
91
+ homepage: https://github.com/ducknorris/percent_of
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.2.2
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Output the percent of a number from another number.
115
+ test_files:
116
+ - spec/percent_of_spec.rb
117
+ - spec/spec_helper.rb