bmi 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/History.txt +4 -0
- data/Manifest.txt +14 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +106 -0
- data/Rakefile +29 -0
- data/bin/bmi +70 -0
- data/lib/bmi/cli.rb +59 -0
- data/lib/bmi.rb +157 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/test_bmi.rb +42 -0
- data/test/test_bmi_cli.rb +33 -0
- data/test/test_helper.rb +3 -0
- metadata +83 -0
data/.gemtest
ADDED
File without changes
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
= BMI
|
2
|
+
|
3
|
+
* http://github.com/#{githug.com/narcisoguillen}/#{BMI}
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
The Body Mass Index (BMI) Gem is usefull to calculate your BMI from console, and add this gem to your ruby project and use it. See 'bmi -h' to read the instructions of usage.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
Write in your comand line 'bmi -w (YourWeight) -b (Your height)' to calculate your BMI, see 'bmi -h' for more features.
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
Body Mass Index
|
16
|
+
|
17
|
+
Imperial BMI Formula
|
18
|
+
|
19
|
+
Bash
|
20
|
+
|
21
|
+
$bmi -W 189.597 -B 69.6850
|
22
|
+
|
23
|
+
Your body mass index is: 27
|
24
|
+
You are 9% over your ideal weight
|
25
|
+
Overweight
|
26
|
+
|
27
|
+
Rails
|
28
|
+
|
29
|
+
require 'bmi'
|
30
|
+
bmi = BMI.new
|
31
|
+
data = []
|
32
|
+
data[0]='-W 189.597'
|
33
|
+
data[1]='-B 69.6850'
|
34
|
+
bmi.calc(data)
|
35
|
+
|
36
|
+
Your body mass index is: 27
|
37
|
+
You are 9% over your ideal weight
|
38
|
+
Overweight
|
39
|
+
|
40
|
+
|
41
|
+
Metric Imperial BMI Formula
|
42
|
+
|
43
|
+
Bash
|
44
|
+
|
45
|
+
$bmi -w 86 -b 1.77
|
46
|
+
|
47
|
+
Your body mass index is: 27
|
48
|
+
You are 9% over your ideal weight
|
49
|
+
Overweight
|
50
|
+
|
51
|
+
Rails
|
52
|
+
|
53
|
+
require 'bmi'
|
54
|
+
bmi = BMI.new
|
55
|
+
data = []
|
56
|
+
data[0]='-w 86'
|
57
|
+
data[1]='-b 1.77'
|
58
|
+
bmi.calc(data)
|
59
|
+
|
60
|
+
Your body mass index is: 27
|
61
|
+
You are 9% over your ideal weight
|
62
|
+
Overweight
|
63
|
+
|
64
|
+
== REQUIREMENTS:
|
65
|
+
|
66
|
+
Requires ~> ruby-1.9.2-p290
|
67
|
+
|
68
|
+
To build this Gem were installed the following gems:
|
69
|
+
|
70
|
+
gem install newgem
|
71
|
+
gem install hoe
|
72
|
+
gem install rake
|
73
|
+
gem install rubyforge
|
74
|
+
|
75
|
+
== INSTALL:
|
76
|
+
|
77
|
+
To install this Gem you only need to run:
|
78
|
+
|
79
|
+
Gem install bmi
|
80
|
+
|
81
|
+
The Gem is uploaded to http://rubygems.org/
|
82
|
+
|
83
|
+
== LICENSE:
|
84
|
+
|
85
|
+
(The MIT License)
|
86
|
+
|
87
|
+
Copyright (c) 2011 Body Mass Index (BMI)
|
88
|
+
|
89
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
90
|
+
a copy of this software and associated documentation files (the
|
91
|
+
'Software'), to deal in the Software without restriction, including
|
92
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
93
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
94
|
+
permit persons to whom the Software is furnished to do so, subject to
|
95
|
+
the following conditions:
|
96
|
+
|
97
|
+
The above copyright notice and this permission notice shall be
|
98
|
+
included in all copies or substantial portions of the Software.
|
99
|
+
|
100
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
101
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
102
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
103
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
104
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
105
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
106
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
#gem 'rake'
|
4
|
+
#gem 'rdoc'
|
5
|
+
#gem 'rubyforge'
|
6
|
+
require 'hoe'
|
7
|
+
require 'fileutils'
|
8
|
+
require './lib/bmi'
|
9
|
+
|
10
|
+
Hoe.plugin :newgem
|
11
|
+
# Hoe.plugin :website
|
12
|
+
# Hoe.plugin :cucumberfeatures
|
13
|
+
|
14
|
+
# Generate all the Rake tasks
|
15
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
16
|
+
$hoe = Hoe.spec 'bmi' do
|
17
|
+
self.developer 'Narciso Guillen de la Mora', 'narciso.guillen@tangosorce.com'
|
18
|
+
self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
19
|
+
self.rubyforge_name = self.name # TODO this is default value
|
20
|
+
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'newgem/tasks'
|
25
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
26
|
+
|
27
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
28
|
+
# remove_task :default
|
29
|
+
# task :default => [:spec, :features]
|
data/bin/bmi
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# = Created on 2011-11-10.
|
4
|
+
# Copyright (c) 2011. All rights reserved.
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require File.expand_path(File.dirname(__FILE__) + "/../lib/bmi")
|
8
|
+
require "bmi/cli"
|
9
|
+
|
10
|
+
data = Bmi::CLI.calc(ARGV)
|
11
|
+
|
12
|
+
data.select!{ |k, v| v.to_f > 0 }
|
13
|
+
|
14
|
+
imperial = false
|
15
|
+
imperial = true if data[:weight_p] && data[:height_i]
|
16
|
+
|
17
|
+
metric = false
|
18
|
+
metric = true if data[:weight_k] && data[:height_m]
|
19
|
+
|
20
|
+
weight = data[:weight_k] || data[:weight_p]
|
21
|
+
height = data[:height_m] || data[:height_i]
|
22
|
+
|
23
|
+
weight = weight.to_f
|
24
|
+
height = height.to_f
|
25
|
+
|
26
|
+
if imperial
|
27
|
+
bmi =( ( weight ) / ( height * height ) ) * 703
|
28
|
+
end
|
29
|
+
|
30
|
+
if metric
|
31
|
+
bmi =( weight ) / ( height * height )
|
32
|
+
end
|
33
|
+
|
34
|
+
if bmi
|
35
|
+
prime = ( bmi / 25 )
|
36
|
+
puts "Your body mass index is: #{bmi.round}"
|
37
|
+
prti = prime.to_s.match(/\d+/)
|
38
|
+
ceros = prime.to_s.match(/\.(0+)/)
|
39
|
+
|
40
|
+
|
41
|
+
if !ceros
|
42
|
+
ceros = []
|
43
|
+
ceros[1] = "0"
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
prcnt = prime.to_s.match(/\.(\d{1,2})/)
|
48
|
+
if prti[0].to_i <= 0
|
49
|
+
puts "You are #{(100)*(ceros[1].length) - (prcnt[1].to_i)}% under your ideal weight"
|
50
|
+
else
|
51
|
+
puts "You are #{prcnt[1].to_i + (100*(prti[0].to_i-1)) }% over your ideal weight"
|
52
|
+
end
|
53
|
+
|
54
|
+
case
|
55
|
+
when bmi < 18.5
|
56
|
+
puts "Underweight"
|
57
|
+
when bmi.between?(18.5,25)
|
58
|
+
puts "Normal"
|
59
|
+
when bmi.between?(25,30)
|
60
|
+
puts "Overweight"
|
61
|
+
when bmi.between?(30,35)
|
62
|
+
puts "Obese Class I"
|
63
|
+
when bmi.between?(35,40)
|
64
|
+
puts "Obese Class II"
|
65
|
+
when bmi > 40
|
66
|
+
puts "Obese Class III"
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
data/lib/bmi/cli.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module Bmi
|
4
|
+
class CLI
|
5
|
+
def self.calc(arguments=[])
|
6
|
+
|
7
|
+
options = {
|
8
|
+
:weight_k => 0,
|
9
|
+
:height_m => 0,
|
10
|
+
:weight_p => 0,
|
11
|
+
:height_i => 0
|
12
|
+
}
|
13
|
+
mandatory_options = %w( )
|
14
|
+
|
15
|
+
parser = OptionParser.new do |opts|
|
16
|
+
opts.banner = <<-BANNER.gsub(/^ /,'')
|
17
|
+
Body Mass Index [BMI] help guide
|
18
|
+
|
19
|
+
Usage: #{File.basename($0)} [options]
|
20
|
+
|
21
|
+
Options are:
|
22
|
+
BANNER
|
23
|
+
opts.separator ""
|
24
|
+
|
25
|
+
opts.on("-w", "--weight KILOGRAMS", String,
|
26
|
+
"Your current weight.",
|
27
|
+
"Pleace introduce your weight in kilograms.",
|
28
|
+
"Default: ~") { |arg| options[:weight_k] = arg }
|
29
|
+
|
30
|
+
|
31
|
+
opts.on("-b", "--height METERS", String,
|
32
|
+
"How hight you are.",
|
33
|
+
"Pleace introduce your height in meters.",
|
34
|
+
"Default: ~") { |arg| options[:height_m] = arg }
|
35
|
+
|
36
|
+
opts.on("-W", "--Weight POUNDS", String,
|
37
|
+
"Your current weight.",
|
38
|
+
"Pleace introduce your weight in pounds.",
|
39
|
+
"Default: ~") { |arg| options[:weight_p] = arg }
|
40
|
+
|
41
|
+
opts.on("-B", "--Height INCHES", String,
|
42
|
+
"How hight you are.",
|
43
|
+
"Pleace introduce your height in inches.",
|
44
|
+
"Default: ~") { |arg| options[:height_i] = arg }
|
45
|
+
|
46
|
+
opts.on("-h", "--help",
|
47
|
+
"Show this help message.") { puts opts; exit }
|
48
|
+
|
49
|
+
opts.parse!(arguments)
|
50
|
+
|
51
|
+
if mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }
|
52
|
+
puts opts; exit
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
return options
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/bmi.rb
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'optparse'
|
6
|
+
|
7
|
+
class BMI
|
8
|
+
|
9
|
+
attr_accessor :data, :metric, :imperial, :bmi, :metric, :percent
|
10
|
+
|
11
|
+
def initialize(data={})
|
12
|
+
@data = data
|
13
|
+
@data = {
|
14
|
+
:weight_k => 0,
|
15
|
+
:height_m => 0,
|
16
|
+
:weight_p => 0,
|
17
|
+
:height_i => 0
|
18
|
+
}
|
19
|
+
@imperial = false
|
20
|
+
@metric = false
|
21
|
+
@weight = 0
|
22
|
+
@height = 0
|
23
|
+
@bmi = 0
|
24
|
+
@prime = 0
|
25
|
+
@percent = 0
|
26
|
+
end
|
27
|
+
|
28
|
+
def loadata(arguments=[])
|
29
|
+
mandatory_options = %w( )
|
30
|
+
|
31
|
+
parser = OptionParser.new do |opts|
|
32
|
+
opts.banner = <<-BANNER.gsub(/^ /,'')
|
33
|
+
Body Mass Index [BMI] help guide
|
34
|
+
|
35
|
+
Usage: #{File.basename($0)} [options]
|
36
|
+
|
37
|
+
Options are:
|
38
|
+
BANNER
|
39
|
+
opts.separator ""
|
40
|
+
|
41
|
+
opts.on("-w", "--weight KILOGRAMS", String,
|
42
|
+
"Your current weight.",
|
43
|
+
"Pleace introduce your weight in kilograms.",
|
44
|
+
"Default: ~") { |arg| @data[:weight_k] = arg }
|
45
|
+
|
46
|
+
|
47
|
+
opts.on("-b", "--height METERS", String,
|
48
|
+
"How hight you are.",
|
49
|
+
"Pleace introduce your height in meters.",
|
50
|
+
"Default: ~") { |arg| @data[:height_m] = arg }
|
51
|
+
|
52
|
+
opts.on("-W", "--Weight POUNDS", String,
|
53
|
+
"Your current weight.",
|
54
|
+
"Pleace introduce your weight in pounds.",
|
55
|
+
"Default: ~") { |arg| @data[:weight_p] = arg }
|
56
|
+
|
57
|
+
opts.on("-B", "--Height INCHES", String,
|
58
|
+
"How hight you are.",
|
59
|
+
"Pleace introduce your height in inches.",
|
60
|
+
"Default: ~") { |arg| @data[:height_i] = arg }
|
61
|
+
|
62
|
+
opts.on("-h", "--help",
|
63
|
+
"Show this help message.") { puts opts}
|
64
|
+
|
65
|
+
opts.parse!(arguments)
|
66
|
+
|
67
|
+
if mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }
|
68
|
+
puts opts
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def determinates
|
75
|
+
@data.select!{|k,v| v.to_f > 0}
|
76
|
+
@imperial = true if @data[:weight_p] && @data[:height_i]
|
77
|
+
@metric = true if @data[:weight_k] && @data[:height_m]
|
78
|
+
@weight = @data[:weight_k] || @data[:weight_p]
|
79
|
+
@height = @data[:height_m] || @data[:height_i]
|
80
|
+
@weight = @weight.to_f
|
81
|
+
@height = @height.to_f
|
82
|
+
end
|
83
|
+
|
84
|
+
def get_imperial
|
85
|
+
@bmi =( ( @weight ) / ( @height * @height ) ) * 703
|
86
|
+
end
|
87
|
+
|
88
|
+
def get_metric
|
89
|
+
@bmi =( @weight ) / ( @height * @height )
|
90
|
+
end
|
91
|
+
|
92
|
+
def get_prime
|
93
|
+
|
94
|
+
@prime = ( @bmi / 25 )
|
95
|
+
puts "Your body mass index is: #{@bmi.round}"
|
96
|
+
prti = @prime.to_s.match(/\d+/)
|
97
|
+
ceros = @prime.to_s.match(/\.(0+)/)
|
98
|
+
|
99
|
+
|
100
|
+
if !ceros
|
101
|
+
ceros = []
|
102
|
+
ceros[1] = "0"
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
prcnt = @prime.to_s.match(/\.(\d{1,2})/)
|
107
|
+
if prti[0].to_i <= 0
|
108
|
+
@percent = (100)*(ceros[1].length) - (prcnt[1].to_i)
|
109
|
+
puts "You are #{@percent}% under your ideal weight"
|
110
|
+
else
|
111
|
+
@percent = prcnt[1].to_i + (100*(prti[0].to_i-1))
|
112
|
+
puts "You are #{@percent}% over your ideal weight"
|
113
|
+
end
|
114
|
+
return @percent.to_s+"%"
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
def cases
|
119
|
+
case
|
120
|
+
when @bmi < 18.5
|
121
|
+
msj= "Underweight"
|
122
|
+
when @bmi.between?(18.5,25)
|
123
|
+
msj= "Normal"
|
124
|
+
when @bmi.between?(25,30)
|
125
|
+
msj= "Overweight"
|
126
|
+
when @bmi.between?(30,35)
|
127
|
+
msj= "Obese Class I"
|
128
|
+
when @bmi.between?(35,40)
|
129
|
+
msj= "Obese Class II"
|
130
|
+
when @bmi > 40
|
131
|
+
msj= "Obese Class III"
|
132
|
+
end
|
133
|
+
return msj
|
134
|
+
end
|
135
|
+
|
136
|
+
def calc(arguments=[])
|
137
|
+
|
138
|
+
loadata(arguments)
|
139
|
+
determinates()
|
140
|
+
|
141
|
+
if @imperial
|
142
|
+
get_imperial()
|
143
|
+
get_prime()
|
144
|
+
cases()
|
145
|
+
end
|
146
|
+
|
147
|
+
if @metric
|
148
|
+
get_metric()
|
149
|
+
get_prime()
|
150
|
+
cases()
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
154
|
+
|
155
|
+
VERSION = '0.1.2'
|
156
|
+
end
|
157
|
+
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/bmi.rb'}"
|
9
|
+
puts "Loading bmi gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/test/test_bmi.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'bmi'
|
4
|
+
class TestBmi < Test::Unit::TestCase
|
5
|
+
|
6
|
+
#def setup
|
7
|
+
#end
|
8
|
+
@@bmi=BMI.new
|
9
|
+
|
10
|
+
def test_truth
|
11
|
+
assert true
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_metric
|
15
|
+
@@bmi.calc(['-w 60','-b 1.70'])
|
16
|
+
assert_equal(true,@@bmi.metric)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_imperial
|
20
|
+
@@bmi.calc(['-W 189','-B 69.88'])
|
21
|
+
assert_equal(true,@@bmi.imperial)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_get_prime
|
25
|
+
@@bmi.calc(['-w 60','-b 1.70'])
|
26
|
+
assert_equal("17%",@@bmi.get_prime)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_categories_cases
|
30
|
+
cases={'Underweight' =>['-w 50','-b 1.70'],
|
31
|
+
'Normal' =>['-w 60','-b 1.70'],
|
32
|
+
'Overweight' =>['-w 75','-b 1.70'],
|
33
|
+
'Obese Class I' =>['-w 90','-b 1.70'],
|
34
|
+
'Obese Class II' =>['-w 105','-b 1.70'],
|
35
|
+
'Obese Class III' =>['-w 120','-b 1.70']}
|
36
|
+
|
37
|
+
cases.each do |k,v|
|
38
|
+
@@bmi.calc(v)
|
39
|
+
assert_equal(k,@@bmi.cases)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "test_helper.rb")
|
2
|
+
require 'bmi/cli'
|
3
|
+
|
4
|
+
class TestBmiCli < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
Bmi::CLI.calc([])
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_kilograms
|
11
|
+
data = Bmi::CLI.calc(['-w 80'])
|
12
|
+
kilograms = data[:weight_k].to_f
|
13
|
+
assert_equal(80, kilograms)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_meters
|
17
|
+
data = Bmi::CLI.calc(['-b 1.80'])
|
18
|
+
meters = data[:height_m].to_f
|
19
|
+
assert_equal(1.80, meters)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_pounds
|
23
|
+
data = Bmi::CLI.calc(['-W 166'])
|
24
|
+
pounds = data[:weight_p].to_f
|
25
|
+
assert_equal(166, pounds)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_inches
|
29
|
+
data = Bmi::CLI.calc(['-B 68.11'])
|
30
|
+
inches = data[:height_i].to_f
|
31
|
+
assert_equal(68.11, inches)
|
32
|
+
end
|
33
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bmi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Narciso Guillen de la Mora
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-16 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: hoe
|
16
|
+
requirement: &2160826460 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.12'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2160826460
|
25
|
+
description: The Body Mass Index (BMI) Gem is usefull to calculate your BMI from console,
|
26
|
+
and add this gem to your ruby project and use it. See 'bmi -h' to read the instructions
|
27
|
+
of usage.
|
28
|
+
email:
|
29
|
+
- narciso.guillen@tangosorce.com
|
30
|
+
executables:
|
31
|
+
- bmi
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files:
|
34
|
+
- History.txt
|
35
|
+
- Manifest.txt
|
36
|
+
- PostInstall.txt
|
37
|
+
files:
|
38
|
+
- History.txt
|
39
|
+
- Manifest.txt
|
40
|
+
- PostInstall.txt
|
41
|
+
- README.rdoc
|
42
|
+
- Rakefile
|
43
|
+
- bin/bmi
|
44
|
+
- lib/bmi.rb
|
45
|
+
- lib/bmi/cli.rb
|
46
|
+
- script/console
|
47
|
+
- script/destroy
|
48
|
+
- script/generate
|
49
|
+
- test/test_bmi.rb
|
50
|
+
- test/test_bmi_cli.rb
|
51
|
+
- test/test_helper.rb
|
52
|
+
- .gemtest
|
53
|
+
homepage: http://github.com/#{githug.com/narcisoguillen}/#{BMI}
|
54
|
+
licenses: []
|
55
|
+
post_install_message: PostInstall.txt
|
56
|
+
rdoc_options:
|
57
|
+
- --main
|
58
|
+
- README.rdoc
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project: bmi
|
75
|
+
rubygems_version: 1.8.10
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: The Body Mass Index (BMI) Gem is usefull to calculate your BMI from console,
|
79
|
+
and add this gem to your ruby project and use it
|
80
|
+
test_files:
|
81
|
+
- test/test_bmi.rb
|
82
|
+
- test/test_bmi_cli.rb
|
83
|
+
- test/test_helper.rb
|