framingham 0.1.20130710222706 → 0.1.20130711193533

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.
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ spec/reports
16
16
  test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
+
data/README.md CHANGED
@@ -22,9 +22,8 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- ---
26
25
  ### Public Class Methods ###
27
- ![](http://ruby-doc.org/images/brick.png) ::eval(options) → Float or Error String
26
+ ![](http://ruby-doc.org/images/brick.png) ::eval(options) → <code>Hash&lt;<span style="color:purple">​Symbol</span>, <span style="color:cadetblue">Numeric</span>&gt;</span>{:heart_age, :risk, :normal, :optimal}</code> or Error String
28
27
 
29
28
          Evaluates Framingham::Heartdisease score
30
29
 
data/Rakefile CHANGED
@@ -1 +1,17 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ task :default => [:build, :test]
5
+
6
+ task :build do
7
+ "bundle install framingham"
8
+ end
9
+
10
+ task :deploy do
11
+ Rake::Task[:build].execute Rake::Task[:test].execute and sh "gem push framingham.gem"
12
+ end
13
+
14
+ Rake::TestTask.new { |_|
15
+ _.test_files = FileList['framingham/*_tests.rb']
16
+ _.verbose = true
17
+ }
data/bin/rake ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby1.9.1
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rake', 'rake')
@@ -1,4 +1,5 @@
1
1
  module Framingham::Heartdisease extend Framingham, self
2
+ include Framingham
2
3
 
3
4
  def eval options = {}
4
5
  begin
@@ -70,6 +71,14 @@ end
70
71
 
71
72
  protected
72
73
 
74
+ def internal_debug _ = {}
75
+ _ = eval _
76
+ '%i' % _[:heart_age].round +
77
+ '%5.1f' % ((1000 * _[:risk]).round / 10.0) +
78
+ '%5.1f' % ((1000 * _[:normal]).round / 10.0) +
79
+ '%5.1f' % ((1000 * _[:optimal]).round / 10.0)
80
+ end
81
+
73
82
  $, = ", " #default join
74
83
 
75
84
  NORMAL = { #default options
@@ -0,0 +1,48 @@
1
+ require 'test/unit'
2
+ require './framingham'
3
+
4
+ class HeartdiseaseTests < Test::Unit::TestCase
5
+ include Framingham::Heartdisease
6
+
7
+ def yellow _
8
+ "\e[1;7;41;33mFailed:\e[1;3;40m " + _ + " \e[0m"
9
+ end
10
+
11
+ def test_normal
12
+ assert_equal "30 1.1 1.1 0.7", internal_debug, (yellow "Normal test")
13
+ end
14
+
15
+ def test_normal_male
16
+ assert_equal "30 1.8 1.8 1.4", internal_debug({gender: :male}), (yellow "gender: :male test")
17
+ end
18
+
19
+ def test_normal_female
20
+ assert_equal "30 1.1 1.1 0.7", internal_debug({gender: :female}), (yellow "gender: :female test")
21
+ end
22
+
23
+ def test_all_male
24
+ assert_equal "86 99.7 25.8 20.6", internal_debug({
25
+ gender: :male,
26
+ age: 74,
27
+ blood_pressure: 200,
28
+ blood_pressure_treatment: true,
29
+ smoker: true,
30
+ diabetes: true,
31
+ body_mass_index: 40
32
+ }), (yellow "test all male")
33
+ end
34
+
35
+ def test_all_female
36
+ assert_equal "86 97.6 11.9 8.4", internal_debug({
37
+ gender: :female,
38
+ age: 74,
39
+ blood_pressure: 200,
40
+ blood_pressure_treatment: true,
41
+ smoker: true,
42
+ diabetes: true,
43
+ body_mass_index: 40
44
+ }), (yellow "test all female")
45
+ end
46
+
47
+ end
48
+
@@ -1,3 +1,3 @@
1
1
  module Framingham
2
- VERSION = "0.1.20130710222706"
2
+ VERSION = "0.1.20130711193533"
3
3
  end
data/framingham.gemspec CHANGED
@@ -11,7 +11,7 @@ File.open('framingham/version.rb','w'){ |_|
11
11
  _.puts " VERSION = \"" + version + "\""
12
12
  _.puts "end"
13
13
  }
14
- FileUtils.ln_sf "framingham-" + version + ".gem", "framingham.gem"
14
+ FileUtils.ln_sf "pkg/framingham-" + version + ".gem", "framingham.gem"
15
15
 
16
16
  require 'version'
17
17
 
@@ -19,6 +19,7 @@ Gem::Specification.new{ |_|
19
19
  _.name = "framingham"
20
20
  _.version = Framingham::VERSION
21
21
  _.author = "3PoundHealth"
22
+ _.homepage = "https://github.com/3poundhealth/framingham#framingham"
22
23
  _.summary = "Gem to implement Framingham Heart Study calculators"
23
24
  _.license = "MIT"
24
25
  _.files = `git ls-files`.split($/)
data/framingham.rb CHANGED
@@ -18,5 +18,3 @@ end
18
18
 
19
19
  end
20
20
 
21
- puts self.eval ARGV[0].to_s if ARGV.length !=0
22
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: framingham
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20130710222706
4
+ version: 0.1.20130711193533
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-10 00:00:00.000000000 Z
12
+ date: 2013-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -54,11 +54,13 @@ files:
54
54
  - LICENSE.txt
55
55
  - README.md
56
56
  - Rakefile
57
+ - bin/rake
57
58
  - framingham.gemspec
58
59
  - framingham.rb
59
60
  - framingham/heartdisease.rb
61
+ - framingham/heartdisease_tests.rb
60
62
  - framingham/version.rb
61
- homepage:
63
+ homepage: https://github.com/3poundhealth/framingham#framingham
62
64
  licenses:
63
65
  - MIT
64
66
  post_install_message: