rx_nav 0.1.3 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6633b0bda99be55c44b3d152c66cc9094a79a73
4
- data.tar.gz: ae06ac9f8c9a1d918f25f831c63d081579e83661
3
+ metadata.gz: 8367470122958506ce71097193a6cf0412337350
4
+ data.tar.gz: 09ab00eadee63525cffff3503bd2b6cf727c6692
5
5
  SHA512:
6
- metadata.gz: 3ce7dfe514871db74d52f3325404601012dcba1b5e554d01c51611d38a14fa118c12e62aaaa744d95fdeeca3ae81402c545065306608821fcdca02e67bfc2bb6
7
- data.tar.gz: 4f5acd0857e68c6812d7af19d0a8e6c99d44c90cb2a54677b47bedab39a3ed8bdda07151f67f86cedee19ff30f0e430ab567ba0d9d6030b5755a79f237e8d3ef
6
+ metadata.gz: bd3d4a99fbddfe32604451cbe3a59f94de135ba097d4cf15637220bf403e08260f619bea1ab0d7b6109a48630ac982ef6c49f56400356966c917e6cd55982030
7
+ data.tar.gz: 90540aea81270a5926f35808add76a13add19e980a9a2c43d5634e0883973c2b52148344ed6e5c58297d029abd69c8a059ed3685ba45b9d87d2a7d9a18742892
data/Gemfile CHANGED
@@ -2,3 +2,9 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rx_nav.gemspec
4
4
  gemspec
5
+
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
7
+
8
+ group :development do
9
+ gem 'guard-rspec', require: false
10
+ end
@@ -0,0 +1,16 @@
1
+ clearing :on
2
+
3
+ guard :rspec, cmd: "bundle exec rspec" do
4
+ require "guard/rspec/dsl"
5
+ dsl = Guard::RSpec::Dsl.new(self)
6
+
7
+ # RSpec files
8
+ rspec = dsl.rspec
9
+ watch(rspec.spec_helper) { rspec.spec_dir }
10
+ watch(rspec.spec_support) { rspec.spec_dir }
11
+ watch(rspec.spec_files)
12
+
13
+ # Ruby files
14
+ ruby = dsl.ruby
15
+ dsl.watch_spec_files_for(ruby.lib_files)
16
+ end
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # RxNav
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/rx_nav.png)](http://badge.fury.io/rb/rx_nav) [![Code Climate](https://codeclimate.com/github/jbender/rx_nav_ruby.png)](https://codeclimate.com/github/jbender/rx_nav_ruby)
3
+ [![Gem Version](http://img.shields.io/gem/v/rx_nav.svg?style=flat-square)](https://rubygems.org/gems/rx_nav) [![Dependency Status](http://img.shields.io/gemnasium/jbender/rx_nav_ruby.svg?style=flat-square)](https://gemnasium.com/jbender/rx_nav_ruby)
4
+ [![Code Climate](http://img.shields.io/codeclimate/github/jbender/rx_nav_ruby.svg?style=flat-square)](https://codeclimate.com/github/jbender/rx_nav_ruby) [![Test Coverage](https://img.shields.io/codeclimate/coverage/github/jbender/rx_nav_ruby.svg?style=flat-square)](https://codeclimate.com/github/jbender/rx_nav_ruby)
5
+ [ ![Codeship Status for jbender/rx_nav_ruby](https://img.shields.io/codeship/e1dd97e0-8d48-0132-a9a4-5691319bff63.svg?style=flat-square)](https://codeship.com/projects/60640)
4
6
 
5
7
  This gem makes it easier to work with the RxNav REST APIs, as enumerated on [this page](http://rxnav.nlm.nih.gov/APIsOverview.html).
6
8
 
@@ -22,7 +24,41 @@ Or install it yourself as:
22
24
 
23
25
  ## Usage
24
26
 
25
- TODO: Write usage instructions here
27
+ Each service has it's own class, which have the class methods enumerated below. When appropriate, these methods will return `Concept`s, which are further queryable to retrieve more information about a specific drug. **Question marks indicate optional parameters.**
28
+
29
+ Please note that according to the [NLM Terms of Service](http://rxnav.nlm.nih.gov/TermOfService.html), you can will only be able to make **20 requests/second/IP**, so keep that in mind when implementing this project.
30
+
31
+ ### [NDF-RT (Class named NDFRT)](https://github.com/jbender/rx_nav_ruby/blob/master/lib/rx_nav/ndfrt.rb)
32
+
33
+ * all_records_by_kind
34
+ * get_info
35
+ * find_by_name(name, kind?)
36
+ * find_by_id(type, id)
37
+ * find_by({type: x, id: y} OR {name: x, kind: y})
38
+ * possible_roles
39
+ * possible_properties
40
+ * possible_kinds
41
+ * possible_types
42
+ * possible_associations
43
+ * possible_options_for(type)
44
+ * api_version
45
+
46
+ ### [RxNorm](https://github.com/jbender/rx_nav_ruby/blob/master/lib/rx_nav/rx_norm.rb)
47
+
48
+ * search_by_name(name, options?)
49
+ * find_rxcui_by_id(type, id)
50
+ * find_rxcui_by_name(name)
51
+ * find_drugs_by_name(name)
52
+ * spelling_suggestions(name)
53
+ * status(id)
54
+ * properties(id)
55
+ * quantity(id)
56
+ * strength(id)
57
+
58
+ ### [RxTerms](https://github.com/jbender/rx_nav_ruby/blob/master/lib/rx_nav/rx_terms.rb)
59
+
60
+ * all_concepts
61
+ * all_info(id)
26
62
 
27
63
  ## Contributing
28
64
 
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
- require "bundler/gem_tasks"
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec) do |t|
4
+ t.pattern = 'spec/**/*_spec.rb'
5
+ end
6
+
7
+ task default: :spec
@@ -24,4 +24,8 @@ module RxNav
24
24
  return RxNav.nori.parse(Net::HTTP.get request)
25
25
  end
26
26
 
27
+ def self.ensure_array obj
28
+ (obj && !obj.is_a?(Array)) ? [obj] : obj
29
+ end
30
+
27
31
  end
@@ -28,10 +28,10 @@ module RxNav
28
28
 
29
29
  # Supplementary calls to fetch info from other DBs
30
30
  # Note: these methods return false if no information was found
31
-
31
+
32
32
  def get_terms_info
33
33
  rxcui = get_rxcui
34
- info = RxNav::RxTerms.get_info(rxcui)
34
+ info = RxNav::RxTerms.all_info(rxcui)
35
35
  merge_concept info
36
36
  end
37
37
 
@@ -58,7 +58,8 @@ module RxNav
58
58
  if self.nui.nil?
59
59
  raise "This concept doesn't have a nui or rxcui"
60
60
  else
61
- self.rxcui = RxNav::RxNorm.find_rxcui_by_id('nui', self.nui)
61
+ rxcui = RxNav::RxNorm.find_rxcui_by_id('nui', self.nui)
62
+ self.rxcui = rxcui.is_a?(Array) ? rxcui.first : rxcui
62
63
  end
63
64
  end
64
65
  # If we had to look it up, use that, otherwise use the model's
@@ -85,7 +86,7 @@ module RxNav
85
86
  str.gsub(/\w+/) { |w| w.capitalize } if str.is_a? String
86
87
  end
87
88
 
88
- def merge_concept concept
89
+ def merge_concept concept_hash
89
90
  if concept_hash.nil? || concept_hash.empty?
90
91
  return false
91
92
  else
@@ -99,4 +100,4 @@ module RxNav
99
100
  end
100
101
 
101
102
  end
102
- end
103
+ end
@@ -38,7 +38,7 @@ module RxNav
38
38
  type = type.upcase
39
39
  id = id.to_s
40
40
  query = "/idType=#{type}&idString=#{id}"
41
- return get_concepts query
41
+ get_concepts query
42
42
  end
43
43
 
44
44
  def find_by_name name, kind = nil
@@ -47,24 +47,27 @@ module RxNav
47
47
  kind = kind.upcase + '_KIND'
48
48
  query += "&kindName=#{kind}"
49
49
  end
50
- return get_concepts query
51
- end
52
-
53
- def find_interacting_drugs nui, scope = 3
54
- query = "/interaction/nui=#{nui}&scope=#{scope}"
55
- response = get_response_hash query
56
- data = response[:group_interactions][:interactions][:group_interacting_drugs][:interacting_drug]
57
- data = [data] unless data.is_a? Array
58
- return data.map { |i| RxNav::Concept.new i[:concept] }
59
- end
60
-
61
- def find_interactions_between nuis, scope = 3
62
- query = "/interaction?nuis=#{nuis.join('+')}&scope=#{scope}"
63
- data = get_response_hash query
64
- return data[:full_interaction_group][:full_interaction].map do |fi|
65
- RxNav::Interaction.new fi[:interaction_triple_group][:interaction_triple]
66
- end
67
- end
50
+ get_concepts query
51
+ end
52
+
53
+ # PLEASE NOTE:
54
+ # These methods were deprecated in the Sept 2014 release of ND-FRT
55
+ #
56
+ # def find_interacting_drugs nui, scope = 3
57
+ # query = "/interaction/nui=#{nui}&scope=#{scope}"
58
+ # response = get_response_hash query
59
+ # data = response[:group_interactions][:interactions][:group_interacting_drugs][:interacting_drug]
60
+ # data = [data] unless data.is_a? Array
61
+ # return data.map { |i| RxNav::Concept.new i[:concept] }
62
+ # end
63
+ #
64
+ # def find_interactions_between nuis, scope = 3
65
+ # query = "/interaction?nuis=#{nuis.join('+')}&scope=#{scope}"
66
+ # data = get_response_hash query
67
+ # return data[:full_interaction_group][:full_interaction].map do |fi|
68
+ # RxNav::Interaction.new fi[:interaction_triple_group][:interaction_triple]
69
+ # end
70
+ # end
68
71
 
69
72
  def get_info nui, concept = nil
70
73
  raise "Nui cannot be nil" if nui.nil?
@@ -79,7 +82,7 @@ module RxNav
79
82
  data = get_response_hash(query)[:group_concepts][:concept]
80
83
  return data.map { |c| RxNav::Concept.new c }
81
84
  end
82
-
85
+
83
86
  private
84
87
 
85
88
  def get_response_hash query
@@ -94,8 +97,7 @@ module RxNav
94
97
  def get_concepts query
95
98
  data = get_response_hash(query)[:group_concepts]
96
99
  if data && data[:concept]
97
- concepts = data[:concept]
98
- concepts = [concepts] unless concepts.is_a?(Array)
100
+ concepts = RxNav.ensure_array data[:concept]
99
101
  return concepts.map { |c| RxNav::Concept.new(c) }
100
102
  else
101
103
  return nil
@@ -1,21 +1,23 @@
1
1
  module RxNav
2
2
  class RxNorm
3
3
  class << self
4
-
4
+
5
5
  def search_by_name name, options = {}
6
6
  options = {max_results: 20, options: 0}.merge(options)
7
-
7
+
8
8
  query = "/approximateTerm?term=#{name}"\
9
9
  "&maxEntries=#{options[:max_results]}"\
10
10
  "&options=#{options[:options]}"
11
11
 
12
12
  # Get the data we care about in the right form
13
13
  data = get_response_hash(query)[:approximate_group][:candidate]
14
- data = [data] if (data && !data.is_a?(Array))
15
14
 
16
15
  # If we didn't get anything, say so
17
16
  return nil if data.nil?
18
-
17
+
18
+ # Put it in the right form
19
+ data = RxNav.ensure_array data
20
+
19
21
  return data.map { |c| RxNav::Concept.new(c) }
20
22
  end
21
23
 
@@ -65,13 +67,12 @@ module RxNav
65
67
 
66
68
  status.send("remapped?=", reported_status == 'remapped')
67
69
  status.send("active?=", reported_status == 'active')
68
-
70
+
69
71
  if status.remapped?
70
- concepts = data[:min_concept_group][:min_concept]
71
- concepts = [concepts] if (concepts && !concepts.is_a?(Array))
72
+ concepts = RxNav.ensure_array data[:min_concept_group][:min_concept]
72
73
  status.remapped_to = concepts.map { |c| c[:rxcui] }
73
74
  end
74
-
75
+
75
76
  return status
76
77
  end
77
78
 
@@ -80,14 +81,27 @@ module RxNav
80
81
  return OpenStruct.new get_response_hash(query)[:properties]
81
82
  end
82
83
 
84
+ def property id, name
85
+ query = "/rxcui/#{id}/property?propName=#{name.upcase}"
86
+ response = get_response_hash(query)
87
+
88
+ concept_group = response[:property_concept_group]
89
+ return nil unless concept_group
90
+
91
+ concepts = concept_group[:property_concept]
92
+ return concepts ? concepts[:prop_value] : nil
93
+ end
94
+
83
95
  def quantity id
84
- query = "/rxcui/#{id}/quantity"
85
- return get_response_hash(query)[:quantity_group][:quantity]
96
+ property id, "quantity"
86
97
  end
87
98
 
88
99
  def strength id
89
- query = "/rxcui/#{id}/strength"
90
- return get_response_hash(query)[:strength_group][:strength]
100
+ property id, "strength"
101
+ end
102
+
103
+ def available_strength id
104
+ property id, "available_strength"
91
105
  end
92
106
 
93
107
  private
@@ -95,12 +109,12 @@ module RxNav
95
109
  def get_response_hash query
96
110
  RxNav.make_request(query)[:rxnormdata]
97
111
  end
98
-
112
+
99
113
  def extract_rxcui query
100
114
  data = get_response_hash(query)
101
115
  if data[:id_group]
102
- data = [data] unless data.is_a?(Array)
103
- return data.map { |c| c[:rxnorm_id] }
116
+ data = RxNav.ensure_array data
117
+ return data.map { |c| c[:id_group][:rxnorm_id] }
104
118
  else
105
119
  return nil
106
120
  end
@@ -1,3 +1,3 @@
1
1
  module RxNav
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_development_dependency 'bundler', '~> 1.3'
25
25
  spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'rspec', '>= 2.0.0'
26
27
  end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe RxNav::Concept do
4
+ context 'new concept' do
5
+ subject { RxNav::Concept.new }
6
+ it { is_expected.to be_kind_of(OpenStruct) }
7
+ it { is_expected.to respond_to(:name) }
8
+ it { is_expected.to respond_to(:kind) }
9
+ it { is_expected.to respond_to(:nui) }
10
+ it { is_expected.to respond_to(:to_s) }
11
+ it { is_expected.to respond_to(:get_terms_info) }
12
+ it { is_expected.to respond_to(:get_ndfrt_info) }
13
+ it { is_expected.to respond_to(:get_norm_info) }
14
+ end
15
+
16
+ context 'NDF-RT concept "N0000152900"' do
17
+ let(:nui) { "N0000152900" }
18
+ let(:concept) { RxNav::NDFRT.get_info nui }
19
+ subject { concept }
20
+
21
+ context "#name" do
22
+ subject { concept.name }
23
+ it { is_expected.to be_kind_of(String) }
24
+ it { is_expected.to eq("Acetic Acid 2%/Hydrocortisone 1% Soln,Otic") }
25
+ end
26
+
27
+ context "#kind" do
28
+ subject { concept.kind }
29
+ it { is_expected.to be_kind_of(String) }
30
+ it { is_expected.to eq("Drug") }
31
+ end
32
+
33
+ context "#nui" do
34
+ subject { concept.nui }
35
+ it { is_expected.to be_kind_of(String) }
36
+ it { is_expected.to eq(nui) }
37
+ end
38
+
39
+ context "#to_s" do
40
+ subject { concept.to_s }
41
+ it { is_expected.to be_kind_of(String) }
42
+ it { is_expected.to eq(concept.name) }
43
+ end
44
+
45
+ context "#get_terms_info" do
46
+ let(:original) { concept }
47
+ subject { concept.get_terms_info }
48
+ it { is_expected.to be_kind_of(RxNav::Concept) }
49
+ end
50
+
51
+ context "#get_ndfrt_info" do
52
+ let(:original) { concept }
53
+ subject { concept.get_ndfrt_info }
54
+ it { is_expected.to be_kind_of(RxNav::Concept) }
55
+ end
56
+
57
+ context "#get_norm_info" do
58
+ let(:original) { concept }
59
+ subject { concept.get_norm_info }
60
+ it { is_expected.to be_kind_of(RxNav::Concept) }
61
+ end
62
+
63
+ end
64
+ end
@@ -0,0 +1,116 @@
1
+ require 'spec_helper'
2
+ require 'support/api'
3
+ require 'support/array_type'
4
+
5
+ describe RxNav::NDFRT do
6
+
7
+ describe "remote endpoints" do
8
+ url = "http://rxnav.nlm.nih.gov/REST/Ndfrt"
9
+ response = Net::HTTP.get(URI("#{url}/json"))
10
+ subject { JSON.parse(response)["resourceList"]["resource"] }
11
+
12
+ include_examples 'uses valid endpoints', [
13
+ "#{url}/version",
14
+ "#{url}/associationList",
15
+ "#{url}/typeList",
16
+ "#{url}/kindList",
17
+ "#{url}/propertyList",
18
+ "#{url}/roleList",
19
+ "#{url}/idType={idType}&idString={idString}",
20
+ "#{url}/search?conceptName={conceptName}&kindName={kindName}",
21
+ "#{url}/allInfo/{nui}",
22
+ "#{url}/allconcepts?kind=yourKinds"
23
+ ]
24
+ end
25
+
26
+ describe "#api_version" do
27
+ subject { RxNav::NDFRT.api_version }
28
+
29
+ it { is_expected.to be_kind_of(String) }
30
+ end
31
+
32
+ describe "#possible_associations" do
33
+ subject { RxNav::NDFRT.possible_associations }
34
+
35
+ include_examples 'should be an array of', String
36
+ end
37
+
38
+ describe "#possible_types" do
39
+ subject { RxNav::NDFRT.possible_types }
40
+
41
+ include_examples 'should be an array of', String
42
+ end
43
+
44
+ describe "#possible_kinds" do
45
+ subject { RxNav::NDFRT.possible_kinds }
46
+
47
+ include_examples 'should be an array of', String
48
+ end
49
+
50
+ describe "#possible_properties" do
51
+ subject { RxNav::NDFRT.possible_properties }
52
+
53
+ include_examples 'should be an array of', String
54
+ end
55
+
56
+ describe "#possible_roles" do
57
+ subject { RxNav::NDFRT.possible_roles }
58
+
59
+ include_examples 'should be an array of', String
60
+ end
61
+
62
+ describe "#find_by_id for type RXCUI and id 161" do
63
+ subject { RxNav::NDFRT.find_by_id 'RXCUI', '161' }
64
+
65
+ include_examples 'should be an array of', RxNav::Concept
66
+ end
67
+
68
+ describe "#find_by_name morphine without kind" do
69
+ subject { RxNav::NDFRT.find_by_name 'morphine' }
70
+
71
+ include_examples 'should be an array of', RxNav::Concept
72
+ end
73
+
74
+ describe "#find_by_name morphine with kind ingredient" do
75
+ subject { RxNav::NDFRT.find_by_name 'morphine', 'ingredient' }
76
+
77
+ include_examples 'should be an array of', RxNav::Concept
78
+ end
79
+
80
+ describe "#find_by with hash of name" do
81
+ it "should return the same as find_by_name" do
82
+ @generic_find = RxNav::NDFRT.find_by name: 'morphine'
83
+ @specific_find = RxNav::NDFRT.find_by_name 'morphine'
84
+ expect(@generic_find).to eq(@specific_find)
85
+ end
86
+ end
87
+
88
+ describe "#find_by with hash of name and kind" do
89
+ it "should return the same as find_by_name" do
90
+ @generic_find = RxNav::NDFRT.find_by name: 'morphine', kind: 'ingredient'
91
+ @specific_find = RxNav::NDFRT.find_by_name 'morphine', 'ingredient'
92
+ expect(@generic_find).to eq(@specific_find)
93
+ end
94
+ end
95
+
96
+ describe "#find_by with hash of type and id" do
97
+ it "should return the same as find_by_name" do
98
+ @generic_find = RxNav::NDFRT.find_by type: 'RXCUI', id: '161'
99
+ @specific_find = RxNav::NDFRT.find_by_id 'RXCUI', '161'
100
+ expect(@generic_find).to eq(@specific_find)
101
+ end
102
+ end
103
+
104
+ describe "#all_records_by_kind" do
105
+ subject { RxNav::NDFRT.all_records_by_kind "pharmacokinetics" }
106
+
107
+ include_examples 'should be an array of', RxNav::Concept
108
+ end
109
+
110
+ describe "#get_info" do
111
+ subject { RxNav::NDFRT.get_info "N0000152900" }
112
+
113
+ it { is_expected.to be_kind_of(RxNav::Concept) }
114
+ end
115
+
116
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe "http://rxnav.nlm.nih.gov/REST" do
4
+ before :all do
5
+ @url = URI "http://rxnav.nlm.nih.gov/REST/json"
6
+ @response = Net::HTTP.get(@url)
7
+ @json = JSON.parse(@response)
8
+ end
9
+
10
+ it "should be online" do
11
+ expect(@json).to_not be_empty
12
+ end
13
+
14
+ end
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+ require 'support/api'
3
+ require 'support/array_type'
4
+
5
+ describe RxNav::RxNorm do
6
+
7
+ describe "remote endpoints" do
8
+ url = "http://rxnav.nlm.nih.gov/REST"
9
+ response = Net::HTTP.get(URI("#{url}/json"))
10
+ subject { JSON.parse(response)["resourceList"]["resource"] }
11
+
12
+ include_examples 'uses valid endpoints', [
13
+ "#{url}/approximateTerm?term=value&maxEntries=value&option=value",
14
+ "#{url}/rxcui?idtype=yourIdtype&id=yourId&allsrc=0or1",
15
+ "#{url}/rxcui?name=yourName&srclist=yourSources&allsrc=0or1&search=0or1or2",
16
+ "#{url}/drugs?name=yourName",
17
+ "#{url}/spellingsuggestions?name=yourName",
18
+ "#{url}/rxcui/{rxcui}/status",
19
+ "#{url}/rxcui/{rxcui}/properties",
20
+ "#{url}/rxcui/{rxcui}/property?propName=propName"
21
+ ]
22
+ end
23
+
24
+ describe "#search_by_name" do
25
+ subject { RxNav::RxNorm.search_by_name "zocor" }
26
+
27
+ include_examples 'should be an array of', RxNav::Concept
28
+ end
29
+
30
+ describe "#find_rxcui_by_id" do
31
+ describe "NUI search" do
32
+ subject { RxNav::RxNorm.find_rxcui_by_id "NUI", "N0000148200" }
33
+ include_examples 'should be an array of', String
34
+ end
35
+
36
+ describe "NDC search" do
37
+ subject { RxNav::RxNorm.find_rxcui_by_id "NDC", "0781-1506-10" }
38
+ include_examples 'should be an array of', String
39
+ end
40
+ end
41
+
42
+ describe "#find_rxcui_by_name" do
43
+ subject { RxNav::RxNorm.find_rxcui_by_name "lipitor" }
44
+ include_examples 'should be an array of', String
45
+ end
46
+
47
+ describe "#find_drugs_by_name" do
48
+ let(:results) { RxNav::RxNorm.find_drugs_by_name "cymbalta" }
49
+
50
+ context "at the top level" do
51
+ subject { results }
52
+ include_examples 'should be an array of', Hash
53
+ end
54
+
55
+ context "first result" do
56
+ subject { results.first }
57
+ it { is_expected.to include(:name) }
58
+ it { is_expected.to include(:concepts) }
59
+
60
+ context 'name' do
61
+ subject { results.first[:name] }
62
+ it { is_expected.to be_kind_of(String) }
63
+ end
64
+
65
+ context 'concepts' do
66
+ subject { results.first[:concepts] }
67
+ include_examples 'should be an array of', RxNav::Concept
68
+ end
69
+ end
70
+ end
71
+
72
+ describe '#spelling_suggestions' do
73
+ subject { RxNav::RxNorm.spelling_suggestions "ambienn" }
74
+
75
+ include_examples 'should be an array of', String
76
+ end
77
+
78
+ describe "#status" do
79
+ subject { RxNav::RxNorm.status "105048" }
80
+
81
+ it { is_expected.to be_kind_of(OpenStruct) }
82
+ it { is_expected.to respond_to(:active?) }
83
+ it { is_expected.to respond_to(:remapped?) }
84
+ end
85
+
86
+ describe "#properties" do
87
+ subject { RxNav::RxNorm.properties "131725" }
88
+
89
+ it { is_expected.to be_kind_of(OpenStruct) }
90
+ end
91
+
92
+ end
@@ -0,0 +1,4 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
4
+ require_relative '../lib/rx_nav'
@@ -0,0 +1,5 @@
1
+ shared_examples 'uses valid endpoints' do |endpoints|
2
+ endpoints.each do |endpoint|
3
+ it { should include(endpoint) }
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ shared_examples 'should be an array of' do |klass|
2
+ it { is_expected.to be_kind_of(Array) }
3
+ it { is_expected.to_not be_empty }
4
+ it { is_expected.to all( be_a klass ) }
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rx_nav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Bender
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-09 00:00:00.000000000 Z
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nori
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 2.0.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 2.0.0
69
83
  description: Ruby wrappers for the RxNav RESTful APIs
70
84
  email:
71
85
  - jlbender@gmail.com
@@ -75,6 +89,7 @@ extra_rdoc_files: []
75
89
  files:
76
90
  - ".gitignore"
77
91
  - Gemfile
92
+ - Guardfile
78
93
  - LICENSE.txt
79
94
  - README.md
80
95
  - Rakefile
@@ -86,6 +101,13 @@ files:
86
101
  - lib/rx_nav/rx_terms.rb
87
102
  - lib/rx_nav/version.rb
88
103
  - rx_nav.gemspec
104
+ - spec/concept_spec.rb
105
+ - spec/ndfrt_spec.rb
106
+ - spec/rx_nav_spec.rb
107
+ - spec/rx_norm_spec.rb
108
+ - spec/spec_helper.rb
109
+ - spec/support/api.rb
110
+ - spec/support/array_type.rb
89
111
  homepage: https://github.com/jbender/rx_nav_ruby
90
112
  licenses:
91
113
  - MIT
@@ -106,8 +128,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
128
  version: '0'
107
129
  requirements: []
108
130
  rubyforge_project:
109
- rubygems_version: 2.2.1
131
+ rubygems_version: 2.2.2
110
132
  signing_key:
111
133
  specification_version: 4
112
134
  summary: Ruby-based way of interacting with the RxNav APIs (http://rxnav.nlm.nih.gov/APIsOverview.html)
113
- test_files: []
135
+ test_files:
136
+ - spec/concept_spec.rb
137
+ - spec/ndfrt_spec.rb
138
+ - spec/rx_nav_spec.rb
139
+ - spec/rx_norm_spec.rb
140
+ - spec/spec_helper.rb
141
+ - spec/support/api.rb
142
+ - spec/support/array_type.rb