jgm-cloudlib 0.3.3 → 0.3.4
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/cloudlib.gemspec +1 -1
- data/lib/cloudlib.rb +5 -3
- metadata +1 -1
data/cloudlib.gemspec
CHANGED
data/lib/cloudlib.rb
CHANGED
@@ -168,12 +168,14 @@ class Entry
|
|
168
168
|
else
|
169
169
|
'all'
|
170
170
|
end
|
171
|
-
|
171
|
+
# split hyphenated names into components, since a query might just have one
|
172
|
+
vals = val.split(/[-[:space:]]+/)
|
172
173
|
vals.map do |v|
|
173
174
|
if key_full == 'year' # there is no year_words field
|
174
175
|
"['year' #{comparison} '#{v}']"
|
175
176
|
else
|
176
|
-
|
177
|
+
v_escaped = v.gsub(/\\/,"\\\\\\\\").gsub(/'/,"\\\\'")
|
178
|
+
"['#{key_full}_words' = '#{v_escaped}']"
|
177
179
|
end
|
178
180
|
end.join(" intersection ")
|
179
181
|
end.join(" intersection ")
|
@@ -315,7 +317,7 @@ class Entry
|
|
315
317
|
self.attributes[attribute] = newval
|
316
318
|
unless ['url', 'doi', 'keywords'].member?(attribute)
|
317
319
|
self.attributes[attribute + "_lowercase"] = newval.map {|a| a.downcase}
|
318
|
-
self.attributes[attribute + "_words"] = self.attributes[attribute + "_lowercase"].map {|a| a.split(/[[:
|
320
|
+
self.attributes[attribute + "_words"] = self.attributes[attribute + "_lowercase"].map {|a| a.split(/[[:punct:]]*[[:space:]]+|-+/)}.flatten.reject {|a| a.empty?}
|
319
321
|
end
|
320
322
|
# recalculate all_words
|
321
323
|
tit_auth_words = ['title', 'authors', 'editors', 'booktitle'].map {|att| self.attributes[att + "_words"] || []}.flatten
|