percentise 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -2
- data/lib/percentise.rb +6 -1
- data/test/percentise_test.rb +12 -0
- metadata +21 -8
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'rake/rdoctask'
|
4
|
+
require File.dirname(__FILE__)+"/lib/percentise"
|
4
5
|
|
5
6
|
desc 'Default: run unit tests.'
|
6
7
|
task :default => :test
|
@@ -35,7 +36,7 @@ spec = Gem::Specification.new do |s|
|
|
35
36
|
|
36
37
|
# Change these as appropriate
|
37
38
|
s.name = "percentise"
|
38
|
-
s.version =
|
39
|
+
s.version = Percentise::VERSION
|
39
40
|
s.summary = "Simple, consistent Percentises"
|
40
41
|
s.author = "Matthew Rudy Jacobs"
|
41
42
|
s.email = "MatthewRudyJacobs@gmail.com"
|
@@ -54,7 +55,7 @@ spec = Gem::Specification.new do |s|
|
|
54
55
|
# s.add_dependency("some_other_gem", "~> 0.1.0")
|
55
56
|
|
56
57
|
# If your tests use any gems, include them here
|
57
|
-
|
58
|
+
s.add_development_dependency("activesupport")
|
58
59
|
end
|
59
60
|
|
60
61
|
# This task actually builds the gem. We also regenerate a static
|
data/lib/percentise.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Percentise
|
2
2
|
module Percentise
|
3
|
+
|
4
|
+
VERSION = "0.1.2"
|
3
5
|
|
4
6
|
def self.this(top, bottom)
|
5
7
|
if top && bottom
|
@@ -13,7 +15,10 @@ module Percentise
|
|
13
15
|
end
|
14
16
|
|
15
17
|
def self.diff(top, bottom)
|
16
|
-
|
18
|
+
# if either is nil, then it is nil
|
19
|
+
if top && bottom
|
20
|
+
self.this(top - bottom, bottom)
|
21
|
+
end
|
17
22
|
end
|
18
23
|
|
19
24
|
end
|
data/test/percentise_test.rb
CHANGED
@@ -37,4 +37,16 @@ class PercentiseTest < Test::Unit::TestCase
|
|
37
37
|
assert_equal -50.0, Percentise.diff(50, 100)
|
38
38
|
end
|
39
39
|
|
40
|
+
test "diff - if top is nil it is nil" do
|
41
|
+
assert_nil Percentise.diff(nil, 100)
|
42
|
+
end
|
43
|
+
|
44
|
+
test "diff - if bottom is nil it is nil" do
|
45
|
+
assert_nil Percentise.diff(50, nil)
|
46
|
+
end
|
47
|
+
|
48
|
+
test "diff - if both are nil" do
|
49
|
+
assert_nil Percentise.diff(nil, nil)
|
50
|
+
end
|
51
|
+
|
40
52
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: percentise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 31
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthew Rudy Jacobs
|
@@ -15,10 +15,23 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-03-07 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: activesupport
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
22
35
|
description:
|
23
36
|
email: MatthewRudyJacobs@gmail.com
|
24
37
|
executables: []
|
@@ -65,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
78
|
requirements: []
|
66
79
|
|
67
80
|
rubyforge_project:
|
68
|
-
rubygems_version: 1.
|
81
|
+
rubygems_version: 1.5.2
|
69
82
|
signing_key:
|
70
83
|
specification_version: 3
|
71
84
|
summary: Simple, consistent Percentises
|