rx_nav 0.1.2 → 0.1.3

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: c2c59070713b04541c769ff646e41b604a6bf346
4
- data.tar.gz: 0a97e79e7f9702a0f3723be29bc44acbf61a8bef
3
+ metadata.gz: e6633b0bda99be55c44b3d152c66cc9094a79a73
4
+ data.tar.gz: ae06ac9f8c9a1d918f25f831c63d081579e83661
5
5
  SHA512:
6
- metadata.gz: 210aea05d43b00d1fb5187f0c03d5236dbab72ec0c53f3e66d12e19ed7f9e445422c08e2f0d9bd6c4059fca4183b9c3f2db6e982422cef38a74166e4d7271066
7
- data.tar.gz: a064ff45a78dcccd3777933609bfd133e02a96e6ccc39d54ef3734e10bc62c57c459fc1d01123ef55075d81eeb3e1c0b6f8213466da6026631486022f7706b26
6
+ metadata.gz: 3ce7dfe514871db74d52f3325404601012dcba1b5e554d01c51611d38a14fa118c12e62aaaa744d95fdeeca3ae81402c545065306608821fcdca02e67bfc2bb6
7
+ data.tar.gz: 4f5acd0857e68c6812d7af19d0a8e6c99d44c90cb2a54677b47bedab39a3ed8bdda07151f67f86cedee19ff30f0e430ab567ba0d9d6030b5755a79f237e8d3ef
@@ -5,10 +5,12 @@ module RxNav
5
5
 
6
6
  def name
7
7
  name = self.display_name ||
8
+ self.synonym ||
8
9
  self.full_name ||
9
10
  self.full_generic_name ||
10
- self.concept_name
11
- name ? name.capitalize : nil
11
+ self.concept_name ||
12
+ @table[:name]
13
+ name ? titleize_str(name) : nil
12
14
  end
13
15
 
14
16
  def kind
@@ -79,8 +81,12 @@ module RxNav
79
81
  str.split("_")[0...-1].map(&:capitalize).join(" ") if str.is_a? String
80
82
  end
81
83
 
84
+ def titleize_str str
85
+ str.gsub(/\w+/) { |w| w.capitalize } if str.is_a? String
86
+ end
87
+
82
88
  def merge_concept concept
83
- if concept_hash.empty?
89
+ if concept_hash.nil? || concept_hash.empty?
84
90
  return false
85
91
  else
86
92
  concept_hash.each do |k,v|
@@ -35,18 +35,26 @@ module RxNav
35
35
  query = "/drugs?name=#{name}"
36
36
  drugs = []
37
37
  dg = get_response_hash(query)[:drug_group]
38
+ return nil if dg[:concept_group].nil?
38
39
  dg[:concept_group].each do |cg|
39
- drugs << {
40
- name: dg[:name],
41
- concepts: cg[:concept_properties].map { |c| RxNav::Concept.new(c) }
42
- }
40
+ props = cg[:concept_properties]
41
+ if props.nil?
42
+ next
43
+ else
44
+ concepts = props.kind_of?(Array) ? props.map { |c| RxNav::Concept.new(c) } : RxNav::Concept.new(props)
45
+ drugs << {
46
+ name: dg[:name],
47
+ concepts: concepts
48
+ }
49
+ end
43
50
  end
44
51
  return drugs
45
52
  end
46
53
 
47
54
  def spelling_suggestions name
48
55
  query = "/spellingsuggestions?name=#{name}"
49
- get_response_hash(query)[:suggestion_group][:suggestion_list][:suggestion]
56
+ data = get_response_hash(query)[:suggestion_group][:suggestion_list]
57
+ data ? data[:suggestion] : nil
50
58
  end
51
59
 
52
60
  def status id
@@ -1,3 +1,3 @@
1
1
  module RxNav
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rx_nav
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Bender
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-20 00:00:00.000000000 Z
11
+ date: 2014-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nori
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Ruby wrappers for the RxNav RESTful APIs
@@ -73,7 +73,7 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
76
+ - ".gitignore"
77
77
  - Gemfile
78
78
  - LICENSE.txt
79
79
  - README.md
@@ -96,17 +96,17 @@ require_paths:
96
96
  - lib
97
97
  required_ruby_version: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - '>='
99
+ - - ">="
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - '>='
104
+ - - ">="
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.1.10
109
+ rubygems_version: 2.2.1
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: Ruby-based way of interacting with the RxNav APIs (http://rxnav.nlm.nih.gov/APIsOverview.html)