gcig_ca125 0.1.0 → 0.2.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
  SHA1:
3
- metadata.gz: d133224038fb6ef26a93a6f8e32585f222e74ca3
4
- data.tar.gz: 592cec79d5630e8841308510953eb38215462c7c
3
+ metadata.gz: 76fa91bd39d34feb8ae7b5521132c18beb344e3d
4
+ data.tar.gz: c87cff8d12dbae562b935d983bc8c84a49988748
5
5
  SHA512:
6
- metadata.gz: 28daead6112db7d7aaa2b3885012f03c852e471e16bcca2053b778a7bb36afa9f826a1e05b2db665c2bbb595976edbfe8d87a24b9993255602e9708d9de0ba83
7
- data.tar.gz: 26174659d1b40019e22fd9de89b26ef87243594b69405221962c7f954c41df657c97f53e152d6b07da1ae6968fa84bc92962ef1677428dbcbde837ff4ddcdba7
6
+ metadata.gz: 91620c11a1bb806f70c8f8f7a49ccf0efe84a28d5f71d7c82ee8c7a80ab78c0bb6e0814b1e9343e3d7a9656b3be1262ac95c6e2aab910372a963932dba8ce659
7
+ data.tar.gz: 218edbbc82098ae824811291f5853d91e3641dd149976f606b8972401261b92f316649d8af3cd4c5193b87614d23c3721c70d8f7b4d3d1bc9f3827cbca94810a
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ - jruby-19mode
5
+ - ruby-head
6
+ addons:
7
+ code_climate:
8
+ repo_token: 936ba787c4e63cb58c1de8ba0cdd098ad7f6a5611ad8830ea133744b5c7ee065
data/Gemfile CHANGED
@@ -6,9 +6,9 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
8
  group :development do
9
+ gem "codeclimate-test-reporter", group: :test, require: nil
9
10
  gem "rspec", "~> 3.2"
10
11
  gem "rdoc", "~> 4.2"
11
12
  gem "bundler", "~> 1.7"
12
13
  gem "jeweler", "~> 2.0"
13
- gem "simplecov", "~> 0.9"
14
14
  end
@@ -3,6 +3,8 @@ GEM
3
3
  specs:
4
4
  addressable (2.3.7)
5
5
  builder (3.2.2)
6
+ codeclimate-test-reporter (0.4.7)
7
+ simplecov (>= 0.7.1, < 1.0.0)
6
8
  descendants_tracker (0.0.4)
7
9
  thread_safe (~> 0.3, >= 0.3.1)
8
10
  diff-lcs (1.2.5)
@@ -72,7 +74,7 @@ PLATFORMS
72
74
 
73
75
  DEPENDENCIES
74
76
  bundler (~> 1.7)
77
+ codeclimate-test-reporter
75
78
  jeweler (~> 2.0)
76
79
  rdoc (~> 4.2)
77
80
  rspec (~> 3.2)
78
- simplecov (~> 0.9)
@@ -1,6 +1,10 @@
1
+ {<img src="https://travis-ci.org/yatsura/gcig_ca125.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/yatsura/gcig_ca125]
2
+ {<img src="https://codeclimate.com/github/yatsura/gcig_ca125.png" />}[https://codeclimate.com/github/yatsura/gcig_ca125]
3
+ {<img src="https://codeclimate.com/github/yatsura/gcig_ca125/coverage.png" />}[https://codeclimate.com/github/yatsura/gcig_ca125]
4
+
1
5
  = gcig_ca125
2
6
 
3
- Description goes here.
7
+ http://www.gcig.igcs.org/CA-125.html
4
8
 
5
9
  == Contributing to gcig_ca125
6
10
 
data/Rakefile CHANGED
@@ -33,12 +33,6 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
33
33
  spec.pattern = FileList['spec/**/*_spec.rb']
34
34
  end
35
35
 
36
- desc "Code coverage detail"
37
- task :simplecov do
38
- ENV['COVERAGE'] = "true"
39
- Rake::Task['spec'].execute
40
- end
41
-
42
36
  task :default => :spec
43
37
 
44
38
  require 'rdoc/task'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -0,0 +1,71 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: gcig_ca125 0.2.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "gcig_ca125"
9
+ s.version = "0.2.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Paul D Mitchell"]
14
+ s.date = "2015-03-09"
15
+ s.description = " A Ruby gem of calculating the response of Ovarian cancer patient\naccording to levels of CA 125 as defined by the GCIG"
16
+ s.email = "paul.d.mitchell@ed.ac.uk"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ ".travis.yml",
25
+ "Gemfile",
26
+ "Gemfile.lock",
27
+ "LICENSE.txt",
28
+ "README.rdoc",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "gcig_ca125.gemspec",
32
+ "lib/gcig_ca125.rb",
33
+ "lib/gcig_ca125/calculator.rb",
34
+ "lib/gcig_ca125/result.rb",
35
+ "lib/gcig_ca125/version.rb",
36
+ "spec/data/gcig_test_data.csv",
37
+ "spec/gcig_ca125_spec.rb",
38
+ "spec/lib/gcig_ca125/calculator_spec.rb",
39
+ "spec/spec_helper.rb",
40
+ "spec/support/test_data_reader.rb"
41
+ ]
42
+ s.homepage = "http://github.com/yatsura/gcig_ca125"
43
+ s.licenses = ["MIT"]
44
+ s.rubygems_version = "2.4.2"
45
+ s.summary = "Response and progression of ovarian cancer according to serum CA 125 levels"
46
+
47
+ if s.respond_to? :specification_version then
48
+ s.specification_version = 4
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ s.add_development_dependency(%q<codeclimate-test-reporter>, [">= 0"])
52
+ s.add_development_dependency(%q<rspec>, ["~> 3.2"])
53
+ s.add_development_dependency(%q<rdoc>, ["~> 4.2"])
54
+ s.add_development_dependency(%q<bundler>, ["~> 1.7"])
55
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
56
+ else
57
+ s.add_dependency(%q<codeclimate-test-reporter>, [">= 0"])
58
+ s.add_dependency(%q<rspec>, ["~> 3.2"])
59
+ s.add_dependency(%q<rdoc>, ["~> 4.2"])
60
+ s.add_dependency(%q<bundler>, ["~> 1.7"])
61
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<codeclimate-test-reporter>, [">= 0"])
65
+ s.add_dependency(%q<rspec>, ["~> 3.2"])
66
+ s.add_dependency(%q<rdoc>, ["~> 4.2"])
67
+ s.add_dependency(%q<bundler>, ["~> 1.7"])
68
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
69
+ end
70
+ end
71
+
@@ -9,7 +9,7 @@ module GcigCa125
9
9
  end
10
10
 
11
11
  def result
12
- Result.new is_evaluable?, is_response?, is_normalised?
12
+ Result.new self
13
13
  end
14
14
 
15
15
  def add_ca125_test(date, value)
@@ -18,21 +18,53 @@ module GcigCa125
18
18
  end
19
19
 
20
20
  def is_evaluable?
21
- @evaluable = (@tests.first[0] <= @rx_date) && (@tests.first[0] >= (@rx_date - 9))
22
- @evaluable = (@tests.first[1] > @normal_range.max * 2) if @evaluable
21
+ sample_before_rx? && sample_within_a_week_of_rx? && first_twice_uln?
23
22
  end
24
23
 
25
24
  def is_response?
26
25
  if is_evaluable?
27
- @tests.select { |test| (test[0] > date_of_fall + 28 ) && test[1] < half_of_first }.any?
26
+ @tests.select { |test| (test[0] > day_28_after_fall ) && test[1] < half_of_first }.any?
28
27
  else
29
- @response = false
28
+ false
30
29
  end
31
30
  end
32
31
 
33
32
  def is_normalised?
34
- @normalised = find_normalised
35
- @normalised.any?
33
+ find_normalised().any?
34
+ end
35
+
36
+ def samples_28days_after_fall?
37
+ test = Proc.new do |item|
38
+ item[0] > day_28_after_fall
39
+ end
40
+ @tests.select(&test).any?
41
+ end
42
+
43
+ def reduced_by_half?
44
+ (@tests.last[1].to_f / @tests.first[1].to_f ) <= 0.5
45
+ end
46
+
47
+ def first_twice_uln?
48
+ @tests.first[1] > @normal_range.max * 2
49
+ end
50
+
51
+ def test_pre_rx?
52
+ sample_before_rx? && sample_within_a_week_of_rx?
53
+ end
54
+
55
+ def sample_before_rx?
56
+ @tests.first[0] <= @rx_date
57
+ end
58
+
59
+ def sample_within_a_week_of_rx?
60
+ @tests.first[0] >= (@rx_date - 9)
61
+ end
62
+
63
+ def reduction_maintained?
64
+ test = Proc.new do |item|
65
+ item[0] > day_28_after_fall && item[1] > (value_at_fall+15)
66
+ end
67
+ @tests.select(&test).empty?
36
68
  end
37
69
 
38
70
  def sort_tests
@@ -40,17 +72,29 @@ module GcigCa125
40
72
  end
41
73
 
42
74
  private
75
+ def day_28_after_fall
76
+ date_of_fall + 28
77
+ end
78
+
43
79
  def date_of_fall
44
- valid_response = Proc.new do |test|
45
- #(test[1] < half_of_first) && (test[0] > (@rx_date + 28))
46
- (test[1] < half_of_first) && (test[0] > (@tests.first[0]))
47
- end
48
- if @tests.select(&valid_response).any?
49
- @tests.select(&valid_response).first[0]
80
+ if tests_after_fall.any?
81
+ tests_after_fall.first[0]
50
82
  else
51
83
  Date.parse('2999-01-01')
52
84
  end
53
85
  end
86
+
87
+ def value_at_fall
88
+ tests_after_fall.first[1] if tests_after_fall.any?
89
+ end
90
+
91
+ def tests_after_fall
92
+ valid_response = Proc.new do |test|
93
+ (test[1] < half_of_first) && (test[0] > (@tests.first[0]))
94
+ end
95
+ @tests.select(&valid_response)
96
+ end
97
+
54
98
  def half_of_first
55
99
  @tests.first[1] / 2.0
56
100
  end
@@ -1,12 +1,50 @@
1
1
  module GcigCa125
2
2
  class Result
3
- def initialize(eva, res, norm)
4
- @evaluable = eva
5
- @response = res
6
- @normalised = norm
3
+ def initialize(calculator)
4
+ @calculator = calculator
7
5
  end
6
+
8
7
  def to_s
9
- "Not evaluable"
8
+ result_string = if @calculator.is_evaluable?
9
+ if @calculator.is_normalised?
10
+ if @calculator.is_response?
11
+ "Confirmed response"
12
+ else
13
+ "Not confirmed"
14
+ end
15
+ else
16
+ if @calculator.is_response?
17
+ "Confirmed response"
18
+ else
19
+ "No response"
20
+ end
21
+ end
22
+ else
23
+ "Not evaluable"
24
+ end
25
+ if !@calculator.samples_28days_after_fall?
26
+ result_string = "Not confirmed: no sample > 28 days after fall"
27
+ end
28
+ if !@calculator.reduced_by_half?
29
+ result_string = "No response: no 50% reduction"
30
+ end
31
+ if !@calculator.first_twice_uln?
32
+ result_string = "Not evaluable: 1st sample < 2.ULN"
33
+ end
34
+ if !@calculator.reduction_maintained?
35
+ result_string = "Not confirmed: reduction not maintained"
36
+ end
37
+ if !@calculator.test_pre_rx?
38
+ result_string = "Not evaluable: no sample pre-Rx"
39
+ end
40
+ if !@calculator.sample_within_a_week_of_rx?
41
+ result_string = "Not evaluable: no sample within 1 week of Rx"
42
+ if !@calculator.first_twice_uln?
43
+ result_string = "Not evaluable: 1st sample < 2.ULN"
44
+ end
45
+
46
+ end
47
+ result_string
10
48
  end
11
49
 
12
50
  def message
@@ -14,16 +52,15 @@ module GcigCa125
14
52
  end
15
53
 
16
54
  def evaluable?
17
- @evaluable
55
+ @calculator.is_evaluable?
18
56
  end
19
57
 
20
58
  def response?
21
- @response
59
+ @calculator.is_response?
22
60
  end
23
61
 
24
62
  def normalised?
25
- @normalised
63
+ @calculator.is_normalised?
26
64
  end
27
-
28
65
  end
29
66
  end
@@ -1,7 +1,7 @@
1
1
  module GcigCa125
2
2
  class Version
3
3
  MAJOR = 0
4
- MINOR = 1
4
+ MINOR = 2
5
5
  PATCH = 0
6
6
  BUILD = nil
7
7
 
@@ -80,11 +80,11 @@
80
80
  ,,1994-12-28,500,,,,
81
81
  ,,1995-01-17,74,,,,
82
82
  ,,1995-02-14,8,,,1,
83
- 17,1994-07-28,1994-07-25,75,YES,YES,YES,Confirmed response.
83
+ 17,1994-07-28,1994-07-25,75,YES,YES,YES,Confirmed response
84
84
  ,,1994-08-07,25,,1,1,
85
85
  ,,1994-09-20,13,,2,2,
86
86
  ,,1994-10-18,11,,,,
87
- 18,1994-11-16,1994-11-10,8384,YES,YES,NO,Confirmed response.
87
+ 18,1994-11-16,1994-11-10,8384,YES,YES,NO,Confirmed response
88
88
  ,,1994-12-06,1030,,1,,
89
89
  ,,1994-12-27,818,,2,,
90
90
  ,,1995-01-17,155,,,,
@@ -1,8 +1,7 @@
1
- require 'pry'
2
1
  require 'spec_helper'
3
2
 
4
3
  # Test data from GCIG RESP SET
5
- #
4
+ # This is an integration test
6
5
 
7
6
  describe "GcigCa125::Calculator" do
8
7
  before(:all) do
@@ -44,6 +43,11 @@ describe "GcigCa125::Calculator" do
44
43
  expect(@calculator.result).not_to be_normalised
45
44
  end
46
45
  end
46
+
47
+ it "message" do
48
+ start_of_message = @data[:note].strip
49
+ expect(@calculator.result.message).to eq(start_of_message)
50
+ end
47
51
  end
48
52
  end
49
53
  end
@@ -1,19 +1,6 @@
1
- require 'simplecov'
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
2
3
 
3
- module SimpleCov::Configuration
4
- def clean_filters
5
- @filters = []
6
- end
7
- end
8
-
9
- SimpleCov.configure do
10
- clean_filters
11
- load_adapter 'test_frameworks'
12
- end
13
-
14
- ENV["COVERAGE"] && SimpleCov.start do
15
- add_filter "/.rvm/"
16
- end
17
4
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
18
5
  $LOAD_PATH.unshift(File.dirname(__FILE__))
19
6
 
@@ -25,5 +12,7 @@ require 'gcig_ca125'
25
12
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
26
13
 
27
14
  RSpec.configure do |config|
28
-
15
+ config.mock_with :rspec do |mocks|
16
+ mocks.verify_doubled_constant_names = true
17
+ end
29
18
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gcig_ca125
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul D Mitchell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: codeclimate-test-reporter
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +80,6 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '2.0'
69
- - !ruby/object:Gem::Dependency
70
- name: simplecov
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '0.9'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '0.9'
83
83
  description: |2-
84
84
  A Ruby gem of calculating the response of Ovarian cancer patient
85
85
  according to levels of CA 125 as defined by the GCIG
@@ -92,12 +92,14 @@ extra_rdoc_files:
92
92
  files:
93
93
  - ".document"
94
94
  - ".rspec"
95
+ - ".travis.yml"
95
96
  - Gemfile
96
97
  - Gemfile.lock
97
98
  - LICENSE.txt
98
99
  - README.rdoc
99
100
  - Rakefile
100
101
  - VERSION
102
+ - gcig_ca125.gemspec
101
103
  - lib/gcig_ca125.rb
102
104
  - lib/gcig_ca125/calculator.rb
103
105
  - lib/gcig_ca125/result.rb
@@ -105,7 +107,6 @@ files:
105
107
  - spec/data/gcig_test_data.csv
106
108
  - spec/gcig_ca125_spec.rb
107
109
  - spec/lib/gcig_ca125/calculator_spec.rb
108
- - spec/lib/gcig_ca125/result_spec.rb
109
110
  - spec/spec_helper.rb
110
111
  - spec/support/test_data_reader.rb
111
112
  homepage: http://github.com/yatsura/gcig_ca125
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "GcigCa125::Result" do
4
- it "response to message" do
5
- expect(GcigCa125::Result.instance_methods).to include(:message)
6
- end
7
-
8
- it "response to evaluable" do
9
- expect(GcigCa125::Result.instance_methods).to include(:evaluable?)
10
- end
11
-
12
- it "response to response" do
13
- expect(GcigCa125::Result.instance_methods).to include(:response?)
14
- end
15
-
16
- it "response to normalised" do
17
- expect(GcigCa125::Result.instance_methods).to include(:normalised?)
18
- end
19
-
20
- context "#message" do
21
- it "starts with 'No response' if evaluable but no response and has not normalised" do
22
- skip
23
- end
24
-
25
- it "starts with 'Not evaluable' if not evaluable" do
26
- skip
27
- end
28
-
29
- it "starts with 'Not confirmed' if evaluable and normalised but not response" do
30
- skip
31
- end
32
-
33
- it "starts with 'Confirmed response' if evaluable, normalised and is a response" do
34
- skip
35
- end
36
- end
37
- end