mesh-medical-subject-headings 2.0.2 → 2.0.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: ff85c9bce1237839fe7afdc94b9026c9e6761abb
4
- data.tar.gz: 42308e03d574784a942cff743ddd1c5be8509c03
3
+ metadata.gz: b2319bc27d6bc4f2564f73648af6fc13cbcb3d8c
4
+ data.tar.gz: ad0787c9a3229e15d0b591504c2882bd8756379b
5
5
  SHA512:
6
- metadata.gz: 487fbb55afa5c0aa404d5c343d9ce334591b2d87a71388cc8a9abf0a0001092597cf65d44328598d211d315266daa060eea01068f53068da4126d16c555f6852
7
- data.tar.gz: 7867334fc8d9634cc437c4aa22d2d6d56e9fb183034022033870228ac8cb5e1a2b1a96561b6f46f7db7a3fb0447156afb35f07d613e6019d26f42362ebabf5bd
6
+ metadata.gz: e0ff231b13d0223d9f8a33972117e97a3ee0a5459ea40587e11b11ab6c69b4233fb713601e6e64c3c14e5c90a09ccd4ae33fc39f87a87f776624a6922fcf09fe
7
+ data.tar.gz: a86aa7a5f3db453cc37d5528900fcf1f006793b8eb53b44fa54cce0057887dfc816e4b62b801396e0dd98e54f97db69ac3fe89bfcf90ab2dd6ad60667dcedfb7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ #2.0.3 / 2014-06-25
2
+ * [FEATURE] You can now link cross-references in heading.summary by passing a block to heading.linkify_summary
3
+
1
4
  #2.0.2 / 2014-06-23
2
5
  * [BUGFIX] Removed duplicates in children and parents
3
6
  * [BUGFIX] Added require for zlib
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mesh-medical-subject-headings (2.0.2)
4
+ mesh-medical-subject-headings (2.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/MESH/heading.rb CHANGED
@@ -20,6 +20,16 @@ module MESH
20
20
  return @summary[locale]
21
21
  end
22
22
 
23
+ def linkify_summary
24
+ linkified_summary = summary.dup
25
+ linkified_summary.scan(/[A-Z]+[A-Z,\s]+[A-Z]+/).each do |text|
26
+ heading = @tree.where(entries: /^#{text.strip}$/i).first
27
+ replacement_text = yield text, heading
28
+ linkified_summary.sub!(text, replacement_text)
29
+ end
30
+ linkified_summary
31
+ end
32
+
23
33
  def entries(locale = default_locale)
24
34
  @entries[locale] ||= []
25
35
  return @entries[locale]
@@ -73,10 +83,14 @@ module MESH
73
83
  return true
74
84
  end
75
85
 
76
- def inspect
86
+ def to_s
77
87
  return "#{unique_id}, #{original_heading}, [#{tree_numbers.join(',')}]"
78
88
  end
79
89
 
90
+ def inspect
91
+ to_s
92
+ end
93
+
80
94
  def set_original_heading(heading, locale = default_locale)
81
95
  @original_heading[locale] = heading
82
96
  end
@@ -91,7 +105,8 @@ module MESH
91
105
 
92
106
  private
93
107
 
94
- def initialize
108
+ def initialize(tree)
109
+ @tree = tree
95
110
  @useful = true
96
111
  @tree_numbers = []
97
112
  @roots = []
data/lib/MESH/tree.rb CHANGED
@@ -17,7 +17,7 @@ module MESH
17
17
  gzipped_file = File.open(filename)
18
18
  file = Zlib::GzipReader.new(gzipped_file)
19
19
 
20
- current_heading = MESH::Heading.new
20
+ current_heading = MESH::Heading.new(self)
21
21
  current_heading.default_locale = @@default_locale
22
22
  file.each_line do |line|
23
23
 
@@ -33,7 +33,7 @@ module MESH
33
33
  @by_tree_number[tree_number] = current_heading
34
34
  end
35
35
  end
36
- current_heading = MESH::Heading.new
36
+ current_heading = MESH::Heading.new(self)
37
37
  current_heading.default_locale = @@default_locale
38
38
 
39
39
  when matches = line.match(/^UI = (.*)/)
data/lib/MESH/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mesh
2
- VERSION = "2.0.2"
2
+ VERSION = "2.0.3"
3
3
  end
@@ -109,6 +109,39 @@ module MESH
109
109
  assert_equal 'A condition with damage to the lining of the lower OESOPHAGUS resulting from chronic acid reflux (OESOPHAGITIS, REFLUX). Through the process of metaplasia, the squamous cells are replaced by a columnar epithelium with cells resembling those of the INTESTINE or the salmon-pink mucosa of the STOMACH. Barrett\'s columnar epithelium is a marker for severe reflux and precursor to ADENOCARCINOMA of the oesophagus.', mh.summary(:en_gb)
110
110
  end
111
111
 
112
+ def test_linkify_summary
113
+ mh = @mesh_tree.find('D001471')
114
+ assert_equal 'A condition with damage to the lining of the lower ESOPHAGUS resulting from chronic acid reflux (ESOPHAGITIS, REFLUX). Through the process of metaplasia, the squamous cells are replaced by a columnar epithelium with cells resembling those of the INTESTINE or the salmon-pink mucosa of the STOMACH. Barrett\'s columnar epithelium is a marker for severe reflux and precursor to ADENOCARCINOMA of the esophagus.', mh.summary
115
+
116
+ found = {
117
+ 'ESOPHAGUS' => false,
118
+ 'ESOPHAGITIS, REFLUX' => false,
119
+ 'INTESTINE' => false,
120
+ 'STOMACH' => false,
121
+ 'ADENOCARCINOMA' => false
122
+ }
123
+
124
+ linkified_summary = mh.linkify_summary do |text, heading|
125
+ found[text] = true unless heading.nil?
126
+ "<foo>#{text.downcase}</foo>"
127
+ end
128
+
129
+ assert_equal 5, found.length
130
+ assert found['ESOPHAGUS']
131
+ assert found['ESOPHAGITIS, REFLUX']
132
+ assert found['INTESTINE']
133
+ assert found['STOMACH']
134
+ assert found['ADENOCARCINOMA']
135
+
136
+ assert_equal 'A condition with damage to the lining of the lower <foo>esophagus</foo> resulting from chronic acid reflux (<foo>esophagitis, reflux</foo>). Through the process of metaplasia, the squamous cells are replaced by a columnar epithelium with cells resembling those of the <foo>intestine</foo> or the salmon-pink mucosa of the <foo>stomach</foo>. Barrett\'s columnar epithelium is a marker for severe reflux and precursor to <foo>adenocarcinoma</foo> of the esophagus.', linkified_summary
137
+
138
+ end
139
+
140
+ def test_to_s
141
+ mh = @mesh_tree.find('D001471')
142
+ assert_equal 'D001471, Barrett Esophagus, [C06.198.102,C06.405.117.102]', mh.to_s
143
+ end
144
+
112
145
  def test_have_the_correct_entries
113
146
  expected_entries = ['Activity Cycles', 'Ultradian Cycles', 'Activity Cycle', 'Cycle, Activity', 'Cycle, Ultradian', 'Cycles, Activity', 'Cycles, Ultradian', 'Ultradian Cycle']
114
147
  expected_entries.sort!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mesh-medical-subject-headings
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Styles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-23 00:00:00.000000000 Z
11
+ date: 2014-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler