pillboxr 0.0.2
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 +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +27 -0
- data/README.rdoc +44 -0
- data/Rakefile +15 -0
- data/lib/activeresource_patch.rb +27 -0
- data/lib/compatibility.rb +15 -0
- data/lib/pillbox_resource_noko.rb +40 -0
- data/lib/pillboxr.rb +552 -0
- data/lib/version.rb +1 -0
- data/pillboxr.gemspec +28 -0
- data/test/fixtures/all_meds.yml +8445 -0
- data/test/fixtures/image_meds.yml +4223 -0
- data/test/fixtures/meds.xml +73 -0
- data/test/fixtures/no_image_meds.yml +4223 -0
- data/test/pillboxr_test.rb +106 -0
- data/test/test_helper.rb +16 -0
- metadata +131 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class PillboxrTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
# @meds = load_yaml_fixture
|
8
|
+
Pillboxr.test!
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_should_find_by_combo_shape
|
12
|
+
med = Pillboxr.first(:params=>{'color'=>"C48324;C48323"})
|
13
|
+
assert_equal("Acetaminophen 150 MG / Aspirin 180 MG / Codeine 30 MG Oral Capsule", med.rxstring)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_should_accept_shape_as_hex
|
17
|
+
meds = Pillboxr.all(:params=>{'shape' => 'C48336'})
|
18
|
+
assert_equal(2345, Pillboxr.record_count)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_should_accept_color_as_hex
|
22
|
+
meds = Pillboxr.all(:params => {'color' => "C48328"})
|
23
|
+
assert_equal(886, Pillboxr.record_count)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_should_accept_multiple_colors
|
27
|
+
meds = Pillboxr.all(:params => { 'color' => ['C48328', 'C48327']})
|
28
|
+
assert_equal(1, meds.count)
|
29
|
+
assert_equal('Selfemra 20 MG Oral Capsule', meds.first.rxstring)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_should_accept_shape_as_string
|
33
|
+
meds = Pillboxr.all(:params => {'shape' => 'capsule'})
|
34
|
+
assert_equal(2345, Pillboxr.record_count)
|
35
|
+
meds.each { |m| assert_equal('capsule', m.shape.kind_of?(Array) ? m.shape.first.downcase : m.shape.downcase) }
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_should_accept_color_as_string
|
39
|
+
meds = Pillboxr.all(:params => {'color' => 'white'})
|
40
|
+
assert_equal(4364, Pillboxr.record_count)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_param_combinations_should_work
|
44
|
+
meds = Pillboxr.all(:params => {'shape' => 'C48348', 'color' => 'C48325'})
|
45
|
+
assert_equal(2401, Pillboxr.record_count)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_imprint_search_should_work
|
49
|
+
meds = Pillboxr.all(:params => {'imprint' => 'NVR'})
|
50
|
+
assert_equal(69, Pillboxr.record_count)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_size_search_should_work
|
54
|
+
meds = Pillboxr.all(:params => {'size' => '12.00'})
|
55
|
+
assert_equal(3082, Pillboxr.record_count)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_should_return_normalized_array_of_strings_for_inactive_ingredients
|
59
|
+
meds = Pillboxr.all(:params => {:has_image => true})
|
60
|
+
assert_equal(Array, meds.first.inactive.class)
|
61
|
+
meds.first.inactive.each do |ing|
|
62
|
+
assert_no_match(/\s$/, ing)
|
63
|
+
assert_no_match(/^\s/, ing)
|
64
|
+
end
|
65
|
+
assert_equal("SILICON DIOXIDE", meds.first.inactive[1])
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_should_return_appropriate_dea_schedule
|
69
|
+
med = Pillboxr.first(:params => {:ingredient => 'Hydromorphone'})
|
70
|
+
assert_equal('Schedule II', med.dea)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_should_allow_searching_for_multiple_active_ingredients
|
74
|
+
med = Pillboxr.all(:params => {:ingredient => ['amlodipine', 'benazepril']})
|
75
|
+
assert_equal(28, med.count)
|
76
|
+
med = Pillboxr.all(:params => {:ingredient => ['valsartan','hydrochlorothiazide', 'amlodipine']})
|
77
|
+
assert_not_nil(med)
|
78
|
+
assert_equal(5, med.count)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_should_return_a_valid_image_url
|
82
|
+
meds = Pillboxr.all(:params => {:has_image => 1})
|
83
|
+
meds.each { |m| assert_equal("http://pillbox.nlm.nih.gov/assets/super_small/#{m.image_id}ss.png", m.image_url)}
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_should_return_an_array_of_valid_urls
|
87
|
+
meds = Pillboxr.all(:params => {:has_image => 1})
|
88
|
+
meds.each do |m|
|
89
|
+
assert_equal(["http://pillbox.nlm.nih.gov/assets/super_small/#{m.image_id}ss.png",
|
90
|
+
"http://pillbox.nlm.nih.gov/assets/small/#{m.image_id}sm.jpg",
|
91
|
+
"http://pillbox.nlm.nih.gov/assets/medium/#{m.image_id}md.jpg",
|
92
|
+
"http://pillbox.nlm.nih.gov/assets/large/#{m.image_id}lg.jpg"], m.image_url('all'))
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_should_return_a_valid_trade_name
|
97
|
+
med = Pillboxr.first(:params => {:ingredient => 'Sildenafil'})
|
98
|
+
assert_equal('Viagra', med.trade_name)
|
99
|
+
end
|
100
|
+
|
101
|
+
if RUBY_VERSION > '1.9'
|
102
|
+
def test_should_rescue_rexml_parser_error
|
103
|
+
assert_nothing_raised { med = Pillboxr.all(:params => {:dea => "a"} ) }
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.unshift File.dirname(File.dirname(__FILE__))
|
3
|
+
require 'test/unit'
|
4
|
+
require 'lib/pillboxr'
|
5
|
+
|
6
|
+
class Test::Unit::TestCase
|
7
|
+
|
8
|
+
def load_yaml_fixture(path = all_meds.yml)
|
9
|
+
absolute_path = File.join(File.dirname(__FILE__), "fixtures", path)
|
10
|
+
YAML::load_file absolute_path
|
11
|
+
end
|
12
|
+
|
13
|
+
def deny(*args)
|
14
|
+
args.each { |arg| assert !arg }
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pillboxr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Keith Gautreaux
|
13
|
+
- David Hale
|
14
|
+
- Darius Roberts
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2010-10-24 00:00:00 -05:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: activeresource
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">"
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 3
|
33
|
+
- 5
|
34
|
+
version: 2.3.5
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: bundler
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
segments:
|
46
|
+
- 1
|
47
|
+
- 0
|
48
|
+
- 0
|
49
|
+
version: 1.0.0
|
50
|
+
type: :development
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
name: activeresource
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
segments:
|
61
|
+
- 2
|
62
|
+
- 3
|
63
|
+
- 5
|
64
|
+
version: 2.3.5
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
67
|
+
description: |
|
68
|
+
Pillboxr is a subclass of ActiveResource::Base that provides additional convenience methods and some parameter wrapping for querying the Pillbox API Service located at http://pillbox.nlm.nih.gov/PHP/pillboxAPIService.php
|
69
|
+
|
70
|
+
email:
|
71
|
+
- keith.gautreaux@gmail.com
|
72
|
+
executables: []
|
73
|
+
|
74
|
+
extensions: []
|
75
|
+
|
76
|
+
extra_rdoc_files: []
|
77
|
+
|
78
|
+
files:
|
79
|
+
- .gitignore
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- README.rdoc
|
83
|
+
- Rakefile
|
84
|
+
- lib/activeresource_patch.rb
|
85
|
+
- lib/compatibility.rb
|
86
|
+
- lib/pillbox_resource_noko.rb
|
87
|
+
- lib/pillboxr.rb
|
88
|
+
- lib/version.rb
|
89
|
+
- pillboxr.gemspec
|
90
|
+
- test/fixtures/all_meds.yml
|
91
|
+
- test/fixtures/image_meds.yml
|
92
|
+
- test/fixtures/meds.xml
|
93
|
+
- test/fixtures/no_image_meds.yml
|
94
|
+
- test/pillboxr_test.rb
|
95
|
+
- test/test_helper.rb
|
96
|
+
has_rdoc: true
|
97
|
+
homepage: http://rubygems.org/gems/pillboxr
|
98
|
+
licenses: []
|
99
|
+
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
segments:
|
111
|
+
- 0
|
112
|
+
version: "0"
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
segments:
|
119
|
+
- 1
|
120
|
+
- 3
|
121
|
+
- 6
|
122
|
+
version: 1.3.6
|
123
|
+
requirements: []
|
124
|
+
|
125
|
+
rubyforge_project: pillboxr
|
126
|
+
rubygems_version: 1.3.7
|
127
|
+
signing_key:
|
128
|
+
specification_version: 3
|
129
|
+
summary: Access the NLM Pillbox API using ActiveResource.
|
130
|
+
test_files: []
|
131
|
+
|